mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:45:33 +00:00
2D Character and weapons
This commit is contained in:
parent
072f6d0ce6
commit
cc9c4e5aa1
37 changed files with 1115 additions and 91 deletions
70
Scripts/Components/FSM/3DPlayer/PlayerWeaponModule3D.cs
Normal file
70
Scripts/Components/FSM/3DPlayer/PlayerWeaponModule3D.cs
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
using Cirno.Scripts.Components.Actors;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.FSM._3DPlayer;
|
||||
|
||||
public partial class PlayerWeaponModule3D : ModuleBase<PlayerState, CharacterBody3D>
|
||||
{
|
||||
[Export] public PlayerWeaponProvider3D WeaponProvider { get; private set; }
|
||||
|
||||
[Export] public InputProvider InputProvider { get; private set; }
|
||||
[Export] public IsoPlayerStorageModule Storage { get; private set; }
|
||||
|
||||
private IStateMachine<PlayerState, CharacterBody3D> _stateMachine;
|
||||
private CharacterBody3D MainObject => _stateMachine.MainObject;
|
||||
|
||||
public override void EnterState(PlayerState state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void ExitState(PlayerState state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Init(IStateMachine<PlayerState, CharacterBody3D> machine)
|
||||
{
|
||||
_stateMachine = machine;
|
||||
|
||||
WeaponProvider.Init(MainObject);
|
||||
}
|
||||
|
||||
public override void Process(double delta)
|
||||
{
|
||||
WeaponProvider.Update(delta);
|
||||
|
||||
HandleShoot();
|
||||
|
||||
HandleWeaponSwitch();
|
||||
}
|
||||
|
||||
public override void PhysicsProcess(double delta)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void HandleShoot()
|
||||
{
|
||||
if (InputProvider.GetReloadJustPressed())
|
||||
{
|
||||
WeaponProvider.Reload();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!InputProvider.GetShootPressed()) return;
|
||||
WeaponProvider.Shoot(Storage.AimingDirection);
|
||||
}
|
||||
|
||||
private void HandleWeaponSwitch()
|
||||
{
|
||||
if (InputProvider.GetWeaponNextJustPressed())
|
||||
{
|
||||
WeaponProvider.NextWeapon();
|
||||
}
|
||||
else if (InputProvider.GetWeaponPreviousJustPressed())
|
||||
{
|
||||
WeaponProvider.PreviousWeapon();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue