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

Wrapper class for managing sound through SEffectManager. More...

Inheritance diagram for EffectSound:
[legend]
Collaboration diagram for EffectSound:
[legend]

Protected Member Functions

EffectType

Information about what type of effect the Effect is, without the need for casting

override EffectType GetEffectType ()
 Get what type of effect the Effect is.
 
override bool IsSound ()
 Check whether the Effect is EffectSound without casting.
 
Playback

Methods to Play/Stop sound Generally, SEffectManager.PlaySound methods are used instead of SoundPlay

bool SoundPlayEx (out SoundParams params)
 Plays sound.
 
bool SoundPlay ()
 Plays sound.
 
override void Start ()
 Plays sound.
 
void SoundStop ()
 Stops sound.
 
override void Stop ()
 Stops sound.
 
void SoundReset ()
 Resets EffectSound.
 
bool IsSoundPlaying ()
 Get whether EffectSound is currently playing.
 
override bool IsPlaying ()
 Returns true when the effect is playing, false otherwise.
 
Sound load

Methods regarding the loading of the sound, used in SoundPlay

bool SoundLoadEx (out SoundParams params)
 Loads in the sound when it is requested for playing through 'SoundPlayEx'.
 
bool SoundLoad ()
 Loads in the sound when it is requested for playing.
 
bool IsSoundValid ()
 Helper for checking if params are valid.
 
void ValidateSoundWave ()
 Gets called to fill in the necessary data when the header has finished loading.
 
bool SoundWaveValidation ()
 Validation of fade settings.
 
void UpdateEvents ()
 Enables the frame event on the EffectSound.
 
Events

Various events that can be overriden for custom behaviour

override void Event_OnFrameUpdate (float time_delta)
 Event called on frame when enabled by SetEnableEventFrame(true)
 
override void Event_OnRegistered (int id)
 Event called from SEffectManager when the Effect is registered.
 
override void Event_OnUnregistered ()
 Event called from SEffectManager when the Effect is unregistered.
 
void Event_OnSoundWaveStarted ()
 Event called when sound starts playing.
 
void Event_OnSoundWaveEnded ()
 Event called when sound stops playing.
 
void Event_OnSoundFadeInStopped ()
 Event called when sound fade in stops.
 
void Event_OnSoundFadeOutStarted ()
 Event called when sound fade out starts.
 
AutoDestroy

Methods regarding automatic cleanup on stop

override void SetAutodestroy (bool auto_destroy)
 Sets whether Effect automatically cleans up when it stops.
 
override bool IsAutodestroy ()
 Get whether Effect automatically cleans up when it stops.
 
void SetSoundAutodestroy (bool auto_destroy)
 Sets whether EffectSound automatically cleans up when sound stops.
 
bool IsSoundAutodestroy ()
 Get whether EffectSound automatically cleans up when sound stops.
 
override bool CanDestroy ()
 
Generic API

Setters and getters for generic data and properties

override void SetParent (Object parent_obj)
 Set parent for the sound to follow.
 
override Object GetParent ()
 Get parent for the EffectSound.
 
override Object GetCurrentParent ()
 Get parent for the EffectSound.
 
override void SetCurrentPosition (vector pos, bool updateCached=true)
 Set the world position of the managed sound.
 
override vector GetCurrentPosition ()
 Get the current world position of the managed sound.
 
override void SetCurrentLocalPosition (vector pos, bool updateCached=true)
 Set the current local position of the managed sound.
 
override vector GetCurrentLocalPosition ()
 Get the current local position of the managed sound.
 
void SetSoundWaveKind (WaveKind wave_kind)
 Set WaveKind for the sound.
 
void SetSoundSet (string snd)
 Set soundset for the sound.
 
string GetSoundSet ()
 Get soundset for the sound.
 
void SetSoundLoop (bool loop)
 Set if the sound loops.
 
void SetEnviromentVariables (bool setEnvVariables)
 Sets whether AddEnvSoundVariables needs to be called during Loading.
 
float GetSoundWaveLenght ()
 Get the sound wave length.
 
float GetSoundWaveLength ()
 Get the sound wave length.
 
void SetSoundVolume (float volume)
 Set the RELATIVE volume for the sound.
 
float GetSoundVolume ()
 Get the RELATIVE volume set by 'SetSoundVolume'.
 
void SetSoundMaxVolume (float volume)
 Set the sound max volume.
 
float GetSoundWaveTime ()
 Get the time since EffectSound started playing.
 
void SetSoundFadeIn (float fade_in)
 Set the sound fade in duration.
 
void SetSoundFadeOut (float fade_out)
 Set the sound fade out duration.
 
void SetDoppler (bool setDoppler)
 Set if the sound has the doppler effect enabled.
 
void SoundError (string err_msg)
 Helper for throwing sound errors.
 

Protected Attributes

Sound objects and structures

Objects and structures for the sound

ref SoundParams m_SoundParams
 
ref SoundObjectBuilder m_SoundObjectBuilder
 
ref SoundObject m_SoundObject
 
AbstractWave m_SoundWaveObject
 
Generic data

Generic data for the sound

WaveKind m_SoundWaveKind
 
string m_SoundSetName
 
bool m_SoundLoop
 
bool m_SetEnvVariables
 
bool m_SoundAutodestroy
 
bool m_SoundWaveIsPlaying
 
float m_SoundWaveLenght
 
