DayZ 1.24
Loading...
Searching...
No Matches
EffectParticle.c
Go to the documentation of this file.
1
4class EffectParticle : Effect
5{
8
14 protected int m_ParticleID;
20
26 protected Object m_Object;
28
29
34 {
35
36 }
37
42 {
43
44 }
45
49 override void InitEffect()
50 {
51 super.InitEffect();
52
53 // Would be neat, but since particles are often already playing
54 // BEFORE they are even registered as the particle for the Effect
55 // Better to just keep that one I guess..
56 // Event_OnStarted.Remove(Event_OnEffectStarted);
57
58 // Will be called by the particle events
60 }
61
62
66 override string GetDebugName()
67 {
68 string identifier;
69 if (GetParticle())
70 identifier = GetParticle().GetDebugNameNative();
71 else
72 identifier = "NO_PARTICLE";
73
74 return string.Format("%1:%2:%3", super.GetDebugName(), m_ParticleID, identifier);
75 }
76
82 override void ValidateStart()
83 {
84 if (!GetParticle())
85 {
86 ErrorEx(string.Format("No Particle started playing, stopping EffectParticle: %1", GetDebugName()), ErrorExSeverity.WARNING);
87 Stop();
88 }
89 }
90
91
96
102 {
103 return EffectType.PARTICLE;
104 }
105
110 override bool IsParticle()
111 {
112 return true;
113 }
114
116
117
122
128 {
129 // Unregister the events on the old
130 if (m_ParticleObj)
131 {
132 ParticleEvents ope = m_ParticleObj.GetEvents();
133 ope.Event_OnParticleStart.Remove(Event_OnEffectStarted);
134 ope.Event_OnParticleStop.Remove(Event_OnEffectEnded);
135 }
136
137 // Assign the new main Particle
139
140 // Register the events on the new
141 if (m_ParticleObj)
142 {
143 ParticleEvents npe = m_ParticleObj.GetEvents();
144 npe.Event_OnParticleStart.Insert(Event_OnEffectStarted);
145 // We will use Stop instead of End, as old particles were destroyed when they stopped
146 // And this system kinda relies on that
147 npe.Event_OnParticleStop.Insert(Event_OnEffectEnded);
148 }
149 }
150
156 {
157 return m_ParticleObj;
158 }
159
161
162
168
173 override void Start()
174 {
175 if (m_ParticleID > 0)
176 {
177 vector pos = GetPosition();
179
180 if (m_ParentObject)
181 {
182 pos = GetLocalPosition();
184 }
185
186 SetParticle(ParticleManager.GetInstance().CreateParticle(m_ParticleID, pos, true, GetParent(), ori, IsParticleRotationRelativeToWorld()));
187 }
188
189 super.Start();
190 }
191
196 override void Stop()
197 {
198 if (GetParticle())
199 {
200 GetParticle().Stop();
202 }
203
204 super.Stop();
205 }
206
208
209
214
218 void AttachTo(Object obj, vector local_pos = "0 0 0", vector local_ori = "0 0 0", bool force_rotation_to_world = false)
219 {
220 // Update the cached variables...
221 SetParent(obj);
225
226 // Now attach it
228 }
229
233 void ReAttach()
234 {
235 // Skip the updating, as we are going to reuse what was set before
237 }
238
243 {
245 if (p)
246 p.AddAsChild(obj, local_pos, local_ori, force_rotation_to_world);
247 }
248
250
251
256
263 {
264
265 }
266
273 {
274
275 }
276
278
279
284
290 void SetParticleID(int id)
291 {
293 }
294
301 {
302 return m_ParticleID;
303 }
304
311 {
313
315 if (p)
316 p.SetSource(id);
317 }
318
324 {
326 if (p)
327 return p.GetParticleID();
328 else
329 return ParticleList.INVALID;
330 }
331
337 override void SetCurrentParent(Object parent_obj, bool updateCached = true)
338 {
339 super.SetCurrentParent(parent_obj, updateCached);
340
341 ReAttach();
342 }
343
349 {
351
352 if (p)
353 return Object.Cast(p.GetParent());
354 else
355 return super.GetParent();
356 }
357
363 override void SetCurrentPosition(vector pos, bool updateCached = true)
364 {
365 super.SetCurrentPosition(pos, updateCached);
366
368
369 if (p)
370 p.SetPosition(pos);
371 }
372
378 {
380
381 if (p)
382 return p.GetPosition();
383 else
384 return super.GetPosition();
385 }
386
392 override void SetCurrentLocalPosition(vector pos, bool updateCached = true)
393 {
394 super.SetCurrentLocalPosition(pos, updateCached);
395
397 if (p)
398 {
399 Object parent = GetParent();
400
401 if (parent)
402 ReAttach();
403 else
404 p.SetPosition(pos);
405 }
406 }
407
413 {
415
416 if (p)
417 {
418 Object parent = GetParent();
419
420 if (parent)
421 return parent.WorldToModel(p.GetPosition());
422 else
423 return p.GetPosition();
424 }
425 else
426 return super.GetLocalPosition();
427 }
428
435 {
437 }
438
445 {
446 return m_Orientation;
447 }
448
454 {
455 if (updateCached)
457
459
460 if (p)
461 p.SetOrientation(ori);
462 }
463
469 {
471
472 if (p)
473 return p.GetOrientation();
474 else
475 return vector.Zero;
476 }
477
488
495 {
497
498 if (p)
499 return p.IsHierarchyPositionOnly();
500 else
502 }
503
509 {
511
512 if (p)
513 return p.IsHierarchyPositionOnly();
514 else
515 return false;
516 }
517
519
520
525
531 {
532 /*
533 if ( !m_ParticleObj )
534 {
535 delete this;
536 }
537
538 OnCheckUpdate();
539 */
540 }
541
543 {
544 m_Object = o;
545 }
546
548}
Object m_ParentObject
Cached parent.
Definition Effect.c:39
ref ScriptInvoker Event_OnEffectStarted
Event used when the actual effect started playing.
Definition Effect.c:24
EffectType
Enum to determine what type of effect the Effect is.
Definition Effect.c:3
void SetParent(Object parent_obj)
Set parent of the Effect.
Definition Effect.c:378
ref ScriptInvoker Event_OnEffectEnded
Event used when the actual effect stopped playing.
Definition Effect.c:25
void SetLocalPosition(vector pos)
Set the local position of the Effect.
Definition Effect.c:460
vector GetLocalPosition()
Get the local position of the Effect.
Definition Effect.c:470
ref ScriptInvoker Event_OnStopped
Event used when Stop was called.
Definition Effect.c:23
void SetAttachedLocalOri(vector ori)
Set local orientation for the Effectparticle to attach to when the Effect is started.
Definition Effect.c:583
vector GetAttachedLocalOri()
Get the local orientation set by SetAttachedLocalOri.
Definition Effect.c:593
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
class JsonUndergroundAreaTriggerData GetPosition
Wrapper class for managing particles through SEffectManager.
override string GetDebugName()
Override when getting debug information.
override void Stop()
Stops all elements this effect consists of.
Particle GetParticle()
Gets the main particle which this Effect is managing.
int GetCurrentParticleID()
Gets the current id of the managed Particle.
vector GetOrientation()
Get the orientation of the EffectParticle.
override void Start()
Plays all elements this effect consists of.
bool m_ForceRotationRelativeToWorld
Orientation setting to be used by the effect when the Effect starts.
void ~EffectParticle()
dtor
void SetParticleID(int id)
Sets the id of the particle to be used.
void SetParticle(Particle p)
Sets the main particle which this Effect will manage.
void Event_OnPlayStarted()
Event which just simply exists (DEPRECATED)
override void ValidateStart()
Validation whether an effect truly started playing or if the Effect should stop as none is present.
void EffectParticle()
ctor
void SetCurrentOrientation(vector ori, bool updateCached=true)
Set the current orientation of the managed Particle.
int GetParticleID()
Gets the id of the particle to be used.
override void InitEffect()
init
vector GetCurrentOrientation()
Get the current orientation of the managed Particle.
bool IsParticleRotationRelativeToWorld()
Get the orientation setting to be used by the effect when the Effect starts.
Particle m_ParticleObj
The main Particle effect that this Effect wrapper manages.
void ReAttach()
Helper method to attach to parent using stored settings.
override Object GetCurrentParent()
Get the current parent of the managed Particle.
override void SetCurrentPosition(vector pos, bool updateCached=true)
Set the current world position of the managed Particle.
vector m_ParticleOrientation
void SetDecalOwner(Object o)
void Event_OnPlayStart()
Event which just simply exists (DEPRECATED)
override bool IsParticle()
Check whether the Effect is EffectParticle without casting.
override void SetCurrentParent(Object parent_obj, bool updateCached=true)
Set current parent of the managed Particle.
void ForceParticleRotationRelativeToWorld(bool state)
Set orientation setting to be used by the effect when the Effect starts.
override EffectType GetEffectType()
Get what type of effect the Effect is.
void AttachTo(Object obj, vector local_pos="0 0 0", vector local_ori="0 0 0", bool force_rotation_to_world=false)
Read Particle.AddAsChild.
bool IsParticleCurrentRotationRelativeToWorld()
Get the current orientation setting to be used by the managed Particle.
void AddAsChild(Object obj, vector local_pos, vector local_ori, bool force_rotation_to_world)
Helper method to attach to parent.
override vector GetCurrentPosition()
Get the current world position of the managed Particle.
void SetOrientation(vector ori)
Set orientation of the EffectParticle.
override vector GetCurrentLocalPosition()
Get the current local position of the managed Particle.
int m_ParticleID
The ID in the ParticleList to create Particle from.
override void SetCurrentLocalPosition(vector pos, bool updateCached=true)
Set the current local position of the managed Particle.
void SetCurrentParticleID(int id)
Sets the id of the particle to be used.
vector m_Orientation
Orientation set by SetOrientation.
void CheckLifeSpan()
Was never called and probably should never be called.
Invokers for ParticleBase events, called from events.
Legacy way of using particles in the game.
Definition Particle.c:7
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Definition Particle.c:262
static const int INVALID
static const vector Zero
Definition EnConvert.c:110
ErrorExSeverity
Definition EnDebug.c:62
enum ShapeType ErrorEx
proto native Widget GetParent()
Get parent of the Effect.
Definition Effect.c:389