Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ScenarioFrameworkSlotTask.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/ScenarioFramework/Slot", description: "")]
3 {
4 }
5 
6 class SCR_ScenarioFrameworkSlotTask : SCR_ScenarioFrameworkSlotBase
7 {
8  [Attribute(desc: "Name of the task in list of tasks", category: "Task")]
9  LocalizedString m_sTaskTitle;
10 
11  [Attribute(desc: "Description of the task", category: "Task")]
12  LocalizedString m_sTaskDescription;
13 
14  [Attribute(desc: "Text for the Execution category in Briefing", category: "Task")]
15  LocalizedString m_sTaskExecutionBriefing;
16 
17  [Attribute(desc: "StringID for the Intro Voiceline action to be processed. Processing must be setup after tasks are initialized.", category: "Task")]
18  string m_sTaskIntroVoiceline;
19 
20  [Attribute(defvalue: "1", desc: "What to do once task is finished", UIWidgets.Auto, category: "OnTaskFinish")]
21  ref array<ref SCR_ScenarioFrameworkActionBase> m_aActionsOnFinished;
22 
23  [Attribute(defvalue: "1", desc: "What to do once task is created", UIWidgets.Auto, category: "OnTaskCreate")]
24  ref array<ref SCR_ScenarioFrameworkActionBase> m_aActionsOnCreated;
25 
26  [Attribute(defvalue: "1", desc: "What to do once task is created", UIWidgets.Auto, category: "OnTaskFailed")]
27  ref array<ref SCR_ScenarioFrameworkActionBase> m_aActionsOnFailed;
28 
29  [Attribute(defvalue: "1", desc: "What to do once task progressed", UIWidgets.Auto, category: "OnTaskProgress")]
30  ref array<ref SCR_ScenarioFrameworkActionBase> m_aActionsOnProgress;
31 
32  [Attribute(defvalue: "1", desc: "What to do once task is updated", UIWidgets.Auto, category: "OnTaskUpdated")]
33  ref array<ref SCR_ScenarioFrameworkActionBase> m_aActionsOnUpdated;
34 
35  SCR_ScenarioFrameworkLayerTask m_TaskLayer; //parent layer where the task is defined
36  bool m_bTaskResolvedBeforeLoad;
37 
38  //------------------------------------------------------------------------------------------------
40  void OnTaskStateChanged(SCR_TaskState newState)
41  {
42  if (newState == SCR_TaskState.OPENED)
43  {
44  foreach (SCR_ScenarioFrameworkActionBase action : m_aActionsOnCreated)
45  {
46  action.OnActivate(GetOwner());
47  }
48  }
49  else if (newState == SCR_TaskState.FINISHED && !m_bTaskResolvedBeforeLoad)
50  {
51  foreach (SCR_ScenarioFrameworkActionBase action : m_aActionsOnFinished)
52  {
53  action.OnActivate(GetOwner());
54  }
55  }
56  else if (newState == SCR_TaskState.CANCELLED && !m_bTaskResolvedBeforeLoad)
57  {
58  foreach (SCR_ScenarioFrameworkActionBase action : m_aActionsOnFailed)
59  {
60  action.OnActivate(GetOwner());
61  }
62  }
63  else if (newState == SCR_TaskState.PROGRESSED && !m_bTaskResolvedBeforeLoad)
64  {
65  foreach (SCR_ScenarioFrameworkActionBase action : m_aActionsOnProgress)
66  {
67  action.OnActivate(GetOwner());
68  }
69  }
70  else
71  {
72  foreach (SCR_ScenarioFrameworkActionBase action : m_aActionsOnUpdated)
73  {
74  action.OnActivate(GetOwner());
75  };
76  }
77  }
78 
79  //------------------------------------------------------------------------------------------------
81  void SetTaskResolvedBeforeLoad(bool state)
82  {
83  m_bTaskResolvedBeforeLoad = state;
84  }
85 
86  //------------------------------------------------------------------------------------------------
88  {
89  m_TaskLayer = GetParentTaskLayer();
90  if (m_TaskLayer)
91  {
92  m_TaskLayer.SetSlotTask(this);
93  if (m_Entity)
94  m_TaskLayer.SetEntity(m_Entity);
95  }
96  else
97  {
98  Print(string.Format("ScenarioFramework: %1 could not be spawned and cannot bind it to task %2", m_sObjectToSpawn, m_TaskLayer.GetOwner().GetName()), LogLevel.ERROR);
99  }
100  }
101 
102  //------------------------------------------------------------------------------------------------
106  {
107  return m_sTaskTitle;
108  }
109 
110  //------------------------------------------------------------------------------------------------
113  {
114  return m_sTaskExecutionBriefing;
115  }
116 
117  //------------------------------------------------------------------------------------------------
120  string GetTaskDescription(int iState = 0)
121  {
122  return m_sTaskDescription;
123  }
124 
125  //------------------------------------------------------------------------------------------------
127  SCR_ScenarioFrameworkLayerTask GetParentTaskLayer()
128  {
129  SCR_ScenarioFrameworkLayerTask layer;
130  IEntity entity = GetOwner().GetParent();
131  while (entity)
132  {
133  layer = SCR_ScenarioFrameworkLayerTask.Cast(entity.FindComponent(SCR_ScenarioFrameworkLayerTask));
134  if (layer)
135  return layer;
136 
137  entity = entity.GetParent();
138  }
139 
140  return null;
141  }
142 
143  //------------------------------------------------------------------------------------------------
145  override void RestoreToDefault(bool includeChildren = false, bool reinitAfterRestoration = false)
146  {
147  foreach (SCR_ScenarioFrameworkActionBase activationAction : m_aActionsOnFinished)
148  {
149  activationAction.m_iNumberOfActivations = 0;
150  }
151 
152  foreach (SCR_ScenarioFrameworkActionBase activationAction : m_aActionsOnCreated)
153  {
154  activationAction.m_iNumberOfActivations = 0;
155  }
156 
157  foreach (SCR_ScenarioFrameworkActionBase activationAction : m_aActionsOnFailed)
158  {
159  activationAction.m_iNumberOfActivations = 0;
160  }
161 
162  foreach (SCR_ScenarioFrameworkActionBase activationAction : m_aActionsOnProgress)
163  {
164  activationAction.m_iNumberOfActivations = 0;
165  }
166 
167  foreach (SCR_ScenarioFrameworkActionBase activationAction : m_aActionsOnUpdated)
168  {
169  activationAction.m_iNumberOfActivations = 0;
170  }
171 
172  m_TaskLayer = null;
173  m_bTaskResolvedBeforeLoad = false;
174 
175  super.RestoreToDefault(includeChildren, reinitAfterRestoration);
176  }
177 
178  //------------------------------------------------------------------------------------------------
179  override void DynamicReinit()
180  {
181  Init(null, SCR_ScenarioFrameworkEActivationType.SAME_AS_PARENT);
182  }
183 
184  //------------------------------------------------------------------------------------------------
186  {
188  if (!m_Entity && !SCR_StringHelper.IsEmptyOrWhiteSpace(m_sObjectToSpawn))
189  {
191  return;
192  }
193 
195  return;
196 
197  if (m_Entity)
198  {
199  m_vPosition = m_Entity.GetOrigin();
201  if (invComp)
202  invComp.m_OnParentSlotChangedInvoker.Remove(OnInventoryParentChanged);
203  }
204 
205  m_bInitiated = false;
207  SCR_EntityHelper.DeleteEntityAndChildren(m_Entity);
208  }
209 
210  //------------------------------------------------------------------------------------------------
211  override void Init(SCR_ScenarioFrameworkArea area = null, SCR_ScenarioFrameworkEActivationType activation = SCR_ScenarioFrameworkEActivationType.SAME_AS_PARENT)
212  {
213  if (m_bInitiated)
214  return;
215 
216  if (!m_bDynamicallyDespawned && activation != m_eActivationType)
217  {
218  if (m_ParentLayer)
219  m_ParentLayer.CheckAllChildrenSpawned(this);
220 
221  return;
222  }
223 
225  {
226  //If just one condition is false, we don't continue and interrupt the init
227  if (!activationCondition.Init(GetOwner()))
228  {
230  return;
231  }
232  }
233 
234  bool tempTerminated = m_bIsTerminated;
235  m_bIsTerminated = false;
236 
237  if (m_bIsTerminated)
238  {
239  if (m_ParentLayer)
240  m_ParentLayer.CheckAllChildrenSpawned(this);
241 
242  return;
243  }
244 
246  {
247  IEntity entity = GetOwner().GetParent();
248  if (!entity)
249  return;
250 
252  if (!layerBase)
253  return;
254 
255  if (!layerBase.GetEnableRepeatedSpawn())
256  {
257  Print(string.Format("ScenarioFramework: Object %1 already exists and won't be spawned for %2, exiting...", m_Entity, GetOwner().GetName()), LogLevel.ERROR);
258  return;
259  }
260  }
261 
262  // Handles inheritance of faction settings from parents
263  if (m_sFactionKey.IsEmpty() && m_ParentLayer && !m_ParentLayer.GetFactionKey().IsEmpty())
264  SetFactionKey(m_ParentLayer.GetFactionKey());
265 
266  if (!m_bUseExistingWorldAsset)
267  {
268  m_Entity = SpawnAsset();
269  }
270  else
271  {
272  QueryObjectsInRange(); //sets the m_Entity in subsequent callback
273  }
274 
276 
277  if (!m_Entity)
278  {
280  m_bIsTerminated = tempTerminated;
282  return;
283  }
284 
285  if (!m_sID.IsEmpty())
286  m_Entity.SetName(m_sID);
287 
288  SCR_DamageManagerComponent objectDmgManager = SCR_DamageManagerComponent.Cast(m_Entity.FindComponent(SCR_DamageManagerComponent));
289  if (objectDmgManager)
290  objectDmgManager.GetOnDamageStateChanged().Insert(OnObjectDamage);
291 
292  if (Vehicle.Cast(m_Entity))
293  {
294  EventHandlerManagerComponent ehManager = EventHandlerManagerComponent.Cast(m_Entity.FindComponent(EventHandlerManagerComponent));
295  if (ehManager)
296  ehManager.RegisterScriptHandler("OnCompartmentEntered", this, OnCompartmentEntered, false, true);
297  }
298 
300  if (invComp)
301  invComp.m_OnParentSlotChangedInvoker.Insert(OnInventoryParentChanged);
302 
303  if (!m_bCanBeGarbageCollected)
304  {
305  SCR_GarbageSystem garbageSystem = SCR_GarbageSystem.GetByEntityWorld(m_Entity);
306  if (garbageSystem)
307  garbageSystem.UpdateBlacklist(m_Entity, true);
308  }
309 
311  m_bIsTerminated = tempTerminated;
312 
314  }
315 }
GetTaskTitle
LocalizedString GetTaskTitle(int iState=0)
Definition: SCR_ScenarioFrameworkSlotTask.c:105
SetTaskResolvedBeforeLoad
void SetTaskResolvedBeforeLoad(bool state)
Definition: SCR_ScenarioFrameworkSlotTask.c:81
SCR_ScenarioFrameworkActivationConditionBase
Definition: SCR_ScenarioFrameworkSlotBase.c:677
m_eActivationType
protected SCR_ScenarioFrameworkEActivationType m_eActivationType
Definition: SCR_ScenarioFrameworkLayerBase.c:43
SCR_EntityHelper
Definition: SCR_EntityHelper.c:1
GetName
string GetName()
Definition: SCR_ScenarioFrameworkLayerBase.c:85
m_bInitiated
protected bool m_bInitiated
Definition: SCR_ScenarioFrameworkLayerBase.c:72
EntityEditorProps
enum EQueryType EntityEditorProps(category:"GameScripted/Sound", description:"THIS IS THE SCRIPT DESCRIPTION.", color:"0 0 255 255")
Definition: SCR_AmbientSoundsComponent.c:12
SCR_ScenarioFrameworkSlotBaseClass
Definition: SCR_ScenarioFrameworkSlotBase.c:2
OnInventoryParentChanged
void OnInventoryParentChanged(InventoryStorageSlot oldSlot, InventoryStorageSlot newSlot)
Definition: SCR_ScenarioFrameworkSlotBase.c:90
GetOnAllChildrenSpawned
ScriptInvokerScenarioFrameworkLayer GetOnAllChildrenSpawned()
Definition: SCR_ScenarioFrameworkLayerBase.c:450
m_bEnableRepeatedSpawn
protected bool m_bEnableRepeatedSpawn
Definition: SCR_ScenarioFrameworkLayerBase.c:31
SCR_StringHelper
Definition: SCR_StringHelper.c:1
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
DynamicDespawn
override void DynamicDespawn(SCR_ScenarioFrameworkLayerBase layer)
Definition: SCR_ScenarioFrameworkSlotTask.c:185
m_Entity
enum EAITargetInfoCategory m_Entity
OnCompartmentEntered
event protected void OnCompartmentEntered(IEntity targetEntity, BaseCompartmentManagerComponent manager, int mgrID, int slotID, bool move)
Definition: SCR_CharacterInventoryStorageComponent.c:1248
m_sFactionKey
protected FactionKey m_sFactionKey
Definition: SCR_ScenarioFrameworkLayerBase.c:25
InvokeAllChildrenSpawned
void InvokeAllChildrenSpawned()
Definition: SCR_ScenarioFrameworkLayerBase.c:460
m_bExcludeFromDynamicDespawn
protected bool m_bExcludeFromDynamicDespawn
Definition: SCR_ScenarioFrameworkLayerBase.c:52
RestoreToDefault
override void RestoreToDefault(bool includeChildren=false, bool reinitAfterRestoration=false)
Definition: SCR_ScenarioFrameworkSlotTask.c:145
GetTaskExecutionBriefing
LocalizedString GetTaskExecutionBriefing()
Definition: SCR_ScenarioFrameworkSlotTask.c:112
SCR_ScenarioFrameworkSlotBase
void SCR_ScenarioFrameworkSlotBase(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_ScenarioFrameworkSlotBase.c:661
m_bDynamicallyDespawned
protected bool m_bDynamicallyDespawned
Definition: SCR_ScenarioFrameworkLayerBase.c:74
SCR_ScenarioFrameworkArea
Definition: SCR_ScenarioFrameworkArea.c:24
DynamicReinit
override void DynamicReinit()
Definition: SCR_ScenarioFrameworkSlotTask.c:179
Attribute
SCR_ScenarioFrameworkSlotTaskClass SCR_ScenarioFrameworkSlotBaseClass Attribute(desc:"Name of the task in list of tasks", category:"Task")
Definition: SCR_ScenarioFrameworkSlotTask.c:8
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
SCR_GarbageSystem
Script entry for garbage system modding.
Definition: SCR_GarbageSystem.c:2
m_ParentLayer
protected SCR_ScenarioFrameworkLayerBase m_ParentLayer
Definition: SCR_ScenarioFrameworkLayerBase.c:65
InventoryItemComponent
Definition: InventoryItemComponent.c:12
AfterAllChildrenSpawned
void AfterAllChildrenSpawned(SCR_ScenarioFrameworkLayerBase layer)
Definition: SCR_ScenarioFrameworkLayerBase.c:779
OnTaskStateChanged
void OnTaskStateChanged(SCR_TaskState previousState, SCR_TaskState newState)
Definition: SCR_ScenarioFrameworkLayerTask.c:234
m_bIsTerminated
protected bool m_bIsTerminated
Definition: SCR_ScenarioFrameworkLayerBase.c:75
GetTaskDescription
string GetTaskDescription(int iState=0)
Definition: SCR_ScenarioFrameworkSlotTask.c:120
SCR_TaskState
SCR_TaskState
Definition: SCR_TaskState.c:2
SCR_ScenarioFrameworkLayerBase
void SCR_ScenarioFrameworkLayerBase(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_ScenarioFrameworkLayerBase.c:875
GetParentTaskLayer
SCR_ScenarioFrameworkLayerTask GetParentTaskLayer()
Get the Layer Task which is parent of this Slot.
Definition: SCR_ScenarioFrameworkSlotTask.c:127
m_vPosition
vector m_vPosition
Definition: SCR_AITalkRequest.c:23
SpawnAsset
IEntity SpawnAsset(string name, ResourceName type, IEntity spawnpoint=null)
Definition: SCR_CampaignTutorialComponentArland.c:1199
StoreTaskSubjectToParentTaskLayer
protected void StoreTaskSubjectToParentTaskLayer()
Definition: SCR_ScenarioFrameworkSlotTask.c:87
LocalizedString
Definition: LocalizedString.c:21
Init
override void Init(SCR_ScenarioFrameworkArea area=null, SCR_ScenarioFrameworkEActivationType activation=SCR_ScenarioFrameworkEActivationType.SAME_AS_PARENT)
Definition: SCR_ScenarioFrameworkSlotTask.c:211
SCR_ScenarioFrameworkSlotTaskClass
Definition: SCR_ScenarioFrameworkSlotTask.c:2
SetFactionKey
protected void SetFactionKey(FactionKey factionKey)
Definition: SCR_ScenarioFrameworkLayerBase.c:242
m_aActivationConditions
protected ref array< ref SCR_ScenarioFrameworkActivationConditionBase > m_aActivationConditions
Definition: SCR_ScenarioFrameworkLayerBase.c:46
OnObjectDamage
void OnObjectDamage(EDamageState state)
Definition: SCR_ScenarioFrameworkSlotBase.c:67
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180