using Invector.vCharacterController.AI.FSMBehaviour; using UnityEngine; namespace DemonBoss.Summoner { /// /// FSM Decision checking if summoner should engage in melee combat /// Checks: player distance, minion status, combat settings /// [CreateAssetMenu(menuName = "Invector/FSM/Decisions/Summoner/Should Melee Attack")] public class DEC_ShouldMeleeAttack : vStateDecision { public override string categoryName => "Summoner"; public override string defaultName => "Should Melee Attack"; [Header("Distance Configuration")] [Tooltip("Minimum distance to engage melee")] public float minMeleeDistance = 0f; [Tooltip("Maximum distance to engage melee")] public float maxMeleeDistance = 3f; [Header("Behavior")] [Tooltip("Attack even when minions are alive")] public bool attackWithMinions = false; [Header("Debug")] [Tooltip("Enable debug logging")] public bool enableDebug = false; public override bool Decide(vIFSMBehaviourController fsmBehaviour) { var summoner = fsmBehaviour.gameObject.GetComponent(); if (summoner == null) { if (enableDebug) Debug.LogWarning("[DEC_ShouldMeleeAttack] No SummonerAI component found!"); return false; } // Don't attack while spawning if (summoner.IsSpawning) { if (enableDebug) Debug.Log("[DEC_ShouldMeleeAttack] Currently spawning - FALSE"); return false; } // Check if has minions and shouldn't attack with them if (!attackWithMinions && summoner.HasActiveMinions) { if (enableDebug) Debug.Log($"[DEC_ShouldMeleeAttack] Has {summoner.ActiveMinionCount} minions and attackWithMinions=false - FALSE"); return false; } // Check distance to player float distance = summoner.GetDistanceToPlayer(); bool inRange = distance >= minMeleeDistance && distance <= maxMeleeDistance; if (enableDebug) { if (inRange) { Debug.Log($"[DEC_ShouldMeleeAttack] Player in melee range ({distance:F1}m) - TRUE"); } else { Debug.Log($"[DEC_ShouldMeleeAttack] Player not in melee range ({distance:F1}m, need {minMeleeDistance:F1}-{maxMeleeDistance:F1}m) - FALSE"); } } return inRange; } } }