Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
particlemanager.c
Go to the documentation of this file.
3 {
4  NONE,
13 };
14 
17 {
22  static const int POOL_SIZE = 10000;
23  static const int FLAGS = ParticleManagerSettingsFlags.NONE;
25 }
26 
29 {
35  void ParticleManagerSettings(int poolSize, int flags = ParticleManagerSettingsFlags.NONE)
36  {
37  }
38 
41  {
42  }
43 }
44 
47 {
48  ref ScriptInvoker Event_OnAllocation = new ScriptInvoker();
49  ref ScriptInvoker Event_OnAllocationEnd = new ScriptInvoker();
50 }
51 
54 {
56  private static ref ParticleManager g_ParticleManager;
57 
59  static ParticleManager GetInstance()
60  {
61  if (!g_ParticleManager && !GetGame().IsDedicatedServer())
62  {
65  ParticleManagerConstants.POOL_SIZE,
67  g_ParticleManager.SetName("GlobalParticleManager");
68  }
69 
70  return g_ParticleManager;
71  }
72 
74  static void CleanupInstance()
75  {
77  delete g_ParticleManager;
78  }
79 
85  {
86  }
87 
90  {
91  }
92 
93 
94 
99 
111  ParticleSource CreateParticle( int id, vector pos, bool playOnCreation = false, Object parent = null, vector ori = vector.Zero, bool forceWorldRotation = false, Class owner = null )
112  {
113  int flags = ParticlePropertiesFlags.NONE;
114 
115  if (playOnCreation)
116  {
117  flags = flags | ParticlePropertiesFlags.PLAY_ON_CREATION;
118  }
119 
120  if (forceWorldRotation)
121  {
122  flags = flags | ParticlePropertiesFlags.FORCE_WORLD_ROT;
123  }
124 
125  return CreateParticleEx(id, pos, flags, parent, ori, owner);
126  }
127 
138  ParticleSource CreateParticleEx( int id, vector pos, int flags = ParticlePropertiesFlags.NONE, Object parent = null, vector ori = vector.Zero, Class owner = null )
139  {
140  string particlePath = ParticleList.GetParticleFullPath(id);
141  if (particlePath == "") // There is already an error inside of ParticleList signaling this
142  {
143  ErrorEx(string.Format("Could not create ParticleSource as particle id %1 is invalid.", id));
144  return null;
145  }
146 
147  ParticleProperties props = new ParticleProperties(pos, flags, parent, ori, owner);
148  ParticleSource p = CreateParticleByPath(particlePath, props);
149  return p;
150  }
151 
162  int particle_id,
163  Object parent_obj,
164  vector local_pos = "0 0 0",
165  vector local_ori = "0 0 0",
166  bool force_world_rotation = false )
167  {
168  return CreateParticle(particle_id, local_pos, false, parent_obj, local_ori, force_world_rotation);
169  }
170 
174  ParticleSource Create( int particle_id, Object parent_obj, vector local_pos = "0 0 0", vector local_ori = "0 0 0" )
175  {
176  return CreateOnObject( particle_id, parent_obj, local_pos, local_ori);
177  }
178 
187  ParticleSource CreateInWorld( int particle_id, vector global_pos, vector global_ori = "0 0 0", bool force_world_rotation = false )
188  {
189  return CreateParticle(particle_id, global_pos, false, null, global_ori, force_world_rotation);
190  }
191 
195  ParticleSource Create( int particle_id, vector global_pos, vector global_ori = "0 0 0" )
196  {
197  return CreateInWorld( particle_id, global_pos, global_ori );
198  }
199 
201 
202 
203 
208 
218  ParticleSource PlayOnObject(int particle_id, Object parent_obj, vector local_pos = "0 0 0", vector local_ori = "0 0 0", bool force_world_rotation = false )
219  {
220  return CreateParticle(particle_id, local_pos, true, parent_obj, local_ori, force_world_rotation);
221  }
222 
226  ParticleSource Play( int particle_id, Object parent_obj, vector local_pos = "0 0 0", vector local_ori = "0 0 0" )
227  {
228  return PlayOnObject( particle_id, parent_obj, local_pos, local_ori);
229  }
230 
238  {
239  return PlayInWorldEx(particle_id, null, global_pos);
240  }
241 
242  ParticleSource PlayInWorldEx(int particle_id, Object parent_obj, vector global_pos, vector global_ori = "0 0 0", bool force_world_rotation = false)
243  {
244  return CreateParticle(particle_id, global_pos, true, parent_obj, global_ori, force_world_rotation);
245 
246  }
247 
252  {
253  return PlayInWorld( particle_id, global_pos);
254  }
255 
257 
258 
259 
264 
273  proto native int CreateParticles(array<ParticleSource> particles, string path, notnull ParticlePropertiesArray properties, int count = 1);
274 
281  ParticleSource CreateParticleByPath(string path, notnull ParticleProperties properties)
282  {
284  CreateParticles(tempArr, path, {properties}, 1);
285 
286  if (tempArr.Count() > 0)
287  return tempArr[0];
288  else
289  return null;
290  }
291 
299  int CreateParticlesById(int id, notnull ParticlePropertiesArray properties, int count)
300  {
301  return CreateParticles(null, ParticleList.GetParticleFullPath(id), properties, count);
302  }
303 
311  array<ParticleSource> CreateParticlesByIdArr(int id, notnull ParticlePropertiesArray properties, int count)
312  {
314  CreateParticles(outArr, ParticleList.GetParticleFullPath(id), properties, count);
315  return outArr;
316  }
317 
324  ParticleSource CreateParticleById(int id, ParticleProperties properties)
325  {
327  CreateParticles(tempArr, ParticleList.GetParticleFullPath(id), {properties}, 1);
328 
329  if (tempArr.Count() > 0)
330  return tempArr[0];
331  else
332  return null;
333  }
334 
343  proto native int PlayParticles(out array<ParticleSource> particles, string path, notnull array<vector> positions, int count = 1);
344 
353  {
355  PlayParticles(outArr, ParticleList.GetParticleFullPath(id), positions, count);
356  return outArr;
357  }
358 
366  {
368  PlayParticles(tempArr, ParticleList.GetParticleFullPath(id), position, 1);
369 
370  if (tempArr.Count() > 0)
371  return tempArr[0];
372  else
373  return null;
374  }
375 
381  proto native ParticleSource GetParticle(int index);
382 
390  proto native int GetParticles(out array<ParticleSource> outArray, int startIndex, int count);
391 
398  array<ParticleSource> GetParticlesEx(int startIndex, int count)
399  {
401  GetParticles(outArr, startIndex, count);
402  return outArr;
403  }
404 
406 
407 
408 
413 
418  proto native void SetName(string name);
419 
424  proto string GetName();
425 
430  proto string GetDebugNameNative();
431 
436  override string GetDebugName()
437  {
438  return GetDebugNameNative();
439  }
440 
445  proto int GetCountID();
446 
451  proto native static int GetStaticCount();
452 
457  proto native static int GetStaticActiveCount();
458 
460 
461 
462 
467 
472  proto native int GetPoolSize();
473 
478  proto native int GetAllocatedCount();
479 
484  proto native int GetVirtualCount();
485 
490  proto native int GetPlayingCount();
491 
496  proto native bool IsFinishedAllocating();
497 
499 
500 
501 
506 
511  private proto void SetScriptEvents(Managed events);
512 
517  private proto Managed GetScriptEvents();
518 
524  {
525  return ParticleManagerEvents.Cast(GetScriptEvents());
526  }
527 
529 
530 
531 
536 
537  void OnAllocation(array<ParticleSource> allocatedParticles)
538  {
539  GetEvents().Event_OnAllocation.Invoke(this, allocatedParticles);
540  }
541 
543  {
544  GetEvents().Event_OnAllocationEnd.Invoke(this);
545  }
546 
548 }
GetGame
proto native CGame GetGame()
CreateParticleEx
ParticleSource CreateParticleEx(int id, vector pos, int flags=ParticlePropertiesFlags.NONE, Object parent=null, vector ori=vector.Zero, Class owner=null)
Master create function.
Definition: particlemanager.c:138
GetDebugName
override string GetDebugName()
Gets the debug name for the ParticleManager.
Definition: particlemanager.c:436
BLOCKING
@ BLOCKING
Allocation blocks the game until it is done.
Definition: particlemanager.c:8
SetName
proto native void SetName(string name)
Set a name for the ParticleManager to identify it more easily.
particle_id
int particle_id
Definition: smokesimulation.c:3
PlayInWorldEx
ParticleSource PlayInWorldEx(int particle_id, Object parent_obj, vector global_pos, vector global_ori="0 0 0", bool force_world_rotation=false)
Definition: particlemanager.c:242
CreateParticle
ParticleSource CreateParticle(int id, vector pos, bool playOnCreation=false, Object parent=null, vector ori=vector.Zero, bool forceWorldRotation=false, Class owner=null)
Create function.
Definition: particlemanager.c:111
SetScriptEvents
private proto void SetScriptEvents(Managed events)
Set the events.
Play
ParticleSource 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.
Definition: particlemanager.c:226
CreateOnObject
ParticleSource 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.
Definition: particlemanager.c:161
ParticleManagerConstants
Class simply to have easily modded constants.
Definition: particlemanager.c:16
PlayOnObject
ParticleSource 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.
Definition: particlemanager.c:218
REUSE_OWNED
@ REUSE_OWNED
Reuse stopped particles even if they are owned by something.
Definition: particlemanager.c:12
GetName
proto string GetName()
Gets the name which is set for the ParticleManager, default is "ParticleSourceManager".
Definition: gesturesmenu.c:37
~ParticleManagerSettings
void ~ParticleManagerSettings()
dtor
Definition: particlemanager.c:40
Managed
TODO doc.
Definition: enscript.c:117
ParticleManagerSettingsFlags
ParticleManagerSettingsFlags
Flags for ParticleManagerSettings.
Definition: particlemanager.c:2
g_ParticleManager
class ParticleManagerEvents g_ParticleManager
Has a fixed pool of precreated and reserved particles.
Create
ParticleSource Create(int particle_id, Object parent_obj, vector local_pos="0 0 0", vector local_ori="0 0 0")
Legacy function for backwards compatibility.
Definition: particlemanager.c:174
ErrorEx
enum ShapeType ErrorEx
GetParticlesEx
array< ParticleSource > GetParticlesEx(int startIndex, int count)
Manually get a portion of the particles in the pool.
Definition: particlemanager.c:398
CreateParticlesByIdArr
array< ParticleSource > CreateParticlesByIdArr(int id, notnull ParticlePropertiesArray properties, int count)
QoL function using script ParticleList, strongly recommend to read comments for CreateParticles as we...
Definition: particlemanager.c:311
ParticleList
Definition: particlelist.c:11
GetParticle
proto native ParticleSource GetParticle(int index)
Manually get the particle at index.
~ParticleManager
void ~ParticleManager()
dtor
Definition: particlemanager.c:89
OnAllocationEnd
void OnAllocationEnd()
Definition: particlemanager.c:542
vector
Definition: enconvert.c:105
DISABLE_VIRTUAL
@ DISABLE_VIRTUAL
Disable the creation of virtual particles when the pool is still allocating.
Definition: particlemanager.c:10
GetEvents
ParticleManagerEvents GetEvents()
Get the events.
Definition: particlemanager.c:523
ParticleManagerSettings
class ParticleManagerConstants ParticleManagerSettings(int poolSize, int flags=ParticleManagerSettingsFlags.NONE)
Settings given to ParticleManager on creation (in ctor)
Definition: particlemanager.c:35
Object
Definition: objecttyped.c:1
GetVirtualCount
proto native int GetVirtualCount()
Gets the amount of virtual particles.
CreateParticlesById
int CreateParticlesById(int id, notnull ParticlePropertiesArray properties, int count)
QoL function using script ParticleList, strongly recommend to read comments for CreateParticles as we...
Definition: particlemanager.c:299
PlayParticles
proto native int PlayParticles(out array< ParticleSource > particles, string path, notnull array< vector > positions, int count=1)
QoL function for when wanting to play a particle at a position right away.
PlayInWorld
ParticleSource PlayInWorld(int particle_id, vector global_pos)
Creates a particle emitter on the given position and activates it.
Definition: particlemanager.c:237
CreateParticleByPath
ParticleSource CreateParticleByPath(string path, notnull ParticleProperties properties)
Create a particle.
Definition: particlemanager.c:281
CreateParticleById
ParticleSource CreateParticleById(int id, ParticleProperties properties)
QoL function for when only one particle is needed using script ParticleList, strongly recommend to re...
Definition: particlemanager.c:324
array< ParticleSource >
ParticleSource
Entity which has the particle instance as an ObjectComponent.
Definition: particlesource.c:123
PlayParticlesById
array< ParticleSource > PlayParticlesById(int id, array< vector > positions, int count)
QoL function using script ParticleList, strongly recommend to read comments for PlayParticles as well...
Definition: particlemanager.c:352
OnAllocation
void OnAllocation(array< ParticleSource > allocatedParticles)
Definition: particlemanager.c:537
NONE
@ NONE
Definition: particlemanager.c:4
GetCountID
proto int GetCountID()
Gets the ID for the ParticleManager.
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
GetPlayingCount
proto native int GetPlayingCount()
Gets the amount of playing particles.
ParticleManagerEvents
Invokers for ParticleManager events.
Definition: particlemanager.c:46
CreateParticles
proto native int CreateParticles(array< ParticleSource > particles, string path, notnull ParticlePropertiesArray properties, int count=1)
Creates an amount of particles with the properties given.
GetAllocatedCount
proto native int GetAllocatedCount()
Gets the amount of particles currently allocated.
CreateInWorld
ParticleSource 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.
Definition: particlemanager.c:187
GetParticles
proto native int GetParticles(out array< ParticleSource > outArray, int startIndex, int count)
Manually get a portion of the particles in the pool.
FIXED_INDEX
@ FIXED_INDEX
Particles will be locked to the index and not reused.
Definition: particlemanager.c:6
GetScriptEvents
private proto Managed GetScriptEvents()
Get the events.
PlayParticleById
ParticleSource PlayParticleById(int id, array< vector > position)
QoL function for when only one particle is needed using script ParticleList, strongly recommend to re...
Definition: particlemanager.c:365
ParticleManager
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Definition: particlemanager.c:84
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
IsFinishedAllocating
proto native bool IsFinishedAllocating()
Checks if the ParticleManager has allocated all slots in the pool.
GetPoolSize
proto native int GetPoolSize()
Gets the fixed maximum size of the pool.
path
string path
Definition: optionselectormultistate.c:135
GetDebugNameNative
proto string GetDebugNameNative()
Gets the debug name for the ParticleManager.
ScriptInvoker
ScriptInvoker Class provide list of callbacks usage:
Definition: tools.c:115