using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;
using Newtonsoft.Json;
using SabreTools.Core;
namespace SabreTools.DatItems.Formats
{
///
/// Represents one ListXML input
///
[JsonObject("input"), XmlRoot("input")]
public class Input : DatItem
{
#region Fields
///
/// Input service ID
///
[JsonProperty("service", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("service")]
public bool? Service
{
get => _internal.ReadBool(Models.Internal.Input.ServiceKey);
set => _internal[Models.Internal.Input.ServiceKey] = value;
}
[JsonIgnore]
public bool ServiceSpecified { get { return Service != null; } }
///
/// Determins if this has a tilt sensor
///
[JsonProperty("tilt", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("tilt")]
public bool? Tilt
{
get => _internal.ReadBool(Models.Internal.Input.TiltKey);
set => _internal[Models.Internal.Input.TiltKey] = value;
}
[JsonIgnore]
public bool TiltSpecified { get { return Tilt != null; } }
///
/// Number of players on the input
///
[JsonProperty("players", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("players")]
public long? Players
{
get => _internal.ReadLong(Models.Internal.Input.PlayersKey);
set => _internal[Models.Internal.Input.PlayersKey] = value;
}
[JsonIgnore]
public bool PlayersSpecified { get { return Players != null; } }
///
/// Number of coins required
///
[JsonProperty("coins", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("coins")]
public long? Coins
{
get => _internal.ReadLong(Models.Internal.Input.CoinsKey);
set => _internal[Models.Internal.Input.CoinsKey] = value;
}
[JsonIgnore]
public bool CoinsSpecified { get { return Coins != null; } }
///
/// Set of controls for the input
///
[JsonProperty("controls", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("controls")]
public List? Controls
{
get => _internal.Read(Models.Internal.Input.ControlKey)?.ToList();
set => _internal[Models.Internal.Input.ControlKey] = value?.ToArray();
}
[JsonIgnore]
public bool ControlsSpecified { get { return Controls != null && Controls.Count > 0; } }
#endregion
#region Constructors
///
/// Create a default, empty Input object
///
public Input()
{
_internal = new Models.Internal.Input();
ItemType = ItemType.Input;
}
#endregion
#region Cloning Methods
///
public override object Clone()
{
return new Input()
{
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine?.Clone() as Machine,
Source = this.Source?.Clone() as Source,
Remove = this.Remove,
_internal = this._internal?.Clone() as Models.Internal.Input ?? new Models.Internal.Input(),
};
}
#endregion
}
}