float m_SoundWaveVolume
 
float m_SoundWaveVolumeMax
 
float m_SoundWaveTime
 
int m_SoundDoppler
 

Private Attributes

Event invokers

ScriptInvonkers for certain events

ref ScriptInvoker Event_OnSoundWaveStarted = new ScriptInvoker()
 
ref ScriptInvoker Event_OnSoundWaveEnded = new ScriptInvoker()
 
ref ScriptInvoker Event_OnSoundFadeInStopped = new ScriptInvoker()
 
ref ScriptInvoker Event_OnSoundFadeOutStarted = new ScriptInvoker()
 

Fading data

Data for fadein/fadeout for the sound

bool m_SoundWaveStarting
 
bool m_SoundWaveStopping
 
bool m_SoundFadedOut
 
float m_SoundFadeInDuration
 
float m_SoundFadeOutStartTime
 
float m_SoundFadeOutDuration
 
float m_SoundFadeOutInitVolume
 
void EffectSound ()
 ctor
 
void ~EffectSound ()
 dtor
 
override void InitEffect ()
 init
 
override string GetDebugName ()
 Override when getting debug information.
 

Detailed Description

Wrapper class for managing sound through SEffectManager.

Definition at line 4 of file EffectSound.c.

Constructor & Destructor Documentation

◆ EffectSound()

void EffectSound::EffectSound ( )
inlineprotected

ctor

Definition at line 62 of file EffectSound.c.

63 {
64 m_SoundWaveKind = WaveKind.WAVEEFFECTEX;
67 m_SoundAutodestroy = false;
68 m_SoundWaveStopping = false;
69 m_SoundFadedOut = false;
70 m_SoundDoppler = -1;
71 }
WaveKind
Definition Sound.c:2
float m_SoundWaveVolume
Definition EffectSound.c:37
WaveKind m_SoundWaveKind
Definition EffectSound.c:30
bool m_SoundAutodestroy
Definition EffectSound.c:34
int m_SoundDoppler
Definition EffectSound.c:40
bool m_SoundFadedOut
Definition EffectSound.c:49
float m_SoundWaveVolumeMax
Definition EffectSound.c:38
bool m_SoundWaveStopping
Definition EffectSound.c:48

References m_SoundAutodestroy, m_SoundDoppler, m_SoundFadedOut, m_SoundWaveKind, m_SoundWaveStopping, m_SoundWaveVolume, and m_SoundWaveVolumeMax.

◆ ~EffectSound()

void EffectSound::~EffectSound ( )
inlineprotected

dtor

Definition at line 76 of file EffectSound.c.

77 {
78
79 }

Member Function Documentation

◆ CanDestroy()

override bool EffectSound::CanDestroy ( )
inlineprotected

Definition at line 598 of file EffectSound.c.

599 {
601 }
float m_SoundFadeOutDuration
Definition EffectSound.c:54

References m_SoundFadedOut, and m_SoundFadeOutDuration.

◆ Event_OnFrameUpdate()

override void EffectSound::Event_OnFrameUpdate ( float time_delta)
inlineprotected

Event called on frame when enabled by SetEnableEventFrame(true)

Note
Is always enabled on sound
Called from SEffectManager.Event_OnFrameUpdate in MissionGameplay.OnUpdate
Parameters
time_deltafloat Time passed since the previous frame

Definition at line 427 of file EffectSound.c.

428 {
429 if (IsSoundPlaying())
430 {
431 if (m_SoundDoppler != -1)
433 // FadeIn
435 {
436 if (m_SoundFadeInDuration > 0)
437 {
439
441 {
444 m_SoundWaveStarting = false;
445 }
446 }
447 else
448 {
450 m_SoundWaveStarting = false;
451 }
452 }
453
454 // FadeOut
456 {
458 {
460 {
463 }
465 }
466 else
468
469 if (GetSoundVolume() <= 0)
470 {
472 {
474 m_SoundWaveStopping = false;
475 m_SoundFadedOut = true;
476 }
477 }
478 }
479
480 // Counting timer here because loop play
482 }
483 }
proto void Stop()
proto void SetDoppler(bool setDoppler)
float GetSoundVolume()
Get the RELATIVE volume set by 'SetSoundVolume'.
float m_SoundFadeInDuration
Definition EffectSound.c:51
AbstractWave m_SoundWaveObject
Definition EffectSound.c:23
ref ScriptInvoker Event_OnSoundFadeOutStarted
Definition EffectSound.c:13
float m_SoundWaveTime
Definition EffectSound.c:39
float m_SoundFadeOutInitVolume
Definition EffectSound.c:55
ref ScriptInvoker Event_OnSoundFadeInStopped
Definition EffectSound.c:12
void SetSoundVolume(float volume)
Set the RELATIVE volume for the sound.
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
bool m_SoundWaveStarting
Definition EffectSound.c:47

References Event_OnSoundFadeInStopped, Event_OnSoundFadeOutStarted, GetSoundVolume(), IsSoundPlaying(), m_SoundDoppler, m_SoundFadedOut, m_SoundFadeInDuration, m_SoundFadeOutDuration, m_SoundFadeOutInitVolume, m_SoundWaveObject, m_SoundWaveStarting, m_SoundWaveStopping, m_SoundWaveTime, m_SoundWaveVolumeMax, AbstractWave::SetDoppler(), SetSoundVolume(), and AbstractWave::Stop().

