PC Stable Documentation
 
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Loading...
Searching...
No Matches
SEffectManager Class Reference

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

Static Private 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 protected int GetFreeEffecterID ()
 
static void EffectUnregister (int id)
 Unregisters Effect in SEffectManager.
 
static void EffectUnregisterEx (Effect effect)
 Unregisters Effect in SEffectManager.
 
static protected 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 InitServer ()
 
static void Cleanup ()
 Cleanup method to properly clean up the static data.
 
static int CreateParticleServer (vector pos, EffecterParameters parameters)
 returns unique effecter ID
 
static void ReinitParticleServer (int effecterID, EffecterParameters parameters)
 allows re-initializing existing effecter with new parameters (extept m_EffecterType, obviously)
 
static void ReactivateParticleServer (int effecterID)
 
static void StartParticleServer (int effecterID)
 
static void StopParticleServer (int effecterID)
 
static void DestroyEffecterParticleServer (int effecterID)
 
static void OnUpdate (float timeslice)
 

Static Private Attributes

static protected ref map< int, ref Effectm_EffectsMap
 Static map of all registered effects <id, Effect>
 
static protected ref array< intm_FreeEffectIDs
 Static array of IDs that were previously used, but freed up by unregistering.
 
static protected 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 protected bool m_IsCleanup
 Bool to check whether Cleanup is happening, which means that the maps should no longer be accessed.
 
static protected bool m_IsInitialized
 Bool to check whether Init was called.
 
static protected 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.
 
static protected ref map< int, EffecterBasem_EffectersMap
 
static protected ref array< intm_FreeEffecterIDs
 Static array of IDs that were previously used, but freed up by unregistering Effecters.
 
static protected int m_HighestFreeEffecterID = 1
 

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

Member Function Documentation

◆ Cleanup()

static void Cleanup ( )
inlinestaticprivate

Cleanup method to properly clean up the static data.

Note
Will be called when MissionBase is destroyed

References ScriptInvoker::Clear(), Effect(), EffecterBase(), ErrorEx, Event_OnFrameUpdate, GetGame(), m_EffectersMap, m_EffectsMap, m_HighestFreeEffectID, m_IsCleanup, m_IsInitialized, m_ParamsMap, and Print().

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

◆ CreateParticleServer()

◆ CreateSound()

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

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

References EffectRegister(), EffectSound::SetEnviromentVariables(), EffectSound::SetSoundFadeIn(), EffectSound::SetSoundFadeOut(), EffectSound::SetSoundLoop(), and EffectSound::SetSoundSet().

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

◆ DestroyEffect()

◆ DestroyEffecterParticleServer()

static void DestroyEffecterParticleServer ( int  effecterID)
inlinestaticprivate

◆ DestroySound()

static bool DestroySound ( EffectSound  sound_effect)
inlinestaticprivate

Legacy, backwards compatibility.

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

References DestroyEffect().

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

◆ EffectRegister()

static int EffectRegister ( Effect  effect)
inlinestaticprivate

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

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

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

◆ EffectUnregister()

static void EffectUnregister ( int  id)
inlinestaticprivate

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

References Effect(), m_EffectsMap, m_FreeEffectIDs, and m_IsCleanup.

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

◆ EffectUnregisterEx()

static void EffectUnregisterEx ( Effect  effect)
inlinestaticprivate

Unregisters Effect in SEffectManager.

Parameters
effectEffect The Effect to unregister

References EffectUnregister().

Referenced by BoatScript::CleanupEffects().

◆ Event_OnFrameUpdate()

static void Event_OnFrameUpdate ( float  time_delta)
inlinestaticprivate

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

References Event_OnFrameUpdate, and ScriptInvoker::Invoke().

◆ Event_OnSoundWaveEnded()

static void Event_OnSoundWaveEnded ( EffectSound  effect_sound)
inlinestaticprivate

Event called from EffectSound.Event_OnSoundWaveEnded.

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

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

◆ GetCachedSoundParam()

static SoundParams GetCachedSoundParam ( string  soundset)
inlinestaticprivate

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

References m_ParamsMap, and SoundParams().

Referenced by PlaySoundCachedParams().

◆ GetEffectByID()

static Effect GetEffectByID ( int  effect_id)
inlinestaticprivate

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

References m_EffectsMap, and m_IsCleanup.

◆ GetFreeEffecterID()

static protected int GetFreeEffecterID ( )
inlinestaticprivate

◆ GetFreeEffectID()

static protected int GetFreeEffectID ( )
inlinestaticprivate

Helper function for EffectRegister to decide an Effect ID.

Returns
int A currently unused Effect ID

References m_FreeEffectIDs, and m_HighestFreeEffectID.

Referenced by EffectRegister().

◆ Init()

static void Init ( )
inlinestaticprivate

Initialize the containers.

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

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

Referenced by CGame::CGame().

◆ InitServer()

static void InitServer ( )
inlinestaticprivate

References m_EffectersMap, and m_FreeEffecterIDs.

Referenced by CGame::CGame().

◆ IsEffectExist()

