31 lines
769 B
C#
31 lines
769 B
C#
using Chickensoft.Introspection;
|
|
using Godot;
|
|
|
|
namespace GameJamDungeon
|
|
{
|
|
public partial class EnemyLogic
|
|
{
|
|
public partial record State
|
|
{
|
|
[Meta, Id("enemy_logic_state_followplayer")]
|
|
public partial record FollowPlayer : Alive, IGet<Input.PhysicsTick>, IGet<Input.LostPlayer>
|
|
{
|
|
public Transition On(in Input.PhysicsTick input)
|
|
{
|
|
var delta = input.Delta;
|
|
var enemy = Get<IEnemy>();
|
|
var gameRepo = Get<IGameRepo>();
|
|
var target = gameRepo.PlayerGlobalPosition.Value;
|
|
enemy.MoveToLocation(target, (float)delta);
|
|
return ToSelf();
|
|
}
|
|
|
|
public Transition On(in Input.LostPlayer input)
|
|
{
|
|
return To<Idle>();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|