◆ Event_OnRegistered()

override void EffectSound::Event_OnRegistered ( int id)
inlineprotected

Event called from SEffectManager when the Effect is registered.

Note
Should only ever be called by SEffectManager!
Parameters
idint ID registered in SEffectManager

Definition at line 490 of file EffectSound.c.

491 {
492 super.Event_OnRegistered(id);
493
495 }
ref ScriptInvoker Event_OnSoundWaveEnded
Definition EffectSound.c:11
Manager class for managing Effect (EffectParticle, EffectSound)
static void Event_OnSoundWaveEnded(EffectSound effect_sound)
Event called from EffectSound.Event_OnSoundWaveEnded.

References SEffectManager::Event_OnSoundWaveEnded(), and Event_OnSoundWaveEnded.

◆ Event_OnSoundFadeInStopped()

void EffectSound::Event_OnSoundFadeInStopped ( )
inlineprotected

Event called when sound fade in stops.

Note
Called from Event_OnFrameUpdate

Definition at line 538 of file EffectSound.c.

539 {
540 Event_OnSoundFadeInStopped.Invoke(this);
541 }

References Event_OnSoundFadeInStopped.

◆ Event_OnSoundFadeOutStarted()

void EffectSound::Event_OnSoundFadeOutStarted ( )
inlineprotected

Event called when sound fade out starts.

Note
Called from Event_OnFrameUpdate

Definition at line 547 of file EffectSound.c.

548 {
549 Event_OnSoundFadeOutStarted.Invoke(this);
550 }

References Event_OnSoundFadeOutStarted.

◆ Event_OnSoundWaveEnded()

void EffectSound::Event_OnSoundWaveEnded ( )
inlineprotected

Event called when sound stops playing.

Note
Inserted into events of m_SoundWaveObject

Definition at line 525 of file EffectSound.c.

526 {
527 m_SoundWaveIsPlaying = false;
528
529 Event_OnSoundWaveEnded.Invoke(this);
530
532 }
ref ScriptInvoker Event_OnEffectEnded
Event used when the actual effect stopped playing.
Definition Effect.c:25
bool m_SoundWaveIsPlaying
Definition EffectSound.c:35

References Event_OnEffectEnded, Event_OnSoundWaveEnded, and m_SoundWaveIsPlaying.

◆ Event_OnSoundWaveStarted()

void EffectSound::Event_OnSoundWaveStarted ( )
inlineprotected

Event called when sound starts playing.

Note
Inserted into events of m_SoundWaveObject

Definition at line 512 of file EffectSound.c.

513 {
515
516 Event_OnSoundWaveStarted.Invoke(this);
517
519 }
ref ScriptInvoker Event_OnEffectStarted
Event used when the actual effect started playing.
Definition Effect.c:24
ref ScriptInvoker Event_OnSoundWaveStarted
Definition EffectSound.c:10

References Event_OnEffectStarted, Event_OnSoundWaveStarted, and m_SoundWaveIsPlaying.

◆ Event_OnUnregistered()

override void EffectSound::Event_OnUnregistered ( )
inlineprotected

Event called from SEffectManager when the Effect is unregistered.

Note
Should only ever be called by SEffectManager!

Definition at line 501 of file EffectSound.c.

502 {
503 super.Event_OnUnregistered();
504
506 }

References SEffectManager::Event_OnSoundWaveEnded(), and Event_OnSoundWaveEnded.

◆ GetCurrentLocalPosition()

override vector EffectSound::GetCurrentLocalPosition ( )
inlineprotected

Get the current local position of the managed sound.

Returns
vector The current local position of the managed sound

Definition at line 700 of file EffectSound.c.

701 {
702 Object parent = GetParent();
703
704 if (m_SoundObject)
705 {
706 //TODO(kumarjac): Create and expose 'SoundObject.GetLocalPosition'
707 if (parent)
708 return parent.WorldToModel(m_SoundObject.GetPosition());
709 else
710 return m_SoundObject.GetPosition();
711 }
712 else
713 {
714 if (parent)
715 return GetLocalPosition();
716 else
717 return GetPosition();
718 }
719
720 return vector.Zero;
721 }
vector GetLocalPosition()
Get the local position of the Effect.
Definition Effect.c:470
class JsonUndergroundAreaTriggerData GetPosition
override Object GetParent()
Get parent for the EffectSound.
ref SoundObject m_SoundObject
Definition EffectSound.c:22
static const vector Zero
Definition EnConvert.c:110

References GetLocalPosition(), GetParent(), GetPosition, m_SoundObject, and vector::Zero.

Referenced by SoundPlayEx().

◆ GetCurrentParent()

override Object EffectSound::GetCurrentParent ( )
inlineprotected

Get parent for the EffectSound.

Note
There is no real parenting with sound, so the setters and getters for parents do the exact same
Returns
Object The parent for the EffectSound

Definition at line 640 of file EffectSound.c.

641 {
642 if (m_SoundObject)
643 return Object.Cast(m_SoundObject.GetParent());
644 else
645 return super.GetParent(); // Yes, intentionally this one
646 }

References m_SoundObject.

◆ GetCurrentPosition()

override vector EffectSound::GetCurrentPosition ( )
inlineprotected

Get the current world position of the managed sound.

Returns
vector The current world position of the managed sound

Definition at line 672 of file EffectSound.c.

673 {
674 if (m_SoundObject)
675 return m_SoundObject.GetPosition();
676
677 if (m_ParentObject)
678 return m_ParentObject.ModelToWorld(GetPosition());
679
680 return GetPosition();
681 }
Object m_ParentObject
Cached parent.
Definition Effect.c:39

References GetPosition, m_ParentObject, and m_SoundObject.

◆ GetDebugName()

override string EffectSound::GetDebugName ( )
inlineprotected

Override when getting debug information.

Definition at line 96 of file EffectSound.c.

97 {
98 string identifier;
99 if (m_SoundSetName != "")
101 else
102 identifier = "NO_SOUNDSET";
103
104 return string.Format("%1:%2", super.GetDebugName(), identifier);
105 }
string m_SoundSetName
Definition EffectSound.c:31

References m_SoundSetName.

◆ GetEffectType()

override EffectType EffectSound::GetEffectType ( )
inlineprotected

Get what type of effect the Effect is.

Returns
EffectType What type of effect the Effect is

Definition at line 117 of file EffectSound.c.

118 {
119 return EffectType.SOUND;
120 }
EffectType
Enum to determine what type of effect the Effect is.
Definition Effect.c:3

◆ GetParent()

override Object EffectSound::GetParent ( )
inlineprotected

Get parent for the EffectSound.

Returns
Object The parent for the EffectSound

Definition at line 627 of file EffectSound.c.

628 {
629 if (m_SoundObject)
630 return Object.Cast(m_SoundObject.GetParent());
631 else
632 return super.GetParent();
633 }

References m_SoundObject.

Referenced by GetCurrentLocalPosition(), and SetCurrentPosition().

◆ GetSoundSet()

string EffectSound::GetSoundSet ( )
inlineprotected

Get soundset for the sound.

Returns
string Name of the soundset

Definition at line 747 of file EffectSound.c.

748 {
749 return m_SoundSetName;
750 }

References m_SoundSetName.

◆ GetSoundVolume()

float EffectSound::GetSoundVolume ( )
inlineprotected

Get the RELATIVE volume set by 'SetSoundVolume'.

Returns
float The relative volume for the sound set by 'SetSoundVolume'

Definition at line 807 of file EffectSound.c.

808 {
809 return m_SoundWaveVolume;
810 }

References m_SoundWaveVolume.

Referenced by Event_OnFrameUpdate().

◆ GetSoundWaveLenght()

float EffectSound::GetSoundWaveLenght ( )
inlineprotected

Get the sound wave length.

Note
Legacy, exists for backwards compatibility
Returns
float The sound wave length

Definition at line 778 of file EffectSound.c.

779 {
780 return GetSoundWaveLength();
781 }
float GetSoundWaveLength()
Get the sound wave length.

References GetSoundWaveLength().

◆ GetSoundWaveLength()

float EffectSound::GetSoundWaveLength ( )
inlineprotected

Get the sound wave length.

Returns
float The sound wave length

Definition at line 787 of file EffectSound.c.

788 {
789 return m_SoundWaveLenght;
790 }
float m_SoundWaveLenght
Definition EffectSound.c:36

References m_SoundWaveLenght.

Referenced by GetSoundWaveLenght(), and SoundWaveValidation().

◆ GetSoundWaveTime()

float EffectSound::GetSoundWaveTime ( )
inlineprotected

Get the time since EffectSound started playing.

Warning
May not reflect the actual time of the sound, as it can start at negative time to simulate speed of sound
Returns
float The time since EffectSound started playing

Definition at line 830 of file EffectSound.c.

831 {
832 return m_SoundWaveTime;
833 }

References m_SoundWaveTime.

◆ InitEffect()

override void EffectSound::InitEffect ( )
inlineprotected

init

Definition at line 84 of file EffectSound.c.

85 {
86 super.InitEffect();
87
88 // These will be called by the sound events
91 }
ref ScriptInvoker Event_OnStopped
Event used when Stop was called.
Definition Effect.c:23
Event_OnStarted
Event used when Start was called.
Definition Effect.c:287

References Event_OnEffectEnded, Event_OnEffectStarted, Event_OnStarted, and Event_OnStopped.

◆ IsAutodestroy()

override bool EffectSound::IsAutodestroy ( )
inlineprotected

Get whether Effect automatically cleans up when it stops.

Returns
bool Whether Effect automatically cleans up when it stops

Definition at line 575 of file EffectSound.c.

576 {
577 return IsSoundAutodestroy();
578 }
bool IsSoundAutodestroy()
Get whether EffectSound automatically cleans up when sound stops.

References IsSoundAutodestroy().

◆ IsPlaying()

override bool EffectSound::IsPlaying ( )
inlineprotected

Returns true when the effect is playing, false otherwise.

Definition at line 269 of file EffectSound.c.

270 {
271 return IsSoundPlaying(); // Just in case, as that's what used to be the actual way to check
272 }

References IsSoundPlaying().

Referenced by FlashbangEffect::PlaySound().

◆ IsSound()

override bool EffectSound::IsSound ( )
inlineprotected

Check whether the Effect is EffectSound without casting.

Returns
bool Whether the Effect is EffectSound

Definition at line 126 of file EffectSound.c.

127 {
128 return true;
129 }

◆ IsSoundAutodestroy()

bool EffectSound::IsSoundAutodestroy ( )
inlineprotected

Get whether EffectSound automatically cleans up when sound stops.

Returns
bool Whether EffectSound automatically cleans up when sound stops

Definition at line 593 of file EffectSound.c.

594 {
595 return m_SoundAutodestroy;
596 }

References m_SoundAutodestroy.

Referenced by IsAutodestroy().

◆ IsSoundPlaying()

bool EffectSound::IsSoundPlaying ( )
inlineprotected

Get whether EffectSound is currently playing.

Returns
bool Whether EffectSound is currently playing

Definition at line 261 of file EffectSound.c.

262 {
264 }

References m_SoundWaveIsPlaying.

Referenced by Event_OnFrameUpdate(), IsPlaying(), InventoryItem::OnRPC(), ActionBuildShelter::PlayActionLoopSound(), PlayEmptyingLoopSound(), PlayPouringLoopSound(), and SoundStop().

◆ IsSoundValid()

bool EffectSound::IsSoundValid ( )
inlineprotected

Helper for checking if params are valid.

Definition at line 336 of file EffectSound.c.

337 {
338 return m_SoundParams.IsValid();
339 }
ref SoundParams m_SoundParams
Definition EffectSound.c:20

References m_SoundParams.

◆ SetAutodestroy()

override void EffectSound::SetAutodestroy ( bool auto_destroy)
inlineprotected

Sets whether Effect automatically cleans up when it stops.

Note
This means that it will be unregistered from SEffectManager as well
Parameters
auto_destroybool Whether Effect automatically cleans up when it stops

Definition at line 565 of file EffectSound.c.

566 {
567 super.SetAutodestroy(auto_destroy);
569 }

References m_SoundAutodestroy.

Referenced by InventoryItem::PlayDeployFinishSound(), InventoryItem::PlayDeployLoopSoundEx(), InventoryItem::PlayDeploySound(), InventoryItem::PlayPlaceSound(), FlashbangEffect::PlaySound(), PlaySound(), and SetSoundAutodestroy().

◆ SetCurrentLocalPosition()

override void EffectSound::SetCurrentLocalPosition ( vector pos,
bool updateCached = true )
inlineprotected

Set the current local position of the managed sound.

Parameters
posvector The current local position for the managed sound
updateCachedbool Whether to update the cached variable

Definition at line 688 of file EffectSound.c.

689 {
690 super.SetCurrentLocalPosition(pos, updateCached);
691
692 if (m_SoundObject)
693 m_SoundObject.SetPosition(pos);
694 }

References m_SoundObject.

Referenced by SoundPlayEx().

◆ SetCurrentPosition()

override void EffectSound::SetCurrentPosition ( vector pos,
bool updateCached = true )
inlineprotected

Set the world position of the managed sound.

Parameters
posvector The world position of the managed sound
updateCachedbool Whether to update the cached variable

Definition at line 653 of file EffectSound.c.

654 {
655 super.SetCurrentPosition(pos, updateCached);
656
657 if (m_SoundObject)
658 {
659 Object parent = GetParent();
660
661 if (parent)
662 pos = parent.WorldToModel(pos);
663
664 m_SoundObject.SetPosition(pos);
665 }
666 }

References GetParent(), and m_SoundObject.

◆ SetDoppler()

void EffectSound::SetDoppler ( bool setDoppler)
inlineprotected

Set if the sound has the doppler effect enabled.

Parameters
setDopplerfloat If the doppler effect is enabled

bool is a fancy int, ensure the bool is 0 or 1 and don't allow -1 here since resetting isn't supported

Definition at line 857 of file EffectSound.c.

858 {
860 m_SoundDoppler = 0;
861 if (setDoppler)
862 m_SoundDoppler = 1;
863 }

References m_SoundDoppler.

◆ SetEnviromentVariables()

void EffectSound::SetEnviromentVariables ( bool setEnvVariables)
inlineprotected

Sets whether AddEnvSoundVariables needs to be called during Loading.

Parameters
setEnvVariablesbool Whether AddEnvSoundVariables is called

Definition at line 768 of file EffectSound.c.

769 {
771 }
bool m_SetEnvVariables
Definition EffectSound.c:33

References m_SetEnvVariables.

◆ SetParent()

override void EffectSound::SetParent ( Object parent_obj)
inlineprotected

Set parent for the sound to follow.

Parameters
parent_objObject The parent for the sound to follow

Definition at line 615 of file EffectSound.c.

616 {
617 super.SetParent(parent_obj); // ...
618
619 if (m_SoundObject)
620 m_SoundObject.SetParent(parent_obj);
621 }

References m_SoundObject.

Referenced by FlashbangEffect::PlaySound().

◆ SetSoundAutodestroy()

void EffectSound::SetSoundAutodestroy ( bool auto_destroy)
inlineprotected

Sets whether EffectSound automatically cleans up when sound stops.

Parameters
auto_destroybool Whether EffectSound automatically cleans up when sound stops

Definition at line 584 of file EffectSound.c.

585 {
587 }
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.

References SetAutodestroy().

◆ SetSoundFadeIn()

void EffectSound::SetSoundFadeIn ( float fade_in)
inlineprotected

Set the sound fade in duration.

Parameters
fade_infloat The fade in duration

Definition at line 839 of file EffectSound.c.

840 {
842 }

References m_SoundFadeInDuration.

Referenced by FlashbangEffect::PlaySound().

◆ SetSoundFadeOut()

