Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_EditableTaskComponent.c
Go to the documentation of this file.
1 [ComponentEditorProps(category: "GameScripted/Editor (Editables)", description: "", icon: "WBData/ComponentEditorProps/componentEditor.png")]
3 {
4  [Attribute("#AR-Tasks_Objective", desc: "Name of objective type eg: Attack objective. Used among in, among other things, in notifications", category: "Visualization")]
5  protected LocalizedString m_sObjectiveTypeName;
6 
7  //------------------------------------------------------------------------------------------------
10  LocalizedString GetObjectiveTypeName()
11  {
12  return m_sObjectiveTypeName;
13  }
14 }
15 
17 
20 {
21  protected SCR_EditorTask m_Task;
23  protected int m_iTextIndex;
24 
25  //------------------------------------------------------------------------------------------------
27  void ActivateTask()
28  {
29  if (!GetTaskManager())
30  return;
31 
32  SCR_BaseTaskSupportEntity supportEntity = GetTaskManager().FindSupportEntity(SCR_BaseTaskSupportEntity);
33  if (supportEntity)
34  supportEntity.SetTargetFaction(m_Task, m_TargetFaction);
35  }
36 
37  //------------------------------------------------------------------------------------------------
41  {
42  return m_Task.GetTargetFaction() == m_TargetFaction;
43  }
44 
45  //------------------------------------------------------------------------------------------------
48  ETaskTextType GetTextType()
49  {
50  return m_Task.GetTextType();
51  }
52 
53  //------------------------------------------------------------------------------------------------
57  {
58  return m_iTextIndex;
59  }
60 
61  //------------------------------------------------------------------------------------------------
64  void SetTextIndex(int index)
65  {
68  }
69 
70  //------------------------------------------------------------------------------------------------
71  [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
72  protected void SetTextIndexBroadcast(int index)
73  {
75  m_Task.SetTextIndex(index);
76  UpdateText();
77  }
78 
79  //------------------------------------------------------------------------------------------------
83  {
84  return m_Task.GetTaskCompletionType();
85  }
86 
87  //------------------------------------------------------------------------------------------------
91  {
92  if (m_Task.GetTaskCompletionType() == completionType)
93  return;
94 
95  SetTaskCompletionTypeBroadcast(completionType);
96  Rpc(SetTaskCompletionTypeBroadcast, completionType);
97  }
98 
99  //------------------------------------------------------------------------------------------------
100  [RplRpc(RplChannel.Reliable, RplRcver.Broadcast)]
102  {
103  m_Task.SetTaskCompletionType(completionType);
104  }
105 
106  //------------------------------------------------------------------------------------------------
107  protected void UpdateText()
108  {
109  UpdateInfo(m_Task.GetInfo());
110 
111  m_Task.SetTextIndex(m_iTextIndex);
112  m_Task.SetLocationName(m_UIInfoDescriptor.GetLocationName());
113  }
114 
115  //------------------------------------------------------------------------------------------------
116  override protected void GetOnLocationChange(SCR_EditableEntityComponent nearestLocation)
117  {
118  UpdateText();
119  }
120 
121  //------------------------------------------------------------------------------------------------
122  override Faction GetFaction()
123  {
124  return m_TargetFaction;
125  }
126 
127  //------------------------------------------------------------------------------------------------
128  override void SetTransform(vector transform[4], bool changedByUser = false)
129  {
130  super.SetTransform(transform, changedByUser);
132  }
133 
134  //------------------------------------------------------------------------------------------------
135  override bool Serialize(out SCR_EditableEntityComponent outTarget = null, out int outTargetIndex = -1, out EEditableEntitySaveFlag outSaveFlags = 0)
136  {
137  outTargetIndex = GetGame().GetFactionManager().GetFactionIndex(m_TargetFaction);
138  return super.Serialize(outTarget, outTargetIndex, outSaveFlags);
139  }
140 
141  //------------------------------------------------------------------------------------------------
142  override void Deserialize(SCR_EditableEntityComponent target, int targetValue)
143  {
144  super.Deserialize(target, targetValue);
145 
146  SCR_BaseTaskSupportEntity supportEntity = GetTaskManager().FindSupportEntity(SCR_BaseTaskSupportEntity);
147  if (!supportEntity)
148  return;
149 
150  m_TargetFaction = GetGame().GetFactionManager().GetFactionByIndex(targetValue);
151  supportEntity.SetTargetFaction(m_Task, m_TargetFaction);
152  }
153 
154  //------------------------------------------------------------------------------------------------
155  override ScriptInvoker GetOnUIRefresh()
156  {
157  return Event_OnUIRefresh;
158  }
159 
160  //------------------------------------------------------------------------------------------------
161  override bool RplSave(ScriptBitWriter writer)
162  {
163  if (!super.RplSave(writer))
164  return false;
165 
166  int factionIndex;
167  if (GetGame().GetFactionManager())
168  factionIndex = GetGame().GetFactionManager().GetFactionIndex(m_TargetFaction);
169 
170  writer.WriteInt(factionIndex);
171  writer.WriteInt(m_iTextIndex);
172 
173  if (m_Task)
174  m_Task.Serialize(writer);
175 
176  return true;
177  }
178 
179  //------------------------------------------------------------------------------------------------
180  override bool RplLoad(ScriptBitReader reader)
181  {
182  if (!super.RplLoad(reader))
183  return false;
184 
185  int factionIndex;
186  reader.ReadInt(factionIndex);
187  if (GetGame().GetFactionManager())
188  m_TargetFaction = GetGame().GetFactionManager().GetFactionByIndex(factionIndex);
189 
190  reader.ReadInt(m_iTextIndex);
191  m_Task.SetTextIndex(m_iTextIndex);
192 
193  m_Task.Deserialize(reader);
194 
195  UpdateText();
196 
197  return true;
198  }
199 
200  //------------------------------------------------------------------------------------------------
202  {
203  if (recipient)
204  {
205  m_TargetFaction = recipient.GetFaction();
206  if (m_TargetFaction)
207  {
208  //--- When the task is placed as inactive, don't assign faction yet, do it only upon manual activation
209  if (!SCR_Enum.HasFlag(flags, EEditorPlacingFlags.TASK_INACTIVE))
210  m_Task.SetTargetFaction(m_TargetFaction);
211 
213  }
214  }
215  return this;
216  }
217 
218  //------------------------------------------------------------------------------------------------
223  void SCR_EditableTaskComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
224  {
225  m_Task = SCR_EditorTask.Cast(ent);
226  }
227 
228  //------------------------------------------------------------------------------------------------
229  override bool Delete(bool changedByUser = false, bool updateNavmesh = true)
230  {
231  if (m_Task)
232  m_Task.ShowTaskNotification(ENotification.EDITOR_TASK_DELETED, true);
233 
234  return super.Delete(changedByUser, updateNavmesh);
235  }
236 }
ComponentEditorProps
SCR_FragmentEntityClass ComponentEditorProps
Delete
override bool Delete(bool changedByUser=false, bool updateNavmesh=true)
Definition: SCR_EditableTaskComponent.c:229
Serialize
override bool Serialize(out SCR_EditableEntityComponent outTarget=null, out int outTargetIndex=-1, out EEditableEntitySaveFlag outSaveFlags=0)
Definition: SCR_EditableTaskComponent.c:135
SCR_Enum
Definition: SCR_Enum.c:1
EOnEditorPlace
override SCR_EditableEntityComponent EOnEditorPlace(out SCR_EditableEntityComponent parent, SCR_EditableEntityComponent recipient, EEditorPlacingFlags flags, bool isQueue, int playerID=0)
Definition: SCR_EditableTaskComponent.c:201
SetTransform
override void SetTransform(vector transform[4], bool changedByUser=false)
Definition: SCR_EditableTaskComponent.c:128
m_Task
SCR_EditableTaskComponentClass m_Task
Editable SCR_BaseTask.
Event_OnUIRefresh
protected ref ScriptInvoker Event_OnUIRefresh
Definition: SCR_EditableGroupComponent.c:38
UpdateText
protected void UpdateText()
Definition: SCR_EditableTaskComponent.c:107
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
SetTextIndex
void SetTextIndex(int index)
Definition: SCR_EditableTaskComponent.c:64
ActivateTask
void ActivateTask()
Reveal the task to all players.
Definition: SCR_EditableTaskComponent.c:27
m_UIInfoDescriptor
protected ref SCR_EditableDescriptorUIInfo m_UIInfoDescriptor
Definition: SCR_EditableDescriptorComponent.c:21
GetTextIndex
int GetTextIndex()
Definition: SCR_EditableTaskComponent.c:56
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
RplRpc
SCR_AchievementsHandlerClass ScriptComponentClass RplRpc(RplChannel.Reliable, RplRcver.Owner)] void UnlockOnClient(AchievementId achievement)
Definition: SCR_AchievementsHandler.c:11
m_iTextIndex
protected int m_iTextIndex
Definition: SCR_EditableTaskComponent.c:23
GetOnUIRefresh
override ScriptInvoker GetOnUIRefresh()
Definition: SCR_EditableTaskComponent.c:155
ENotification
ENotification
Definition: ENotification.c:4
RplSave
override bool RplSave(ScriptBitWriter writer)
Definition: SCR_EditableTaskComponent.c:161
GetOnLocationChange
override protected void GetOnLocationChange(SCR_EditableEntityComponent nearestLocation)
Definition: SCR_EditableTaskComponent.c:116
m_TargetFaction
protected Faction m_TargetFaction
Definition: SCR_EditableTaskComponent.c:22
Attribute
typedef Attribute
Post-process effect of scripted camera.
SetTaskCompletionType
void SetTaskCompletionType(EEditorTaskCompletionType completionType)
Definition: SCR_EditableTaskComponent.c:90
GetTextType
ETaskTextType GetTextType()
Definition: SCR_EditableTaskComponent.c:48
GetTaskManager
SCR_BaseTaskManager GetTaskManager()
Definition: SCR_BaseTaskManager.c:7
SCR_EditorTask
Definition: SCR_EditorTask.c:7
RplLoad
override bool RplLoad(ScriptBitReader reader)
Definition: SCR_EditableTaskComponent.c:180
EEditorPlacingFlags
EEditorPlacingFlags
Definition: EEditorPlacingFlags.c:1
SetTaskCompletionTypeBroadcast
protected void SetTaskCompletionTypeBroadcast(EEditorTaskCompletionType completionType)
Definition: SCR_EditableTaskComponent.c:101
SetTextIndexBroadcast
protected void SetTextIndexBroadcast(int index)
Definition: SCR_EditableTaskComponent.c:72
SCR_EditableEntityComponent
Definition: SCR_EditableEntityComponent.c:13
SCR_BaseTaskSupportEntity
Definition: SCR_BaseTaskSupportEntity.c:8
EEditorTaskCompletionType
EEditorTaskCompletionType
Way of determening if a task is completed automaticly, manually or always manually (In the latter cas...
Definition: EEditorTaskCompletionType.c:2
IsTaskActivated
bool IsTaskActivated()
Definition: SCR_EditableTaskComponent.c:40
Faction
Definition: Faction.c:12
UpdateNearestLocation
bool UpdateNearestLocation(vector pos=vector.Zero)
Definition: SCR_EditableDescriptorComponent.c:38
SCR_EditableDescriptorComponentClass
Definition: SCR_EditableDescriptorComponent.c:6
index
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
Definition: SCR_DestructionSynchronizationComponent.c:17
GetFaction
override Faction GetFaction()
Definition: SCR_EditableTaskComponent.c:122
EEditableEntitySaveFlag
EEditableEntitySaveFlag
Definition: EEditableEntitySaveFlag.c:9
UpdateInfo
protected void UpdateInfo(SCR_UIDescription from=null)
Definition: SCR_EditableDescriptorComponent.c:87
SCR_EditableTaskComponentClass
Definition: SCR_EditableTaskComponent.c:2
Deserialize
override void Deserialize(SCR_EditableEntityComponent target, int targetValue)
Definition: SCR_EditableTaskComponent.c:142
SCR_EditableDescriptorComponent
void SCR_EditableDescriptorComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_EditableDescriptorComponent.c:137
SCR_EditableTaskComponent
void SCR_EditableTaskComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_EditableTaskComponent.c:223
LocalizedString
Definition: LocalizedString.c:21
GetTaskCompletionType
EEditorTaskCompletionType GetTaskCompletionType()
Definition: SCR_EditableTaskComponent.c:82
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180