static bool IsEffectExist ( int  effect_id)
inlinestaticprivate

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

References m_EffectsMap, and m_IsCleanup.

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

◆ OnUpdate()

static void OnUpdate ( float  timeslice)
inlinestaticprivate

References EffecterBase(), and m_EffectersMap.

Referenced by CGame::OnUpdate().

◆ PlayInWorld()

static int PlayInWorld ( notnull Effect  eff,
vector  pos 
)
inlinestaticprivate

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

References EffectRegister().

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

◆ PlayOnObject()

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 
)
inlinestaticprivate

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

References EffectRegister(), ErrorEx, and EffectParticle::ForceParticleRotationRelativeToWorld().

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

◆ PlaySound()

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

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

References CreateSound(), and EffectSound::SoundPlay().

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(), PlayDisarmingLoopSound(), PlayItemSoundClient(), PlayRepackingLoopSound(), Backpack_Base::PlayRepackingLoopSound(), PlaySoundActivate(), TrapBase::PlaySoundBiteEmpty(), TrapBase::PlaySoundBiteLeg(), TrapBase::PlaySoundOpen(), Edible_Base::SoundCookingStart(), Entity::SoundHardBushFallingPlay(), Entity::SoundHardTreeFallingPlay(), Entity::SoundSoftBushFallingPlay(), Entity::SoundSoftTreeFallingPlay(), StartActivate(), and GeyserTrigger::UpdateGeyserState().

◆ PlaySoundCachedParams()

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

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

References CreateSound(), GetCachedSoundParam(), SoundParams(), and EffectSound::SoundPlayEx().

Referenced by Land_WarheadStorage_PowerStation::OnVariablesSynchronized(), PlayItemSoundClient(), BoatScript::PlaySound(), and PlaySoundEx().

◆ PlaySoundEnviroment()

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

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

References CreateSound(), and EffectSound::SoundPlay().

Referenced by ScriptConsoleSoundsTab::HandleKeys(), ScriptConsoleSoundsTab::OnClick(), ContainerLockedBase::OnDoorUnlocked(), OnVariablesSynchronized(), ItemBase::PlayCatchSound(), and IEntity::PlaySoundSetAtMemoryPoint().

◆ PlaySoundOnObject()

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

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

References CreateSound(), EffectSound::SetParent(), EffectSound::SoundPlay(), 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 PlaySoundParams ( notnull SoundParams  params,
vector  position,
float  play_fade_in = 0,
float  stop_fade_out = 0,
bool  loop = false 
)
inlinestaticprivate

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

References CreateSound(), and EffectSound::SoundPlayEx().

◆ ReactivateParticleServer()

static void ReactivateParticleServer ( int  effecterID)
inlinestaticprivate

◆ ReinitParticleServer()

static void ReinitParticleServer ( int  effecterID,
EffecterParameters  parameters 
)
inlinestaticprivate

allows re-initializing existing effecter with new parameters (extept m_EffecterType, obviously)

References EffecterBase(), and m_EffectersMap.

Referenced by ItemBase::PlayCatchParticleSynced(), and ActionFishingNew::PlaySplashEffectSynced().

◆ StartParticleServer()

static void StartParticleServer ( int  effecterID)
inlinestaticprivate

References EffecterBase(), and m_EffectersMap.

◆ Stop()

static void Stop ( int  effect_id)
inlinestaticprivate

Stops the Effect.

Parameters
effect_idint The ID of the Effect to Stop

References Effect(), ErrorEx, and m_EffectsMap.

Referenced by EOnPostSimulate().

◆ StopParticleServer()

static void StopParticleServer ( int  effecterID)
inlinestaticprivate

References EffecterBase(), and m_EffectersMap.

Field Documentation

◆ Event_OnFrameUpdate

ref ScriptInvoker Event_OnFrameUpdate
staticprivate

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

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

◆ INVALID_ID

const int INVALID_ID = 0
staticprivate

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

Referenced by Event_OnUnregistered().

◆ m_EffectersMap

◆ m_EffectsMap

protected ref map<int, ref Effect> m_EffectsMap
staticprivate

Static map of all registered effects <id, Effect>

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

◆ m_FreeEffecterIDs

protected ref array<int> m_FreeEffecterIDs
staticprivate

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

Referenced by GetFreeEffecterID(), and InitServer().

◆ m_FreeEffectIDs

protected ref array<int> m_FreeEffectIDs
staticprivate

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

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

◆ m_HighestFreeEffecterID

protected int m_HighestFreeEffecterID = 1
staticprivate

Referenced by GetFreeEffecterID().

◆ m_HighestFreeEffectID

protected int m_HighestFreeEffectID = 1
staticprivate

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

Referenced by Cleanup(), and GetFreeEffectID().

◆ m_IsCleanup

protected bool m_IsCleanup
staticprivate

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

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

◆ m_IsInitialized

protected bool m_IsInitialized
staticprivate

Bool to check whether Init was called.

Referenced by Cleanup(), and Init().

◆ m_ParamsMap

protected ref map<string, ref SoundParams> m_ParamsMap
staticprivate

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

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


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