DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
EffectParticle.c
См. документацию.
1
5{
8
13
14 protected int m_ParticleID;
20 protected int m_PPFlags;
22
28 protected Object m_Object;
30
31
32
37 {
38 }
39
50
54 override void InitEffect()
55 {
56 super.InitEffect();
57
58 // Would be neat, but since particles are often already playing
59 // BEFORE they are even registered as the particle for the Effect
60 // Better to just keep that one I guess..
61 // Event_OnStarted.Remove(Event_OnEffectStarted);
62
63 // Will be called by the particle events
65 }
66
67
71 override string GetDebugName()
72 {
73 string identifier;
74 if (GetParticle())
75 {
76 identifier = GetParticle().GetDebugNameNative();
77 }
78 else
79 {
80 identifier = "NO_PARTICLE";
81 }
82
83 return string.Format("%1:%2:%3", super.GetDebugName(), m_ParticleID, identifier);
84 }
85
91 override void ValidateStart()
92 {
93 if (!GetParticle())
94 {
95 //ErrorEx(string.Format("No Particle started playing, stopping EffectParticle: %1", GetDebugName()), ErrorExSeverity.WARNING);
96 Stop();
97 }
98 }
99
100
101
106
112 {
113 return EffectType.PARTICLE;
114 }
115
120 override bool IsParticle()
121 {
122 return true;
123 }
124
126
127
128
133
139 {
140 // Unregister the events on the old
141 if (m_ParticleObj)
142 {
143 ParticleEvents ope = m_ParticleObj.GetEvents();
146 }
147
148 // Assign the new main Particle
149 m_ParticleObj = p;
150
151 // Register the events on the new
152 if (m_ParticleObj)
153 {
154 ParticleEvents npe = m_ParticleObj.GetEvents();
156 // We will use Stop instead of End, as old particles were destroyed when they stopped
157 // And this system kinda relies on that
159 }
160 }
161
167 {
168 return m_ParticleObj;
169 }
170
172
173
174
180
185 override void Start()
186 {
187 if (m_ParticleID > 0)
188 {
189 vector pos = GetPosition();
190 vector ori = GetOrientation();
191
192 if (m_ParentObject)
193 {
194 pos = GetLocalPosition();
195 ori = GetAttachedLocalOri();
196 }
197
198 SetParticle(ParticleManager.GetInstance().CreateParticleEx(m_ParticleID, pos, m_PPFlags, GetParent(), ori));
199 if (m_ParticleObj)
200 {
201 if (m_EffectSound)
202 {
203 if (GetParent())
204 {
206 }
207 else
208 {
209 m_EffectSound.Start();
210 }
211 }
212
213 m_ParticleObj.PlayParticleEx(m_ParticleID);
214 }
215 }
216
217 super.Start();
218 }
219
224 override void Stop()
225 {
226 if ( GetParticle() )
227 {
228 GetParticle().Stop();
229 SetParticle(null);
230 }
231
232 if (m_EffectSound)
233 {
234 m_EffectSound.Stop();
235 }
236
237 super.Stop();
238 }
239
240
241
242
247
251 void AttachTo(Object obj, vector local_pos = "0 0 0", vector local_ori = "0 0 0", bool force_rotation_to_world = false)
252 {
253 // Update the cached variables...
254 SetParent(obj);
255 SetLocalPosition(local_pos);
256 SetAttachedLocalOri(local_ori);
257 ForceParticleRotationRelativeToWorld(force_rotation_to_world);
258
259 // Now attach it
260 AddAsChild(obj, local_pos, local_ori, force_rotation_to_world);
261 }
262
266 void ReAttach()
267 {
268 // Skip the updating, as we are going to reuse what was set before
270 }
271
275 protected void AddAsChild(Object obj, vector local_pos, vector local_ori, bool force_rotation_to_world)
276 {
277 Particle p = GetParticle();
278 if (p)
279 {
280 p.AddAsChild(obj, local_pos, local_ori, force_rotation_to_world);
281 }
282 }
283
285
286
287
292
299 {
300
301 }
302
309 {
310
311 }
312
314
315
316
321
327 void SetParticleID( int id )
328 {
329 m_ParticleID = id;
330 }
331
338 {
339 return m_ParticleID;
340 }
341
347 void SetCurrentParticleID( int id )
348 {
349 m_ParticleID = id;
350
351 Particle p = GetParticle();
352 if (p)
353 {
354 p.SetSource(id);
355 }
356 }
357
363 {
364 Particle p = GetParticle();
365 if (p)
366 {
367 return p.GetParticleID();
368 }
369 else
370 {
371 return ParticleList.INVALID;
372 }
373 }
374
380 override void SetCurrentParent( Object parent_obj, bool updateCached = true )
381 {
382 super.SetCurrentParent(parent_obj, updateCached);
383
384 ReAttach();
385 }
386
392 {
393 Particle p = GetParticle();
394
395 if (p)
396 return Object.Cast(p.GetParent());
397 else
398 return super.GetParent();
399 }
400
406 override void SetCurrentPosition( vector pos, bool updateCached = true )
407 {
408 super.SetCurrentPosition(pos, updateCached);
409
410 Particle p = GetParticle();
411
412 if (p)
413 p.SetPosition(pos);
414 }
415
421 {
422 Particle p = GetParticle();
423
424 if (p)
425 return p.GetPosition();
426 else
427 return super.GetPosition();
428 }
429
435 override void SetCurrentLocalPosition( vector pos, bool updateCached = true )
436 {
437 super.SetCurrentLocalPosition(pos, updateCached);
438
439 Particle p = GetParticle();
440 if (p)
441 {
442 Object parent = GetParent();
443
444 if (parent)
445 ReAttach();
446 else
447 p.SetPosition(pos);
448 }
449 }
450
456 {
457 Particle p = GetParticle();
458
459 if (p)
460 {
461 Object parent = GetParent();
462
463 if (parent)
464 return parent.WorldToModel(p.GetPosition());
465 else
466 return p.GetPosition();
467 }
468 else
469 return super.GetLocalPosition();
470 }
471
478 {
479 m_Orientation = ori;
480 }
481
488 {
489 return m_Orientation;
490 }
491
496 void SetCurrentOrientation( vector ori, bool updateCached = true )
497 {
498 if ( updateCached)
499 SetOrientation(ori);
500
501 Particle p = GetParticle();
502
503 if (p)
504 p.SetOrientation(ori);
505 }
506
512 {
513 Particle p = GetParticle();
514
515 if (p)
516 return p.GetOrientation();
517 else
518 return vector.Zero;
519 }
520
521 protected void AddParticlePropertiesFlag(ParticlePropertiesFlags flag)
522 {
523 m_PPFlags = m_PPFlags | flag;
524 }
525
526 protected void RemoveParticlePropertiesFlag(ParticlePropertiesFlags flag)
527 {
528 m_PPFlags = m_PPFlags & ~flag;
529 }
530
531 protected bool IsSetParticlePropertiesFlag(ParticlePropertiesFlags flag)
532 {
533 return m_PPFlags & flag;
534 }
535
543 {
544 if (state)
545 AddParticlePropertiesFlag(ParticlePropertiesFlags.FORCE_WORLD_ROT);
546 else
547 RemoveParticlePropertiesFlag(ParticlePropertiesFlags.FORCE_WORLD_ROT);
548 }
549
556 {
557 Particle p = GetParticle();
558
559 if (p)
560 return p.IsHierarchyPositionOnly();
561 else
562 return IsSetParticlePropertiesFlag(ParticlePropertiesFlags.FORCE_WORLD_ROT);
563 }
564
569 void DisableParticleInUI(bool disable)
570 {
571 if (disable)
572 AddParticlePropertiesFlag(ParticlePropertiesFlags.DISABLED_IN_UI);
573 else
574 RemoveParticlePropertiesFlag(ParticlePropertiesFlags.DISABLED_IN_UI);
575 }
576
578 {
579 return IsSetParticlePropertiesFlag(ParticlePropertiesFlags.DISABLED_IN_UI);
580 }
581
587 {
588 Particle p = GetParticle();
589
590 if (p)
591 return p.IsHierarchyPositionOnly();
592 else
593 return false;
594 }
595
599 void SetEffectSound(EffectSound effectSound)
600 {
601 if (m_EffectSound)
602 {
604 }
605 m_EffectSound = effectSound;
606 }
607
611 void SelectFromSurface(string surface);
613
614 void SetParticleState(int state);
615
619 void ParticleParamsOverride(notnull ParticleParamsOverrideData data);
621
626
632 {
633 /*
634 if ( !m_ParticleObj )
635 {
636 delete this;
637 }
638
639 OnCheckUpdate();
640 */
641 }
642
644 {
645 m_Object = o;
646 }
647
649}
650
651class ParticleParamsOverrideData
652{
654
655 void ClearAll()
656 {
657 m_FloatModifiers.Clear();
658 }
659}
Object m_ParentObject
Cached parent.
Определения Effect.c:39
void SetParent(Object parent_obj, int pivot)
Set parent of the Effect.
Определения Effect.c:399
ref ScriptInvoker Event_OnEffectStarted
Event used when the actual effect started playing.
Определения Effect.c:24
EffectType
Enum to determine what type of effect the Effect is.
Определения Effect.c:3
ref ScriptInvoker Event_OnEffectEnded
Event used when the actual effect stopped playing.
Определения Effect.c:25
void SetLocalPosition(vector pos)
Set the local position of the Effect.
Определения Effect.c:503
vector GetLocalPosition()
Get the local position of the Effect.
Определения Effect.c:513
ref ScriptInvoker Event_OnStopped
Event used when Stop was called.
Определения Effect.c:23
void Effect()
ctor
Определения Effect.c:72
void SetAttachedLocalOri(vector ori)
Set local orientation for the Effectparticle to attach to when the Effect is started.
Определения Effect.c:628
vector GetAttachedLocalOri()
Get the local orientation set by SetAttachedLocalOri.
Определения Effect.c:638
void ClearAll()
Определения EffectParticle.c:655
EffectParticle m_FloatModifiers
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Определения ParticleManager.c:88
override string GetDebugName()
Override when getting debug information.
Определения EffectParticle.c:71
override void Stop()
Stops all elements this effect consists of.
Определения EffectParticle.c:224
Particle GetParticle()
Gets the main particle which this Effect is managing.
Определения EffectParticle.c:166
Object m_Object
Определения EffectParticle.c:28
int GetCurrentParticleID()
Gets the current id of the managed Particle.
Определения EffectParticle.c:362
vector GetOrientation()
Get the orientation of the EffectParticle.
Определения EffectParticle.c:487
override void Start()
Plays all elements this effect consists of.
Определения EffectParticle.c:185
void AddParticlePropertiesFlag(ParticlePropertiesFlags flag)
Определения EffectParticle.c:521
void ~EffectParticle()
dtor
Определения EffectParticle.c:43
void SetParticleID(int id)
Sets the id of the particle to be used.
Определения EffectParticle.c:327
void SetParticle(Particle p)
Sets the main particle which this Effect will manage.
Определения EffectParticle.c:138
void Event_OnPlayStarted()
Event which just simply exists (DEPRECATED)
Определения EffectParticle.c:308
override void ValidateStart()
Validation whether an effect truly started playing or if the Effect should stop as none is present.
Определения EffectParticle.c:91
void DisableParticleInUI(bool disable)
Disable creating particle for preview player.
Определения EffectParticle.c:569
void SelectFromSurface(SurfaceInfo surfaceInfo)
void EffectParticle()
ctor
Определения EffectParticle.c:36
void RemoveParticlePropertiesFlag(ParticlePropertiesFlags flag)
Определения EffectParticle.c:526
void SetCurrentOrientation(vector ori, bool updateCached=true)
Set the current orientation of the managed Particle.
Определения EffectParticle.c:496
int GetParticleID()
Gets the id of the particle to be used.
Определения EffectParticle.c:337
override void InitEffect()
init
Определения EffectParticle.c:54
vector GetCurrentOrientation()
Get the current orientation of the managed Particle.
Определения EffectParticle.c:511
bool IsParticleRotationRelativeToWorld()
Get the orientation setting to be used by the effect when the Effect starts.
Определения EffectParticle.c:555
EffectSound m_EffectSound
Name of sound set that is going to be played when particle starts playback.
Определения EffectParticle.c:18
Particle m_ParticleObj
The main Particle effect that this Effect wrapper manages.
Определения EffectParticle.c:7
void ReAttach()
Helper method to attach to parent using stored settings.
Определения EffectParticle.c:266
override Object GetCurrentParent()
Get the current parent of the managed Particle.
Определения EffectParticle.c:391
override void SetCurrentPosition(vector pos, bool updateCached=true)
Set the current world position of the managed Particle.
Определения EffectParticle.c:406
vector m_ParticleOrientation
Определения EffectParticle.c:27
void SetDecalOwner(Object o)
Определения EffectParticle.c:643
void Event_OnPlayStart()
Event which just simply exists (DEPRECATED)
Определения EffectParticle.c:298
override bool IsParticle()
Check whether the Effect is EffectParticle without casting.
Определения EffectParticle.c:120
void SelectFromSurface(string surface)
Selection of particle based on Surface.
override void SetCurrentParent(Object parent_obj, bool updateCached=true)
Set current parent of the managed Particle.
Определения EffectParticle.c:380
void ForceParticleRotationRelativeToWorld(bool state)
Set orientation setting to be used by the effect when the Effect starts.
Определения EffectParticle.c:542
override EffectType GetEffectType()
Get what type of effect the Effect is.
Определения EffectParticle.c:111
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.
Определения EffectParticle.c:251
bool IsParticleCurrentRotationRelativeToWorld()
Get the current orientation setting to be used by the managed Particle.
Определения EffectParticle.c:586
void AddAsChild(Object obj, vector local_pos, vector local_ori, bool force_rotation_to_world)
Helper method to attach to parent.
Определения EffectParticle.c:275
override vector GetCurrentPosition()
Get the current world position of the managed Particle.
Определения EffectParticle.c:420
bool IsSetParticlePropertiesFlag(ParticlePropertiesFlags flag)
Определения EffectParticle.c:531
void SetOrientation(vector ori)
Set orientation of the EffectParticle.
Определения EffectParticle.c:477
bool IsDisableParticleInUI()
Определения EffectParticle.c:577
override vector GetCurrentLocalPosition()
Get the current local position of the managed Particle.
Определения EffectParticle.c:455
void SetParticleState(int state)
int m_PPFlags
Flags passed to ParticleManager.CreateParticleEx when the particle is created, see ParticleProperties...
Определения EffectParticle.c:20
int m_ParticleID
The ID in the ParticleList to create Particle from.
Определения EffectParticle.c:14
void SetEffectSound(EffectSound effectSound)
Set effect sound play with particle.
Определения EffectParticle.c:599
override void SetCurrentLocalPosition(vector pos, bool updateCached=true)
Set the current local position of the managed Particle.
Определения EffectParticle.c:435
void SetCurrentParticleID(int id)
Sets the id of the particle to be used.
Определения EffectParticle.c:347
vector m_Orientation
Orientation set by SetOrientation.
Определения EffectParticle.c:16
void ParticleParamsOverride(notnull ParticleParamsOverrideData data)
Callback for overriding effect's particle attributes.
void CheckLifeSpan()
Was never called and probably should never be called.
Определения EffectParticle.c:631
Wrapper class for managing sound through SEffectManager.
Определения EffectSound.c:5
Определения ObjectTyped.c:2
void SetSource(int particle_id)
Sets particle id.
Определения Particle.c:285
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...
Определения Particle.c:563
int GetParticleID()
Gets particle id.
Определения Particle.c:297
void Stop()
Legacy function for backwards compatibility with 1.14 and below.
Определения Particle.c:266
ref ScriptInvoker Event_OnParticleStart
Called when particle starts playing.
Определения ParticleBase.c:22
ref ScriptInvoker Event_OnParticleStop
Called when particle stops playing.
Определения ParticleBase.c:28
Invokers for ParticleBase events, called from events.
Определения ParticleBase.c:16
Legacy way of using particles in the game.
Определения Particle.c:7
static const int INVALID
Определения ParticleList.c:20
Определения ParticleList.c:12
static int PlayOnObject(notnull Effect eff, Object obj, vector local_pos="0 0 0", vector local_ori="0 0 0", bool force_rotation_relative_to_world=false)
Play an Effect.
Определения EffectManager.c:70
static bool DestroySound(EffectSound sound_effect)
Legacy, backwards compatibility.
Определения EffectManager.c:441
Manager class for managing Effect (EffectParticle, EffectSound)
Определения EffectManager.c:6
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
Определения SurfaceInfo.c:9
static const vector Zero
Определения EnConvert.c:123
Определения EnConvert.c:119
array< float > TFloatArray
Определения EnScript.c:732
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
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.
Определения Effect.c:422