mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-14 09:53:47 +00:00
Add FSM components for player and enemy state management, including initialization and module resolution
This commit is contained in:
parent
18683c0680
commit
b6cc5a00e8
57 changed files with 526 additions and 506 deletions
|
|
@ -8,17 +8,14 @@ public partial class Controlled : EnemyStateBase
|
|||
{
|
||||
public override EnemyState StateId => EnemyState.Controlled;
|
||||
|
||||
[Export]
|
||||
public EnemyStorageModule StorageModule { get; private set; }
|
||||
private EnemyStorageModule StorageModule { get; set; }
|
||||
|
||||
[Export]
|
||||
public GenericDamageReceiver DamageReceiver { get; private set; }
|
||||
private GenericDamageReceiver DamageReceiver { get; set; }
|
||||
|
||||
[Export]
|
||||
private InputProvider _inputProvider;
|
||||
|
||||
[Export]
|
||||
public PlayerCrosshairProvider CrosshairProvider { get; private set; }
|
||||
private PlayerCrosshairProvider CrosshairProvider { get; set; }
|
||||
|
||||
[Export] public Weapon EquippedWeapon { get; private set; }
|
||||
|
||||
|
|
@ -28,6 +25,14 @@ public partial class Controlled : EnemyStateBase
|
|||
|
||||
private bool _isStrafing = false;
|
||||
|
||||
public override void Init(IStateMachine<EnemyState, CharacterBody2D> machine)
|
||||
{
|
||||
base.Init(machine);
|
||||
StorageModule ??= StateMachine.GetModule<EnemyStorageModule>();
|
||||
DamageReceiver ??= StateMachine.GetModule<GenericDamageReceiver>();
|
||||
CrosshairProvider ??= StateMachine.GetModule<PlayerCrosshairProvider>();
|
||||
}
|
||||
|
||||
public override void EnterState()
|
||||
{
|
||||
base.EnterState();
|
||||
|
|
@ -80,10 +85,6 @@ public partial class Controlled : EnemyStateBase
|
|||
|
||||
if (Input.IsActionJustPressed(ControlEndAction))
|
||||
{
|
||||
// if (GameManager.Instance.ToggleControlMode() is GameState.Playing)
|
||||
// {
|
||||
// ResumeControl();
|
||||
// }
|
||||
StateMachine.SetState(EnemyState.Idle);
|
||||
}
|
||||
|
||||
|
|
@ -126,7 +127,6 @@ public partial class Controlled : EnemyStateBase
|
|||
|
||||
// Shoot at the player's last known position
|
||||
EquippedWeapon.ShootDirection = direction;
|
||||
//StorageModule.FacingDirection = direction;
|
||||
//StorageModule.FacingDirection = direction.SnapToCardinal().Normalized();
|
||||
|
||||
EquippedWeapon.Shoot(BulletOwner.Player);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue