2020-12-14 10:11:20 -08:00
|
|
|
|
using System.Collections.Generic;
|
2023-08-14 13:17:51 -04:00
|
|
|
|
using System.Linq;
|
2020-09-07 22:00:02 -07:00
|
|
|
|
using System.Xml.Serialization;
|
2020-09-03 13:20:56 -07:00
|
|
|
|
using Newtonsoft.Json;
|
2022-11-03 12:22:17 -07:00
|
|
|
|
using SabreTools.Core;
|
2020-09-02 21:59:26 -07:00
|
|
|
|
|
2021-02-02 10:23:43 -08:00
|
|
|
|
namespace SabreTools.DatItems.Formats
|
2020-09-02 21:59:26 -07:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents one ListXML input
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonObject("input"), XmlRoot("input")]
|
2020-09-02 21:59:26 -07:00
|
|
|
|
public class Input : DatItem
|
|
|
|
|
|
{
|
|
|
|
|
|
#region Fields
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Input service ID
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("service", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("service")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public bool? Service
|
|
|
|
|
|
{
|
2023-08-14 22:33:05 -04:00
|
|
|
|
get => _internal.ReadBool(Models.Internal.Input.ServiceKey);
|
|
|
|
|
|
set => _internal[Models.Internal.Input.ServiceKey] = value;
|
2023-08-14 13:17:51 -04:00
|
|
|
|
}
|
2020-09-02 21:59:26 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool ServiceSpecified { get { return Service != null; } }
|
|
|
|
|
|
|
2020-09-02 21:59:26 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Determins if this has a tilt sensor
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("tilt", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("tilt")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public bool? Tilt
|
|
|
|
|
|
{
|
2023-08-14 22:33:05 -04:00
|
|
|
|
get => _internal.ReadBool(Models.Internal.Input.TiltKey);
|
|
|
|
|
|
set => _internal[Models.Internal.Input.TiltKey] = value;
|
2023-08-14 13:17:51 -04:00
|
|
|
|
}
|
2020-09-02 21:59:26 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool TiltSpecified { get { return Tilt != null; } }
|
|
|
|
|
|
|
2020-09-02 21:59:26 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Number of players on the input
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("players", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("players")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public long? Players
|
|
|
|
|
|
{
|
2023-08-14 22:33:05 -04:00
|
|
|
|
get => _internal.ReadLong(Models.Internal.Input.PlayersKey);
|
|
|
|
|
|
set => _internal[Models.Internal.Input.PlayersKey] = value;
|
2023-08-14 13:17:51 -04:00
|
|
|
|
}
|
2020-09-02 21:59:26 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool PlayersSpecified { get { return Players != null; } }
|
|
|
|
|
|
|
2020-09-02 21:59:26 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Number of coins required
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("coins", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("coins")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public long? Coins
|
|
|
|
|
|
{
|
2023-08-14 22:33:05 -04:00
|
|
|
|
get => _internal.ReadLong(Models.Internal.Input.CoinsKey);
|
|
|
|
|
|
set => _internal[Models.Internal.Input.CoinsKey] = value;
|
2023-08-14 13:17:51 -04:00
|
|
|
|
}
|
2020-09-02 21:59:26 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool CoinsSpecified { get { return Coins != null; } }
|
|
|
|
|
|
|
2020-09-02 21:59:26 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Set of controls for the input
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("controls", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("controls")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public List<Control>? Controls
|
|
|
|
|
|
{
|
2023-08-14 22:33:05 -04:00
|
|
|
|
get => _internal.Read<Control[]>(Models.Internal.Input.ControlKey)?.ToList();
|
|
|
|
|
|
set => _internal[Models.Internal.Input.ControlKey] = value?.ToArray();
|
2023-08-14 13:17:51 -04:00
|
|
|
|
}
|
2020-09-02 21:59:26 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool ControlsSpecified { get { return Controls != null && Controls.Count > 0; } }
|
|
|
|
|
|
|
2020-09-02 21:59:26 -07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a default, empty Input object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Input()
|
|
|
|
|
|
{
|
2023-08-14 22:33:05 -04:00
|
|
|
|
_internal = new Models.Internal.Input();
|
2020-09-02 21:59:26 -07:00
|
|
|
|
ItemType = ItemType.Input;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Cloning Methods
|
|
|
|
|
|
|
2022-11-03 12:22:17 -07:00
|
|
|
|
/// <inheritdoc/>
|
2020-09-02 21:59:26 -07:00
|
|
|
|
public override object Clone()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Input()
|
|
|
|
|
|
{
|
|
|
|
|
|
ItemType = this.ItemType,
|
|
|
|
|
|
DupeType = this.DupeType,
|
|
|
|
|
|
|
2023-08-14 13:17:51 -04:00
|
|
|
|
Machine = this.Machine?.Clone() as Machine,
|
|
|
|
|
|
Source = this.Source?.Clone() as Source,
|
2020-09-02 21:59:26 -07:00
|
|
|
|
Remove = this.Remove,
|
|
|
|
|
|
|
2023-08-14 22:33:05 -04:00
|
|
|
|
_internal = this._internal?.Clone() as Models.Internal.Input ?? new Models.Internal.Input(),
|
2020-09-02 21:59:26 -07:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|