mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
102 lines
2.9 KiB
C#
102 lines
2.9 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Xml.Serialization;
|
|
using Newtonsoft.Json;
|
|
using SabreTools.Core;
|
|
|
|
namespace SabreTools.DatItems.Formats
|
|
{
|
|
/// <summary>
|
|
/// Represents which Adjuster(s) is associated with a set
|
|
/// </summary>
|
|
[JsonObject("adjuster"), XmlRoot("adjuster")]
|
|
public class Adjuster : DatItem
|
|
{
|
|
#region Fields
|
|
|
|
/// <summary>
|
|
/// Name of the item
|
|
/// </summary>
|
|
[JsonProperty("name"), XmlElement("name")]
|
|
public string? Name
|
|
{
|
|
get => _internal.ReadString(Models.Metadata.Adjuster.NameKey);
|
|
set => _internal[Models.Metadata.Adjuster.NameKey] = value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Determine whether the value is default
|
|
/// </summary>
|
|
[JsonProperty("default", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("default")]
|
|
public bool? Default
|
|
{
|
|
get => _internal.ReadBool(Models.Metadata.Adjuster.DefaultKey);
|
|
set => _internal[Models.Metadata.Adjuster.DefaultKey] = value;
|
|
}
|
|
|
|
[JsonIgnore]
|
|
public bool DefaultSpecified { get { return Default != null; } }
|
|
|
|
/// <summary>
|
|
/// Conditions associated with the adjustment
|
|
/// </summary>
|
|
[JsonProperty("conditions", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("conditions")]
|
|
public List<Condition>? Conditions
|
|
{
|
|
get => _internal.Read<Condition[]>(Models.Metadata.Adjuster.ConditionKey)?.ToList();
|
|
set => _internal[Models.Metadata.Adjuster.ConditionKey] = value?.ToArray();
|
|
}
|
|
|
|
[JsonIgnore]
|
|
public bool ConditionsSpecified { get { return Conditions != null && Conditions.Count > 0; } }
|
|
|
|
#endregion
|
|
|
|
#region Accessors
|
|
|
|
/// <inheritdoc/>
|
|
public override string? GetName() => Name;
|
|
|
|
/// <inheritdoc/>
|
|
public override void SetName(string? name) => Name = name;
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
/// <summary>
|
|
/// Create a default, empty Adjuster object
|
|
/// </summary>
|
|
public Adjuster()
|
|
{
|
|
_internal = new Models.Metadata.Adjuster();
|
|
Machine = new Machine();
|
|
|
|
Name = string.Empty;
|
|
ItemType = ItemType.Adjuster;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Cloning Methods
|
|
|
|
/// <inheritdoc/>
|
|
public override object Clone()
|
|
{
|
|
return new Adjuster()
|
|
{
|
|
ItemType = this.ItemType,
|
|
DupeType = this.DupeType,
|
|
|
|
Machine = this.Machine.Clone() as Machine ?? new Machine(),
|
|
Source = this.Source?.Clone() as Source,
|
|
Remove = this.Remove,
|
|
|
|
_internal = this._internal?.Clone() as Models.Metadata.Adjuster ?? [],
|
|
};
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|