updated demon
This commit is contained in:
@@ -1,58 +1,58 @@
|
||||
using Invector.vCharacterController.AI.FSMBehaviour;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DemonBoss.Magic
|
||||
{
|
||||
/// <summary>
|
||||
/// Decision checking if target is far away (for Turret ability)
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "Invector/FSM/Decisions/DemonBoss/Target Far")]
|
||||
public class DEC_TargetFar : vStateDecision
|
||||
{
|
||||
public override string categoryName => "DemonBoss/Magic";
|
||||
public override string defaultName => "Target Far";
|
||||
|
||||
[Header("Distance Configuration")]
|
||||
[Tooltip("Minimum distance for target to be considered far")]
|
||||
public float minDistance = 8f;
|
||||
|
||||
[Tooltip("Maximum distance for checking")]
|
||||
public float maxDistance = 30f;
|
||||
|
||||
[Header("Debug")]
|
||||
[Tooltip("Enable debug logging")]
|
||||
public bool enableDebug = false;
|
||||
|
||||
public override bool Decide(vIFSMBehaviourController fsmBehaviour)
|
||||
{
|
||||
Transform target = GetTarget(fsmBehaviour);
|
||||
if (target == null)
|
||||
{
|
||||
if (enableDebug) Debug.Log("[DEC_TargetFar] No target found");
|
||||
return false;
|
||||
}
|
||||
|
||||
float distance = Vector3.Distance(fsmBehaviour.transform.position, target.position);
|
||||
bool isFar = distance >= minDistance && distance <= maxDistance;
|
||||
|
||||
if (enableDebug)
|
||||
{
|
||||
Debug.Log($"[DEC_TargetFar] Distance to target: {distance:F1}m - {(isFar ? "FAR" : "CLOSE")}");
|
||||
}
|
||||
|
||||
return isFar;
|
||||
}
|
||||
|
||||
private Transform GetTarget(vIFSMBehaviourController fsmBehaviour)
|
||||
{
|
||||
// Try through AI controller
|
||||
var aiController = fsmBehaviour as Invector.vCharacterController.AI.vIControlAI;
|
||||
if (aiController != null && aiController.currentTarget != null)
|
||||
return aiController.currentTarget.transform;
|
||||
|
||||
// Fallback - find player
|
||||
GameObject player = GameObject.FindGameObjectWithTag("Player");
|
||||
return player?.transform;
|
||||
}
|
||||
}
|
||||
using Invector.vCharacterController.AI.FSMBehaviour;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DemonBoss.Magic
|
||||
{
|
||||
/// <summary>
|
||||
/// Decision checking if target is far away (for Turret ability)
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "Invector/FSM/Decisions/DemonBoss/Target Far")]
|
||||
public class DEC_TargetFar : vStateDecision
|
||||
{
|
||||
public override string categoryName => "DemonBoss/Magic";
|
||||
public override string defaultName => "Target Far";
|
||||
|
||||
[Header("Distance Configuration")]
|
||||
[Tooltip("Minimum distance for target to be considered far")]
|
||||
public float minDistance = 8f;
|
||||
|
||||
[Tooltip("Maximum distance for checking")]
|
||||
public float maxDistance = 30f;
|
||||
|
||||
[Header("Debug")]
|
||||
[Tooltip("Enable debug logging")]
|
||||
public bool enableDebug = false;
|
||||
|
||||
public override bool Decide(vIFSMBehaviourController fsmBehaviour)
|
||||
{
|
||||
Transform target = GetTarget(fsmBehaviour);
|
||||
if (target == null)
|
||||
{
|
||||
if (enableDebug) Debug.Log("[DEC_TargetFar] No target found");
|
||||
return false;
|
||||
}
|
||||
|
||||
float distance = Vector3.Distance(fsmBehaviour.transform.position, target.position);
|
||||
bool isFar = distance >= minDistance && distance <= maxDistance;
|
||||
|
||||
if (enableDebug)
|
||||
{
|
||||
Debug.Log($"[DEC_TargetFar] Distance to target: {distance:F1}m - {(isFar ? "FAR" : "CLOSE")}");
|
||||
}
|
||||
|
||||
return isFar;
|
||||
}
|
||||
|
||||
private Transform GetTarget(vIFSMBehaviourController fsmBehaviour)
|
||||
{
|
||||
// Try through AI controller
|
||||
var aiController = fsmBehaviour as Invector.vCharacterController.AI.vIControlAI;
|
||||
if (aiController != null && aiController.currentTarget != null)
|
||||
return aiController.currentTarget.transform;
|
||||
|
||||
// Fallback - find player
|
||||
GameObject player = GameObject.FindGameObjectWithTag("Player");
|
||||
return player?.transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user