Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_ScenarioFrameworkSlotTrigger.c
Go to the documentation of this file.
1 [EntityEditorProps(category: "GameScripted/ScenarioFramework/Slot", description: "")]
3 {
4 }
5 
6 class SCR_ScenarioFrameworkSlotTrigger : SCR_ScenarioFrameworkSlotBase
7 {
8  [Attribute(desc: "Actions that will be performed after trigger conditions are true and the trigger itself activates (not the slot itself)", category: "OnActivation")];
9  protected ref array<ref SCR_ScenarioFrameworkActionBase> m_aTriggerActions;
10 
11  //------------------------------------------------------------------------------------------------
13  override void RestoreToDefault(bool includeChildren = false, bool reinitAfterRestoration = false)
14  {
15  foreach (SCR_ScenarioFrameworkActionBase activationAction : m_aTriggerActions)
16  {
17  activationAction.m_iNumberOfActivations = 0;
18  }
19 
20  super.RestoreToDefault(includeChildren, reinitAfterRestoration);
21  }
22 
23  //------------------------------------------------------------------------------------------------
24  override void Init(SCR_ScenarioFrameworkArea area = null, SCR_ScenarioFrameworkEActivationType activation = SCR_ScenarioFrameworkEActivationType.SAME_AS_PARENT)
25  {
26  if (m_bIsTerminated)
27  {
28  if (m_ParentLayer)
29  m_ParentLayer.CheckAllChildrenSpawned(this);
30 
31  return;
32  }
33 
34  if (!m_ParentLayer)
35  {
36  IEntity entity = GetOwner().GetParent();
37  if (!entity)
38  return;
39 
41  }
42 
43  if (!m_bDynamicallyDespawned && activation != m_eActivationType)
44  {
45  if (m_ParentLayer)
46  m_ParentLayer.CheckAllChildrenSpawned(this);
47  }
48 
50  {
51  //If just one condition is false, we don't continue and interrupt the init
52  if (!activationCondition.Init(GetOwner()))
53  {
54  if (m_ParentLayer)
55  m_ParentLayer.CheckAllChildrenSpawned(this);
56 
57  return;
58  }
59  }
60 
62  {
63  IEntity entity = GetOwner().GetParent();
64  if (!entity)
65  return;
66 
68  if (!layerBase)
69  return;
70 
71  if (!layerBase.GetEnableRepeatedSpawn())
72  {
73  Print(string.Format("ScenarioFramework: Object %1 already exists and won't be spawned for %2, exiting...", m_Entity, GetOwner().GetName()), LogLevel.ERROR);
74  return;
75  }
76  }
77 
78  // Handles inheritance of faction settings from parents
79  if (m_sFactionKey.IsEmpty() && m_ParentLayer && !m_ParentLayer.GetFactionKey().IsEmpty())
80  SetFactionKey(m_ParentLayer.GetFactionKey());
81 
82  if (!m_bUseExistingWorldAsset)
83  {
84  m_Entity = SpawnAsset();
85  }
86  else
87  {
88  QueryObjectsInRange(); //sets the m_Entity in subsequent callback
89  }
90 
92 
93  if (m_Entity)
94  {
95  BaseGameTriggerEntity trigger = BaseGameTriggerEntity.Cast(m_Entity);
96  if (trigger)
97  trigger.EnablePeriodicQueries(false);
98  }
99  else
100  {
102  return;
103  }
104 
105  if (!m_sID.IsEmpty())
106  m_Entity.SetName(m_sID);
107 
108  SCR_DamageManagerComponent objectDmgManager = SCR_DamageManagerComponent.GetDamageManager(m_Entity);
109  if (objectDmgManager)
110  objectDmgManager.GetOnDamageStateChanged().Insert(OnObjectDamage);
111 
112  if (Vehicle.Cast(m_Entity))
113  {
114  EventHandlerManagerComponent ehManager = EventHandlerManagerComponent.Cast(m_Entity.FindComponent(EventHandlerManagerComponent));
115  if (ehManager)
116  ehManager.RegisterScriptHandler("OnCompartmentEntered", this, OnCompartmentEntered, true);
117  }
118 
119  if (!area)
120  {
121  SCR_GameModeSFManager gameModeComp = SCR_GameModeSFManager.Cast(GetGame().GetGameMode().FindComponent(SCR_GameModeSFManager));
122  if (gameModeComp)
123  area = gameModeComp.GetParentArea(GetOwner());
124  }
125  m_Area = area;
126 
128  }
129 
130  //------------------------------------------------------------------------------------------------
132  {
133  m_bInitiated = true;
134 
135  if (m_ParentLayer)
136  m_ParentLayer.CheckAllChildrenSpawned(this);
137 
138  if (!m_Area)
139  m_Area = GetParentArea();
140 
141  if (m_Area)
142  {
143  m_Area.GetOnAllChildrenSpawned().Insert(AfterParentAreaChildrenSpawned);
144  m_Area.CheckAllChildrenSpawned(this);
145  }
146 
148  }
149 
150  //------------------------------------------------------------------------------------------------
152  {
153  foreach (SCR_ScenarioFrameworkPlugin plugin : m_aPlugins)
154  {
155  plugin.Init(this);
156  }
157 
158  foreach (SCR_ScenarioFrameworkActionBase activationAction : m_aActivationActions)
159  {
160  activationAction.Init(GetOwner());
161  }
162 
163  foreach (SCR_ScenarioFrameworkActionBase triggerAction : m_aTriggerActions)
164  {
165  triggerAction.Init(m_Entity);
166  }
167 
168  if (m_fRepeatedSpawnTimer >= 0)
169  RepeatedSpawn();
170 
171  if (m_Area)
172  m_Area.GetOnAllChildrenSpawned().Remove(AfterParentAreaChildrenSpawned);
173 
174  if (m_Entity)
175  {
176  BaseGameTriggerEntity trigger = BaseGameTriggerEntity.Cast(m_Entity);
177  if (trigger)
178  trigger.EnablePeriodicQueries(true);
179  }
180  }
181 }
m_aPlugins
protected ref array< ref SCR_ScenarioFrameworkPlugin > m_aPlugins
Definition: SCR_ScenarioFrameworkLayerBase.c:55
SCR_ScenarioFrameworkActivationConditionBase
Definition: SCR_ScenarioFrameworkSlotBase.c:677
m_eActivationType
protected SCR_ScenarioFrameworkEActivationType m_eActivationType
Definition: SCR_ScenarioFrameworkLayerBase.c:43
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
GetOnAllChildrenSpawned
ScriptInvokerScenarioFrameworkLayer GetOnAllChildrenSpawned()
Definition: SCR_ScenarioFrameworkLayerBase.c:450
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
m_bEnableRepeatedSpawn
protected bool m_bEnableRepeatedSpawn
Definition: SCR_ScenarioFrameworkLayerBase.c:31
m_Area
protected SCR_ScenarioFrameworkArea m_Area
Definition: SCR_ScenarioFrameworkLayerBase.c:64
m_aActivationActions
protected ref array< ref SCR_ScenarioFrameworkActionBase > m_aActivationActions
Definition: SCR_ScenarioFrameworkLayerBase.c:49
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
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_fRepeatedSpawnTimer
protected float m_fRepeatedSpawnTimer
Definition: SCR_ScenarioFrameworkLayerBase.c:37
GetGameMode
SCR_BaseGameMode GetGameMode()
Definition: SCR_BaseGameModeComponent.c:15
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
RepeatedSpawn
protected void RepeatedSpawn()
Definition: SCR_ScenarioFrameworkLayerBase.c:426
SCR_ScenarioFrameworkPlugin
Definition: SCR_ScenarioFrameworkLayerBase.c:888
GetOwner
IEntity GetOwner()
Owner entity of the fuel tank.
Definition: SCR_FuelNode.c:128
m_ParentLayer
protected SCR_ScenarioFrameworkLayerBase m_ParentLayer
Definition: SCR_ScenarioFrameworkLayerBase.c:65
m_bIsTerminated
protected bool m_bIsTerminated
Definition: SCR_ScenarioFrameworkLayerBase.c:75
GetParentArea
SCR_ScenarioFrameworkArea GetParentArea()
Get parent area the object is nested into.
Definition: SCR_ScenarioFrameworkLayerBase.c:179
m_aTriggerActions
protected ref array< ref SCR_ScenarioFrameworkActionBase > m_aTriggerActions
Definition: SCR_ScenarioFrameworkSlotTrigger.c:9
Attribute
SCR_ScenarioFrameworkSlotTriggerClass SCR_ScenarioFrameworkSlotBaseClass Attribute(desc:"Actions that will be performed after trigger conditions are true and the trigger itself activates (not the slot itself)", category:"OnActivation")]
SCR_ScenarioFrameworkLayerBase
void SCR_ScenarioFrameworkLayerBase(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition: SCR_ScenarioFrameworkLayerBase.c:875
RestoreToDefault
override void RestoreToDefault(bool includeChildren=false, bool reinitAfterRestoration=false)
Definition: SCR_ScenarioFrameworkSlotTrigger.c:13
AfterParentAreaChildrenSpawned
protected void AfterParentAreaChildrenSpawned(SCR_ScenarioFrameworkLayerBase layer)
Definition: SCR_ScenarioFrameworkSlotTrigger.c:151
SpawnAsset
IEntity SpawnAsset(string name, ResourceName type, IEntity spawnpoint=null)
Definition: SCR_CampaignTutorialComponentArland.c:1199
Init
override void Init(SCR_ScenarioFrameworkArea area=null, SCR_ScenarioFrameworkEActivationType activation=SCR_ScenarioFrameworkEActivationType.SAME_AS_PARENT)
Definition: SCR_ScenarioFrameworkSlotTrigger.c:24
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
SCR_ScenarioFrameworkSlotTriggerClass
Definition: SCR_ScenarioFrameworkSlotTrigger.c:2
OnObjectDamage
void OnObjectDamage(EDamageState state)
Definition: SCR_ScenarioFrameworkSlotBase.c:67
category
params category
Definition: SCR_VehicleDamageManagerComponent.c:180
AfterAllChildrenSpawned
override void AfterAllChildrenSpawned(SCR_ScenarioFrameworkLayerBase layer)
Definition: SCR_ScenarioFrameworkSlotTrigger.c:131