Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_EditorTask.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/Tasks", description: "Move task.", color: "0 0 255 255")]
3 {
4 };
5 
6 //------------------------------------------------------------------------------------------------
8 {
9  [Attribute(SCR_Enum.GetDefault(ETaskTextType.NONE), UIWidgets.ComboBox, enums: ParamEnumArray.FromEnum(ETaskTextType))]
10  protected ETaskTextType m_TextType;
11 
12  [Attribute("0", category: "Editor Task")]
13  protected int m_iTextIndex;
14 
15  [Attribute("0", UIWidgets.ComboBox, "Task completion", "", ParamEnumArray.FromEnum(EEditorTaskCompletionType) )]
16  protected EEditorTaskCompletionType m_iTaskCompletionType;
17 
18  protected LocalizedString m_sLocationName;
19 
24  void SetLocationName(LocalizedString locationName)
25  {
26  m_sLocationName = locationName;
27  }
28 
33  string GetLocationName()
34  {
35  return m_sLocationName;
36  }
41  ETaskTextType GetTextType()
42  {
43  return m_TextType;
44  }
49  int GetTextIndex()
50  {
51  return m_iTextIndex;
52  }
57  void SetTextIndex(int index)
58  {
60  }
65  EEditorTaskCompletionType GetTaskCompletionType()
66  {
67  return m_iTaskCompletionType;
68  }
73  void SetTaskCompletionType(EEditorTaskCompletionType newTaskCompletionType)
74  {
75  if (m_iTaskCompletionType == newTaskCompletionType)
76  return;
77 
78  m_iTaskCompletionType = newTaskCompletionType;
79  }
84  SCR_UIDescription GetInfo()
85  {
86  SCR_TextsTaskManagerComponent textsComponent = SCR_TextsTaskManagerComponent.GetInstance();
87  if (textsComponent)
88  return textsComponent.GetText(m_TextType, m_iTextIndex);
89  else
90  return null;
91  }
92  override string GetTitle()
93  {
94  SCR_UIName info = GetInfo();
95  if (info)
96  return info.GetName();
97  else
98  return m_sName;
99  }
100  override void SetTitleWidgetText(notnull TextWidget textWidget, string taskText)
101  {
102  SCR_UIName info = GetInfo();
103  if (info)
104  textWidget.SetTextFormat(info.GetName(), m_sLocationName);
105  else
106  textWidget.SetTextFormat(taskText, m_sLocationName);
107  }
108  override void SetDescriptionWidgetText(notnull TextWidget textWidget, string taskText)
109  {
110  SCR_UIDescription info = GetInfo();
111  if (info)
112  textWidget.SetTextFormat(info.GetDescription(), m_sLocationName);
113  else
114  textWidget.SetTextFormat(taskText);
115  }
116 
117  protected void PopUpNotification(string prefix, bool alwaysInEditor)
118  {
119  //--- Get player faction (prioritize respawn faction, because it's defined even when player is waiting for respawn)
120  Faction playerFaction;
121  SCR_FactionManager factionManager = SCR_FactionManager.Cast(GetGame().GetFactionManager());
122  if (factionManager)
123  playerFaction = factionManager.GetLocalPlayerFaction();
124 
125  if (!playerFaction)
126  playerFaction = SCR_PlayerController.GetLocalMainEntityFaction();
127 
128  //--- Show notification when player is assigned, of the same faction, or has unlimited editor (i.e., is Game Master)
129  if (IsAssignedToLocalPlayer() || playerFaction == GetTargetFaction() || (alwaysInEditor && !SCR_EditorManagerEntity.IsLimitedInstance()))
130  {
131  //--- SCR_PopUpNotification.GetInstance() is never null, as it creates the instance if it doesn't exist yet
132  SCR_PopUpNotification.GetInstance().PopupMsg(prefix + " " + GetTitle(), prio: SCR_ECampaignPopupPriority.TASK_DONE, param1: m_sLocationName, sound: SCR_SoundEvent.TASK_SUCCEED);
133  }
134  }
135  override protected void ShowPopUpNotification(string subtitle)
136  {
137  SCR_PopUpNotification.GetInstance().PopupMsg(GetTitle(), text2: subtitle, param1: m_sLocationName);
138  }
139 
144  void ShowTaskNotification(ENotification taskNotification, bool SendOverNetwork = false)
145  {
147  if (!editableTask)
148  return;
149 
150  int taskID = Replication.FindId(editableTask);
151 
152  Faction faction = GetTargetFaction();
153  if (!faction)
154  return;
155 
156  FactionManager factionManager = GetGame().GetFactionManager();
157  if (!factionManager)
158  return;
159 
160  vector position;
161  editableTask.GetPos(position);
162 
163  int factionIndex = factionManager.GetFactionIndex(faction);
164 
165  //Send local GM
166  if (!SendOverNetwork)
167  {
168  if (taskNotification == ENotification.EDITOR_TASK_PLACED)
169  GetGame().GetCallqueue().CallLater(DelayedPlacedNotification, 1, false, position, taskID, factionIndex);
170  else
171  SCR_NotificationsComponent.SendLocalUnlimitedEditor(taskNotification, position, taskID, factionIndex);
172  }
173  else
174  {
175  SCR_NotificationsComponent.SendToUnlimitedEditorPlayers(taskNotification, position, taskID, factionIndex);
176  }
177  }
178 
179  protected override void OnStateChanged(SCR_TaskState previousState, SCR_TaskState newState)
180  {
181  //--- Delete the task once it's finished (ToDo: Keep it, but hide it in the editor once completed tasks can be shown in the task list)
182  RplComponent rplComponent = RplComponent.Cast(FindComponent(RplComponent));
183  if ((!rplComponent || rplComponent.Role() == RplRole.Authority) && (newState == SCR_TaskState.FINISHED || newState == SCR_TaskState.CANCELLED))
184  {
185  if (GetTaskManager())
186  GetTaskManager().DeleteTask(this);
187  }
188  }
189 
190  protected void DelayedPlacedNotification(vector position, int taskID, int factionIndex)
191  {
192  SCR_NotificationsComponent.SendLocalUnlimitedEditor(ENotification.EDITOR_TASK_PLACED, position, taskID, factionIndex);
193  }
194 
195 
196  override void Create(bool showMsg = true)
197  {
198  super.Create(showMsg);
199 
200  if (showMsg)
201  PopUpNotification(TASK_AVAILABLE_TEXT, false);
202 
203  ShowTaskNotification(ENotification.EDITOR_TASK_PLACED);
204  }
205  override void Finish(bool showMsg = true)
206  {
207  super.Finish(showMsg);
208 
209  if (showMsg)
210  PopUpNotification(TASK_COMPLETED_TEXT, true);
211 
212  ShowTaskNotification(ENotification.EDITOR_TASK_COMPLETED);
213 
214  }
215  override void Fail(bool showMsg = true)
216  {
217  super.Fail(showMsg);
218 
219  if (showMsg)
220  PopUpNotification(TASK_FAILED_TEXT, true);
221 
222  ShowTaskNotification(ENotification.EDITOR_TASK_FAILED);
223 
224  }
225  override void Cancel(bool showMsg = true)
226  {
227  super.Cancel(showMsg);
228 
229  if (showMsg)
230  PopUpNotification(TASK_CANCELLED_TEXT, true);
231 
232  ShowTaskNotification(ENotification.EDITOR_TASK_CANCELED);
233  }
234 
235  //------------------------------------------------------------------------------------------------
236  protected override bool RplLoad(ScriptBitReader reader)
237  {
238  Deserialize(reader);
239  return true;
240  }
241 
242  //------------------------------------------------------------------------------------------------
243  protected override bool RplSave(ScriptBitWriter writer)
244  {
245  Serialize(writer);
246  return true;
247  }
248 };
SCR_BaseTaskClass
Definition: SCR_BaseTask.c:2
SCR_PlayerController
Definition: SCR_PlayerController.c:31
SCR_Enum
Definition: SCR_Enum.c:1
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
SCR_UIName
Definition: SCR_UIName.c:5
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SCR_SoundEvent
Definition: SCR_SoundEvent.c:1
SCR_PopUpNotification
Takes care of dynamic and static onscreen popups.
Definition: SCR_PopupNotification.c:24
SCR_BaseTask
A base class for tasks.
Definition: SCR_BaseTask.c:8
m_iTextIndex
protected int m_iTextIndex
Definition: SCR_EditableTaskComponent.c:23
ENotification
ENotification
Definition: ENotification.c:4
Attribute
typedef Attribute
Post-process effect of scripted camera.
GetTaskManager
SCR_BaseTaskManager GetTaskManager()
Definition: SCR_BaseTaskManager.c:7
SCR_ECampaignPopupPriority
SCR_ECampaignPopupPriority
Popup message priorities sorted from lowest to highest.
Definition: SCR_CampaignFeedbackComponent.c:1419
m_sLocationName
protected LocalizedString m_sLocationName
Definition: SCR_EditableDescriptorComponent.c:18
SCR_EditorTask
Definition: SCR_EditorTask.c:7
Serialize
override bool Serialize(out SCR_EditableEntityComponent outTarget=null, out int outTargetIndex=-1, out EEditableEntitySaveFlag outSaveFlags=0)
Definition: SCR_EditableCharacterComponent.c:737
SCR_EditorTaskClass
Definition: SCR_EditorTask.c:2
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
EEditorTaskCompletionType
EEditorTaskCompletionType
Way of determening if a task is completed automaticly, manually or always manually (In the latter cas...
Definition: EEditorTaskCompletionType.c:2
Faction
Definition: Faction.c:12
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
SCR_TaskState
SCR_TaskState
Definition: SCR_TaskState.c:2
SCR_FactionManager
void SCR_FactionManager(IEntitySource src, IEntity parent)
Definition: SCR_FactionManager.c:461
m_sName
protected LocalizedString m_sName
Definition: SCR_GroupIdentityComponent.c:19
position
vector position
Definition: SCR_DestructibleTreeV2.c:30
LocalizedString
Definition: LocalizedString.c:21
SCR_UIDescription
Definition: SCR_UIDescription.c:5
Deserialize
override void Deserialize(SCR_EditableEntityComponent target, int targetValue)
Definition: SCR_EditableCharacterComponent.c:758
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
SCR_EditorManagerEntity
Definition: SCR_EditorManagerEntity.c:26