mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-06 12:15:55 +00:00
Fix for immediately closing inventory
This commit is contained in:
parent
f1b5251045
commit
c11acda1df
4 changed files with 93 additions and 26 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using Cirno.Scripts.Components.Actors;
|
||||
using System.Threading.Tasks;
|
||||
using Cirno.Scripts.Components.Actors;
|
||||
using Cirno.Scripts.Components.Actors._3D;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot;
|
||||
|
|
@ -62,7 +63,8 @@ public partial class Active : BaseState<PlayerState, CharacterBody3D>
|
|||
//_activationProvider.Enabled = true;
|
||||
//_interactionController.Enabled = true;
|
||||
|
||||
|
||||
_canOpenInventory = true;
|
||||
_inventoryCooldown = 0;
|
||||
}
|
||||
|
||||
public override void ExitState()
|
||||
|
|
@ -74,11 +76,11 @@ public partial class Active : BaseState<PlayerState, CharacterBody3D>
|
|||
// _hitboxSpriteProvider.Hide();
|
||||
//
|
||||
DamageReceiver.Enabled = false;
|
||||
|
||||
_canOpenInventory = true;
|
||||
// _activationProvider.Enabled = false;
|
||||
// _interactionController.Enabled = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void PhysicsProcessState(double delta)
|
||||
{
|
||||
|
|
@ -87,36 +89,54 @@ public partial class Active : BaseState<PlayerState, CharacterBody3D>
|
|||
|
||||
// Process modules
|
||||
base.PhysicsProcessState(delta);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override void ProcessState(double delta)
|
||||
{
|
||||
base.ProcessState(delta);
|
||||
|
||||
HandleInputHotkeys();
|
||||
HandleInputHotkeys(delta);
|
||||
|
||||
AnimationProvider.SetAnimationSpeed(new Vector2(MainObject.Velocity.X, MainObject.Velocity.Z));
|
||||
AnimationProvider.SetAnimation(Storage.FacingDirection);
|
||||
}
|
||||
|
||||
private bool _canOpenInventory = true;
|
||||
private double _inventoryCooldown = 0;
|
||||
|
||||
private void HandleInputHotkeys()
|
||||
private void HandleInputHotkeys(double delta)
|
||||
{
|
||||
if (_inputProvider.GetInventoryJustPressed())
|
||||
if (_canOpenInventory && _inputProvider.GetInventoryJustPressed())
|
||||
{
|
||||
_canOpenInventory = false;
|
||||
|
||||
GameStateManager.SetState(GameState.Inventory);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_canOpenInventory)
|
||||
{
|
||||
_inventoryCooldown += delta;
|
||||
if (_inventoryCooldown >= 0.2)
|
||||
{
|
||||
_canOpenInventory = true;
|
||||
_inventoryCooldown = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (_inputProvider.GetPauseJustPressed())
|
||||
{
|
||||
GameStateManager.Instance.Pause();
|
||||
//PauseDeferred();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void InventoryDeferred()
|
||||
{
|
||||
GameStateManager.SetState(GameState.Inventory);
|
||||
}
|
||||
|
||||
private void PauseDeferred()
|
||||
{
|
||||
GameStateManager.Instance.Pause();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue