Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_BaseEffectManagerComponent.c
Go to the documentation of this file.
1//class SCR_BaseEffectManagerComponentClass : MotorExhaustEffectComponentClass
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 {
61 continue;
62 if (m_aEffectModulesActive[i].GetTickOnFrame() == bPhysics)
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 //------------------------------------------------------------------------------------------------------------
90 {
91 return EEntityFrameUpdateSpecs.CALL_WHEN_ENTITY_VISIBLE;
92 }
93
94 //------------------------------------------------------------------------------------------------------------
95 override void _WB_AfterWorldUpdate(IEntity owner, float timeSlice)
96 {
97 foreach (SCR_EffectModule pModule : m_aEffectModules)
98 {
99 if (!pModule)
100 continue;
101 pModule.WB_Update(owner, timeSlice);
102 }
103 }
104 #endif
105
106 //------------------------------------------------------------------------------------------------
107 void UpdateModules(float timeSlice)
108 {
109 foreach (SCR_EffectModule pModule : m_aEffectModulesActive)
110 {
111 if (!pModule)
112 continue;
113 pModule.Update(m_pOwner, timeSlice);
114 }
115 }
116
117 //------------------------------------------------------------------------------------------------
118 override void EOnInit(IEntity owner)
119 {
121 }
122
123 override void EOnPhysicsActive(IEntity owner, bool activeState)
124 {
125 if (System.IsConsoleApp()) //don't run it on DS
126 return;
127
128 if (activeState)
129 {
130 m_pOwner = owner;
132
133 }
134 else
135 {
137 }
138 }
139
140 override void EOnDeactivate(IEntity owner)
141 {
142 super.EOnDeactivate(owner);
143
144 DisconnectFromEffectManagerSystem();
145 }
146
147 override void EOnActivate(IEntity owner)
148 {
149 super.EOnActivate(owner);
150
151 ConnectToEffectManagerSystem();
152 }
153
154 //------------------------------------------------------------------------------------------------
155 override void OnPostInit(IEntity owner)
156 {
157 super.OnPostInit(owner);
158
159 m_pOwner = owner;
160
161 if (System.IsConsoleApp()) //don't run it on DS
162 return;
163
164 SetEventMask(owner, EntityEvent.INIT | EntityEvent.PHYSICSACTIVE);
165 ConnectToEffectManagerSystem();
166 }
167
168 override void OnDelete(IEntity owner)
169 {
170 DisconnectFromEffectManagerSystem();
171
172 super.OnDelete(owner);
173 }
174
175 private void ConnectToEffectManagerSystem()
176 {
177 World world = m_pOwner.GetWorld();
178 EffectManagerSystem updateSystem = EffectManagerSystem.Cast(world.FindSystem(EffectManagerSystem));
179 if (!updateSystem)
180 return;
181
182 updateSystem.Register(this);
183 }
184
185 private void DisconnectFromEffectManagerSystem()
186 {
187 World world = m_pOwner.GetWorld();
188 EffectManagerSystem updateSystem = EffectManagerSystem.Cast(world.FindSystem(EffectManagerSystem));
189 if (!updateSystem)
190 return;
191
192 updateSystem.Unregister(this);
193 }
194
195 #ifdef WORKBENCH
196 //------------------------------------------------------------------------------------------------
197 override void _WB_OnInit(IEntity owner, inout vector mat[4], IEntitySource src)
198 {
199 foreach (SCR_EffectModule pModule : m_aEffectModules)
200 {
201 if (!pModule)
202 continue;
203 pModule.WB_OnInit(owner, mat, src);
204 }
205 }
206 #endif
207};
208
209//------------------------------------------------------------------------------------------------
213
214//------------------------------------------------------------------------------------------------
215//Helicopter specific effect class
217{
218 //------------------------------------------------------------------------------------------------
219 SCR_HelicopterControllerComponent GetHelicopterController()
220 {
221 if (!m_pOwner)
222 return null; //we don't have owner
223 return SCR_HelicopterControllerComponent.Cast(m_pOwner.FindComponent(SCR_HelicopterControllerComponent));
224 }
225
226 //------------------------------------------------------------------------------------------------
227 override void EOnInit(IEntity owner)
228 {
229 super.EOnInit(owner);
230 }
231};
232
233
234
235
236
237
238
enum EVehicleType IEntity
void Register(SCR_BaseEffectManagerComponent component)
void Unregister(SCR_BaseEffectManagerComponent component)
event int _WB_GetAfterWorldUpdateSpecs(IEntity owner, IEntitySource src)
Called after _WB_OnInit or also later when editor needs to know whether _WB_AfterWorldUpdate needs to...
proto external int SetEventMask(notnull IEntity owner, int mask)
event void _WB_OnInit(IEntity owner, inout vector mat[4], IEntitySource src)
Called always after entity creation. It's purpose is to prepare entity for editing....
event void _WB_AfterWorldUpdate(IEntity owner, float timeSlice)
Called after updating world in Workbench. The entity must be selected. You can use editor API here an...
proto external BaseWorld GetWorld()
void ActivateModule(SCR_EffectModule pModule)
ref array< ref SCR_EffectModule > m_aEffectModules
ref array< ref SCR_EffectModule > m_aEffectModulesActive
void ActivateAllModules(bool bPhysics)
Activate all modules which should be activated. Parameter decides if it should be activated on physic...
override void EOnPhysicsActive(IEntity owner, bool activeState)
void InitModules(bool bTickOnFrame=false)
void DeactivateModule(SCR_EffectModule pModule)
void DeactivateAllModules(bool bPhysics)
Deactivate all modules which should be deactivated. Parameter decides if it should be activated on ph...
void Init(SCR_BaseEffectManagerComponent manager)
Definition World.c:16
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14