DayZ 1.24
Loading...
Searching...
No Matches
SEffectManager Class Reference

Manager class for managing Effect (EffectParticle, EffectSound) More...

Collaboration diagram for SEffectManager:
[legend]

Static Protected Member Functions

Generic playback

Methods for playing Effect

Note
Since 1.15, these should work on EffectSound as well
static int PlayInWorld (notnull Effect eff, vector pos)
 Play an Effect.
 
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.
 
static void Stop (int effect_id)
 Stops the Effect.
 
Create/Play sound

Methods for playing/creating sound

static EffectSound CreateSound (string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false, bool enviroment=false)
 Create an EffectSound.
 
static EffectSound PlaySound (string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
 Create and play an EffectSound.
 
static EffectSound PlaySoundParams (notnull SoundParams params, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
 Create and play an EffectSound.
 
static EffectSound PlaySoundCachedParams (string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
 Create and play an EffectSound, using or creating cached SoundParams.
 
static EffectSound PlaySoundEnviroment (string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
 Create and play an EffectSound, updating environment variables.
 
static EffectSound PlaySoundOnObject (string sound_set, Object parent_object, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
 Create and play an EffectSound.
 
Generic API

General methods used for SEffectManager

static void DestroyEffect (Effect effect)
 Unregisters, stops and frees the Effect.
 
static bool IsEffectExist (int effect_id)
 Checks whether an Effect ID is registered in SEffectManager.
 
static Effect GetEffectByID (int effect_id)
 Gets the Effect with the given registered Effect ID.
 
static int EffectRegister (Effect effect)
 Registers Effect in SEffectManager.
 
static void EffectUnregister (int id)
 Unregisters Effect in SEffectManager.
 
static void EffectUnregisterEx (Effect effect)
 Unregisters Effect in SEffectManager.
 
static int GetFreeEffectID ()
 Helper function for EffectRegister to decide an Effect ID.
 
Sound helpers

Sound specific helper methods

static bool DestroySound (EffectSound sound_effect)
 Legacy, backwards compatibility.
 
static SoundParams GetCachedSoundParam (string soundset)
 Get or create a cached SoundParams object.
 
Events

Various events that can be overriden for custom behaviour

static void Event_OnSoundWaveEnded (EffectSound effect_sound)
 Event called from EffectSound.Event_OnSoundWaveEnded.
 
static void Event_OnFrameUpdate (float time_delta)
 Event called on frame.
 
Lifetime

Creation and cleanup

static void Init ()
 Initialize the containers.
 
static void Cleanup ()
 Cleanup method to properly clean up the static data.
 

Static Protected Attributes

static ref map< int, ref Effectm_EffectsMap
 Static map of all registered effects <id, Effect>
 
static ref array< intm_FreeEffectIDs
 Static array of IDs that were previously used, but freed up by unregistering.
 
static int m_HighestFreeEffectID = 1
 Counter for quickly getting the next ID if FreeEffectIDs array is empty.
 
static const int INVALID_ID = 0
 As the counter starts at 1, Effect ID can never be 0.
 
static bool m_IsCleanup
 Bool to check whether Cleanup is happening, which means that the maps should no longer be accessed.
 
static bool m_IsInitialized
 Bool to check whether Init was called.
 
static ref map< string, ref SoundParamsm_ParamsMap
 Static map of cached sound params, to prevent having to recreate them.
 
static ref ScriptInvoker Event_OnFrameUpdate
 Static invoker for the SEffectManager.Event_OnFrameUpdate called form MissionGameplay.OnUpdate.
 

Detailed Description

Manager class for managing Effect (EffectParticle, EffectSound)

Warning
Keeps a ref to any Effect registered (Created/Played), make sure to perform the necessary cleanup

Definition at line 5 of file EffectManager.c.

Member Function Documentation

◆ Cleanup()

static void SEffectManager::Cleanup ( )
inlinestaticprotected

Cleanup method to properly clean up the static data.

Note
Will be called when MissionBase is destroyed

Definition at line 474 of file EffectManager.c.

475 {
476 // Nothing to clean
477 if (!m_IsInitialized)
478 return;
479
480 m_IsCleanup = true;
481
482 // There should not be anything in here on server
483 if (GetGame() && GetGame().IsDedicatedServer())
484 {
485 if (m_ParamsMap.Count() > 0)
486 ErrorEx(string.Format("SEffectManager containing SoundParams on server."), ErrorExSeverity.WARNING);
487
488 if (m_EffectsMap.Count() > 0)
489 ErrorEx(string.Format("SEffectManager containing Effect on server."), ErrorExSeverity.WARNING);
490 }
491
492 // These are intentionally cached, just clear them
493 m_ParamsMap.Clear();
494
495 // These might not be intentionally still here, so log how many there are
496#ifdef DEVELOPER
497 Print("--- SEffectManager Cleanup dump - Begin ------------------------");
498 Print(string.Format("Effect count: %1", m_EffectsMap.Count()));
499#endif
500
501 // Best to call the unregister event before clearing the map
502 // In case some ref is still being held elsewhere and will still be kept alive
503 foreach (int id, Effect eff : m_EffectsMap)
504 {
505 eff.Event_OnUnregistered();
506#ifdef SFXM_DUMP
507 Print(string.Format("%1 :: %2 :: %3", eff, typename.EnumToString(EffectType, eff.GetEffectType()), eff.GetDebugName()));
508#endif
509 }
510
511#ifdef DEVELOPER
512 Print("--- SEffectManager Cleanup dump - End --------------------------");
513#endif
514
515 // Now we can clear it
516 m_EffectsMap.Clear();
517
518 // Reset the state
520 Event_OnFrameUpdate.Clear();
521 m_IsCleanup = false;
522 }
EffectType
Enum to determine what type of effect the Effect is.
Definition Effect.c:3
static ref ScriptInvoker Event_OnFrameUpdate
Static invoker for the SEffectManager.Event_OnFrameUpdate called form MissionGameplay....
static ref map< int, ref Effect > m_EffectsMap
Static map of all registered effects <id, Effect>
static int m_HighestFreeEffectID
Counter for quickly getting the next ID if FreeEffectIDs array is empty.
static bool m_IsCleanup
Bool to check whether Cleanup is happening, which means that the maps should no longer be accessed.
static bool m_IsInitialized
Bool to check whether Init was called.
static ref map< string, ref SoundParams > m_ParamsMap
Static map of cached sound params, to prevent having to recreate them.
proto native CGame GetGame()
ErrorExSeverity
Definition EnDebug.c:62
proto void Print(void var)
Prints content of variable to console/log.
enum ShapeType ErrorEx

References ErrorEx, Event_OnFrameUpdate, GetGame(), m_EffectsMap, m_HighestFreeEffectID, m_IsCleanup, m_IsInitialized, m_ParamsMap, and Print().

Referenced by MissionBaseWorld::MissionBase(), and CGame::~CGame().

◆ CreateSound()

static EffectSound SEffectManager::CreateSound ( string sound_set,
vector position,
float play_fade_in = 0,
float stop_fade_out = 0,
bool loop = false,
bool enviroment = false )
inlinestaticprotected

Create an EffectSound.

Warning
Read PlayInWorld warning
Parameters
sound_setstring The sound set name of the sound
positionvector The position to play the sound
play_fade_infloat The fade in duration of the sound (Optional)
stop_fade_outfloat The fade out duration of the sound (Optional)
loopbool Whether the sound should loop (Optional)
enviromentbool Whether to set environment variables (Optional)
Returns
EffectSound The created EffectSound

Definition at line 130 of file EffectManager.c.

131 {
133 effect_sound.SetSoundSet(sound_set);
134 effect_sound.SetPosition(position);
135 effect_sound.SetSoundFadeIn(play_fade_in);
136 effect_sound.SetSoundFadeOut(stop_fade_out);
137 effect_sound.SetSoundLoop(loop);
138 effect_sound.SetEnviromentVariables(enviroment);
139
141
142 return effect_sound;
143 }
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
static int EffectRegister(Effect effect)
Registers Effect in SEffectManager.

References EffectRegister().

Referenced by HandleEngineSound(), FlashbangEffect::PlaySound(), PlaySound(), PlaySoundCachedParams(), PlaySoundEnviroment(), PlaySoundOnObject(), PlaySoundParams(), and UpdateMusic().

◆ DestroyEffect()

static void SEffectManager::DestroyEffect ( Effect effect)
inlinestaticprotected

◆ DestroySound()

static bool SEffectManager::DestroySound ( EffectSound sound_effect)
inlinestaticprotected

Legacy, backwards compatibility.

Parameters
sound_effectEffectSound The EffectSound to free
Returns
bool A bool which is always true

Definition at line 396 of file EffectManager.c.

397 {
399 return true;
400 }
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.

References DestroyEffect().

Referenced by CleanSoundEffects(), CleanUpOnClosedClient(), and Land_Underground_Stairs_Exit::CleanUpOnClosedClient().

◆ EffectRegister()

static int SEffectManager::EffectRegister ( Effect effect)
inlinestaticprotected

Registers Effect in SEffectManager.

Note
Already handled in SEffectManager Create/Play methods
This will make SEffectManager hold a strong ref for the Effect
Parameters
effectEffect The Effect to register
Returns
int The Effect ID

Definition at line 307 of file EffectManager.c.

308 {
309 if (effect.IsRegistered())
310 {
311 ErrorEx(string.Format("Attempted to register Effect '%1' which was already registered.", effect.GetDebugName()), ErrorExSeverity.INFO);
312 return effect.GetID();
313 }
314
315 int id;
316
317 if (!m_IsCleanup)
318 {
319 id = GetFreeEffectID();
320 m_EffectsMap.Insert(id, effect);
321 effect.Event_OnRegistered(id);
322 }
323 else
324 ErrorEx("Attempted to register Effect while SEffectManager is cleaning up, request ignored.", ErrorExSeverity.WARNING);
325
326 return id;
327 }
static int GetFreeEffectID()
Helper function for EffectRegister to decide an Effect ID.

References ErrorEx, GetFreeEffectID(), m_EffectsMap, and m_IsCleanup.

Referenced by CreateSound(), PlayInWorld(), and PlayOnObject().

◆ EffectUnregister()

static void SEffectManager::EffectUnregister ( int id)
inlinestaticprotected

Unregisters Effect in SEffectManager.

Note
Will automatically occur on stop when the Effect is AutoDestroy
ID can be gotten from the Effect by calling Effect.GetID
Generic Play methods will also return the ID
Parameters
idint The ID of the Effect to unregister

Definition at line 336 of file EffectManager.c.

337 {
338 if (m_IsCleanup)
339 return; // No error needed, since it will have been unregistered anyways after cleanup is finished
340
341 Effect effect;
342 if (m_EffectsMap.Find(id, effect))
343 {
344 effect.Event_OnUnregistered();
345 m_EffectsMap.Remove(id);
346 }
347
348 if (m_FreeEffectIDs.Find(id) == -1)
349 m_FreeEffectIDs.Insert(id);
350 }
static ref array< int > m_FreeEffectIDs
Static array of IDs that were previously used, but freed up by unregistering.

References m_EffectsMap, m_FreeEffectIDs, and m_IsCleanup.

Referenced by EffectUnregisterEx(), and ~Effect().

◆ EffectUnregisterEx()

static void SEffectManager::EffectUnregisterEx ( Effect effect)
inlinestaticprotected

Unregisters Effect in SEffectManager.

Parameters
effectEffect The Effect to unregister

Definition at line 356 of file EffectManager.c.

357 {
358 EffectUnregister(effect.GetID());
359 }
static void EffectUnregister(int id)
Unregisters Effect in SEffectManager.

References EffectUnregister().

◆ Event_OnFrameUpdate()

static void SEffectManager::Event_OnFrameUpdate ( float time_delta)
inlinestaticprotected

Event called on frame.

Note
Called from MissionGameplay.OnUpdate
Effects register themselves by Effect.SetEnableEventFrame(true)
EffectSound is automatically registered
Parameters
time_deltafloat Time passed since the previous frame

Definition at line 443 of file EffectManager.c.

444 {
446 }

References Event_OnFrameUpdate.

◆ Event_OnSoundWaveEnded()

static void SEffectManager::Event_OnSoundWaveEnded ( EffectSound effect_sound)
inlinestaticprotected

Event called from EffectSound.Event_OnSoundWaveEnded.

Note
Every registered sound is registered to call this
Parameters
effect_soundEffectSound The EffectSound calling the event

Definition at line 431 of file EffectManager.c.

432 {
433
434 }

Referenced by EffectSound::Event_OnRegistered(), and EffectSound::Event_OnUnregistered().

◆ GetCachedSoundParam()

static SoundParams SEffectManager::GetCachedSoundParam ( string soundset)
inlinestaticprotected

Get or create a cached SoundParams object.

Parameters
soundsetstring The sound set name of the sound
Returns
SoundParams The cached SoundParams for the given soundset

Definition at line 407 of file EffectManager.c.

408 {
410 if (!m_ParamsMap.Find(soundset, params))
411 {
413 m_ParamsMap.Insert(soundset, params);
414 }
415 return params;
416 }

References m_ParamsMap.

Referenced by PlaySoundCachedParams().

◆ GetEffectByID()

static Effect SEffectManager::GetEffectByID ( int effect_id)
inlinestaticprotected

Gets the Effect with the given registered Effect ID.

Parameters
effect_idint The Effect ID
Returns
Effect The Effect registered to the ID or null

Definition at line 292 of file EffectManager.c.

293 {
294 if (!m_IsCleanup)
295 return m_EffectsMap[effect_id];
296 else
297 return null;
298 }

References m_EffectsMap, and m_IsCleanup.

◆ GetFreeEffectID()

static int SEffectManager::GetFreeEffectID ( )
inlinestaticprotected

Helper function for EffectRegister to decide an Effect ID.

Returns
int A currently unused Effect ID

Definition at line 365 of file EffectManager.c.

366 {
367 int return_id;
368
369 if (m_FreeEffectIDs.Count() > 0)
370 {
371 return_id = m_FreeEffectIDs.Get(0);
372 m_FreeEffectIDs.Remove(0);
373 }
374 else
375 {
378 }
379
380 return return_id;
381 }

References m_FreeEffectIDs, and m_HighestFreeEffectID.

Referenced by EffectRegister().

◆ Init()

static void SEffectManager::Init ( )
inlinestaticprotected

Initialize the containers.

Note
This is done this way, to have these not exist on server

Definition at line 460 of file EffectManager.c.

461 {
466
467 m_IsInitialized = true;
468 }
ScriptInvoker Class provide list of callbacks usage:
Definition tools.c:116

References Event_OnFrameUpdate, m_EffectsMap, m_FreeEffectIDs, m_IsInitialized, and m_ParamsMap.

Referenced by CGame::CGame().

◆ IsEffectExist()

static bool SEffectManager::IsEffectExist ( int effect_id)
inlinestaticprotected

Checks whether an Effect ID is registered in SEffectManager.

Parameters
effect_idint The Effect ID to check
Returns
bool Whether there is an Effect registered for this ID

Definition at line 279 of file EffectManager.c.

280 {
281 if (!m_IsCleanup)
282 return m_EffectsMap[effect_id] != null;
283 else
284 return false;
285 }

References m_EffectsMap, and m_IsCleanup.

Referenced by CreateCarDestroyedEffect(), EOnPostSimulate(), and ManBase::SetDecayEffects().

◆ PlayInWorld()

static int SEffectManager::PlayInWorld ( notnull Effect eff,
vector pos )
inlinestaticprotected

Play an Effect.

Warning
As the Effect is automatically registered, it will not be freed automatically (because of the ref) Unless 'SetAutodestroy(true)' is called on the created 'Effect', which will clean it up when the sound stop Alternatively, SEffectManager.DestroyEffect can be called manually, which will also unregister and cleanup
Parameters
effEffect The Effect to play
posvector The position to play the Effect
Returns
int The registered ID of the Effect

Definition at line 42 of file EffectManager.c.

43 {
44 // Stop the effect first, just in case
45 eff.Stop();
46
47 int id = EffectRegister(eff);
48
49 eff.SetPosition(pos);
50 eff.Start();
51
52 return id;
53 }

References EffectRegister().

Referenced by Hit_MeatBones::BloodSplatGround(), CreateParticle(), ImpactMaterials::EvaluateImpactEffect(), ManBase::OnParticleEvent(), AmmoEffects::PlayAmmoEffect(), BleedingSourcesManagerBase::SetDiag(), DayZIntroSceneXbox::SetupParticles(), and Explosion::SpawnEffect().

◆ PlayOnObject()

static int SEffectManager::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 )
inlinestaticprotected

Play an Effect.

Warning
Read PlayInWorld warning
Parameters
effEffect The Effect to play
objObject The parent of the Effect
local_posvector The local position to play the Effect in relation to the parent (Optional)
local_orivector The local orientation to play the Effect in relation to the parent (Optional)
force_rotation_relative_to_worldbool Whether to force the orientation to stay in WS (Optional)
Returns
int The registered ID of the Effect

Definition at line 65 of file EffectManager.c.

66 {
67 // Stop the effect first, just in case
68 eff.Stop();
69
70 int id = EffectRegister(eff);
71
72 if (!obj)
73 {
74 ErrorEx("Parent object is null.", ErrorExSeverity.WARNING);
75 eff.SetPosition(local_pos);
76 }
77 else
78 eff.SetPosition(obj.GetPosition());
79
80 eff.SetParent(obj);
81 eff.SetLocalPosition(local_pos);
82 eff.SetAttachedLocalOri(local_ori);
83
85 {
87
88 if (eff_particle)
89 eff_particle.ForceParticleRotationRelativeToWorld(force_rotation_relative_to_world);
90 }
91
92 eff.Start();
93
94 return id;
95 }
Wrapper class for managing particles through SEffectManager.

References EffectRegister(), and ErrorEx.

Referenced by CreateCarDestroyedEffect(), EOnPostSimulate(), ManBase::SetDecayEffects(), and ItemBase::StartLoopSound().

◆ PlaySound()

static EffectSound SEffectManager::PlaySound ( string sound_set,
vector position,
float play_fade_in = 0,
float stop_fade_out = 0,
bool loop = false )
inlinestaticprotected

Create and play an EffectSound.

Warning
Calls CreateSound, read CreateSound warning
Parameters
sound_setstring The sound set name of the sound
positionvector The position to play the sound
play_fade_infloat The fade in duration of the sound (Optional)
stop_fade_outfloat The fade out duration of the sound (Optional)
loopbool Whether the sound should loop (Optional)
Returns
EffectSound The created EffectSound

Definition at line 155 of file EffectManager.c.

156 {
158
159 effect_sound.SoundPlay();
160
161 return effect_sound;
162 }
static EffectSound CreateSound(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false, bool enviroment=false)
Create an EffectSound.

References CreateSound().

Referenced by CGame::DelayedMidAirDetonation(), House::EEInit(), ItemBase::EEItemAttached(), ItemBase::EEItemDetached(), HandleDoorsSound(), HandleEngineSound(), HandleSeatAdjustmentSound(), CarScript::OnAnimationPhaseStarted(), Weapon::OnFireModeChange(), InventoryItem::OnRPC(), CGame::OnRPC(), OnSteppedOn(), InventoryItemSuper::OnWasAttached(), InventoryItemSuper::OnWasDetached(), SpookyEventBase::Perform(), ActionBuildShelter::PlayActionFinishSound(), ActionBuildShelter::PlayActionLoopSound(), ActionBuildShelter::PlayActionStartSound(), InventoryItem::PlayAttachSound(), InventoryItem::PlayDeployFinishSound(), ItemBase::PlayDeployLoopSound(), Inventory_Base::PlayDeployLoopSound(), InventoryItem::PlayDeployLoopSoundEx(), InventoryItem::PlayDeploySound(), PlayDisarmingLoopSound(), InventoryItem::PlayPlaceSound(), PlayRepackingLoopSound(), Backpack_Base::PlayRepackingLoopSound(), PlaySoundActivate(), TrapBase::PlaySoundBiteEmpty(), TrapBase::PlaySoundBiteLeg(), TrapBase::PlaySoundOpen(), Barrel_ColorBase::SoundBarrelClosePlay(), FireplaceBase::SoundBarrelClosePlay(), Barrel_ColorBase::SoundBarrelOpenPlay(), FireplaceBase::SoundBarrelOpenPlay(), Edible_Base::SoundCookingStart(), Entity::SoundHardBushFallingPlay(), Entity::SoundHardTreeFallingPlay(), Entity::SoundSoftBushFallingPlay(), Entity::SoundSoftTreeFallingPlay(), ItemBase::SoundTentClosePlay(), ItemBase::SoundTentCloseWindowPlay(), ItemBase::SoundTentOpenPlay(), ItemBase::SoundTentOpenWindowPlay(), and StartActivate().

◆ PlaySoundCachedParams()

static EffectSound SEffectManager::PlaySoundCachedParams ( string sound_set,
vector position,
float play_fade_in = 0,
float stop_fade_out = 0,
bool loop = false )
inlinestaticprotected

Create and play an EffectSound, using or creating cached SoundParams.

Warning
Calls CreateSound, read CreateSound warning
Parameters
sound_setstring The sound set name of the sound
positionvector The position to play the sound
play_fade_infloat The fade in duration of the sound (Optional)
stop_fade_outfloat The fade out duration of the sound (Optional)
loopbool Whether the sound should loop (Optional)
Returns
EffectSound The created EffectSound

Definition at line 193 of file EffectManager.c.

194 {
196
198
199 effect_sound.SoundPlayEx(params);
200
201 return effect_sound;
202 }
static SoundParams GetCachedSoundParam(string soundset)
Get or create a cached SoundParams object.

References CreateSound(), and GetCachedSoundParam().

Referenced by PlaySoundEx().

◆ PlaySoundEnviroment()

static EffectSound SEffectManager::PlaySoundEnviroment ( string sound_set,
vector position,
float play_fade_in = 0,
float stop_fade_out = 0,
bool loop = false )
inlinestaticprotected

Create and play an EffectSound, updating environment variables.

Warning
Calls CreateSound, read CreateSound warning
Parameters
sound_setstring The sound set name of the sound
positionvector The position to play the sound
play_fade_infloat The fade in duration of the sound (Optional)
stop_fade_outfloat The fade out duration of the sound (Optional)
loopbool Whether the sound should loop (Optional)
Returns
EffectSound The created EffectSound

Definition at line 214 of file EffectManager.c.

215 {
217
218 effect_sound.SoundPlay();
219
220 return effect_sound;
221 }

References CreateSound().

Referenced by ScriptConsoleSoundsTab::HandleKeys(), ScriptConsoleSoundsTab::OnClick(), and IEntity::PlaySoundSetAtMemoryPoint().

◆ PlaySoundOnObject()

static EffectSound SEffectManager::PlaySoundOnObject ( string sound_set,
Object parent_object,
float play_fade_in = 0,
float stop_fade_out = 0,
bool loop = false )
inlinestaticprotected

Create and play an EffectSound.

Warning
Calls CreateSound, read CreateSound warning
Parameters
sound_setstring The sound set name of the sound
parent_objectObject The parent Object for the sound to follow
play_fade_infloat The fade in duration of the sound (Optional)
stop_fade_outfloat The fade out duration of the sound (Optional)
loopbool Whether the sound should loop (Optional)
Returns
EffectSound The created EffectSound

Definition at line 233 of file EffectManager.c.

234 {
236
237 effect_sound.SetParent(parent_object);
238 effect_sound.SetLocalPosition(vector.Zero);
239 effect_sound.SoundPlay();
240
241 return effect_sound;
242 }
static const vector Zero
Definition EnConvert.c:110

References CreateSound(), and vector::Zero.

Referenced by ItemBase::DischargeClient(), ManBase::EEHitByRemote(), ManBase::OnBleedingSourceAdded(), ItemBase::OnIsCharged(), ManBase::OnPlayerRecievedHit(), ItemBase::OnWorkStart(), PlayEmptyingLoopSound(), PlayPouringLoopSound(), PlaySound(), IEntity::PlaySoundSet(), and StopEmptyingLoopSound().

◆ PlaySoundParams()

static EffectSound SEffectManager::PlaySoundParams ( notnull SoundParams params,
vector position,
float play_fade_in = 0,
float stop_fade_out = 0,
bool loop = false )
inlinestaticprotected

Create and play an EffectSound.

Warning
Calls CreateSound, read CreateSound warning
Parameters
paramsSoundParams Params to create the sound with
positionvector The position to play the sound
play_fade_infloat The fade in duration of the sound (Optional)
stop_fade_outfloat The fade out duration of the sound (Optional)
loopbool Whether the sound should loop (Optional)
Returns
EffectSound The created EffectSound

Definition at line 174 of file EffectManager.c.

175 {
177
178 effect_sound.SoundPlayEx(params);
179
180 return effect_sound;
181 }

References CreateSound().

◆ Stop()

static void SEffectManager::Stop ( int effect_id)
inlinestaticprotected

Stops the Effect.

Parameters
effect_idint The ID of the Effect to Stop

Definition at line 101 of file EffectManager.c.

102 {
103 Effect eff = m_EffectsMap.Get(effect_id);
104
105 if (eff)
106 eff.Stop();
107 else
108 ErrorEx(string.Format("Failed to stop Effect with ID %1. The ID is not registered in m_EffectsMap!", effect_id));
109 }

References ErrorEx, and m_EffectsMap.

Referenced by EOnPostSimulate().

Member Data Documentation

◆ Event_OnFrameUpdate

ref ScriptInvoker SEffectManager::Event_OnFrameUpdate
staticprotected

Static invoker for the SEffectManager.Event_OnFrameUpdate called form MissionGameplay.OnUpdate.

Definition at line 24 of file EffectManager.c.

Referenced by Cleanup(), Event_OnFrameUpdate(), Init(), MissionBase::OnUpdate(), and SetEnableEventFrame().

◆ INVALID_ID

const int SEffectManager::INVALID_ID = 0
staticprotected

As the counter starts at 1, Effect ID can never be 0.

Definition at line 14 of file EffectManager.c.

Referenced by Event_OnUnregistered().

◆ m_EffectsMap

ref map<int, ref Effect> SEffectManager::m_EffectsMap
staticprotected

Static map of all registered effects <id, Effect>

Definition at line 8 of file EffectManager.c.

Referenced by Cleanup(), EffectRegister(), EffectUnregister(), GetEffectByID(), Init(), IsEffectExist(), and Stop().

◆ m_FreeEffectIDs

ref array<int> SEffectManager::m_FreeEffectIDs
staticprotected

Static array of IDs that were previously used, but freed up by unregistering.

Definition at line 10 of file EffectManager.c.

Referenced by EffectUnregister(), GetFreeEffectID(), and Init().

◆ m_HighestFreeEffectID

int SEffectManager::m_HighestFreeEffectID = 1
staticprotected

Counter for quickly getting the next ID if FreeEffectIDs array is empty.

Definition at line 12 of file EffectManager.c.

Referenced by Cleanup(), and GetFreeEffectID().

◆ m_IsCleanup

bool SEffectManager::m_IsCleanup
staticprotected

Bool to check whether Cleanup is happening, which means that the maps should no longer be accessed.

Definition at line 16 of file EffectManager.c.

Referenced by Cleanup(), EffectRegister(), EffectUnregister(), GetEffectByID(), and IsEffectExist().

◆ m_IsInitialized

bool SEffectManager::m_IsInitialized
staticprotected

Bool to check whether Init was called.

Definition at line 18 of file EffectManager.c.

Referenced by Cleanup(), and Init().

◆ m_ParamsMap

ref map<string, ref SoundParams> SEffectManager::m_ParamsMap
staticprotected

Static map of cached sound params, to prevent having to recreate them.

Definition at line 21 of file EffectManager.c.

Referenced by Cleanup(), GetCachedSoundParam(), and Init().


The documentation for this class was generated from the following file: