Fixes
This commit is contained in:
@@ -8,7 +8,7 @@ namespace DemonBoss.Magic
|
||||
/// StateAction for Magic Shield spell - boss casts magical shield for 5 seconds
|
||||
/// During casting boss stands still, after completion returns to Combat
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "Invector/FSM/Decisions/DemonBoss/Cast Shield")]
|
||||
[CreateAssetMenu(menuName = "Invector/FSM/Actions/DemonBoss/Cast Shield")]
|
||||
public class SA_CastShield : vStateAction
|
||||
{
|
||||
public override string categoryName => "DemonBoss/Magic";
|
||||
@@ -18,21 +18,19 @@ namespace DemonBoss.Magic
|
||||
[Tooltip("Prefab with magical shield particle effect")]
|
||||
public GameObject shieldFXPrefab;
|
||||
|
||||
[Tooltip("Transform where shield should appear (usually boss center)")]
|
||||
public Transform shieldSpawnPoint;
|
||||
|
||||
[Tooltip("Shield duration in seconds")]
|
||||
public float shieldDuration = 5f;
|
||||
|
||||
[Tooltip("Animator trigger name for shield casting animation")]
|
||||
public string animatorTrigger = "CastShield";
|
||||
[Tooltip("Animator bool parameter name for blocking state")]
|
||||
public string animatorBlockingBool = "IsBlocking";
|
||||
|
||||
[Header("Debug")]
|
||||
[Tooltip("Enable debug logging")]
|
||||
public bool enableDebug = false;
|
||||
|
||||
private GameObject spawnedShield;
|
||||
|
||||
private Animator npcAnimator;
|
||||
private Transform npcTransform;
|
||||
private float shieldStartTime;
|
||||
private bool shieldActive = false;
|
||||
|
||||
@@ -62,6 +60,10 @@ namespace DemonBoss.Magic
|
||||
{
|
||||
if (enableDebug) Debug.Log("[SA_CastShield] Entering shield casting state");
|
||||
|
||||
// Store NPC references
|
||||
npcTransform = fsmBehaviour.transform;
|
||||
npcAnimator = npcTransform.GetComponent<Animator>();
|
||||
|
||||
var aiController = fsmBehaviour as Invector.vCharacterController.AI.vIControlAI;
|
||||
if (aiController != null)
|
||||
{
|
||||
@@ -69,11 +71,10 @@ namespace DemonBoss.Magic
|
||||
if (enableDebug) Debug.Log("[SA_CastShield] AI stopped");
|
||||
}
|
||||
|
||||
var animator = fsmBehaviour.transform.GetComponent<Animator>();
|
||||
if (animator != null && !string.IsNullOrEmpty(animatorTrigger))
|
||||
if (npcAnimator != null && !string.IsNullOrEmpty(animatorBlockingBool))
|
||||
{
|
||||
animator.SetTrigger(animatorTrigger);
|
||||
if (enableDebug) Debug.Log($"[SA_CastShield] Set trigger: {animatorTrigger}");
|
||||
npcAnimator.SetBool(animatorBlockingBool, true);
|
||||
if (enableDebug) Debug.Log($"[SA_CastShield] Set bool: {animatorBlockingBool} = true");
|
||||
}
|
||||
|
||||
SpawnShieldEffect(fsmBehaviour);
|
||||
@@ -101,6 +102,12 @@ namespace DemonBoss.Magic
|
||||
{
|
||||
if (enableDebug) Debug.Log("[SA_CastShield] Exiting shield state");
|
||||
|
||||
if (npcAnimator != null && !string.IsNullOrEmpty(animatorBlockingBool))
|
||||
{
|
||||
npcAnimator.SetBool(animatorBlockingBool, false);
|
||||
if (enableDebug) Debug.Log($"[SA_CastShield] Set bool: {animatorBlockingBool} = false");
|
||||
}
|
||||
|
||||
if (shieldActive)
|
||||
{
|
||||
CleanupShield();
|
||||
@@ -124,17 +131,18 @@ namespace DemonBoss.Magic
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 spawnPosition = shieldSpawnPoint != null ?
|
||||
shieldSpawnPoint.position : fsmBehaviour.transform.position;
|
||||
// Spawn shield at NPC's position and rotation
|
||||
Vector3 spawnPosition = npcTransform.position;
|
||||
Quaternion spawnRotation = npcTransform.rotation;
|
||||
|
||||
spawnedShield = LeanPool.Spawn(shieldFXPrefab, spawnPosition,
|
||||
shieldSpawnPoint != null ? shieldSpawnPoint.rotation : fsmBehaviour.transform.rotation);
|
||||
spawnedShield = LeanPool.Spawn(shieldFXPrefab, spawnPosition, spawnRotation);
|
||||
|
||||
if (enableDebug) Debug.Log($"[SA_CastShield] Shield spawned at position: {spawnPosition}");
|
||||
if (enableDebug) Debug.Log($"[SA_CastShield] Shield spawned at NPC position: {spawnPosition}");
|
||||
|
||||
if (spawnedShield != null && shieldSpawnPoint != null)
|
||||
// Parent the shield to the NPC so it moves with them
|
||||
if (spawnedShield != null)
|
||||
{
|
||||
spawnedShield.transform.SetParent(shieldSpawnPoint);
|
||||
spawnedShield.transform.SetParent(npcTransform);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user