Komodo Engine
C PROJECT_LOGO=
Komodo.Core.ECS.Components.SoundComponent Class Reference

Represents a single Microsoft.Xna.Framework.Audio.SoundEffect and all of the associated Microsoft.Xna.Framework.Audio.SoundEffect More...

Inheritance diagram for Komodo.Core.ECS.Components.SoundComponent:
Komodo.Core.ECS.Components.Component

Public Member Functions

 SoundComponent (string soundPath)
 Creates a SoundComponent with a filepath to a compiled Microsoft.Xna.Framework.Audio.SoundEffect content file. More...
 
void ChangeVolume (Guid id, float volume)
 Changes the intensity of a valid sound instance found in _instances. More...
 
void Clear ()
 Clears all sound instances, stopping all of them immediately. More...
 
bool IsValidInstance (Guid id)
 Checks whether or not a sound instance exists and is not disposed. More...
 
void Pause (Guid id)
 Pauses the given sound if the instance is present on the SoundComponent. More...
 
void PauseAll ()
 Pauses all sound instances found in _instances. More...
 
Guid Play (bool loop=false, bool shouldLayerSound=true)
 Creates a sound instance from Sound. More...
 
void Resume (Guid id)
 Resumes a paused sound instance. More...
 
void Stop (Guid id)
 Stops a sound instance. Stopping a sound will remove the instance from _instances. More...
 
void StopAll ()
 Stops all sound instances found in _instances. More...
 

Properties

SoundEffect Sound [get, set]
 Raw sound data loaded from disk. More...
 
string SoundPath [get]
 Path of the Microsoft.Xna.Framework.Audio.SoundEffect if the SoundComponent was provided a model filepath via SoundComponent.SoundComponent(string). More...
 
- Properties inherited from Komodo.Core.ECS.Components.Component
GameGame [get]
 Each Component maintains a reference to the Komodo.Core.Game instance. More...
 
Guid ID [get]
 Unique identifier for the Component. More...
 
bool IsEnabled [get, set]
 Enabled Components are managed by their corresponding Komodo.Core.ECS.Systems.ISystem, otherwise the Component is ignored. More...
 
bool IsInitialized [get, set]
 Uninitialized Components are initialized by their corresponding Komodo.Core.ECS.Systems.ISystem, otherwise the Component is initialized on the next Komodo.Core.ECS.Systems.ISystem.Initialize, Komodo.Core.ECS.Systems.ISystem.PreUpdate, or Komodo.Core.ECS.Systems.ISystem.PostUpdate methods. More...
 
Entity Parent [get, set]
 Each Component belongs to a Komodo.Core.ECS.Entities.Entity and maintains a reference to the parent Komodo.Core.ECS.Entities.Entity. More...
 
Vector3 Position [get, set]
 Each Component has a position relative to their Parent. More...
 
Vector3?? WorldPosition [get]
 The sum of Position and the Parent's Komodo.Core.ECS.Entities.Entity.Position, representing the Component's position in world space. More...
 
Vector3?? Rotation [get, set]
 Derived from the Parent's Komodo.Core.ECS.Entities.Entity.Rotation. More...
 
Matrix?? RotationMatrix [get]
 Derived from the Parent's Komodo.Core.ECS.Entities.Entity.RotationMatrix. More...
 
Quaternion?? RotationQuaternion [get]
 Derived from the Parent's Komodo.Core.ECS.Entities.Entity.RotationQuaternion. More...
 
Vector3?? Scale [get, set]
 Derived from the Parent's Komodo.Core.ECS.Entities.Entity.Scale. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Komodo.Core.ECS.Components.Component
 Component (bool isEnabled=true, Entity parent=null)
 

Detailed Description

Represents a single Microsoft.Xna.Framework.Audio.SoundEffect and all of the associated Microsoft.Xna.Framework.Audio.SoundEffect

Constructor & Destructor Documentation

◆ SoundComponent()

Komodo.Core.ECS.Components.SoundComponent.SoundComponent ( string  soundPath)

Creates a SoundComponent with a filepath to a compiled Microsoft.Xna.Framework.Audio.SoundEffect content file.

The Microsoft.Xna.Framework.Audio.SoundEffect will be loaded from disk once the relevant Komodo.Core.ECS.Systems.SoundSystem.Initialize, Komodo.Core.ECS.Systems.SoundSystem.PreUpdate, or Komodo.Core.ECS.Systems.SoundSystem.PostUpdate is called.

Parameters
soundPathFile path to a compiled Microsoft.Xna.Framework.Audio.SoundEffect content file.

Member Function Documentation

◆ ChangeVolume()

void Komodo.Core.ECS.Components.SoundComponent.ChangeVolume ( Guid  id,
float  volume 
)

Changes the intensity of a valid sound instance found in _instances.

Parameters
idIdentifier for the instance that will have its volume intensity modified.
volumeValue, clamped between 0 and 1, representing the volume intensity.

◆ Clear()

void Komodo.Core.ECS.Components.SoundComponent.Clear ( )

Clears all sound instances, stopping all of them immediately.

◆ IsValidInstance()

bool Komodo.Core.ECS.Components.SoundComponent.IsValidInstance ( Guid  id)

Checks whether or not a sound instance exists and is not disposed.

Parameters
idIdentifier of the instance to check.
Returns
Whether or not the id represents a valid sound instance.

◆ Pause()

void Komodo.Core.ECS.Components.SoundComponent.Pause ( Guid  id)

Pauses the given sound if the instance is present on the SoundComponent.

Parameters
idIdentifier for the specific instance to pause.

◆ PauseAll()

void Komodo.Core.ECS.Components.SoundComponent.PauseAll ( )

Pauses all sound instances found in _instances.

◆ Play()

Guid Komodo.Core.ECS.Components.SoundComponent.Play ( bool  loop = false,
bool  shouldLayerSound = true 
)

Creates a sound instance from Sound.

Parameters
loopThe sound instance will continue to repeat until paused or stopped.
shouldLayerSound
Returns
A sound instance ID for pausing, resuming, and stopping.

◆ Resume()

void Komodo.Core.ECS.Components.SoundComponent.Resume ( Guid  id)

Resumes a paused sound instance.

Parameters
idSound instance to resume playing.

◆ Stop()

void Komodo.Core.ECS.Components.SoundComponent.Stop ( Guid  id)

Stops a sound instance. Stopping a sound will remove the instance from _instances.

Parameters
idIdentifier for sound to stop.

◆ StopAll()

void Komodo.Core.ECS.Components.SoundComponent.StopAll ( )

Stops all sound instances found in _instances.

Property Documentation

◆ Sound

SoundEffect Komodo.Core.ECS.Components.SoundComponent.Sound
getset

Raw sound data loaded from disk.

◆ SoundPath

string Komodo.Core.ECS.Components.SoundComponent.SoundPath
get

Path of the Microsoft.Xna.Framework.Audio.SoundEffect if the SoundComponent was provided a model filepath via SoundComponent.SoundComponent(string).