using UnityEngine; namespace ProjectI.Enemies { public enum EnemyRole { Melee, Ranged } [CreateAssetMenu(menuName = "ProjectI/Enemies/Definition")] public sealed class EnemyDefinition : ScriptableObject { public string displayName = "Passive Drone"; public EnemyRole role; public EnemyArchetype archetype; public float maximumHealth = 30; public int normalAgentType, largeAgentType; public bool boss; [Range(.25f, 1)] public float meleeVisualScale = .45f; public EnemyResistanceProfile normalResistance, eliteResistance, bossResistance; public bool EliteOnly => archetype == EnemyArchetype.Bombardier; public bool ResolveElite(bool requested) => requested || EliteOnly; public int ResolveAgentType(bool elite) => boss || ResolveElite(elite) ? largeAgentType : normalAgentType; public bool Valid => System.Enum.IsDefined(typeof(EnemyRole), role) && System.Enum.IsDefined(typeof(EnemyArchetype), archetype) && (!EliteOnly || role == EnemyRole.Ranged && !boss) && maximumHealth > 0 && !float.IsNaN(maximumHealth) && !float.IsInfinity(maximumHealth) && meleeVisualScale > 0 && !float.IsNaN(meleeVisualScale) && !float.IsInfinity(meleeVisualScale); public EnemyResistanceValues ResolveResistances(bool elite) { elite = ResolveElite(elite); var profile = boss ? bossResistance : elite ? eliteResistance : normalResistance; if (profile != null) return profile.Resolve(); if (!warnedMissingProfile) { warnedMissingProfile = true; Debug.LogWarning($"{name}: missing resistance profile; using tier defaults.", this); } return EnemyResistanceValues.ForTier(elite, boss); } [System.NonSerialized] private bool warnedMissingProfile; public EnemyDefinition CreateOverride() => Instantiate(this); } }