void EffectSound::SetSoundFadeOut ( float fade_out)
inlineprotected

Set the sound fade out duration.

Parameters
fade_outfloat The fade out duration

Definition at line 848 of file EffectSound.c.

849 {
851 }

References m_SoundFadeOutDuration.

Referenced by FlashbangEffect::PlaySound(), ActionBuildShelter::StopActionLoopSound(), and InventoryItem::StopDeployLoopSoundEx().

◆ SetSoundLoop()

void EffectSound::SetSoundLoop ( bool loop)
inlineprotected

Set if the sound loops.

Parameters
loopbool Whether the sound should loop

Definition at line 756 of file EffectSound.c.

757 {
759
762 }
proto void Loop(bool setLoop)
bool m_SoundLoop
Definition EffectSound.c:32

References AbstractWave::Loop(), m_SoundLoop, and m_SoundWaveObject.

Referenced by FlashbangEffect::PlaySound(), and ValidateSoundWave().

◆ SetSoundMaxVolume()

void EffectSound::SetSoundMaxVolume ( float volume)
inlineprotected

Set the sound max volume.

Warning
Seems to purely be used for fade in effect, rather than really setting the max volume...
Adjusts the current volume to this value as well
Parameters
volumefloat The maximum volume for the sound

Definition at line 818 of file EffectSound.c.

References m_SoundWaveObject, m_SoundWaveVolume, m_SoundWaveVolumeMax, and AbstractWave::SetVolumeRelative().

Referenced by FlashbangEffect::PlaySound().

◆ SetSoundSet()

void EffectSound::SetSoundSet ( string snd)
inlineprotected

Set soundset for the sound.

Note
Needs to be set before playing
Parameters
sndstring Name of the soundset to play

Definition at line 738 of file EffectSound.c.

739 {
741 }

References m_SoundSetName.

◆ SetSoundVolume()

void EffectSound::SetSoundVolume ( float volume)
inlineprotected

Set the RELATIVE volume for the sound.

Parameters
volumefloat The relative volume for the sound

Definition at line 796 of file EffectSound.c.

References m_SoundWaveObject, m_SoundWaveVolume, and AbstractWave::SetVolumeRelative().

Referenced by Event_OnFrameUpdate(), and ProcessSound().

◆ SetSoundWaveKind()

void EffectSound::SetSoundWaveKind ( WaveKind wave_kind)
inlineprotected

Set WaveKind for the sound.

Note
Needs to be set before playing
Parameters
wave_kindWaveKind The WaveKind for the sound

Definition at line 728 of file EffectSound.c.

729 {
731 }

References m_SoundWaveKind.

Referenced by FlashbangEffect::PlaySound().

◆ SoundError()

void EffectSound::SoundError ( string err_msg)
inlineprotected

Helper for throwing sound errors.

Definition at line 871 of file EffectSound.c.

872 {
873 ErrorEx(string.Format("%1: SoundSetName: '%2' :: %3", this, m_SoundSetName, err_msg));
874 }
enum ShapeType ErrorEx

References ErrorEx, and m_SoundSetName.

Referenced by SoundLoadEx(), SoundPlayEx(), and SoundWaveValidation().

◆ SoundLoad()

bool EffectSound::SoundLoad ( )
inlineprotected

Loads in the sound when it is requested for playing.

Note
Legacy, backwards compatibility

Definition at line 327 of file EffectSound.c.

328 {
330 return SoundLoadEx(params);
331 }
bool SoundLoadEx(out SoundParams params)
Loads in the sound when it is requested for playing through 'SoundPlayEx'.

References SoundLoadEx().

◆ SoundLoadEx()

bool EffectSound::SoundLoadEx ( out SoundParams params)
inlineprotected

Loads in the sound when it is requested for playing through 'SoundPlayEx'.

Parameters
paramsSoundParams Possibility of passing in an already existing SoundParams, else one will get created

Definition at line 286 of file EffectSound.c.

287 {
288 if (!m_SoundParams || !m_SoundParams.IsValid())
289 {
290 if (!params)
292
293 //Print("SoundLoad is loading..");
295 if (!m_SoundParams.IsValid())
296 {
297 SoundError("Invalid sound set.");
298 return false;
299 }
300
303 m_SoundObjectBuilder.AddEnvSoundVariables(GetPosition());
304
305 m_SoundObject = m_SoundObjectBuilder.BuildSoundObject();
306
307 if (m_SoundObject)
308 {
310 m_SoundObject.SetParent(m_ParentObject);
311 }
312 else
313 SoundError("m_SoundObject is null.");
314 }
315 else
316 {
317 //Print("SoundLoad is loaded.");
318 }
319
320 return true;
321 }
void SoundObjectBuilder(SoundParams soundParams)
void SoundError(string err_msg)
Helper for throwing sound errors.
ref SoundObjectBuilder m_SoundObjectBuilder
Definition EffectSound.c:21

References GetPosition, m_ParentObject, m_SetEnvVariables, m_SoundObject, m_SoundObjectBuilder, m_SoundParams, m_SoundSetName, m_SoundWaveKind, SoundError(), and SoundObjectBuilder().

Referenced by SoundLoad(), and SoundPlayEx().

◆ SoundPlay()

bool EffectSound::SoundPlay ( )
inlineprotected

Plays sound.

Returns
bool Whether the sound will start playing

