[Refactor] Replace [SerializeField] + getter with [field: SerializeField] auto-properties
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,15 +9,12 @@ namespace YachtDice.Dice
|
||||
[Serializable]
|
||||
public struct Entry : IEquatable<Entry>
|
||||
{
|
||||
[SerializeField] private int value;
|
||||
[SerializeField] private Transform point;
|
||||
[field: SerializeField] public int Value { get; private set; }
|
||||
[field: SerializeField] public Transform Point { get; private set; }
|
||||
|
||||
public int Value => value;
|
||||
public Transform Point => point;
|
||||
|
||||
public bool Equals(Entry other) => point == other.point;
|
||||
public bool Equals(Entry other) => Point == other.Point;
|
||||
public override bool Equals(object obj) => obj is Entry other && Equals(other);
|
||||
public override int GetHashCode() => point != null ? point.GetHashCode() : 0;
|
||||
public override int GetHashCode() => Point != null ? Point.GetHashCode() : 0;
|
||||
}
|
||||
|
||||
[SerializeField] private List<Entry> entries = new();
|
||||
|
||||
@@ -8,14 +8,10 @@ namespace YachtDice.Dice
|
||||
/// </summary>
|
||||
public abstract class DieDefinitionSO : ScriptableObject
|
||||
{
|
||||
[Header("Identity")]
|
||||
[SerializeField] private string id;
|
||||
[SerializeField] private string displayName;
|
||||
[SerializeField] private Sprite icon;
|
||||
|
||||
public string Id => id;
|
||||
public string DisplayName => displayName;
|
||||
public Sprite Icon => icon;
|
||||
[field: Header("Identity")]
|
||||
[field: SerializeField] public string Id { get; private set; }
|
||||
[field: SerializeField] public string DisplayName { get; private set; }
|
||||
[field: SerializeField] public Sprite Icon { get; private set; }
|
||||
|
||||
/// <summary>Количество граней.</summary>
|
||||
public abstract int FaceCount { get; }
|
||||
@@ -27,8 +23,8 @@ namespace YachtDice.Dice
|
||||
public static T CreateForTest<T>(string id, string displayName = null) where T : DieDefinitionSO
|
||||
{
|
||||
var so = CreateInstance<T>();
|
||||
so.id = id;
|
||||
so.displayName = displayName ?? id;
|
||||
so.Id = id;
|
||||
so.DisplayName = displayName ?? id;
|
||||
return so;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user