Files
SabreTools/SabreTools.DatItems/Formats/Sound.cs

84 lines
2.1 KiB
C#
Raw Normal View History

using System.Xml.Serialization;
2020-09-02 12:51:21 -07:00
using Newtonsoft.Json;
2022-11-03 12:22:17 -07:00
using SabreTools.Core;
2020-09-02 12:51:21 -07:00
2021-02-02 10:23:43 -08:00
namespace SabreTools.DatItems.Formats
2020-09-02 12:51:21 -07:00
{
/// <summary>
/// Represents the sound output for a machine
/// </summary>
2020-09-08 10:12:41 -07:00
[JsonObject("sound"), XmlRoot("sound")]
2020-09-02 12:51:21 -07:00
public class Sound : DatItem
{
#region Fields
/// <summary>
/// Number of speakers or channels
2020-09-02 12:51:21 -07:00
/// </summary>
2022-11-03 12:22:17 -07:00
[JsonProperty("channels", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("channels")]
public long? Channels
{
get => _sound.ReadLong(Models.Internal.Sound.ChannelsKey);
set => _sound[Models.Internal.Sound.ChannelsKey] = value;
}
2020-09-02 12:51:21 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool ChannelsSpecified { get { return Channels != null; } }
/// <summary>
/// Internal Sound model
/// </summary>
[JsonIgnore]
private Models.Internal.Sound _sound = new();
2020-09-02 12:51:21 -07:00
#endregion
#region Constructors
/// <summary>
/// Create a default, empty Sound object
/// </summary>
public Sound()
{
ItemType = ItemType.Sound;
}
#endregion
#region Cloning Methods
2022-11-03 12:22:17 -07:00
/// <inheritdoc/>
2020-09-02 12:51:21 -07:00
public override object Clone()
{
return new Sound()
{
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Source = this.Source?.Clone() as Source,
2020-09-02 12:51:21 -07:00
Remove = this.Remove,
_sound = this._sound?.Clone() as Models.Internal.Sound ?? new Models.Internal.Sound(),
2020-09-02 12:51:21 -07:00
};
}
#endregion
#region Comparision Methods
2022-11-03 12:22:17 -07:00
/// <inheritdoc/>
public override bool Equals(DatItem? other)
2020-09-02 12:51:21 -07:00
{
// If we don't have a Sound, return false
if (ItemType != other?.ItemType || other is not Sound otherInternal)
2020-09-02 12:51:21 -07:00
return false;
// Compare the internal models
return _sound.EqualTo(otherInternal._sound);
2020-09-02 12:51:21 -07:00
}
#endregion
}
}