推进计时器逻辑的集中管理

- 将敌人的攻击计时任务放到基类中进行创建
- 将 EnemySpawnScheduler 敌人生成调度器的刷怪计时任务迁移到 TimerComponent
This commit is contained in:
2026-06-23 20:42:24 +08:00
parent 846e4d6f44
commit cc8982b131
6 changed files with 69 additions and 93 deletions
@@ -58,6 +58,7 @@ namespace SepCore.EnemyManager
_spawnCts?.Dispose();
_spawnCts = null;
_enemyRegistry = null;
_spawnScheduler?.Reset();
_spawnScheduler = null;
_entity = null;
}
@@ -71,7 +72,7 @@ namespace SepCore.EnemyManager
_duration = _baseDuration;
_currentLevel = level.Id;
_spawnScheduler.Init(level);
_spawnScheduler.Init(level, OnWaveSpawn);
_enemyRegistry.Clear();
_currentSpawnEnemyId = 0;
}
@@ -79,13 +80,14 @@ namespace SepCore.EnemyManager
public void OnUpdate(float elapseSeconds, float realElapseSeconds)
{
_enemyRegistry.PruneInvalidEntries();
var spawnRequests = _spawnScheduler.Tick(elapseSeconds);
foreach (var request in spawnRequests)
_spawnScheduler.Tick(elapseSeconds);
}
private void OnWaveSpawn(EnemyType enemyType, int count)
{
for (int j = 0; j < count; j++)
{
for (int j = 0; j < request.Count; j++)
{
SpawnEnemyAsync(request.EnemyType).Forget();
}
SpawnEnemyAsync(enemyType).Forget();
}
}