mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Game state manager and restored inventory
This commit is contained in:
parent
f0f49f8fb4
commit
a0ec2f3d74
27 changed files with 1283 additions and 1175 deletions
|
|
@ -47,14 +47,15 @@ public partial class EnemyPossessionMovement : ActorFreeMovement
|
|||
{
|
||||
Shoot();
|
||||
}
|
||||
|
||||
if (GetActionJustPressed(ControlEndAction))
|
||||
{
|
||||
if (GameManager.Instance.ToggleControlMode() is GameState.Playing)
|
||||
{
|
||||
ResumeControl();
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Restore control
|
||||
// if (GetActionJustPressed(ControlEndAction))
|
||||
// {
|
||||
// if (GameManager.Instance.ToggleControlMode() is GameState.Playing)
|
||||
// {
|
||||
// ResumeControl();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
private void Shoot()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.Actors;
|
||||
|
|
@ -25,7 +26,7 @@ public partial class KeyboardInputProvider : InputProvider
|
|||
[Export] private StringName _nextWeaponActionName = "next_weapon";
|
||||
[Export] private StringName _previousWeaponActionName = "previous_weapon";
|
||||
[Export] private StringName _inventoryActionName = "inventory";
|
||||
[Export] private StringName _pauseActionName = "pause";
|
||||
|
||||
[Export] private StringName _freezeActionName = "Freeze";
|
||||
[Export] private StringName _reloadActionName = "Reload";
|
||||
|
||||
|
|
@ -54,20 +55,7 @@ public partial class KeyboardInputProvider : InputProvider
|
|||
GD.Print("Mouse aim provider is null");
|
||||
}
|
||||
|
||||
if (GameManager.Instance is null)
|
||||
{
|
||||
GD.Print("No GameManager found for keyboard inputprovider");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
GameManager.Instance.GameStateChange += InstanceOnGameStateChange;
|
||||
}
|
||||
|
||||
if (GameController.Instance is not null)
|
||||
{
|
||||
GameController.Instance.GameStateChange += InstanceOnGameStateChange;
|
||||
}
|
||||
GameStateManager.Instance.GameStateChange += InstanceOnGameStateChange;
|
||||
|
||||
_enabled = true;
|
||||
}
|
||||
|
|
@ -178,7 +166,7 @@ public partial class KeyboardInputProvider : InputProvider
|
|||
|
||||
public override bool GetPauseJustPressed()
|
||||
{
|
||||
return GetActionJustPressed(_pauseActionName);
|
||||
return GlobalInputManager.IsPauseJustPressed();
|
||||
}
|
||||
|
||||
public override bool GetFreezeJustPressed()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
using Godot;
|
||||
using Cirno.Scripts.Components.Actors;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.FSM._3DPlayer;
|
||||
|
||||
|
|
@ -7,6 +9,7 @@ public partial class Active : BaseState<PlayerState, CharacterBody3D>
|
|||
public override PlayerState StateId => PlayerState.Active;
|
||||
|
||||
private CharacterBody3D _player;
|
||||
[Export] private InputProvider _inputProvider;
|
||||
|
||||
public override void Init(IStateMachine<PlayerState, CharacterBody3D> machine)
|
||||
{
|
||||
|
|
@ -84,12 +87,28 @@ public partial class Active : BaseState<PlayerState, CharacterBody3D>
|
|||
{
|
||||
base.ProcessState(delta);
|
||||
|
||||
HandleInputHotkeys();
|
||||
}
|
||||
|
||||
private void HandleInputHotkeys()
|
||||
{
|
||||
if (_inputProvider.GetInventoryJustPressed())
|
||||
{
|
||||
GameStateManager.SetState(GameState.Inventory);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_inputProvider.GetPauseJustPressed())
|
||||
{
|
||||
GameStateManager.Instance.Pause();
|
||||
//PauseDeferred();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void PauseDeferred()
|
||||
{
|
||||
GameManager.Instance.Pause();
|
||||
GameStateManager.Instance.Pause();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using Cirno.Scripts.Components.Actors;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.FSM.Player;
|
||||
|
|
@ -180,7 +181,7 @@ public partial class Active : PlayerStateBase
|
|||
|
||||
if (_inputProvider.GetInventoryJustPressed())
|
||||
{
|
||||
GameManager.Instance.ChangeState(GameState.Inventory);
|
||||
GameStateManager.SetState(GameState.Inventory);
|
||||
}
|
||||
|
||||
if (_inputProvider.GetPauseJustPressed())
|
||||
|
|
@ -192,7 +193,7 @@ public partial class Active : PlayerStateBase
|
|||
|
||||
private void PauseDeferred()
|
||||
{
|
||||
GameManager.Instance.Pause();
|
||||
GameStateManager.Instance.Pause();
|
||||
}
|
||||
|
||||
private void HandleShoot()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Cirno.Scripts.Components.Actors;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot;
|
||||
|
||||
namespace Cirno.Scripts.Components.FSM.Player.Hacking;
|
||||
|
|
@ -180,7 +181,7 @@ public partial class HackingActive : PlayerStateBase
|
|||
|
||||
if (_inputProvider.GetInventoryJustPressed())
|
||||
{
|
||||
GameManager.Instance.ChangeState(GameState.Inventory);
|
||||
GameStateManager.SetState(GameState.Inventory);
|
||||
}
|
||||
|
||||
if (_inputProvider.GetPauseJustPressed())
|
||||
|
|
@ -192,7 +193,7 @@ public partial class HackingActive : PlayerStateBase
|
|||
|
||||
private void PauseDeferred()
|
||||
{
|
||||
GameManager.Instance.Pause();
|
||||
GameStateManager.Instance.Pause();
|
||||
}
|
||||
|
||||
private void HandleShoot()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue