DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
Effect.c
Go to the documentation of this file.
1
3{
10}
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
66
70 void Effect()
71 {
72 if (GetGame().IsDedicatedServer())
73 {
74 ErrorEx("Created Effect on server.", ErrorExSeverity.WARNING);
75 }
76
77 InitEffect();
78 }
79
83 void ~Effect()
84 {
85 // Safety
86 if ( IsRegistered() )
88
89 // Certain effects need to be stopped to clean up properly
90 Stop();
91
92 // Another safety
94 }
95
100 {
104 }
105
106
111
117 {
118 return EffectType.NONE;
119 }
120
125 bool IsSound()
126 {
127 return false;
128 }
129
135 {
136 return false;
137 }
138
140
141
142
148
153 void Start()
154 {
155 // It is already playing!
156 if (IsPlaying())
157 return;
158
160 // I can't call this from inside the method with same name
161 // because that method is often overriden without super......
162 Event_OnStarted.Invoke(this);
163 }
164
171 {
172
173 }
174
179 void Stop()
180 {
181 // It is not playing!
182 if (!IsPlaying())
183 return;
184
186 // Yes, that event is new, but let's keep up some consistency
187 Event_OnStopped.Invoke(this);
188 }
189
194 {
195 return m_IsPlaying;
196 }
197
199
200
201
206
212 protected void Destroy()
213 {
214 // Already queued
215 if (IsPendingDeletion())
216 return;
217
218 // Mark it to prevent queuing it up multiple times or get stuck in a call loop
219 m_IsPendingDeletion = true;
220
221 // Stop it, so that the effects can clean up themselves
222 // Since if for example this is EffectParticle and the particle is looping
223 // It NEEDS to be stopped to clean up the Particle
224 Stop();
225
226 // Queue up the destroying, as we should not do it while we are accessing it here
227 if (GetGame())
228 {
230 }
231 }
232
238 void SetAutodestroy(bool auto_destroy)
239 {
240 m_IsAutodestroy = auto_destroy;
241 }
242
248 {
249 return m_IsAutodestroy;
250 }
251
257 {
258 return m_IsPendingDeletion;
259 }
260
262
263
264
269 void SetEnableEventFrame(bool enable)
270 {
271 if ( enable )
272 {
274 }
275 else
276 {
278 }
279 }
280
281
282
287
292 {
293 // Override this method for own use
294 }
295
299 void Event_OnStopped()
300 {
301 // Override this method for own use
302 }
303
308 {
309 m_IsPlaying = true;
310
312 }
313
318 {
319 m_IsPlaying = false;
320
322
323 if ( IsAutodestroy() )
324 {
325 Destroy();
326 }
327 }
328
334 void Event_OnFrameUpdate(float time_delta)
335 {
336 // Override this method for own use
337 }
338
345 {
346 SetID(id);
347 m_IsRegistered = true;
348 }
349
355 {
357 m_IsRegistered = false;
358 }
359
366 {
367
368 }
369
371
372
373
378
385 void SetParent(Object parent_obj)
386 {
387 m_ParentObject = parent_obj;
388 }
389
397 {
398 return m_ParentObject;
399 }
400
407 void SetCurrentParent( Object parent_obj, bool updateCached = true )
408 {
409 if (updateCached)
410 SetParent(parent_obj);
411 }
412
418 {
419 return null;
420 }
421
427 void SetPosition( vector pos )
428 {
429 m_Position = pos;
430 }
431
438 {
439 return m_Position;
440 }
441
447 void SetCurrentPosition( vector pos, bool updateCached = true )
448 {
449 if (updateCached)
450 SetPosition(pos);
451 }
452
458 {
459 return vector.Zero;
460 }
461
468 {
469 m_LocalPos = pos;
470 }
471
478 {
479 return m_LocalPos;
480 }
481
487 void SetCurrentLocalPosition( vector pos, bool updateCached = true )
488 {
489 if (updateCached)
490 SetLocalPosition(pos);
491 }
492
498 {
499 return vector.Zero;
500 }
501
503
504
505
510
516 protected void SetID(int id)
517 {
518 m_ID = id;
519 }
520
525 int GetID()
526 {
527 return m_ID;
528 }
529
535 {
536 return m_IsRegistered;
537 }
538
540
541
542
549
555 {
556 SetParent(obj);
557 }
558
564 {
565 return GetParent();
566 }
567
573 {
574 SetLocalPosition(pos);
575 }
576
582 {
583 return GetLocalPosition();
584 }
585
593 {
594 m_LocalOri = ori;
595 }
596
603 {
604 return m_LocalOri;
605 }
606
608}
void Start()
Plays all elements this effects consists of.
Definition Effect.c:153
void Event_OnRegistered(int id)
Event called from SEffectManager when the Effect is registered.
Definition Effect.c:344
void Stop()
Stops all elements this effect consists of.
Definition Effect.c:179
void SetCurrentParent(Object parent_obj, bool updateCached=true)
Set current parent of the managed effect.
Definition Effect.c:407
protected int m_ID
ID of effect, given by SEffectManager when registered (automatically done when playing through it)
Definition Effect.c:49
int GetID()
Get the ID registered in SEffectManager.
Definition Effect.c:525
vector GetAttachedLocalPos()
Get the local pos set by SetAttachedLocalPos.
Definition Effect.c:581
vector GetCurrentPosition()
Get the current world position of the managed effect.
Definition Effect.c:457
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:417
protected void SetID(int id)
Set the ID registered in SEffectManager.
Definition Effect.c:516
PARTICLE
EffectParticle.
Definition Effect.c:9
protected 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:385
protected bool m_IsPlaying
Whether the Effect is currently playing.
Definition Effect.c:37
bool IsRegistered()
Get whether this Effect is registered in SEffectManager.
Definition Effect.c:534
bool IsPlaying()
Returns true when the Effect is playing, false otherwise.
Definition Effect.c:193
protected vector m_LocalOri
Local orientation set by SetAttachedLocalOri, only used by EffectParticle.
Definition Effect.c:62
void InitEffect()
init
Definition Effect.c:99
void SetCurrentPosition(vector pos, bool updateCached=true)
Set the current world position of the managed effect.
Definition Effect.c:447
protected bool m_IsRegistered
Whether the effect is registered in SEffectManager.
Definition Effect.c:51
void SetAttachedLocalPos(vector pos)
Set local pos for the Effect relative to the parent.
Definition Effect.c:572
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 bool m_IsAutodestroy
Whether the Effect cleans up after itself when stopped.
Definition Effect.c:33
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
bool IsParticle()
Check whether the Effect is EffectParticle without casting.
Definition Effect.c:134
void SetAttachmentParent(Object obj)
Set parent for the Effect.
Definition Effect.c:554
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:170
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:487
vector GetCurrentLocalPosition()
Get the current local position of the managed effect.
Definition Effect.c:497
void Event_OnFrameUpdate(float time_delta)
Event called on frame when enabled by SetEnableEventFrame(true)
Definition Effect.c:334
void ~Effect()
dtor
Definition Effect.c:83
Event_OnStarted
Event used when Start was called.
Definition Effect.c:291
protected vector m_LocalPos
Cached local pos.
Definition Effect.c:60
EffectType GetEffectType()
Get what type of effect the Effect is.
Definition Effect.c:116
bool IsSound()
Check whether the Effect is EffectSound without casting.
Definition Effect.c:125
void SetAttachedLocalOri(vector ori)
Set local orientation for the Effectparticle to attach to when the Effect is started.
Definition Effect.c:592
void Event_OnUnregistered()
Event called from SEffectManager when the Effect is unregistered.
Definition Effect.c:354
protected vector m_Position
Cached world position.
Definition Effect.c:41
vector GetAttachedLocalOri()
Get the local orientation set by SetAttachedLocalOri.
Definition Effect.c:602
Object GetAttachmentParent()
Get the parent set by SetAttachmentParent.
Definition Effect.c:563
void OnCheckUpdate()
Event used when EffectParticle.CheckLifeSpan was called (DEPRECATED)
Definition Effect.c:365
override ScriptCallQueue GetCallQueue(int call_category)
Definition DayZGame.c:1153
TODO doc.
Definition EnScript.c:118
vector GetPosition()
Manager class for managing Effect (EffectParticle, EffectSound)
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 EffectUnregister(int id)
Unregisters Effect in SEffectManager.
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
proto void Call(func fn, 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)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
ScriptInvoker Class provide list of callbacks usage:
Definition tools.c:116
proto bool Remove(func fn, int flags=EScriptInvokerRemoveFlags.ALL)
remove specific call from list
proto void Invoke(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)
invoke call on all inserted methods with given arguments
proto bool Insert(func fn, int flags=EScriptInvokerInsertFlags.IMMEDIATE)
insert method to list
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:269
enum ShapeType ErrorEx
proto native void SetPosition(vector position)
Set the world position of the Effect.
Definition Effect.c:427
proto native void Destroy()
Cleans up the Effect, including unregistering if needed.
Definition Effect.c:212
bool IsPendingDeletion()
Get whether the Effect is queued up for being cleaned up.
Definition Effect.c:256
bool IsAutodestroy()
Get whether Effect automatically cleans up when it stops.
Definition Effect.c:247
void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Definition Effect.c:238
const int CALL_CATEGORY_GAMEPLAY
Definition tools.c:10
proto native Widget GetParent()
Get parent of the Effect.
Definition Effect.c:396