2025-03-21 15:16:50 +01:00
|
|
|
|
using Cirno.Scripts.Enums;
|
|
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Cirno.Scripts.Components.FSM.Enemy;
|
|
|
|
|
|
|
|
|
|
|
|
public partial class AnimationModule : ModuleBase<EnemyState, CharacterBody2D>
|
|
|
|
|
|
{
|
|
|
|
|
|
private IStateMachine<EnemyState, CharacterBody2D> _machine;
|
|
|
|
|
|
|
|
|
|
|
|
[Export] public PlayerAnimationProvider AnimationProvider { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[Export] public EnemyStorageModule StorageModule { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public override void EnterState(EnemyState state)
|
|
|
|
|
|
{
|
2025-04-08 10:44:06 +02:00
|
|
|
|
AnimationProvider.SetAnimation(StorageModule.AimingDirection);
|
2025-03-21 15:16:50 +01:00
|
|
|
|
AnimationProvider.SetAnimation(Vector2.Zero);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void ExitState(EnemyState state)
|
|
|
|
|
|
{
|
|
|
|
|
|
AnimationProvider.SetAnimation(Vector2.Zero);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Init(IStateMachine<EnemyState, CharacterBody2D> machine)
|
|
|
|
|
|
{
|
|
|
|
|
|
_machine = machine;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Process(double delta)
|
|
|
|
|
|
{
|
2025-04-08 10:44:06 +02:00
|
|
|
|
AnimationProvider.SetAnimation(StorageModule.AimingDirection);
|
2025-03-21 15:16:50 +01:00
|
|
|
|
|
|
|
|
|
|
if (_machine.MainObject.Velocity == Vector2.Zero)
|
|
|
|
|
|
{
|
|
|
|
|
|
AnimationProvider.SetAnimation(Vector2.Zero);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void PhysicsProcess(double delta)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|