Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
particlemanager.c
Go to the documentation of this file.
14
17{
22#ifdef BULDOZER
23 static const int POOL_SIZE = 1;
24#else
25 static const int POOL_SIZE = 10000;
26#endif
27 static const int FLAGS = ParticleManagerSettingsFlags.NONE;
29}
30
33{
39 void ParticleManagerSettings(int poolSize, int flags = ParticleManagerSettingsFlags.NONE)
40 {
41 }
42
45 {
46 }
47}
48
51{
52 ref ScriptInvoker Event_OnAllocation = new ScriptInvoker();
53 ref ScriptInvoker Event_OnAllocationEnd = new ScriptInvoker();
54}
55
58{
61
63 static ParticleManager GetInstance()
64 {
65 if (!g_ParticleManager && !GetGame().IsDedicatedServer())
66 {
71 g_ParticleManager.SetName("GlobalParticleManager");
72 }
73
74 return g_ParticleManager;
75 }
76
78 static void CleanupInstance()
79 {
81 delete g_ParticleManager;
82 }
83
89 {
90 }
91
94 {
95 }
96
97
98
103
115 ParticleSource CreateParticle( int id, vector pos, bool playOnCreation = false, Object parent = null, vector ori = vector.Zero, bool forceWorldRotation = false, Class owner = null )
116 {
117 int flags = ParticlePropertiesFlags.NONE;
118
119 if (playOnCreation)
120 {
121 flags = flags | ParticlePropertiesFlags.PLAY_ON_CREATION;
122 }
123
124 if (forceWorldRotation)
125 {
126 flags = flags | ParticlePropertiesFlags.FORCE_WORLD_ROT;
127 }
128
129 return CreateParticleEx(id, pos, flags, parent, ori, owner);
130 }
131
142 ParticleSource CreateParticleEx( int id, vector pos, int flags = ParticlePropertiesFlags.NONE, Object parent = null, vector ori = vector.Zero, Class owner = null )
143 {
144 string particlePath = ParticleList.GetParticleFullPath(id);
145 if (particlePath == "") // There is already an error inside of ParticleList signaling this
146 {
147 ErrorEx(string.Format("Could not create ParticleSource as particle id %1 is invalid.", id));
148 return null;
149 }
150
151 ParticleProperties props = new ParticleProperties(pos, flags, parent, ori, owner);
152 ParticleSource p = CreateParticleByPath(particlePath, props);
153 return p;
154 }
155
166 int particle_id,
167 Object parent_obj,
168 vector local_pos = "0 0 0",
169 vector local_ori = "0 0 0",
170 bool force_world_rotation = false )
171 {
172 return CreateParticle(particle_id, local_pos, false, parent_obj, local_ori, force_world_rotation);
173 }
174
178 ParticleSource Create( int particle_id, Object parent_obj, vector local_pos = "0 0 0", vector local_ori = "0 0 0" )
179 {
180 return CreateOnObject( particle_id, parent_obj, local_pos, local_ori);
181 }
182
191 ParticleSource CreateInWorld( int particle_id, vector global_pos, vector global_ori = "0 0 0", bool force_world_rotation = false )
192 {
193 return CreateParticle(particle_id, global_pos, false, null, global_ori, force_world_rotation);
194 }
195
199 ParticleSource Create( int particle_id, vector global_pos, vector global_ori = "0 0 0" )
200 {
201 return CreateInWorld( particle_id, global_pos, global_ori );
202 }
203
205
206
207
212
222 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 )
223 {
224 return CreateParticle(particle_id, local_pos, true, parent_obj, local_ori, force_world_rotation);
225 }
226
230 ParticleSource Play( int particle_id, Object parent_obj, vector local_pos = "0 0 0", vector local_ori = "0 0 0" )
231 {
232 return PlayOnObject( particle_id, parent_obj, local_pos, local_ori);
233 }
234
242 {
243 return PlayInWorldEx(particle_id, null, global_pos);
244 }
245
246 ParticleSource PlayInWorldEx(int particle_id, Object parent_obj, vector global_pos, vector global_ori = "0 0 0", bool force_world_rotation = false)
247 {
248 return CreateParticle(particle_id, global_pos, true, parent_obj, global_ori, force_world_rotation);
249
250 }
251
256 {
257 return PlayInWorld( particle_id, global_pos);
258 }
259
261
262
263
268
277 proto native int CreateParticles(array<ParticleSource> particles, string path, notnull ParticlePropertiesArray properties, int count = 1);
278
285 ParticleSource CreateParticleByPath(string path, notnull ParticleProperties properties)
286 {
288 CreateParticles(tempArr, path, {properties}, 1);
289
290 if (tempArr.Count() > 0)
291 return tempArr[0];
292 else
293 return null;
294 }
295
303 int CreateParticlesById(int id, notnull ParticlePropertiesArray properties, int count)
304 {
305 return CreateParticles(null, ParticleList.GetParticleFullPath(id), properties, count);
306 }
307
315 array<ParticleSource> CreateParticlesByIdArr(int id, notnull ParticlePropertiesArray properties, int count)
316 {
318 CreateParticles(outArr, ParticleList.GetParticleFullPath(id), properties, count);
319 return outArr;
320 }
321
328 ParticleSource CreateParticleById(int id, ParticleProperties properties)
329 {
331 CreateParticles(tempArr, ParticleList.GetParticleFullPath(id), {properties}, 1);
332
333 if (tempArr.Count() > 0)
334 return tempArr[0];
335 else
336 return null;
337 }
338
347 proto native int PlayParticles(out array<ParticleSource> particles, string path, notnull array<vector> positions, int count = 1);
348
357 {
359 PlayParticles(outArr, ParticleList.GetParticleFullPath(id), positions, count);
360 return outArr;
361 }
362
370 {
372 PlayParticles(tempArr, ParticleList.GetParticleFullPath(id), position, 1);
373
374 if (tempArr.Count() > 0)
375 return tempArr[0];
376 else
377 return null;
378 }
379
385 proto native ParticleSource GetParticle(int index);
386
394 proto native int GetParticles(out array<ParticleSource> outArray, int startIndex, int count);
395
402 array<ParticleSource> GetParticlesEx(int startIndex, int count)
403 {
405 GetParticles(outArr, startIndex, count);
406 return outArr;
407 }
408
410
411
412
417
422 proto native void SetName(string name);
423
428 proto string GetName();
429
434 proto string GetDebugNameNative();
435
440 override string GetDebugName()
441 {
442 return GetDebugNameNative();
443 }
444
449 proto int GetCountID();
450
455 proto native static int GetStaticCount();
456
461 proto native static int GetStaticActiveCount();
462
464
465
466
471
476 proto native int GetPoolSize();
477
482 proto native int GetAllocatedCount();
483
488 proto native int GetVirtualCount();
489
494 proto native int GetPlayingCount();
495
500 proto native bool IsFinishedAllocating();
501
503
504
505
510
515 private proto void SetScriptEvents(Managed events);
516
521 private proto Managed GetScriptEvents();
522
528 {
529 return ParticleManagerEvents.Cast(GetScriptEvents());
530 }
531
533
534
535
540
541 void OnAllocation(array<ParticleSource> allocatedParticles)
542 {
543 GetEvents().Event_OnAllocation.Invoke(this, allocatedParticles);
544 }
545
546 void OnAllocationEnd()
547 {
548 GetEvents().Event_OnAllocationEnd.Invoke(this);
549 }
550
552}
void CreateParticle()
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Super root of all classes in Enforce script.
Definition enscript.c:11
TODO doc.
Definition enscript.c:118
Class simply to have easily modded constants.
Invokers for ParticleManager events.
Entity which has the particle instance as an ObjectComponent.
ScriptInvoker Class provide list of callbacks usage:
Definition tools.c:116
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
override string GetDebugName()
proto native CGame GetGame()
enum ShapeType ErrorEx
proto void Play()
ParticleEvents GetEvents()
Get the events.
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.
proto native int GetVirtualCount()
Gets the amount of virtual particles.
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.
proto native int GetPoolSize()
Gets the fixed maximum size of the pool.
class ParticleManagerConstants ParticleManagerSettings(int poolSize, int flags=ParticleManagerSettingsFlags.NONE)
Settings given to ParticleManager on creation (in ctor)
ParticleSource PlayInWorldEx(int particle_id, Object parent_obj, vector global_pos, vector global_ori="0 0 0", bool force_world_rotation=false)
proto native int GetPlayingCount()
Gets the amount of playing particles.
ParticleSource PlayParticleById(int id, array< vector > position)
QoL function for when only one particle is needed using script ParticleList, strongly recommend to re...
proto native int GetParticles(out array< ParticleSource > outArray, int startIndex, int count)
Manually get a portion of the particles in the pool.
ParticleSource CreateParticleEx(int id, vector pos, int flags=ParticlePropertiesFlags.NONE, Object parent=null, vector ori=vector.Zero, Class owner=null)
Master create function.
proto int GetCountID()
Gets the ID for the ParticleManager.
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.
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.
array< ParticleSource > CreateParticlesByIdArr(int id, notnull ParticlePropertiesArray properties, int count)
QoL function using script ParticleList, strongly recommend to read comments for CreateParticles as we...
proto string GetDebugNameNative()
Gets the debug name for the ParticleManager.
ParticleSource PlayInWorld(int particle_id, vector global_pos)
Creates a particle emitter on the given position and activates it.
proto native ParticleSource GetParticle(int index)
Manually get the particle at index.
void ~ParticleManager()
dtor
int CreateParticlesById(int id, notnull ParticlePropertiesArray properties, int count)
QoL function using script ParticleList, strongly recommend to read comments for CreateParticles as we...
proto native int GetAllocatedCount()
Gets the amount of particles currently allocated.
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
ParticleSource CreateParticleById(int id, ParticleProperties properties)
QoL function for when only one particle is needed using script ParticleList, strongly recommend to re...
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.
ParticleManagerSettingsFlags
Flags for ParticleManagerSettings.
@ REUSE_OWNED
Reuse stopped particles even if they are owned by something.
@ DISABLE_VIRTUAL
Disable the creation of virtual particles when the pool is still allocating.
@ BLOCKING
Allocation blocks the game until it is done.
@ FIXED_INDEX
Particles will be locked to the index and not reused.
@ NONE
proto native bool IsFinishedAllocating()
Checks if the ParticleManager has allocated all slots in the pool.
array< ParticleSource > PlayParticlesById(int id, array< vector > positions, int count)
QoL function using script ParticleList, strongly recommend to read comments for PlayParticles as well...
array< ParticleSource > GetParticlesEx(int startIndex, int count)
Manually get a portion of the particles in the pool.
ParticleSource CreateParticleByPath(string path, notnull ParticleProperties properties)
Create a particle.
class ParticleManagerEvents g_ParticleManager
Has a fixed pool of precreated and reserved particles.
proto native int CreateParticles(array< ParticleSource > particles, string path, notnull ParticlePropertiesArray properties, int count=1)
Creates an amount of particles with the properties given.
void ~ParticleManagerSettings()
dtor
int particle_id