mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-05 15:15:54 +00:00
Enemy FSM Animation
This commit is contained in:
parent
dd3d427ac3
commit
e7c1814d98
12 changed files with 161 additions and 6 deletions
44
Scripts/Components/FSM/Enemy/AnimationModule.cs
Normal file
44
Scripts/Components/FSM/Enemy/AnimationModule.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
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)
|
||||
{
|
||||
AnimationProvider.SetAnimation(StorageModule.FacingDirection);
|
||||
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)
|
||||
{
|
||||
AnimationProvider.SetAnimation(StorageModule.FacingDirection);
|
||||
|
||||
if (_machine.MainObject.Velocity == Vector2.Zero)
|
||||
{
|
||||
AnimationProvider.SetAnimation(Vector2.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
public override void PhysicsProcess(double delta)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue