2020-09-01 11:34:52 -07: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-01 11:34:52 -07:00
|
|
|
|
using Newtonsoft.Json;
|
2022-11-03 12:22:17 -07:00
|
|
|
|
using SabreTools.Core;
|
2020-09-01 11:34:52 -07:00
|
|
|
|
|
2021-02-02 10:23:43 -08:00
|
|
|
|
namespace SabreTools.DatItems.Formats
|
2020-09-01 11:34:52 -07:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents which Adjuster(s) is associated with a set
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonObject("adjuster"), XmlRoot("adjuster")]
|
2020-09-01 11:34:52 -07:00
|
|
|
|
public class Adjuster : DatItem
|
|
|
|
|
|
{
|
|
|
|
|
|
#region Fields
|
|
|
|
|
|
|
2020-09-02 12:19:12 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Name of the item
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("name"), XmlElement("name")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public string? Name
|
|
|
|
|
|
{
|
2023-08-14 22:33:05 -04:00
|
|
|
|
get => _internal.ReadString(Models.Internal.Adjuster.NameKey);
|
|
|
|
|
|
set => _internal[Models.Internal.Adjuster.NameKey] = value;
|
2023-08-14 13:17:51 -04:00
|
|
|
|
}
|
2020-09-02 12:19:12 -07:00
|
|
|
|
|
2020-09-01 11:34:52 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Determine whether the value is default
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("default", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("default")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public bool? Default
|
|
|
|
|
|
{
|
2023-08-14 22:33:05 -04:00
|
|
|
|
get => _internal.ReadBool(Models.Internal.Adjuster.DefaultKey);
|
|
|
|
|
|
set => _internal[Models.Internal.Adjuster.DefaultKey] = value;
|
2023-08-14 13:17:51 -04:00
|
|
|
|
}
|
2020-09-01 11:34:52 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool DefaultSpecified { get { return Default != null; } }
|
|
|
|
|
|
|
2020-09-01 11:34:52 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Conditions associated with the adjustment
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("conditions", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("conditions")]
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public List<Condition>? Conditions
|
|
|
|
|
|
{
|
2023-08-14 22:33:05 -04:00
|
|
|
|
get => _internal.Read<Condition[]>(Models.Internal.Adjuster.ConditionKey)?.ToList();
|
|
|
|
|
|
set => _internal[Models.Internal.Adjuster.ConditionKey] = value?.ToArray();
|
2023-08-14 13:17:51 -04:00
|
|
|
|
}
|
2020-09-01 11:34:52 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool ConditionsSpecified { get { return Conditions != null && Conditions.Count > 0; } }
|
|
|
|
|
|
|
2020-09-01 11:34:52 -07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Accessors
|
|
|
|
|
|
|
2020-12-13 14:01:16 -08:00
|
|
|
|
/// <inheritdoc/>
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public override string? GetName() => Name;
|
2020-09-02 12:19:12 -07:00
|
|
|
|
|
2020-12-13 14:01:16 -08:00
|
|
|
|
/// <inheritdoc/>
|
2023-08-14 13:17:51 -04:00
|
|
|
|
public override void SetName(string? name) => Name = name;
|
2020-12-13 14:01:16 -08:00
|
|
|
|
|
2020-09-01 11:34:52 -07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a default, empty Adjuster object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Adjuster()
|
|
|
|
|
|
{
|
2023-08-14 22:33:05 -04:00
|
|
|
|
_internal = new Models.Internal.Adjuster();
|
2020-09-01 11:34:52 -07:00
|
|
|
|
Name = string.Empty;
|
|
|
|
|
|
ItemType = ItemType.Adjuster;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Cloning Methods
|
|
|
|
|
|
|
2022-11-03 12:22:17 -07:00
|
|
|
|
/// <inheritdoc/>
|
2020-09-01 11:34:52 -07:00
|
|
|
|
public override object Clone()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Adjuster()
|
|
|
|
|
|
{
|
|
|
|
|
|
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-01 11:34:52 -07:00
|
|
|
|
Remove = this.Remove,
|
|
|
|
|
|
|
2023-08-14 22:33:05 -04:00
|
|
|
|
_internal = this._internal?.Clone() as Models.Internal.Adjuster ?? new Models.Internal.Adjuster(),
|
2020-09-01 11:34:52 -07:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|