Files
GameJamDungeon/Zennysoft.Game.Ma/src/enemy/state/states/EnemyLogic.State.Patrolling.cs

38 lines
910 B
C#

using Chickensoft.Introspection;
using Zennysoft.Ma.Adapter.Entity;
using static Zennysoft.Game.Ma.EnemyLogic.Input;
namespace Zennysoft.Game.Ma;
public partial class EnemyLogic
{
public partial record State
{
[Meta, Id("enemy_logic_state_patrolling")]
public partial record Patrolling : Alive, IGet<Alert>
{
public Patrolling()
{
OnAttach(() =>
{
var enemy = Get<IEnemy>();
if (enemy is IHavePatrolBehavior patrolEnemy)
{
patrolEnemy.PatrolBehavior.StartPatrol();
Output(new Output.Move());
}
});
OnDetach(() =>
{
var enemy = Get<IEnemy>();
if (enemy is IHavePatrolBehavior patrolEnemy)
{
patrolEnemy.PatrolBehavior.StopPatrol();
}
});
}
public Transition On(in Alert _) => To<Activated>();
}
}
}