mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
78 lines
2.0 KiB
C#
78 lines
2.0 KiB
C#
using System.Xml.Serialization;
|
|
using Newtonsoft.Json;
|
|
using SabreTools.Core;
|
|
|
|
namespace SabreTools.DatItems.Formats
|
|
{
|
|
/// <summary>
|
|
/// Represents which Slot(s) is associated with a set
|
|
/// </summary>
|
|
[JsonObject("slot"), XmlRoot("slot")]
|
|
public class Slot : DatItem
|
|
{
|
|
#region Fields
|
|
|
|
[JsonIgnore]
|
|
public bool SlotOptionsSpecified
|
|
{
|
|
get
|
|
{
|
|
var slotOptions = GetFieldValue<SlotOption[]?>(Models.Metadata.Slot.SlotOptionKey);
|
|
return slotOptions != null && slotOptions.Length > 0;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Accessors
|
|
|
|
/// <inheritdoc/>
|
|
public override string? GetName() => GetFieldValue<string>(Models.Metadata.Slot.NameKey);
|
|
|
|
/// <inheritdoc/>
|
|
public override void SetName(string? name) => SetFieldValue(Models.Metadata.Slot.NameKey, name);
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
/// <summary>
|
|
/// Create a default, empty Slot object
|
|
/// </summary>
|
|
public Slot()
|
|
{
|
|
_internal = new Models.Metadata.Slot();
|
|
|
|
SetName(string.Empty);
|
|
SetFieldValue<ItemType>(Models.Metadata.DatItem.TypeKey, ItemType.Slot);
|
|
SetFieldValue<Machine>(DatItem.MachineKey, new Machine());
|
|
}
|
|
|
|
/// <summary>
|
|
/// Create a Slot object from the internal model
|
|
/// </summary>
|
|
public Slot(Models.Metadata.Slot item)
|
|
{
|
|
_internal = item;
|
|
|
|
SetFieldValue<ItemType>(Models.Metadata.DatItem.TypeKey, ItemType.Slot);
|
|
SetFieldValue<Machine>(DatItem.MachineKey, new Machine());
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Cloning Methods
|
|
|
|
/// <inheritdoc/>
|
|
public override object Clone()
|
|
{
|
|
return new Slot()
|
|
{
|
|
_internal = this._internal?.Clone() as Models.Metadata.Slot ?? [],
|
|
};
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|