DayZ 1.24
Loading...
Searching...
No Matches
ParticleSource.c
Go to the documentation of this file.
1
13
16{
18 NONE,
19 // Is just a placeholder for now
20}
21
24{
26 NONE,
40}
41
44{
51}
52
54{
55 NONE,
62};
63
65class ParticleProperties
66{
79 {
80 }
81
84 {
85 }
86
100}
101
104
124{
127 {
128 m_ParticleEffect = this;
129 }
130
133 {
134 }
135
137 override protected void ParticleInit() {}
138
147
155
161
166
178 static ParticleSource CreateParticle(int id, vector pos, bool playOnCreation = false, Object parent = null, vector ori = vector.Zero, bool forceWorldRotation = false, Class owner = null)
179 {
180 int flags = ParticlePropertiesFlags.NONE;
181
182 if (playOnCreation)
183 flags = flags | ParticlePropertiesFlags.PLAY_ON_CREATION;
184
186 flags = flags | ParticlePropertiesFlags.FORCE_WORLD_ROT;
187
188 return CreateParticleEx(id, pos, flags, parent, ori, owner);
189 }
190
202 {
204 if (particlePath == "") // There is already an error inside of ParticleList signaling this
205 {
206 ErrorEx(string.Format("Could not create ParticleSource as particle id %1 is invalid.", id));
207 return null;
208 }
209
210 vector localPos = pos;
211
212 if (parent)
213 pos = parent.GetPosition();
214
215 ParticleSource p = ParticleSource.Cast(GetGame().CreateObjectEx("ParticleSource", pos, ECE_LOCAL));
216 p.SetParticle(particlePath);
217 ParticleProperties props = new ParticleProperties(localPos, flags, parent, ori, owner);
218 p.ApplyProperties(props);
219
220 return p;
221 }
222
232 override static Particle CreateOnObject(
233 int particle_id,
235 vector local_pos = "0 0 0",
236 vector local_ori = "0 0 0",
237 bool force_world_rotation = false)
238 {
240 }
241
245 override static Particle Create(int particle_id, Object parent_obj, vector local_pos = "0 0 0", vector local_ori = "0 0 0")
246 {
248 }
249
262
270
272
273
278
292
296 override static Particle Play(int particle_id, Object parent_obj, vector local_pos = "0 0 0", vector local_ori = "0 0 0")
297 {
299 }
300
308 {
310 }
311
316 {
318 }
319
321
322
327
333 private proto bool PlayParticleNative(int flags);
334
340 override bool PlayParticleEx(int particle_id = -1, int flags = 0)
341 {
342 if (particle_id > -1)
343 {
344 // Here we can just do it directly
345 // While with the old system it will not work when the particle is already created
347 }
348
349 return PlayParticleNative(flags);
350 }
351
359 private proto bool StopParticleNative(int flags);
360
366 override bool StopParticle(int flags = 0)
367 {
368 return StopParticleNative(flags);
369 }
370
376
381 override bool ResetParticle()
382 {
383 return ResetParticleNative();
384 }
385
391
396 override bool RestartParticle()
397 {
398 return RestartParticleNative();
399 }
400
406
411 override bool IsParticlePlaying()
412 {
414 }
415
417
418
423
429 private proto native bool SetParticleNative(string path);
430
437 private bool SetParticle(string path)
438 {
439 return SetParticleNative(path);
440 }
441
447 bool SetParticleByID(int id)
448 {
450 }
451
457 override void SetSource(int particle_id)
458 {
460 }
461
463
464
469
477
485 {
486 return GetParticleNative(path, mode);
487 }
488
493 override int GetParticleID()
494 {
495 string path;
498 else
499 return -1;
500 }
501
509 {
510 string path;
511 if (GetParticle(path, EGetParticleMode.NO_EXT))
513 else
514 return -1;
515 }
516
518
519
524
531 private proto native bool ApplyPropertiesNative(ParticleProperties properties);
532
538 bool ApplyProperties(ParticleProperties properties)
539 {
541 }
542
544
545
550
557 {
558 return this;
559 }
560
566 {
567 return Object.Cast(GetParent());
568 }
569
575
580 override bool HasActiveParticle()
581 {
583 }
584
591
597 override int GetParticleCount()
598 {
599 return GetParticleCountNative();
600 }
601
606 private proto bool IsRepeatNative();
607
612 override bool IsRepeat()
613 {
614 return IsRepeatNative();
615 }
616
622
627 override float GetMaxLifetime()
628 {
629 return GetMaxLifetimeNative();
630 }
631
637
643
648
650
651
656
662
668
670
671
676
683
689
695
697
698
705
709 override protected void OnParticleParented(IEntity parent)
710 {
711 m_ParentObject = Object.Cast(parent);
712
713 super.OnParticleParented(parent);
714 }
715
719 override protected void OnParticleUnParented(IEntity parent)
720 {
722
723 // Since we have lost the parent, we will need to refresh the wiggle
724 // As it uses a cached local position, which is now no longer correct
726 {
731
732 StopWiggle();
734 }
735
736 super.OnParticleUnParented(parent);
737 }
738
742 override protected void OnParticleStop()
743 {
744 if (IsWiggling())
745 {
746 StopWiggle();
747 delete m_RandomizeOri;
748 }
749
750 super.OnParticleStop();
751 }
752
754
755
760
769 override void AddAsChild(Object parent, vector local_pos = "0 0 0", vector local_ori = "0 0 0", bool force_rotation_to_world = false)
770 {
771 int flags = ParticlePropertiesFlags.NONE;
772
774 flags = ParticlePropertiesFlags.FORCE_WORLD_ROT;
775
776 ParticleProperties props = new ParticleProperties(local_pos, flags, parent, local_ori);
778 }
779
781
782
787
793 override void SetParticleParam(int parameter_id, float value)
794 {
796 }
797
804 override void SetParameter(int emitter, int parameter, float value)
805 {
807 }
808
815 override void GetParameter(int emitter, int parameter, out float value)
816 {
818 }
819
826 override float GetParameterEx(int emitter, int parameter)
827 {
828 float value;
830 return value;
831 }
832
838 override void ScaleParticleParamFromOriginal(int parameter_id, float coef)
839 {
841 for (int i = 0; i < emitors; ++i)
842 {
843 float value;
845 SetParticleParm(this, i, parameter_id, value * coef);
846 }
847 }
848
854 override void ScaleParticleParam(int parameter_id, float coef)
855 {
857 for (int i = 0; i < emitors; ++i)
858 {
859 float value;
861 SetParticleParm(this, i, parameter_id, value * coef);
862 }
863 }
864
872 {
874 for (int i = 0; i < emitors; ++i)
875 {
876 float param;
879 }
880 }
881
888 override void IncrementParticleParam(int parameter_id, float value)
889 {
891 for (int i = 0; i < emitors; ++i)
892 {
893 float param;
896 }
897 }
898
900
901
906
913 override void SetWiggle(float random_angle, float random_interval)
914 {
915 if (random_angle != 0 || random_interval != 0)
916 {
917 if (IsWiggling())
918 {
921 return;
922 }
923
924 // We need the position to be accurate before storing it
925 Update();
926
927 // These are only ever used within the Wiggle API
928 // To restore the properties after wiggling
929 // So let's only set them within the Wiggle API c:
930
932 m_DefaultOri = GetLocalYawPitchRoll();
933 m_DefaultWorldPos = GetWorldPosition();
934 m_DefaultWorldOri = GetYawPitchRoll();
935 m_ForceOrientationRelativeToWorld = IsHierarchyPositionOnly();
936 }
937
939 }
940
944 override void StopWiggle()
945 {
946 bool wiggling = IsWiggling();
947
948 super.StopWiggle();
949
950 if (wiggling)
951 {
952 // Restore pre-wiggle orientation
953 int flags = ParticlePropertiesFlags.NONE;
954
956 flags = ParticlePropertiesFlags.FORCE_WORLD_ROT;
957
958 ParticleProperties prop = new ParticleProperties(m_DefaultPos, flags, GetParticleParent(), m_DefaultOri, GetOwner());
960 }
961 }
962
966 override private void RandomizeOrientation()
967 {
968 if (ToDelete())
969 return;
970
971 m_WiggleProcessing = true;
972
973 if (!m_RandomizeOri.IsRunning())
974 m_RandomizeOri.Run(Math.RandomFloat(0, m_MaxOriInterval), this, "RandomizeOrientation", null, false);
975
976 int flags = ParticlePropertiesFlags.NONE;
977
979 flags = ParticlePropertiesFlags.FORCE_WORLD_ROT;
980
981 ParticleProperties prop = new ParticleProperties(m_DefaultPos, flags, GetParticleParent(), m_DefaultOri + RandWiggleVector(), GetOwner());
983
984 m_WiggleProcessing = false;
985 }
986
988
989
994
996 override private void UpdateState() { ErrorEx("Should not be in use on ParticleSource."); }
997
999 override private void DestroyParticleEffect() { ErrorEx("Should not be in use on ParticleSource."); }
1000
1002 override private void CreateParticleEffect() { ErrorEx("Should not be in use on ParticleSource."); }
1003
1005 override protected void EOnFrame(IEntity other, float timeSlice) { ErrorEx("Should not be in use on ParticleSource."); }
1006
1008 override private void OnCheckAutoDelete() { ErrorEx("Should not be in use on ParticleSource."); }
1009
1011 override private void OnToDelete() { ErrorEx("Should not be in use on ParticleSource."); }
1012
1014}
void CreateParticle()
const int ECE_LOCAL
vector GetLocalPosition()
Get the local position of the Effect.
Definition Effect.c:470
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
enum ParticleAutoDestroyFlags IMMEDIATE
Flag will make the particle stop immediately, taking it out of simulation and clearing VISIBLE flag.
enum ParticleAutoDestroyFlags VISIBLE
Is default behaviour, but can be used in conjuction with IMMEDIATE which hides it when this flag is n...
enum ParticleAutoDestroyFlags PLAY_ON_CREATION
Makes the particle start playing immediately after being created.
enum ParticleAutoDestroyFlags FILE
Filename only ("smoking_barrel_small")
ParticleAutoDestroyFlags
Flags to pass to ParticleSource.SetParticleAutoDestroyFlags.
@ ON_END
Destroy when the Particle ends (looping particle never ends)
@ ON_STOP
Destroy when particle stops.
@ ALL
ON_END | ON_STOP.
enum ParticleAutoDestroyFlags PAUSE
(SPF_IMMEDIATE | SPF_VISIBLE) "Freezes" the particle while keeping it visible
enum ParticleAutoDestroyFlags FULL
Mode for GetParticle.
array< ParticleSource > ParticleSourceArray
enum ParticleAutoDestroyFlags RESET
Reset state after stopping.
enum ParticleAutoDestroyFlags NO_EXT
Full path without ext ("graphics/particles/smoking_barrel_small")
enum ParticleAutoDestroyFlags NONE
Flags to pass to ParticleSource.PlayParticleEx.
enum ParticleAutoDestroyFlags KEEP_PARENT_ON_END
By default, a particle unparents when it ends, this disables this behaviour.
enum ParticleAutoDestroyFlags FORCE_WORLD_ROT
Only applicable when there is a parent, this will force the localOri to be in world space instead of ...
int particle_id
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition EnMath.c:7
Legacy way of using particles in the game.
Definition Particle.c:7
vector m_DefaultPos
Used for Wiggle API, to restore after unparenting.
Definition Particle.c:33
Object m_ParticleEffect
The child object which contains the actual particle.
Definition Particle.c:50
vector m_DefaultWorldOri
Used for Wiggle API, to restore after unparenting.
Definition Particle.c:35
vector m_DefaultOri
Used for Wiggle API, to restore after unparenting.
Definition Particle.c:31
bool m_ForceOrientationRelativeToWorld
Used for Wiggle API, to restore after unparenting.
Definition Particle.c:29
bool m_WiggleProcessing
Used for Wiggle API, to signal that wiggle API is currently doing work.
Definition Particle.c:27
vector m_DefaultWorldPos
Used for Wiggle API, to restore after unparenting.
Definition Particle.c:37
vector RandWiggleVector()
Helper to get a randomized wiggle vector.
Definition Particle.c:794
Object m_ParentObject
Parent Object the Particle is child of.
Definition Particle.c:48
float m_MaxOriWiggle
Used for Wiggle API, Wiggle room [-m_MaxOriWiggle, m_MaxOriWiggle].
Definition Particle.c:40
float m_MaxOriInterval
Used for Wiggle API, Interval for wiggling [0, m_MaxOriInterval[.
Definition Particle.c:42
ref Timer m_RandomizeOri
Used for Wiggle API, calls the Wiggle functionality.
Definition Particle.c:44
bool IsWiggling()
Checks if particle is currently wiggling.
Definition Particle.c:730
static int GetParticleIDByName(string name)
Returns particle's ID based on the filename (without .ptc suffix)
static string GetParticleFullPath(int particle_id)
Returns particle's full path (with .ptc suffix) based on its ID.
static int GetParticleID(string particle_file)
Returns particle's ID based on the path (without .ptc suffix)
Entity which has the particle instance as an ObjectComponent.
override void IncrementParticleParam(int parameter_id, float value)
Increments the value of the given parameter relatively from the CURRENT value.
static override Particle Play(int particle_id, Object parent_obj, vector local_pos="0 0 0", vector local_ori="0 0 0")
Legacy function for backwards compatibility with 1.01 and below.
proto int GetCountID()
Gets the ID for the ParticleSource.
override void ScaleParticleParamFromOriginal(int parameter_id, float coef)
Scales the given parameter on all emitors relatively to their ORIGINAL value.
void ParticleSource()
ctor
proto float GetMaxLifetimeNative()
Returns the approx. max lifetime.
proto bool HasActiveParticleNative()
Returns if there is any particle active.
void UpdateState()
Empty.
static override Particle CreateInWorld(int particle_id, vector global_pos, vector global_ori="0 0 0", bool force_world_rotation=false)
Creates a particle emitter on the given position.
void RandomizeOrientation()
Randomizes a new orientation and applies it.
override int GetParticleCount()
Returns the total count of active particles in all emitors.
override float GetMaxLifetime()
Returns the approx. max lifetime.
void OnCheckAutoDelete()
Empty.
static override Particle PlayOnObject(int particle_id, Object parent_obj, vector local_pos="0 0 0", vector local_ori="0 0 0", bool force_world_rotation=false)
Creates a particle emitter, attaches it on the given object and activates it.
static ParticleSource CreateParticleEx(int id, vector pos, int flags=ParticlePropertiesFlags.NONE, Object parent=null, vector ori=vector.Zero, Class owner=null)
Master create function.
void ParticleInit()
Empty - Only needed for Particle.
override bool StopParticle(int flags=0)
Method to tell the particle to stop playing.
proto native int GetIndex()
Get the index of this ParticleSource in the owning ParticleManager.
proto native bool SetParticleNative(string path)
Assigns a particle to the ParticleSource.
proto bool GetParticleNative(out string path, EGetParticleMode mode)
Gets the path to the currently assigned particle.
bool GetParticle(out string path, EGetParticleMode mode)
Gets the path to the currently assigned particle.
proto int GetParticleCountNative()
Returns the total count of active particles in all emitors.
static ParticleSource CreateParticle(int id, vector pos, bool playOnCreation=false, Object parent=null, vector ori=vector.Zero, bool forceWorldRotation=false, Class owner=null)
Create function.
override bool IsParticlePlaying()
Ask if the particle is still playing.
void OnToDelete()
Empty.
override 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...
override void SetParameter(int emitter, int parameter, float value)
Set the value of a parameter of an emitor in the particle.
static override Particle PlayInWorld(int particle_id, vector global_pos)
Creates a particle emitter on the given position and activates it.
proto native bool RestartParticleNative()
Method to tell the particle to restart (reset + play)
bool SetParticleByID(int id)
Assigns a particle to the ParticleSource.
int GetParticleIDLegacy()
Gets the ParticleList ID of the currently assigned particle.
override void StopWiggle()
Stops randomized wiggle.
static override Particle Create(int particle_id, Object parent_obj, vector local_pos="0 0 0", vector local_ori="0 0 0")
Legacy function for backwards compatibility.
static override Particle Play(int particle_id, vector global_pos)
Legacy function for backwards compatibility with 1.01 and below.
override void IncrementParticleParamFromOriginal(int parameter_id, float value)
Increments the value of the given parameter relatively from the ORIGINAL value.
bool ApplyProperties(ParticleProperties properties)
Applies the properties given to the ParticleSource.
proto bool IsParticlePlayingNative()
Ask if the particle is still playing.
override Object GetParticleParent()
Returns the parent of this Particle if there is one.
proto native Class GetOwner()
Get the owner of this ParticleSource.
override void SetSource(int particle_id)
Sets particle id.
override bool PlayParticleEx(int particle_id=-1, int flags=0)
Method to tell the particle to start playing.
static override ParticleSource Create(int particle_id, vector global_pos, vector global_ori="0 0 0")
Legacy function for backwards compatibility with 1.01 and below.
override float GetParameterEx(int emitter, int parameter)
Get the value of a parameter of an emitor in the particle.
proto native void SetOwner(Class owner)
Set the owner of this ParticleSource.
void ~ParticleSource()
dtor
proto static native int GetStaticActiveCount()
Gets the amount of ParticleSource that are currently existing.
proto native int GetParticleAutoDestroyFlags()
Gets the currently set ParticleAutoDestroyFlags flags set on this ParticleSource.
override bool HasActiveParticle()
Returns if there is any particle active.
void OnParticleParented(IEntity parent)
Event when the particle receives a parent.
proto native void SetParticleAutoDestroyFlags(ParticleAutoDestroyFlags flags)
Enables the particle to automatically clean up itself when ending or stopping.
void DestroyParticleEffect()
Empty.
override void SetWiggle(float random_angle, float random_interval)
Makes the particle change direction by random_angle every random_interval seconds.
void OnParticleUnParented(IEntity parent)
Event when the particle is orphaned.
override bool RestartParticle()
Method to tell the particle to restart (reset + play)
override Object GetDirectParticleEffect()
Returns direct particle effect entity.
static override Particle CreateOnObject(int particle_id, Object parent_obj, vector local_pos="0 0 0", vector local_ori="0 0 0", bool force_world_rotation=false)
Creates a particle emitter and attaches it on the given object.
override bool IsRepeat()
Returns whether there is a repeating particle.
void DisableAutoDestroy()
Disables the particle automatically cleaning up itself when ending or stopping.
proto native bool ApplyPropertiesNative(ParticleProperties properties)
Applies the properties given to the ParticleSource.
void OnParticleStop()
Event when the particle stops.
proto native void Orphan()
null the owner of this ParticleSource
override int GetParticleID()
Gets the ParticleList ID of the currently assigned particle.
bool SetParticle(string path)
Assigns a particle to the ParticleSource.
proto static native int GetStaticCount()
Gets the amount of ParticleSource that have been created since the start of the program.
void CreateParticleEffect()
Empty.
proto native ParticleManager GetParticleManager()
Get the ParticleManager the ParticleSource belongs to if any.
proto bool IsRepeatNative()
Returns whether there is a repeating particle.
proto bool StopParticleNative(int flags)
Method to tell the particle to stop playing.
override void ScaleParticleParam(int parameter_id, float coef)
Scales the given parameter on all emitors relatively to their CURRENT value.
proto bool PlayParticleNative(int flags)
Method to tell the particle to start playing.
proto native bool ResetParticleNative()
Method to tell the particle to reset.
override void GetParameter(int emitter, int parameter, out float value)
Get the value of a parameter of an emitor in the particle.
void EOnFrame(IEntity other, float timeSlice)
Empty.
override bool ResetParticle()
Method to tell the particle to reset.
override void SetParticleParam(int parameter_id, float value)
Set the value of a parameter of all emitors in the particle.
proto vector GetLocalPos()
proto vector GetLocalOri()
proto Object GetParent()
void ~ParticleProperties()
dtor
proto bool IsKeepParentOnEnd()
proto Class GetOwner()
proto int GetPPFlags()
void ParticleProperties(vector localPos, int flags, Object parent=null, vector localOri=vector.Zero, Class owner=null)
Constructor (ctor)
proto bool IsPlayOnCreation()
proto bool IsForceWorldRotation()
static const vector Zero
Definition EnConvert.c:110
proto native CGame GetGame()
enum ShapeType ErrorEx
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
proto void SetParticleParm(notnull IEntity ent, int emitor, EmitorParam parameter, void value)
proto void GetParticleParmOriginal(notnull IEntity ent, int emitor, EmitorParam parameter, out void value)
proto int GetParticleEmitorCount(notnull IEntity ent)
proto void GetParticleParm(notnull IEntity ent, int emitor, EmitorParam parameter, out void value)
proto native Widget GetParent()
Get parent of the Effect.
Definition Effect.c:389
proto native volatile void Update()