DayZ 1.24
Loading...
Searching...
No Matches
Effect.c
Go to the documentation of this file.
1
11
16class Effect : Managed
17{
27
33 protected bool m_IsAutodestroy;
35 protected bool m_IsPendingDeletion;
37 protected bool m_IsPlaying;
41 protected vector m_Position;
43
49 protected int m_ID;
51 protected bool m_IsRegistered;
53
60 protected vector m_LocalPos;
62 protected vector m_LocalOri;
64
65
69 void Effect()
70 {
71 if (GetGame().IsDedicatedServer())
72 ErrorEx("Created Effect on server.", ErrorExSeverity.WARNING);
73
74 InitEffect();
75 }
76
80 void ~Effect()
81 {
82 // Safety
83 if (IsRegistered())
85
86 // Certain effects need to be stopped to clean up properly
87 Stop();
88
89 // Another safety
91 }
92
102
103
108
114 {
115 return EffectType.NONE;
116 }
117
122 bool IsSound()
123 {
124 return false;
125 }
126
132 {
133 return false;
134 }
135
137
138
144
149 void Start()
150 {
151 // It is already playing!
152 if (IsPlaying())
153 return;
154
156 // I can't call this from inside the method with same name
157 // because that method is often overriden without super......
158 Event_OnStarted.Invoke(this);
159 }
160
167 {
168
169 }
170
175 void Stop()
176 {
177 // It is not playing!
178 if (!IsPlaying())
179 return;
180
182 // Yes, that event is new, but let's keep up some consistency
183 Event_OnStopped.Invoke(this);
184 }
185
190 {
191 return m_IsPlaying;
192 }
193
195
196
201
207 protected void Destroy()
208 {
209 // Already queued
210 if (IsPendingDeletion())
211 return;
212
213 // Mark it to prevent queuing it up multiple times or get stuck in a call loop
214 m_IsPendingDeletion = true;
215
216 // Stop it, so that the effects can clean up themselves
217 // Since if for example this is EffectParticle and the particle is looping
218 // It NEEDS to be stopped to clean up the Particle
219 Stop();
220
221 // Queue up the destroying, as we should not do it while we are accessing it here
222 if (GetGame())
224 }
225
235
241 {
242 return m_IsAutodestroy;
243 }
244
250 {
251 return m_IsPendingDeletion;
252 }
253
259 {
260 return true;
261 }
262
264
265
277
278
283
288 {
289 // Override this method for own use
290 }
291
295 void Event_OnStopped()
296 {
297 // Override this method for own use
298 }
299
304 {
305 m_IsPlaying = true;
306
307 Event_OnEffectStarted.Invoke(this);
308 }
309
314 {
315 m_IsPlaying = false;
316
317 Event_OnEffectEnded.Invoke(this);
318
319 if (IsAutodestroy())
320 Destroy();
321 }
322
329 {
330 // Override this method for own use
331 }
332
339 {
340 SetID(id);
341 m_IsRegistered = true;
342 }
343
353
360 {
361
362 }
363
365
366
371
382
390 {
391 return m_ParentObject;
392 }
393
401 {
402 if (updateCached)
404 }
405
411 {
412 return null;
413 }
414
421 {
422 m_Position = pos;
423 }
424
431 {
432 return m_Position;
433 }
434
441 {
442 if (updateCached)
443 SetPosition(pos);
444 }
445
451 {
452 return vector.Zero;
453 }
454
461 {
462 m_LocalPos = pos;
463 }
464
471 {
472 return m_LocalPos;
473 }
474
481 {
482 if (updateCached)
483 SetLocalPosition(pos);
484 }
485
491 {
492 return vector.Zero;
493 }
494
496
497
502
508 protected void SetID(int id)
509 {
510 m_ID = id;
511 }
512
517 int GetID()
518 {
519 return m_ID;
520 }
521
527 {
528 return m_IsRegistered;
529 }
530
532
533
540
546 {
547 SetParent(obj);
548 }
549
555 {
556 return GetParent();
557 }
558
564 {
565 SetLocalPosition(pos);
566 }
567
573 {
574 return GetLocalPosition();
575 }
576
584 {
585 m_LocalOri = ori;
586 }
587
594 {
595 return m_LocalOri;
596 }
597
599}
bool m_IsRegistered
Whether the effect is registered in SEffectManager.
Definition Effect.c:51
void Start()
Plays all elements this effects consists of.
Definition Effect.c:149
void Event_OnRegistered(int id)
Event called from SEffectManager when the Effect is registered.
Definition Effect.c:338
void Stop()
Stops all elements this effect consists of.
Definition Effect.c:175
bool m_IsAutodestroy
Whether the Effect cleans up after itself when stopped.
Definition Effect.c:33
void SetCurrentParent(Object parent_obj, bool updateCached=true)
Set current parent of the managed effect.
Definition Effect.c:400
bool m_IsPlaying
Whether the Effect is currently playing.
Definition Effect.c:37
Object m_ParentObject
Cached parent.
Definition Effect.c:39
int GetID()
Get the ID registered in SEffectManager.
Definition Effect.c:517
vector GetAttachedLocalPos()
Get the local pos set by SetAttachedLocalPos.
Definition Effect.c:572
vector GetCurrentPosition()
Get the current world position of the managed effect.
Definition Effect.c:450
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
Object GetCurrentParent()
Get the current parent of the managed Effect.
Definition Effect.c:410
PARTICLE
EffectParticle.
Definition Effect.c:9
bool m_IsPendingDeletion
Whether the Destroy process has already been called.
Definition Effect.c:35
void SetParent(Object parent_obj)
Set parent of the Effect.
Definition Effect.c:378
int m_ID
ID of effect, given by SEffectManager when registered (automatically done when playing through it)
Definition Effect.c:49
bool IsRegistered()
Get whether this Effect is registered in SEffectManager.
Definition Effect.c:526
bool IsPlaying()
Returns true when the Effect is playing, false otherwise.
Definition Effect.c:189
void InitEffect()
init
Definition Effect.c:96
void SetCurrentPosition(vector pos, bool updateCached=true)
Set the current world position of the managed effect.
Definition Effect.c:440
void SetAttachedLocalPos(vector pos)
Set local pos for the Effect relative to the parent.
Definition Effect.c:563
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
vector m_Position
Cached world position.
Definition Effect.c:41
ref ScriptInvoker Event_OnStopped
Event used when Stop was called.
Definition Effect.c:23
void Effect()
ctor
Definition Effect.c:69
bool IsParticle()
Check whether the Effect is EffectParticle without casting.
Definition Effect.c:131
void SetAttachmentParent(Object obj)
Set parent for the Effect.
Definition Effect.c:545
SOUND
EffectSound.
Definition Effect.c:7
void ValidateStart()
Validation whether an effect truly started playing or if the Effect should stop as none is present.
Definition Effect.c:166
NONE
Plain Effect base.
Definition Effect.c:5
void SetCurrentLocalPosition(vector pos, bool updateCached=true)
Set the current local position of the managed effect.
Definition Effect.c:480
vector GetCurrentLocalPosition()
Get the current local position of the managed effect.
Definition Effect.c:490
void Event_OnFrameUpdate(float time_delta)
Event called on frame when enabled by SetEnableEventFrame(true)
Definition Effect.c:328
void SetID(int id)
Set the ID registered in SEffectManager.
Definition Effect.c:508
void ~Effect()
dtor
Definition Effect.c:80
Event_OnStarted
Event used when Start was called.
Definition Effect.c:287
vector m_LocalPos
Cached local pos.
Definition Effect.c:60
EffectType GetEffectType()
Get what type of effect the Effect is.
Definition Effect.c:113
bool IsSound()
Check whether the Effect is EffectSound without casting.
Definition Effect.c:122
void SetAttachedLocalOri(vector ori)
Set local orientation for the Effectparticle to attach to when the Effect is started.
Definition Effect.c:583
void Event_OnUnregistered()
Event called from SEffectManager when the Effect is unregistered.
Definition Effect.c:348
vector m_LocalOri
Local orientation set by SetAttachedLocalOri, only used by EffectParticle.
Definition Effect.c:62
vector GetAttachedLocalOri()
Get the local orientation set by SetAttachedLocalOri.
Definition Effect.c:593
Object GetAttachmentParent()
Get the parent set by SetAttachmentParent.
Definition Effect.c:554
void OnCheckUpdate()
Event used when EffectParticle.CheckLifeSpan was called (DEPRECATED)
Definition Effect.c:359
class JsonUndergroundAreaTriggerData GetPosition
TODO doc.
Definition EnScript.c:118
Manager class for managing Effect (EffectParticle, EffectSound)
static void EffectUnregister(int id)
Unregisters Effect in SEffectManager.
static const int INVALID_ID
As the counter starts at 1, Effect ID can never be 0.
static ref ScriptInvoker Event_OnFrameUpdate
Static invoker for the SEffectManager.Event_OnFrameUpdate called form MissionGameplay....
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
ScriptInvoker Class provide list of callbacks usage:
Definition tools.c:116
static const vector Zero
Definition EnConvert.c:110
proto native CGame GetGame()
ErrorExSeverity
Definition EnDebug.c:62
void SetEnableEventFrame(bool enable)
Enable Event_OnFrameUpdate for the effect.
Definition Effect.c:270
enum ShapeType ErrorEx
proto native void SetPosition(vector position)
Set the world position of the Effect.
Definition Effect.c:420
proto native void Destroy()
Cleans up the Effect, including unregistering if needed.
Definition Effect.c:207
bool IsPendingDeletion()
Get whether the Effect is queued up for being cleaned up.
Definition Effect.c:249
bool IsAutodestroy()
Get whether Effect automatically cleans up when it stops.
Definition Effect.c:240
bool CanDestroy()
Get whether the Effect can be destroyed right now.
Definition Effect.c:258
void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Definition Effect.c:231
const int CALL_CATEGORY_GAMEPLAY
Definition tools.c:10
proto native Widget GetParent()
Get parent of the Effect.
Definition Effect.c:389