Definition at line 190 of file EffectSound.c.

191 {
193 return SoundPlayEx(params);
194 }
bool SoundPlayEx(out SoundParams params)
Plays sound.

References SoundPlayEx().

Referenced by PlayIntense(), PlayLight(), FlashbangEffect::PlaySound(), and Start().

◆ SoundPlayEx()

bool EffectSound::SoundPlayEx ( out SoundParams params)
inlineprotected

Plays sound.

Parameters
paramsSoundParams Sound Parameters for the sound
Returns
bool Whether the sound will start playing

Definition at line 145 of file EffectSound.c.

146 {
147 super.Start();
148
149 if (m_SoundSetName != "")
150 {
152
153 if (SoundLoadEx(params))
154 {
156 {
157 m_SoundObjectBuilder.AddEnvSoundVariables(GetPosition());
158 m_SoundObject = m_SoundObjectBuilder.BuildSoundObject();
160 m_SoundObject.SetParent(m_ParentObject);
161 }
162
163 if (m_SoundObject)
164 {
166 m_SoundWaveObject = GetGame().GetSoundScene().Play3D(m_SoundObject, m_SoundObjectBuilder);
168 return false;
169
170 // Wait for header to be loaded before asking for its length, else we block the main thread
173 else
174 m_SoundWaveObject.GetEvents().Event_OnSoundWaveHeaderLoaded.Insert(ValidateSoundWave);
175
176 return true;
177 }
178 else
179 SoundError("m_SoundObject is null.");
180 }
181 }
182
183 return false;
184 }
proto bool IsHeaderLoaded()
AbstractWaveEvents GetEvents()
Definition Sound.c:164
override void SetCurrentLocalPosition(vector pos, bool updateCached=true)
Set the current local position of the managed sound.
override vector GetCurrentLocalPosition()
Get the current local position of the managed sound.
void ValidateSoundWave()
Gets called to fill in the necessary data when the header has finished loading.
proto native CGame GetGame()

References GetCurrentLocalPosition(), AbstractWave::GetEvents(), GetGame(), GetPosition, AbstractWave::IsHeaderLoaded(), m_ParentObject, m_SetEnvVariables, m_SoundObject, m_SoundObjectBuilder, m_SoundParams, m_SoundSetName, m_SoundWaveKind, m_SoundWaveObject, SetCurrentLocalPosition(), SoundError(), SoundLoadEx(), and ValidateSoundWave().

Referenced by SoundPlay().

◆ SoundReset()

◆ SoundStop()

◆ SoundWaveValidation()

bool EffectSound::SoundWaveValidation ( )
inlineprotected

Validation of fade settings.

Note
Called from 'ValidateSoundWave'

Definition at line 375 of file EffectSound.c.

376 {
377 bool valid = true;
378
380 {
381 SoundError("FadeIn is longer than sound wave length.");
382 valid = false;
383 }
384
386 {
387 SoundError("FadeOut is longer than sound wave length.");
388 valid = false;
389 }
390
392 {
393 SoundError("FadeIn & FadeOut are longer than sound wave length.");
394 valid = false;
395 }
396
397 return valid;
398 }

References GetSoundWaveLength(), m_SoundFadeInDuration, m_SoundFadeOutDuration, and SoundError().

Referenced by ValidateSoundWave().

◆ Start()

override void EffectSound::Start ( )
inlineprotected

Plays sound.

Definition at line 199 of file EffectSound.c.

200 {
201 SoundPlay();
202 }
bool SoundPlay()
Plays sound.

References SoundPlay().

◆ Stop()

◆ UpdateEvents()

void EffectSound::UpdateEvents ( )
inlineprotected

Enables the frame event on the EffectSound.

Note
Called from 'ValidateSoundWave' when all is successful
So this is effectively enabling frame event on all valid EffectSound

Definition at line 405 of file EffectSound.c.

406 {
409 else
410 SetEnableEventFrame(false);
411 }
void SetEnableEventFrame(bool enable)
Enable Event_OnFrameUpdate for the effect.
Definition Effect.c:270

References m_SoundWaveObject, and SetEnableEventFrame().

Referenced by ValidateSoundWave().

◆ ValidateSoundWave()

void EffectSound::ValidateSoundWave ( )
inlineprotected

Gets called to fill in the necessary data when the header has finished loading.

Note
Called from 'SoundPlayEx'

Definition at line 345 of file EffectSound.c.

346 {
348
350 {
351 if (m_SoundFadeInDuration > 0)
352 {
355 }
356
358
359 m_SoundWaveStarting = true;
360
362 events.Event_OnSoundWaveStarted.Insert(Event_OnSoundWaveStarted);
363 events.Event_OnSoundWaveEnded.Insert(Event_OnSoundWaveEnded);
364
365 UpdateEvents();
366 }
367 else
369 }
proto float GetLength()
WARNING: Blocking! Waits for header to load.
void UpdateEvents()
Enables the frame event on the EffectSound.
void SetSoundLoop(bool loop)
Set if the sound loops.
bool SoundWaveValidation()
Validation of fade settings.

References Event_OnSoundWaveEnded, Event_OnSoundWaveStarted, AbstractWave::GetEvents(), AbstractWave::GetLength(), m_SoundFadeInDuration, m_SoundFadeOutStartTime, m_SoundLoop, m_SoundWaveLenght, m_SoundWaveObject, m_SoundWaveStarting, SetSoundLoop(), AbstractWave::SetVolumeRelative(), SoundWaveValidation(), AbstractWave::Stop(), and UpdateEvents().

