Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_BaseEffectManagerComponent.c
Go to the documentation of this file.
1 //class SCR_BaseEffectManagerComponentClass : MotorExhaustEffectComponentClass
2 class SCR_BaseEffectManagerComponentClass : ScriptComponentClass
3 {
4 };
5 
6 //------------------------------------------------------------------------------------------------
7 //TODO: Get rid of MotorExhaustEffectComponent typename
8 //this class must be independent on vehicles
9 //the base class is meant to work with any type of object
10 //class SCR_BaseEffectManagerComponent : MotorExhaustEffectComponent
12 {
13  [Attribute()]
14  protected ref array<ref SCR_EffectModule> m_aEffectModules; //array of all effect modules
15  protected ref array<ref SCR_EffectModule> m_aEffectModulesActive = {}; //array of all ACTIVATED effect modules
16  protected IEntity m_pOwner; //the entity which is owner of this component
17  protected bool m_bInitiated = false;
18  protected const bool ON_PHYSIC_ONLY = false;
19  protected const bool ON_FRAME = true;
20 
21  //------------------------------------------------------------------------------------------------
22  //USER METHODS
23  //------------------------------------------------------------------------------------------------
24 
25  //------------------------------------------------------------------------------------------------
26  protected void DeactivateModule(SCR_EffectModule pModule)
27  {
28  m_aEffectModulesActive.RemoveItem(pModule);
29  }
30 
31  //------------------------------------------------------------------------------------------------
32  protected void ActivateModule(SCR_EffectModule pModule)
33  {
34  if (m_aEffectModulesActive.Find(pModule) == -1)
35  {
36  pModule.Init(this);
37  m_aEffectModulesActive.Insert(pModule);
38  }
39  }
40 
41  //------------------------------------------------------------------------------------------------
43  protected void ActivateAllModules(bool bPhysics)
44  {
45  foreach (SCR_EffectModule pModule : m_aEffectModules)
46  {
47  if (!pModule)
48  continue;
49  if (pModule.GetTickOnFrame() == bPhysics)
50  ActivateModule(pModule);
51  }
52  }
53 
54  //------------------------------------------------------------------------------------------------
56  protected void DeactivateAllModules(bool bPhysics)
57  {
58  for (int i = 0; i < m_aEffectModulesActive.Count(); i++)
59  {
60  if (!m_aEffectModulesActive[i])
61  continue;
62  if (m_aEffectModulesActive[i].GetTickOnFrame() == bPhysics)
63  DeactivateModule(m_aEffectModulesActive[i]);
64  }
65  }
66 
67  //------------------------------------------------------------------------------------------------
68  protected void InitModules(bool bTickOnFrame = false)
69  {
70  foreach (SCR_EffectModule pModule : m_aEffectModules)
71  {
72  if (!pModule)
73  continue;
74  if (m_aEffectModulesActive.Find(pModule) != -1)
75  continue; //this module is already activated
76  if (pModule.GetTickOnFrame() == bTickOnFrame)
77  {
78  pModule.Init(this);
79  ActivateModule(pModule); //add it to the array of active modules
80  }
81  }
82  }
83 
84  //------------------------------------------------------------------------------------------------
85  //STANDARD METHODS
86  //------------------------------------------------------------------------------------------------
87  #ifdef WORKBENCH
88  //------------------------------------------------------------------------------------------------------------
89  override void _WB_AfterWorldUpdate(IEntity owner, float timeSlice)
90  {
91  foreach (SCR_EffectModule pModule : m_aEffectModules)
92  {
93  if (!pModule)
94  continue;
95  pModule.WB_Update(owner, timeSlice);
96  }
97  }
98  #endif
99 
100  //------------------------------------------------------------------------------------------------
101  void UpdateModules(float timeSlice)
102  {
103  foreach (SCR_EffectModule pModule : m_aEffectModulesActive)
104  {
105  if (!pModule)
106  continue;
107  pModule.Update(m_pOwner, timeSlice);
108  }
109  }
110 
111  //------------------------------------------------------------------------------------------------
112  override void EOnInit(IEntity owner)
113  {
114  ActivateAllModules(ON_FRAME);
115  }
116 
117  override void EOnPhysicsActive(IEntity owner, bool activeState)
118  {
119  if (System.IsConsoleApp()) //don't run it on DS
120  return;
121 
122  if (activeState)
123  {
124  m_pOwner = owner;
125  ActivateAllModules(ON_PHYSIC_ONLY);
126 
127  }
128  else
129  {
130  DeactivateAllModules(ON_PHYSIC_ONLY);
131  }
132  }
133 
134  override void EOnDeactivate(IEntity owner)
135  {
136  super.EOnDeactivate(owner);
137 
138  DisconnectFromEffectManagerSystem();
139  }
140 
141  override void EOnActivate(IEntity owner)
142  {
143  super.EOnActivate(owner);
144 
145  ConnectToEffectManagerSystem();
146  }
147 
148  //------------------------------------------------------------------------------------------------
149  override void OnPostInit(IEntity owner)
150  {
151  super.OnPostInit(owner);
152 
153  m_pOwner = owner;
154 
155  if (System.IsConsoleApp()) //don't run it on DS
156  return;
157 
158  SetEventMask(owner, EntityEvent.INIT | EntityEvent.PHYSICSACTIVE);
159  ConnectToEffectManagerSystem();
160  }
161 
162  override void OnDelete(IEntity owner)
163  {
164  DisconnectFromEffectManagerSystem();
165 
166  super.OnDelete(owner);
167  }
168 
169  private void ConnectToEffectManagerSystem()
170  {
171  World world = m_pOwner.GetWorld();
172  EffectManagerSystem updateSystem = EffectManagerSystem.Cast(world.FindSystem(EffectManagerSystem));
173  if (!updateSystem)
174  return;
175 
176  updateSystem.Register(this);
177  }
178 
179  private void DisconnectFromEffectManagerSystem()
180  {
181  World world = m_pOwner.GetWorld();
182  EffectManagerSystem updateSystem = EffectManagerSystem.Cast(world.FindSystem(EffectManagerSystem));
183  if (!updateSystem)
184  return;
185 
186  updateSystem.Unregister(this);
187  }
188 
189  #ifdef WORKBENCH
190  //------------------------------------------------------------------------------------------------
191  override void _WB_OnInit(IEntity owner, inout vector mat[4], IEntitySource src)
192  {
193  foreach (SCR_EffectModule pModule : m_aEffectModules)
194  {
195  if (!pModule)
196  continue;
197  pModule.WB_OnInit(owner, mat, src);
198  }
199  }
200  #endif
201 };
202 
203 //------------------------------------------------------------------------------------------------
205 {
206 };
207 
208 //------------------------------------------------------------------------------------------------
209 //Helicopter specific effect class
211 {
212  //------------------------------------------------------------------------------------------------
213  SCR_HelicopterControllerComponent GetHelicopterController()
214  {
215  if (!m_pOwner)
216  return null; //we don't have owner
217  return SCR_HelicopterControllerComponent.Cast(m_pOwner.FindComponent(SCR_HelicopterControllerComponent));
218  }
219 
220  //------------------------------------------------------------------------------------------------
221  override void EOnInit(IEntity owner)
222  {
223  super.EOnInit(owner);
224  }
225 };
226 
227 
228 
229 
230 
231 
232 
ScriptComponent
SCR_SiteSlotEntityClass ScriptComponent
SCR_BaseEffectManagerComponentClass
Definition: SCR_BaseEffectManagerComponent.c:2
EffectManagerSystem
Definition: EffectManagerSystem.c:1
SCR_HelicopterEffectManagerComponentClass
Definition: SCR_BaseEffectManagerComponent.c:204
Attribute
typedef Attribute
Post-process effect of scripted camera.
SCR_HelicopterEffectManagerComponent
Definition: SCR_BaseEffectManagerComponent.c:210
SCR_EffectModule
Definition: SCR_EffectModule.c:4
SCR_BaseEffectManagerComponent
Definition: SCR_BaseEffectManagerComponent.c:11