2026-02-26 23:13:57 +01:00
|
|
|
|
using Cirno.Scripts.Components.Actors;
|
2025-03-08 11:33:26 +01:00
|
|
|
|
using Cirno.Scripts.Resources;
|
|
|
|
|
|
using Godot;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Cirno.Scripts.Components.FSM.Player;
|
|
|
|
|
|
|
|
|
|
|
|
public partial class PlayerFSMItemUseModule : ModuleBase<PlayerState, CharacterBody2D>
|
|
|
|
|
|
{
|
2025-03-12 16:31:53 +01:00
|
|
|
|
[Export]
|
|
|
|
|
|
public ActorResourceProvider Health { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
[Export]
|
|
|
|
|
|
public ActorResourceProvider Shield { get; set; }
|
|
|
|
|
|
|
2026-02-26 23:13:57 +01:00
|
|
|
|
private PlayerStorageModule _storageModule;
|
2025-03-15 17:56:55 +01:00
|
|
|
|
|
|
|
|
|
|
public Vector2 FacingDirection
|
|
|
|
|
|
{
|
|
|
|
|
|
get => _storageModule.FacingDirection;
|
|
|
|
|
|
private set => _storageModule.FacingDirection = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-26 23:13:57 +01:00
|
|
|
|
public bool Enabled { get; set; }
|
2025-03-08 11:33:26 +01:00
|
|
|
|
|
|
|
|
|
|
public override void EnterState(PlayerState state)
|
|
|
|
|
|
{
|
|
|
|
|
|
Enabled = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void ExitState(PlayerState state)
|
|
|
|
|
|
{
|
|
|
|
|
|
Enabled = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private IStateMachine<PlayerState, CharacterBody2D> _machine;
|
2025-03-17 16:20:22 +01:00
|
|
|
|
public IStateMachine<PlayerState, CharacterBody2D> Machine => _machine;
|
2025-03-08 11:33:26 +01:00
|
|
|
|
|
|
|
|
|
|
public override void Init(IStateMachine<PlayerState, CharacterBody2D> machine)
|
|
|
|
|
|
{
|
|
|
|
|
|
InventoryManager.Instance.ItemUsed += this.UseItem;
|
|
|
|
|
|
_machine = machine;
|
2026-02-26 23:13:57 +01:00
|
|
|
|
_storageModule ??= StateMachine.GetModule<PlayerStorageModule>();
|
2025-03-08 11:33:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void UseItem(LootItem item, int totalcount)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!Enabled) return;
|
2025-03-17 16:20:22 +01:00
|
|
|
|
GD.Print($"Used {item.ItemName} in player");
|
2025-03-08 11:33:26 +01:00
|
|
|
|
|
2025-03-17 16:20:22 +01:00
|
|
|
|
item.ItemEffect?.Execute(this, item);
|
2025-03-08 11:33:26 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Process(double delta)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void PhysicsProcess(double delta)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|