Referenced by SoundPlayEx().

Member Data Documentation

◆ Event_OnSoundFadeInStopped

ref ScriptInvoker EffectSound::Event_OnSoundFadeInStopped = new ScriptInvoker()
private

Definition at line 12 of file EffectSound.c.

Referenced by Event_OnFrameUpdate(), and Event_OnSoundFadeInStopped().

◆ Event_OnSoundFadeOutStarted

ref ScriptInvoker EffectSound::Event_OnSoundFadeOutStarted = new ScriptInvoker()
private

Definition at line 13 of file EffectSound.c.

Referenced by Event_OnFrameUpdate(), and Event_OnSoundFadeOutStarted().

◆ Event_OnSoundWaveEnded

ref ScriptInvoker EffectSound::Event_OnSoundWaveEnded = new ScriptInvoker()
private

◆ Event_OnSoundWaveStarted

ref ScriptInvoker EffectSound::Event_OnSoundWaveStarted = new ScriptInvoker()
private

Definition at line 10 of file EffectSound.c.

Referenced by Event_OnSoundWaveStarted(), and ValidateSoundWave().

◆ m_SetEnvVariables

bool EffectSound::m_SetEnvVariables
protected

Definition at line 33 of file EffectSound.c.

Referenced by SetEnviromentVariables(), SoundLoadEx(), and SoundPlayEx().

◆ m_SoundAutodestroy

bool EffectSound::m_SoundAutodestroy
protected

Definition at line 34 of file EffectSound.c.

Referenced by EffectSound(), IsSoundAutodestroy(), and SetAutodestroy().

◆ m_SoundDoppler

int EffectSound::m_SoundDoppler
protected

Definition at line 40 of file EffectSound.c.

Referenced by EffectSound(), Event_OnFrameUpdate(), and SetDoppler().

◆ m_SoundFadedOut

bool EffectSound::m_SoundFadedOut
protected

Definition at line 49 of file EffectSound.c.

Referenced by CanDestroy(), EffectSound(), Event_OnFrameUpdate(), SoundReset(), and SoundStop().

◆ m_SoundFadeInDuration

float EffectSound::m_SoundFadeInDuration
protected

◆ m_SoundFadeOutDuration

float EffectSound::m_SoundFadeOutDuration
protected

◆ m_SoundFadeOutInitVolume

float EffectSound::m_SoundFadeOutInitVolume
protected

Definition at line 55 of file EffectSound.c.

Referenced by Event_OnFrameUpdate(), and SoundReset().

◆ m_SoundFadeOutStartTime

float EffectSound::m_SoundFadeOutStartTime
protected

Definition at line 53 of file EffectSound.c.

Referenced by SoundReset(), SoundStop(), and ValidateSoundWave().

◆ m_SoundLoop

bool EffectSound::m_SoundLoop
protected

Definition at line 32 of file EffectSound.c.

Referenced by SetSoundLoop(), and ValidateSoundWave().

◆ m_SoundObject

◆ m_SoundObjectBuilder

ref SoundObjectBuilder EffectSound::m_SoundObjectBuilder
protected

Definition at line 21 of file EffectSound.c.

Referenced by SoundLoadEx(), and SoundPlayEx().

◆ m_SoundParams

ref SoundParams EffectSound::m_SoundParams
protected

Definition at line 20 of file EffectSound.c.

Referenced by IsSoundValid(), SoundLoadEx(), and SoundPlayEx().

◆ m_SoundSetName

string EffectSound::m_SoundSetName
protected

◆ m_SoundWaveIsPlaying

bool EffectSound::m_SoundWaveIsPlaying
protected

◆ m_SoundWaveKind

WaveKind EffectSound::m_SoundWaveKind
protected

Definition at line 30 of file EffectSound.c.

Referenced by EffectSound(), SetSoundWaveKind(), SoundLoadEx(), and SoundPlayEx().

◆ m_SoundWaveLenght

float EffectSound::m_SoundWaveLenght
protected

Definition at line 36 of file EffectSound.c.

Referenced by GetSoundWaveLength(), and ValidateSoundWave().

◆ m_SoundWaveObject

◆ m_SoundWaveStarting

bool EffectSound::m_SoundWaveStarting
protected

Definition at line 47 of file EffectSound.c.

Referenced by Event_OnFrameUpdate(), SoundStop(), and ValidateSoundWave().

◆ m_SoundWaveStopping

bool EffectSound::m_SoundWaveStopping
protected

Definition at line 48 of file EffectSound.c.

Referenced by EffectSound(), Event_OnFrameUpdate(), SoundReset(), and SoundStop().

◆ m_SoundWaveTime

float EffectSound::m_SoundWaveTime
protected

Definition at line 39 of file EffectSound.c.

Referenced by Event_OnFrameUpdate(), GetSoundWaveTime(), SoundReset(), and SoundStop().

◆ m_SoundWaveVolume

float EffectSound::m_SoundWaveVolume
protected

◆ m_SoundWaveVolumeMax

float EffectSound::m_SoundWaveVolumeMax
protected

Definition at line 38 of file EffectSound.c.

Referenced by EffectSound(), Event_OnFrameUpdate(), SetSoundMaxVolume(), and SoundReset().


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