[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
@@ -10,20 +10,14 @@ namespace YachtDice.Categories
/// </summary>
public abstract class CategoryDefinition : ScriptableObject
{
[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("Section")]
[SerializeField] private bool isUpperSection;
public string Id => id;
public string DisplayName => displayName;
public string Description => description;
public Sprite Icon => icon;
public bool IsUpperSection => isUpperSection;
[field: Header("Section")]
[field: SerializeField] public bool IsUpperSection { get; private set; }
/// <summary>
/// Вычисляет очки для данного набора дайсов.
@@ -33,9 +27,9 @@ namespace YachtDice.Categories
#if UNITY_EDITOR
public void SetTestData(string testId, string testDisplayName, bool upperSection = false)
{
id = testId;
displayName = testDisplayName;
isUpperSection = upperSection;
Id = testId;
DisplayName = testDisplayName;
IsUpperSection = upperSection;
}
#endif
}
@@ -11,17 +11,15 @@ namespace YachtDice.Categories
[CreateAssetMenu(fileName = "SumOfValueCategory", menuName = "YachtDice/Categories/Sum Of Value")]
public class SumOfValueCategory : CategoryDefinition
{
[Header("Scoring")]
[Tooltip("Значение грани для суммирования (1-6)")]
[SerializeField, Range(1, 6)] private int targetValue = 1;
public int TargetValue => targetValue;
[field: Header("Scoring")]
[field: Tooltip("Значение грани для суммирования (1-6)")]
[field: SerializeField, Range(1, 6)] public int TargetValue { get; private set; } = 1;
public override int Calculate(IReadOnlyList<IDie> dice)
{
int sum = 0;
for (int i = 0; i < dice.Count; i++)
if (dice[i].Value == targetValue) sum += targetValue;
if (dice[i].Value == TargetValue) sum += TargetValue;
return sum;
}
@@ -30,7 +28,7 @@ namespace YachtDice.Categories
{
var so = CreateInstance<SumOfValueCategory>();
so.SetTestData(id, displayName, upperSection: true);
so.targetValue = target;
so.TargetValue = target;
return so;
}
#endif