mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
60 lines
No EOL
1.5 KiB
C#
60 lines
No EOL
1.5 KiB
C#
using Cirno.Scripts.Components.FSM;
|
|
using Cirno.Scripts.Components.FSM.Player;
|
|
using Godot;
|
|
|
|
namespace Cirno.Scripts.Components.Actors;
|
|
|
|
public partial class PlayerCrosshairProvider : PlayerNode2DModule
|
|
{
|
|
[Export] public PlayerStorageModule StorageModule { get; set; }
|
|
[Export]
|
|
public AnimatedSprite2D AnimatedSprite { get; private set; }
|
|
|
|
[Export]
|
|
public float CrosshairDistance { get; private set; }
|
|
|
|
public bool Enabled { get; set; } = false;
|
|
public void UpdatePosition(Vector2 facingDirection)
|
|
{
|
|
AnimatedSprite.Position = CalculateCrosshairPosition(facingDirection);
|
|
}
|
|
|
|
private Vector2 CalculateCrosshairPosition(Vector2 facingDirection)
|
|
{
|
|
return facingDirection * CrosshairDistance;
|
|
}
|
|
|
|
public override void EnterState(PlayerState state)
|
|
{
|
|
Enabled = true;
|
|
AnimatedSprite.Show();
|
|
}
|
|
|
|
public override void ExitState(PlayerState state)
|
|
{
|
|
Enabled = false;
|
|
AnimatedSprite.Hide();
|
|
}
|
|
|
|
public override void _Ready()
|
|
{
|
|
AnimatedSprite.Hide();
|
|
}
|
|
|
|
public override void Init(IStateMachine<PlayerState, CharacterBody2D> machine)
|
|
{
|
|
AnimatedSprite.Hide();
|
|
}
|
|
|
|
public override void Process(double delta)
|
|
{
|
|
if (!Enabled) return;
|
|
|
|
}
|
|
|
|
public override void PhysicsProcess(double delta)
|
|
{
|
|
if (!Enabled) return;
|
|
AnimatedSprite.Position = CalculateCrosshairPosition(StorageModule.FacingDirection);
|
|
}
|
|
} |