多轮审查和修复
This commit is contained in:
26
Assets/Scripts/Enemies/States/EnemyHurtState.cs
Normal file
26
Assets/Scripts/Enemies/States/EnemyHurtState.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
namespace BaseGames.Enemies.States
|
||||
{
|
||||
/// <summary>
|
||||
/// 受击状态。播放受击动画,动画结束后自动回到 Controlled。
|
||||
/// 原 EnemyBase.ForceState 中的 Hurt if-else 逻辑已迁移至此。
|
||||
/// </summary>
|
||||
public sealed class EnemyHurtState : IEnemyState
|
||||
{
|
||||
public EnemyStateType StateType => EnemyStateType.Hurt;
|
||||
|
||||
public void Enter(EnemyBase owner)
|
||||
{
|
||||
if (owner.Animancer == null || owner.AnimConfig?.Hurt == null) return;
|
||||
|
||||
var animState = owner.Animancer.Play(owner.AnimConfig.Hurt);
|
||||
animState.Events(owner).OnEnd = () =>
|
||||
{
|
||||
// 只在仍处于 Hurt 时才回 Controlled,避免 Die 时被覆盖
|
||||
if (owner.CurrentState == EnemyStateType.Hurt)
|
||||
owner.ForceState(EnemyStateType.Controlled);
|
||||
};
|
||||
}
|
||||
|
||||
public void Exit(EnemyBase owner) { }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user