DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
EffectParticle.c
Go to the documentation of this file.
1
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();
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();
152 // We will use Stop instead of End, as old particles were destroyed when they stopped
153 // And this system kinda relies on that
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
504 {
506 }
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}
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:385
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:467
vector GetLocalPosition()
Get the local position of the Effect.
Definition Effect.c:477
protected Object m_ParentObject
Cached parent.
Definition Effect.c:39
ref ScriptInvoker Event_OnStopped
Event used when Stop was called.
Definition Effect.c:23
void Effect()
ctor
Definition Effect.c:70
void SetAttachedLocalOri(vector ori)
Set local orientation for the Effectparticle to attach to when the Effect is started.
Definition Effect.c:592
vector GetAttachedLocalOri()
Get the local orientation set by SetAttachedLocalOri.
Definition Effect.c:602
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
class JsonUndergroundAreaTriggerData GetPosition
Wrapper class for managing particles through SEffectManager.
protected int m_ParticleID
The ID in the ParticleList to create Particle from.
protected vector m_Orientation
Orientation set by SetOrientation.
void SetCurrentOrientation(vector ori, bool updateCached=true)
Set the current orientation of the managed Particle.
void SetDecalOwner(Object o)
void ReAttach()
Helper method to attach to parent using stored settings.
override string GetDebugName()
Override when getting debug information.
protected bool m_ForceRotationRelativeToWorld
Orientation setting to be used by the effect when the Effect starts.
protected Particle m_ParticleObj
The main Particle effect that this Effect wrapper manages.
void SetParticleID(int id)
Sets the id of the particle to be used.
vector GetOrientation()
Get the orientation of the EffectParticle.
override void SetCurrentPosition(vector pos, bool updateCached=true)
Set the current world position of the managed Particle.
protected Object m_Object
void Event_OnPlayStart()
Event which just simply exists (DEPRECATED)
void EffectParticle()
ctor
override void SetCurrentParent(Object parent_obj, bool updateCached=true)
Set current parent of the managed Particle.
override void InitEffect()
init
protected void AddAsChild(Object obj, vector local_pos, vector local_ori, bool force_rotation_to_world)
Helper method to attach to parent.
bool IsParticleCurrentRotationRelativeToWorld()
Get the current orientation setting to be used by the managed Particle.
void Event_OnPlayStarted()
Event which just simply exists (DEPRECATED)
Particle GetParticle()
Gets the main particle which this Effect is managing.
void SetCurrentParticleID(int id)
Sets the id of the particle to be used.
void ~EffectParticle()
dtor
override void Start()
Plays all elements this effect consists of.
override vector GetCurrentPosition()
Get the current world position of the managed Particle.
override vector GetCurrentLocalPosition()
Get the current local position of the managed Particle.
void SetOrientation(vector ori)
Set orientation of the EffectParticle.
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 IsParticleRotationRelativeToWorld()
Get the orientation setting to be used by the effect when the Effect starts.
void ForceParticleRotationRelativeToWorld(bool state)
Set orientation setting to be used by the effect when the Effect starts.
void CheckLifeSpan()
Was never called and probably should never be called.
override void Stop()
Stops all elements this effect consists of.
override bool IsParticle()
Check whether the Effect is EffectParticle without casting.
int GetParticleID()
Gets the id of the particle to be used.
override Object GetCurrentParent()
Get the current parent of the managed Particle.
override void ValidateStart()
Validation whether an effect truly started playing or if the Effect should stop as none is present.
protected vector m_ParticleOrientation
void SetParticle(Particle p)
Sets the main particle which this Effect will manage.
override void SetCurrentLocalPosition(vector pos, bool updateCached=true)
Set the current local position of the managed Particle.
vector GetCurrentOrientation()
Get the current orientation of the managed Particle.
int GetCurrentParticleID()
Gets the current id of the managed Particle.
override EffectType GetEffectType()
Get what type of effect the Effect is.
Invokers for ParticleBase events, called from events.
ref ScriptInvoker Event_OnParticleStart
Called when particle starts playing.
ref ScriptInvoker Event_OnParticleStop
Called when particle stops playing.
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:266
void AddAsChild(Object parent, vector local_pos="0 0 0", vector local_ori="0 0 0", bool force_rotation_to_world=false)
Attaches this particle onto some object. If null value is provided then the particle will be detached...
Definition Particle.c:563
void SetSource(int particle_id)
Sets particle id.
Definition Particle.c:285
int GetParticleID()
Gets particle id.
Definition Particle.c:297
static const int INVALID
proto bool Remove(func fn, int flags=EScriptInvokerRemoveFlags.ALL)
remove specific call from list
proto bool Insert(func fn, int flags=EScriptInvokerInsertFlags.IMMEDIATE)
insert method to list
static const vector Zero
Definition EnConvert.c:110
ErrorExSeverity
Definition EnDebug.c:62
enum ShapeType ErrorEx
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
proto native Widget GetParent()
Get parent of the Effect.
Definition Effect.c:396