Files
GameJamDungeon/src/enemy/state/states/EnemyLogic.State.Alive.cs

40 lines
1008 B
C#

using Chickensoft.Introspection;
using Godot;
namespace GameJamDungeon
{
public partial class EnemyLogic
{
public partial record State
{
[Meta, Id("enemy_logic_state_alive")]
public abstract partial record Alive : State, IGet<Input.HitByPlayer>, IGet<Input.AttackTimer>, IGet<Input.EnemyDefeated>
{
public Transition On(in Input.HitByPlayer input)
{
var enemy = Get<IEnemy>();
enemy.CurrentHP.OnNext(enemy.CurrentHP.Value - input.Damage);
GD.Print("Current HP: " + enemy.CurrentHP.Value);
Output(new Output.HitByPlayer());
Input(new Input.Alerted());
return ToSelf();
}
public Transition On(in Input.AttackTimer input)
{
Output(new Output.Attack());
return ToSelf();
}
public Transition On(in Input.EnemyDefeated input)
{
Output(new Output.Defeated());
return To<Defeated>();
}
}
}
}
}