Struct SoundAttributes
- Namespace
- Vintagestory.API.Common
- Assembly
- VintagestoryAPI.dll
Properties that control how a sound is played. There are two forms of this that might be used in JSON files: Form 1 is simply stored as an AssetLocation that points to the sound file path. There are no extra proprties. This is what most JSON objects use. Form 2 is more complex, and uses the properties below to fully configure the sound. Only certain JSON objects use this, such as entity sounds. You can mix and match in a single sound array.
[DocumentAsJson]
public struct SoundAttributes
- Inherited Members
- Extension Methods
Examples
Form 1:
"sounds": {
"place": "block/plant",
"break": "block/plant",
"hit": "block/plant"
},
Form 2. Note that entity sounds can include * at the end for multiple sound files: "sounds": {
"hurt": "creature/chicken/chick*",
"death": "creature/chicken/chick*",
"idle": {
"path": "creature/chicken/chick*",
"range": 14,
"pitch": {
"avg": 1,
"var": 0.25
}
}
},
Constructors
SoundAttributes()
public SoundAttributes()
SoundAttributes(AssetLocation, bool)
public SoundAttributes(AssetLocation assetLocation, bool withRandomPitch)
Parameters
assetLocationAssetLocationwithRandomPitchbool
Fields
Location
The location of the sound file.
[DocumentAsJson("Required", "", false)]
[JsonProperty("path")]
public AssetLocation? Location
Field Value
NatFloatOne
public static NatFloat NatFloatOne
Field Value
Pitch
Controls a random pitch for when the sound is played.
[DocumentAsJson("Optional", "1", false)]
public NatFloat Pitch
Field Value
RandomPitch
public static NatFloat RandomPitch
Field Value
Range
The range at which the gain will be attenuated to 1% of the supplied volume. (i.e. the maximum range that the player will hear the sound)
[DocumentAsJson("Optional", "32", false)]
public float Range
Field Value
Type
The type of sound, used for volume control in the settings.
[DocumentAsJson("Optional", "Sound", false)]
[JsonProperty("soundType")]
public EnumSoundType Type
Field Value
Volume
Controls a random volume for when the sound is played.
[DocumentAsJson("Optional", "1", false)]
public NatFloat Volume
Field Value
Methods
Clone()
public SoundAttributes Clone()
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand this instance are the same type and represent the same value; otherwise, false.
Equals(SoundAttributes)
public bool Equals(SoundAttributes other)
Parameters
otherSoundAttributes
Returns
FromBytes(BinaryReader, string)
public static SoundAttributes FromBytes(BinaryReader reader, string version)
Parameters
readerBinaryReaderversionstring
Returns
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
ToBytes(BinaryWriter)
public void ToBytes(BinaryWriter writer)
Parameters
writerBinaryWriter
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Operators
operator ==(SoundAttributes?, SoundAttributes?)
public static bool operator ==(SoundAttributes? left, SoundAttributes? right)
Parameters
leftSoundAttributes?rightSoundAttributes?
Returns
operator !=(SoundAttributes?, SoundAttributes?)
public static bool operator !=(SoundAttributes? left, SoundAttributes? right)
Parameters
leftSoundAttributes?rightSoundAttributes?