Dayz Explorer 1.28.160049
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
30
35 {
36
37 }
38
43 {
44
45 }
46
50 override void InitEffect()
51 {
52 super.InitEffect();
53
54 // Would be neat, but since particles are often already playing
55 // BEFORE they are even registered as the particle for the Effect
56 // Better to just keep that one I guess..
57 // Event_OnStarted.Remove(Event_OnEffectStarted);
58
59 // Will be called by the particle events
61 }
62
63
67 override string GetDebugName()
68 {
69 string identifier;
70 if (GetParticle())
71 {
72 identifier = GetParticle().GetDebugNameNative();
73 }
74 else
75 {
76 identifier = "NO_PARTICLE";
77 }
78
79 return string.Format("%1:%2:%3", super.GetDebugName(), m_ParticleID, identifier);
80 }
81
87 override void ValidateStart()
88 {
89 if (!GetParticle())
90 {
91 //ErrorEx(string.Format("No Particle started playing, stopping EffectParticle: %1", GetDebugName()), ErrorExSeverity.WARNING);
92 Stop();
93 }
94 }
95
96
97
102
108 {
109 return EffectType.PARTICLE;
110 }
111
116 override bool IsParticle()
117 {
118 return true;
119 }
120
122
123
124
129
135 {
136 // Unregister the events on the old
137 if (m_ParticleObj)
138 {
139 ParticleEvents ope = m_ParticleObj.GetEvents();
140 ope.Event_OnParticleStart.Remove(Event_OnEffectStarted);
141 ope.Event_OnParticleStop.Remove(Event_OnEffectEnded);
142 }
143
144 // Assign the new main Particle
145 m_ParticleObj = p;
146
147 // Register the events on the new
148 if (m_ParticleObj)
149 {
150 ParticleEvents npe = m_ParticleObj.GetEvents();
151 npe.Event_OnParticleStart.Insert(Event_OnEffectStarted);
152 // We will use Stop instead of End, as old particles were destroyed when they stopped
153 // And this system kinda relies on that
154 npe.Event_OnParticleStop.Insert(Event_OnEffectEnded);
155 }
156 }
157
163 {
164 return m_ParticleObj;
165 }
166
168
169
170
176
181 override void Start()
182 {
183 if (m_ParticleID > 0)
184 {
185 vector pos = GetPosition();
186 vector ori = GetOrientation();
187
188 if (m_ParentObject)
189 {
190 pos = GetLocalPosition();
191 ori = GetAttachedLocalOri();
192 }
193
194 SetParticle(ParticleManager.GetInstance().CreateParticle(m_ParticleID, pos, true, GetParent(), ori, IsParticleRotationRelativeToWorld()));
195 }
196
197 super.Start();
198 }
199
204 override void Stop()
205 {
206 if ( GetParticle() )
207 {
208 GetParticle().Stop();
209 SetParticle(null);
210 }
211
212 super.Stop();
213 }
214
216
217
218
223
227 void AttachTo(Object obj, vector local_pos = "0 0 0", vector local_ori = "0 0 0", bool force_rotation_to_world = false)
228 {
229 // Update the cached variables...
230 SetParent(obj);
231 SetLocalPosition(local_pos);
232 SetAttachedLocalOri(local_ori);
233 ForceParticleRotationRelativeToWorld(force_rotation_to_world);
234
235 // Now attach it
236 AddAsChild(obj, local_pos, local_ori, force_rotation_to_world);
237 }
238
242 void ReAttach()
243 {
244 // Skip the updating, as we are going to reuse what was set before
246 }
247
251 protected void AddAsChild(Object obj, vector local_pos, vector local_ori, bool force_rotation_to_world)
252 {
253 Particle p = GetParticle();
254 if (p)
255 {
256 p.AddAsChild(obj, local_pos, local_ori, force_rotation_to_world);
257 }
258 }
259
261
262
263
268
275 {
276
277 }
278
285 {
286
287 }
288
290
291
292
297
303 void SetParticleID( int id )
304 {
305 m_ParticleID = id;
306 }
307
314 {
315 return m_ParticleID;
316 }
317
323 void SetCurrentParticleID( int id )
324 {
325 m_ParticleID = id;
326
327 Particle p = GetParticle();
328 if (p)
329 {
330 p.SetSource(id);
331 }
332 }
333
339 {
340 Particle p = GetParticle();
341 if (p)
342 {
343 return p.GetParticleID();
344 }
345 else
346 {
347 return ParticleList.INVALID;
348 }
349 }
350
356 override void SetCurrentParent( Object parent_obj, bool updateCached = true )
357 {
358 super.SetCurrentParent(parent_obj, updateCached);
359
360 ReAttach();
361 }
362
368 {
369 Particle p = GetParticle();
370
371 if (p)
372 return Object.Cast(p.GetParent());
373 else
374 return super.GetParent();
375 }
376
382 override void SetCurrentPosition( vector pos, bool updateCached = true )
383 {
384 super.SetCurrentPosition(pos, updateCached);
385
386 Particle p = GetParticle();
387
388 if (p)
389 p.SetPosition(pos);
390 }
391
397 {
398 Particle p = GetParticle();
399
400 if (p)
401 return p.GetPosition();
402 else
403 return super.GetPosition();
404 }
405
411 override void SetCurrentLocalPosition( vector pos, bool updateCached = true )
412 {
413 super.SetCurrentLocalPosition(pos, updateCached);
414
415 Particle p = GetParticle();
416 if (p)
417 {
418 Object parent = GetParent();
419
420 if (parent)
421 ReAttach();
422 else
423 p.SetPosition(pos);
424 }
425 }
426
432 {
433 Particle p = GetParticle();
434
435 if (p)
436 {
437 Object parent = GetParent();
438
439 if (parent)
440 return parent.WorldToModel(p.GetPosition());
441 else
442 return p.GetPosition();
443 }
444 else
445 return super.GetLocalPosition();
446 }
447
454 {
455 m_Orientation = ori;
456 }
457
464 {
465 return m_Orientation;
466 }
467
472 void SetCurrentOrientation( vector ori, bool updateCached = true )
473 {
474 if ( updateCached)
475 SetOrientation(ori);
476
477 Particle p = GetParticle();
478
479 if (p)
480 p.SetOrientation(ori);
481 }
482
488 {
489 Particle p = GetParticle();
490
491 if (p)
492 return p.GetOrientation();
493 else
494 return vector.Zero;
495 }
496
507
514 {
515 Particle p = GetParticle();
516
517 if (p)
518 return p.IsHierarchyPositionOnly();
519 else
521 }
522
528 {
529 Particle p = GetParticle();
530
531 if (p)
532 return p.IsHierarchyPositionOnly();
533 else
534 return false;
535 }
536
538
539
540
545
551 {
552 /*
553 if ( !m_ParticleObj )
554 {
555 delete this;
556 }
557
558 OnCheckUpdate();
559 */
560 }
561
563 {
564 m_Object = o;
565 }
566
568}
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 SetSource(int particle_id)
Sets particle id.
Definition particle.c:285
int GetParticleID()
Gets particle id.
Definition particle.c:297
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Definition particle.c:266
Object m_ParentObject
Cached parent.
Definition effect.c:39
void SetParent(Object parent_obj, int pivot)
Set parent of the Effect.
Definition effect.c:399
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
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:503
vector GetLocalPosition()
Get the local position of the Effect.
Definition effect.c:513
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:628
vector GetAttachedLocalOri()
Get the local orientation set by SetAttachedLocalOri.
Definition effect.c:638
class JsonUndergroundAreaTriggerData GetPosition
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)