tModLoader  0.12 Alpha
A mod to make and play Terraria mods
Terraria.ModLoader.ModSound Class Reference

This class allows you to customize how a sound you add is played. To use this, pass an instance to Mod.AddSound, or if you are autoloading sounds, give an overriding class the same name as the file with the sound you are adding. More...

Inherits Terraria.ModLoader.ModType.

Public Member Functions

virtual SoundEffectInstance PlaySound (ref SoundEffectInstance soundInstance, float volume, float pan)
 Override this hook to customize how this sound is played. If this sound is already currently playing, you have the option to call soundInstance.Stop(). You must eventually assign the result of sound.CreateInstance() to soundInstace. Afterwards, you can modify soundInstance.Volume, soundInstance.Pan, and soundInstance.Pitch to your liking. The default volume and pan have been passed as parameters. Volume measures loudness, pan measures how far to the left or right the sound is, and pitch measures the octave. Finally, call Main.PlaySoundInstance(soundInstance). More...
 
- Public Member Functions inherited from Terraria.ModLoader.ModType
virtual bool IsLoadingEnabled (Mod mod)
 Allows you to stop Mod.AddContent from actually adding this content. Useful for items that can be disabled by a config. More...
 
virtual void Load ()
 Allows you to perform one-time loading tasks. Beware that mod content has not finished loading here, things like ModContent lookup tables or ID Sets are not fully populated. More...
 
virtual void SetStaticDefaults ()
 Allows you to modify the properties after initial loading has completed. More...
 
virtual void SetupContent ()
 If you make a new ModType, seal this override, and call SetStaticDefaults in it. More...
 
virtual void Unload ()
 Allows you to safely unload things you added in Load. More...
 

Protected Member Functions

sealed override void Register ()
 If you make a new ModType, seal this override. More...
 

Properties

Asset< SoundEffect > Sound [get, set]
 The SoundEffect instance of the sound that this ModSound controls. This is here so you can call CreateInstance on it. More...
 
- Properties inherited from Terraria.ModLoader.ModType
string FullName [get]
 The internal name of this, including the mod it is from. More...
 
Mod Mod [get, set]
 The mod this belongs to. More...
 
virtual string Name [get]
 The internal name of this. More...
 
- Properties inherited from Terraria.ModLoader.IModType
string FullName [get]
 => $"{Mod.Name}/{Name}" More...
 
Mod Mod [get]
 The mod this belongs to. More...
 
string Name [get]
 The internal name of this instance. More...
 

Detailed Description

This class allows you to customize how a sound you add is played. To use this, pass an instance to Mod.AddSound, or if you are autoloading sounds, give an overriding class the same name as the file with the sound you are adding.

Member Function Documentation

◆ PlaySound()

virtual SoundEffectInstance Terraria.ModLoader.ModSound.PlaySound ( ref SoundEffectInstance  soundInstance,
float  volume,
float  pan 
)
virtual

Override this hook to customize how this sound is played. If this sound is already currently playing, you have the option to call soundInstance.Stop(). You must eventually assign the result of sound.CreateInstance() to soundInstace. Afterwards, you can modify soundInstance.Volume, soundInstance.Pan, and soundInstance.Pitch to your liking. The default volume and pan have been passed as parameters. Volume measures loudness, pan measures how far to the left or right the sound is, and pitch measures the octave. Finally, call Main.PlaySoundInstance(soundInstance).

◆ Register()

sealed override void Terraria.ModLoader.ModSound.Register ( )
protectedvirtual

If you make a new ModType, seal this override.

Implements Terraria.ModLoader.ModType.

Property Documentation

◆ Sound

Asset<SoundEffect> Terraria.ModLoader.ModSound.Sound
getset

The SoundEffect instance of the sound that this ModSound controls. This is here so you can call CreateInstance on it.