[Refactor] Replace [SerializeField] + getter with [field: SerializeField] auto-properties

Convert serialized private fields with public arrow getters to
[field: SerializeField] auto-properties across ScriptableObjects
(DieDefinitionSO, CategoryDefinition, ModifierDefinition, Effect,
ModifierBehavior, SumOfValueCategory) and select MonoBehaviours
(DiceRoller, Dice.Entry struct). Fields with type-changing getters
(List→IReadOnlyList) or computed getters are intentionally kept as-is.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-01 21:28:48 +07:00
parent 30f9532fd7
commit f6c354d41c
8 changed files with 59 additions and 90 deletions
+4 -7
View File
@@ -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();
+1 -2
View File
@@ -14,10 +14,9 @@ namespace YachtDice.Dice
[Header("References")]
[SerializeField] private Dice dice;
[SerializeField] private Rigidbody rb;
[SerializeField] private DieDefinitionSO definition;
/// <summary>Определение типа дайса (назначается в инспекторе).</summary>
public DieDefinitionSO Definition => definition;
[field: SerializeField] public DieDefinitionSO Definition { get; private set; }
[Header("Throw Settings")]
[Tooltip("Сила подброса вверх")]
+11 -16
View File
@@ -9,20 +9,15 @@ namespace YachtDice.Dice
/// </summary>
public abstract class DieDefinitionSO : ScriptableObject, IShopItem
{
[Header("Identity")]
[SerializeField] private string id;
[SerializeField] private string displayName;
[SerializeField, TextArea] private string description;
[SerializeField] private Sprite icon;
[field: Header("Identity")]
[field: SerializeField] public string Id { get; private set; }
[field: SerializeField] public string DisplayName { get; private set; }
[field: SerializeField, TextArea] public string Description { get; private set; }
[field: SerializeField] public Sprite Icon { get; private set; }
[Header("Economy")]
[SerializeField] private int shopPrice;
[field: Header("Economy")]
[field: SerializeField] public int ShopPrice { get; private set; }
public string Id => id;
public string DisplayName => displayName;
public string Description => description;
public Sprite Icon => icon;
public int ShopPrice => shopPrice;
public bool IsRepurchasable => false;
/// <summary>Количество граней.</summary>
@@ -36,10 +31,10 @@ namespace YachtDice.Dice
int shopPrice = 0, string description = null) where T : DieDefinitionSO
{
var so = CreateInstance<T>();
so.id = id;
so.displayName = displayName ?? id;
so.description = description ?? id;
so.shopPrice = shopPrice;
so.Id = id;
so.DisplayName = displayName ?? id;
so.Description = description ?? id;
so.ShopPrice = shopPrice;
return so;
}
#endif