34 lines
837 B
C#
34 lines
837 B
C#
using Chickensoft.Introspection;
|
|
using Godot;
|
|
|
|
namespace GameJamDungeon;
|
|
|
|
public partial class EnemyLogic
|
|
{
|
|
public partial record State
|
|
{
|
|
[Meta, Id("enemy_logic_state_idle")]
|
|
public partial record Idle : Alive, IGet<Input.Alerted>, IGet<Input.PhysicsTick>, IGet<Input.PatrolToRandomSpot>
|
|
{
|
|
private Vector3 _patrolTarget { get; set; }
|
|
public Transition On(in Input.Alerted _)
|
|
{
|
|
return To<FollowPlayer>();
|
|
}
|
|
|
|
public Transition On(in Input.PhysicsTick input)
|
|
{
|
|
var delta = input.Delta;
|
|
var enemy = Get<IEnemy>();
|
|
enemy.MoveToLocation(_patrolTarget, (float)delta);
|
|
return ToSelf();
|
|
}
|
|
|
|
public Transition On(in Input.PatrolToRandomSpot input)
|
|
{
|
|
_patrolTarget = input.PatrolTarget;
|
|
return ToSelf();
|
|
}
|
|
}
|
|
}
|
|
} |