DIFF

class SEffectManagerSource

Manager class for managing Effect (EffectParticle, EffectSound)

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

Constants 1

static const int INVALID_ID = 0

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

Members 10

protected static ref map<int, ref Effect> m_EffectsMap

Static map of all registered effects <id, Effect>

protected static ref array<int> m_FreeEffectIDs

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

protected static int m_HighestFreeEffectID = 1

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

Referenced by Cleanup(), and GetFreeEffectID()
protected static bool m_IsCleanup

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

protected static bool m_IsInitialized

Bool to check whether Init was called

Referenced by Cleanup(), and Init()
protected static ref map<string, ref SoundParams> m_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

protected static ref array<int> m_FreeEffecterIDs

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

protected static int m_HighestFreeEffecterID = 1
Referenced by GetFreeEffecterID()

Methods 31

static int PlayInWorld(notnull Effect eff, vector pos)

Play an Effect

eff
Effect The Effect to play
pos
vector The position to play the Effect

Returns: int The registered ID of the Effect

WarningAs 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
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

eff
Effect The Effect to play
obj
Object The parent of the Effect
local_pos
vector The local position to play the Effect in relation to the parent (Optional)
local_ori
vector The local orientation to play the Effect in relation to the parent (Optional)
force_rotation_relative_to_world
bool Whether to force the orientation to stay in WS (Optional)

Returns: int The registered ID of the Effect

WarningRead PlayInWorld warning
static void Stop(int effect_id)

Stops the Effect

effect_id
int The ID of the Effect to Stop
References ErrorEx(), string.Format(), map.Get()
Show 2 more, Effect.Stop(), and m_EffectsMap
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

sound_set
string The sound set name of the sound
position
vector The position to play the sound
play_fade_in
float The fade in duration of the sound (Optional)
stop_fade_out
float The fade out duration of the sound (Optional)
loop
bool Whether the sound should loop (Optional)
enviroment
bool Whether to set environment variables (Optional)

Returns: EffectSound The created EffectSound

WarningRead PlayInWorld warning
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

sound_set
string The sound set name of the sound
position
vector The position to play the sound
play_fade_in
float The fade in duration of the sound (Optional)
stop_fade_out
float The fade out duration of the sound (Optional)
loop
bool Whether the sound should loop (Optional)

Returns: EffectSound The created EffectSound

WarningCalls CreateSound, read CreateSound warning
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

params
SoundParams Params to create the sound with
position
vector The position to play the sound
play_fade_in
float The fade in duration of the sound (Optional)
stop_fade_out
float The fade out duration of the sound (Optional)
loop
bool Whether the sound should loop (Optional)

Returns: EffectSound The created EffectSound

WarningCalls CreateSound, read CreateSound warning
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

sound_set
string The sound set name of the sound
position
vector The position to play the sound
play_fade_in
float The fade in duration of the sound (Optional)
stop_fade_out
float The fade out duration of the sound (Optional)
loop
bool Whether the sound should loop (Optional)

Returns: EffectSound The created EffectSound

WarningCalls CreateSound, read CreateSound warning
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

sound_set
string The sound set name of the sound
position
vector The position to play the sound
play_fade_in
float The fade in duration of the sound (Optional)
stop_fade_out
float The fade out duration of the sound (Optional)
loop
bool Whether the sound should loop (Optional)

Returns: EffectSound The created EffectSound

WarningCalls CreateSound, read CreateSound warning
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

sound_set
string The sound set name of the sound
parent_object
Object The parent Object for the sound to follow
play_fade_in
float The fade in duration of the sound (Optional)
stop_fade_out
float The fade out duration of the sound (Optional)
loop
bool Whether the sound should loop (Optional)

Returns: EffectSound The created EffectSound

WarningCalls CreateSound, read CreateSound warning
static bool IsEffectExist(int effect_id)

Checks whether an Effect ID is registered in SEffectManager

effect_id
int The Effect ID to check

Returns: bool Whether there is an Effect registered for this ID

References m_EffectsMap, and m_IsCleanup
static Effect GetEffectByID(int effect_id)

Gets the Effect with the given registered Effect ID

effect_id
int The Effect ID

Returns: Effect The Effect registered to the ID or null

References m_EffectsMap, and m_IsCleanup
static int EffectRegister(Effect effect)

Registers Effect in SEffectManager

effect
Effect The Effect to register

Returns: int The Effect ID

NoteAlready handled in SEffectManager Create/Play methods
NoteThis will make SEffectManager hold a strong ref for the Effect
protected static int GetFreeEffecterID()
static void EffectUnregister(int id)

Unregisters Effect in SEffectManager

id
int The ID of the Effect to unregister
NoteWill automatically occur on stop when the Effect is AutoDestroy
NoteID can be gotten from the Effect by calling Effect.GetID
NoteGeneric Play methods will also return the ID
static void EffectUnregisterEx(Effect effect)

Unregisters Effect in SEffectManager

effect
Effect The Effect to unregister
protected static int GetFreeEffectID()

Helper function for EffectRegister to decide an Effect ID

Returns: int A currently unused Effect ID

Referenced by EffectRegister()
static bool DestroySound(EffectSound sound_effect)

Legacy, backwards compatibility

sound_effect
EffectSound The EffectSound to free

Returns: bool A bool which is always true

References DestroyEffect()
static SoundParams GetCachedSoundParam(string soundset)

Get or create a cached SoundParams object

soundset
string The sound set name of the sound

Returns: SoundParams The cached SoundParams for the given soundset

References map.Find(), map.Insert(), new SoundParams()
Show 1 more, m_ParamsMap
static void Event_OnSoundWaveEnded(EffectSound effect_sound)

Event called from EffectSound.Event_OnSoundWaveEnded

effect_sound
EffectSound The EffectSound calling the event
NoteEvery registered sound is registered to call this
static void Event_OnFrameUpdate(float time_delta)

Event called on frame

time_delta
float Time passed since the previous frame
NoteCalled from MissionGameplay.OnUpdate
NoteEffects register themselves by Effect.SetEnableEventFrame(true)
NoteEffectSound is automatically registered
static void Init()

Initialize the containers

NoteThis is done this way, to have these not exist on server
Referenced by CGame.CGame()
static void InitServer()
Referenced by CGame.CGame()
static void ReinitParticleServer(int effecterID, EffecterParameters parameters)

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

static void StartParticleServer(int effecterID)
static void StopParticleServer(int effecterID)
static void DestroyEffecterParticleServer(int effecterID)
References EntityAI.DeleteSafe(), map.Get(), map.Remove()
Show 1 more, m_EffectersMap
static void OnUpdate(float timeslice)
Referenced by DayZGame.OnUpdate()