using UnityEngine; [CreateAssetMenu(menuName = "SharpRune/Enemy Profile")] public sealed class EnemyProfile : ScriptableObject { [SerializeField, Min(1)] private int startingHealth = 10; public RuntimeHealth CreateState() { return new RuntimeHealth(Mathf.Max(1, startingHealth)); } [ContextMenu("Preview Independent States")] private void Preview() { RuntimeHealth first = CreateState(); RuntimeHealth second = CreateState(); first.Damage(3); Debug.Log("First=" + first.Current + ", Second=" + second.Current + ", Config=" + startingHealth, this); } public sealed class RuntimeHealth { public int Current { get; private set; } public RuntimeHealth(int health) { Current = health; } public void Damage(int amount) { Current = Mathf.Max(0, Current - Mathf.Max(0, amount)); } } }