Fix null item audio types breaking custom items

This commit is contained in:
Joshua Thome 2025-02-16 23:25:46 -06:00
parent 3270580422
commit 8b49f94bd4
3 changed files with 13 additions and 0 deletions

View File

@ -59,10 +59,18 @@ namespace NewHorizons.Builder.Props
{ {
item.PickupAudio = AudioTypeHandler.GetAudioType(info.pickupAudio, mod); item.PickupAudio = AudioTypeHandler.GetAudioType(info.pickupAudio, mod);
} }
else
{
item.PickupAudio = AudioType.ToolItemWarpCorePickUp;
}
if (!string.IsNullOrEmpty(info.dropAudio)) if (!string.IsNullOrEmpty(info.dropAudio))
{ {
item.DropAudio = AudioTypeHandler.GetAudioType(info.dropAudio, mod); item.DropAudio = AudioTypeHandler.GetAudioType(info.dropAudio, mod);
} }
else
{
item.DropAudio = AudioType.ToolItemWarpCoreDrop;
}
if (!string.IsNullOrEmpty(info.socketAudio)) if (!string.IsNullOrEmpty(info.socketAudio))
{ {
item.SocketAudio = AudioTypeHandler.GetAudioType(info.socketAudio, mod); item.SocketAudio = AudioTypeHandler.GetAudioType(info.socketAudio, mod);

View File

@ -90,6 +90,7 @@ namespace NewHorizons.Components.Props
void PlayCustomSound(AudioType audioType) void PlayCustomSound(AudioType audioType)
{ {
if (audioType == AudioType.None) return;
if (ItemBuilder.IsCustomItemType(ItemType)) if (ItemBuilder.IsCustomItemType(ItemType))
{ {
Locator.GetPlayerAudioController()._oneShotExternalSource.PlayOneShot(audioType); Locator.GetPlayerAudioController()._oneShotExternalSource.PlayOneShot(audioType);

View File

@ -62,21 +62,25 @@ namespace NewHorizons.External.Modules.Props.Item
/// <summary> /// <summary>
/// The audio to play when this item is picked up. Only applies to custom/non-vanilla item types. /// The audio to play when this item is picked up. Only applies to custom/non-vanilla item types.
/// Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list. /// Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// Defaults to "ToolItemWarpCorePickUp". Set to "None" to disable the sound entirely.
/// </summary> /// </summary>
public string pickupAudio; public string pickupAudio;
/// <summary> /// <summary>
/// The audio to play when this item is dropped. Only applies to custom/non-vanilla item types. /// The audio to play when this item is dropped. Only applies to custom/non-vanilla item types.
/// Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list. /// Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// Defaults to "ToolItemWarpCoreDrop". Set to "None" to disable the sound entirely.
/// </summary> /// </summary>
public string dropAudio; public string dropAudio;
/// <summary> /// <summary>
/// The audio to play when this item is inserted into a socket. Only applies to custom/non-vanilla item types. /// The audio to play when this item is inserted into a socket. Only applies to custom/non-vanilla item types.
/// Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list. /// Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// Defaults to the pickup audio. Set to "None" to disable the sound entirely.
/// </summary> /// </summary>
public string socketAudio; public string socketAudio;
/// <summary> /// <summary>
/// The audio to play when this item is removed from a socket. Only applies to custom/non-vanilla item types. /// The audio to play when this item is removed from a socket. Only applies to custom/non-vanilla item types.
/// Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list. /// Can be a path to a .wav/.ogg/.mp3 file, or taken from the AudioClip list.
/// Defaults to the drop audio. Set to "None" to disable the sound entirely.
/// </summary> /// </summary>
public string unsocketAudio; public string unsocketAudio;
/// <summary> /// <summary>