This commit is contained in:
SzymonMis
2026-02-19 21:34:07 +01:00
parent 8de064552e
commit 06f9c7349d
25 changed files with 45269 additions and 346 deletions

View File

@@ -23,6 +23,12 @@ namespace DemonBoss.Summoner
[Header("Behavior")]
[Tooltip("Wait for spawning to complete before allowing state exit")]
public bool waitForCompletion = true;
[Tooltip("If true, spawn starts only after an animation event calls SummonerAI.OnSummonAnimationEvent")]
public bool spawnOnAnimationEvent = true;
[Tooltip("Fallback: start spawn if animation event doesn't fire within this time (seconds). 0 = no fallback.")]
public float animationEventTimeout = 1.2f;
[Header("Debug")]
[Tooltip("Enable debug logging")]
@@ -31,6 +37,8 @@ namespace DemonBoss.Summoner
private SummonerAI summoner;
private Animator animator;
private bool hasStartedSpawning = false;
private float spawnRequestTime = -1f;
private bool spawnTriggered = false;
public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate)
{
@@ -73,15 +81,40 @@ namespace DemonBoss.Summoner
}
}
// Start spawning minions
summoner.StartSpawning();
hasStartedSpawning = true;
if (enableDebug) Debug.Log("[SA_SpawnMinions] Started spawning minions");
if (spawnOnAnimationEvent)
{
summoner.RequestSpawn();
hasStartedSpawning = true;
spawnTriggered = false;
spawnRequestTime = Time.time;
if (enableDebug) Debug.Log("[SA_SpawnMinions] Waiting for animation event to spawn");
}
else
{
// Start spawning minions immediately
summoner.StartSpawning();
hasStartedSpawning = true;
spawnTriggered = true;
if (enableDebug) Debug.Log("[SA_SpawnMinions] Started spawning minions");
}
}
private void OnUpdate(vIFSMBehaviourController fsmBehaviour)
{
if (summoner != null && spawnOnAnimationEvent && !spawnTriggered)
{
if (summoner.IsSpawning)
{
spawnTriggered = true;
}
else if (animationEventTimeout > 0f && spawnRequestTime > 0f && (Time.time - spawnRequestTime) >= animationEventTimeout)
{
summoner.StartSpawning();
spawnTriggered = true;
if (enableDebug) Debug.Log("[SA_SpawnMinions] Animation event timeout - spawning fallback");
}
}
// If waiting for completion, keep state active until spawning is done
if (waitForCompletion && summoner != null && summoner.IsSpawning)
{
@@ -107,8 +140,14 @@ namespace DemonBoss.Summoner
summoner.StopSpawning();
if (enableDebug) Debug.Log("[SA_SpawnMinions] Spawning interrupted on state exit");
}
else if (summoner != null)
{
summoner.CancelSpawnRequest();
}
hasStartedSpawning = false;
spawnTriggered = false;
spawnRequestTime = -1f;
if (enableDebug) Debug.Log("[SA_SpawnMinions] State exited");
}
@@ -122,4 +161,4 @@ namespace DemonBoss.Summoner
return hasStartedSpawning && !summoner.IsSpawning;
}
}
}
}