Refactor inventory menu logic
This commit is contained in:
@@ -4,7 +4,6 @@ namespace Zennysoft.Game.Ma;
|
||||
using Chickensoft.AutoInject;
|
||||
using Chickensoft.Introspection;
|
||||
using Chickensoft.SaveFileBuilder;
|
||||
using Zennysoft.Game.Ma.src.items;
|
||||
using Godot;
|
||||
using System;
|
||||
using System.IO.Abstractions;
|
||||
@@ -193,8 +192,6 @@ public partial class Game : Node3D, IGame
|
||||
.Handle((in GameLogic.Output.LoadMap _) => { Map.LoadMap(); })
|
||||
.Handle((in GameLogic.Output.ShowFloorClearMenu _) => { FloorClearMenu.Show(); FloorClearMenu.FadeIn(); })
|
||||
.Handle((in GameLogic.Output.ExitFloorClearMenu _) => { FloorClearMenu.FadeOut(); })
|
||||
.Handle((in GameLogic.Output.OpenInventory _) => { InGameUI.ShowInventoryScreen(); InGameUI.InventoryMenu.SetProcessInput(true); })
|
||||
.Handle((in GameLogic.Output.CloseInventory _) => { InGameUI.HideInventoryScreen(); InGameUI.InventoryMenu.SetProcessInput(false); })
|
||||
.Handle((in GameLogic.Output.ShowAskForTeleport _) => { GameRepo.Pause(); InGameUI.UseTeleportPrompt.FadeIn(); InGameUI.SetProcessInput(true); })
|
||||
.Handle((in GameLogic.Output.HideAskForTeleport _) => { GameRepo.Resume(); InGameUI.UseTeleportPrompt.FadeOut(); InGameUI.SetProcessInput(false); })
|
||||
.Handle((in GameLogic.Output.ShowLostScreen _) => { DeathMenu.Show(); DeathMenu.FadeIn(); })
|
||||
@@ -215,7 +212,6 @@ public partial class Game : Node3D, IGame
|
||||
|
||||
PauseMenu.TransitionCompleted += OnPauseMenuTransitioned;
|
||||
PauseMenu.UnpauseButtonPressed += PauseMenu_UnpauseButtonPressed;
|
||||
InGameUI.InventoryMenu.ClosedMenu += InventoryMenu_CloseInventory;
|
||||
|
||||
InGameUI.UseTeleportPrompt.TeleportToNextFloor += UseTeleportPrompt_TeleportToNextFloor;
|
||||
InGameUI.UseTeleportPrompt.CloseTeleportPrompt += UseTeleportPrompt_CloseTeleportPrompt;
|
||||
@@ -245,14 +241,6 @@ public partial class Game : Node3D, IGame
|
||||
GameLogic.Input(new GameLogic.Input.PauseGame());
|
||||
}
|
||||
|
||||
public void ToggleInventory()
|
||||
{
|
||||
if (GameLogic.Value is InventoryOpened)
|
||||
GameLogic.Input(new GameLogic.Input.CloseInventory());
|
||||
else
|
||||
GameLogic.Input(new GameLogic.Input.OpenInventory());
|
||||
}
|
||||
|
||||
public void FloorExitReached()
|
||||
{
|
||||
GameLogic.Input(new GameLogic.Input.AskForTeleport());
|
||||
@@ -314,22 +302,28 @@ public partial class Game : Node3D, IGame
|
||||
}
|
||||
if (item is ThrowableItem throwableItem)
|
||||
{
|
||||
if (throwableItem.ThrowableItemTag == ThrowableItemTag.DoubleExp)
|
||||
GameRepo.StartDoubleEXP(TimeSpan.FromSeconds(30));
|
||||
switch (throwableItem.ThrowableItemTag)
|
||||
{
|
||||
case ThrowableItemTag.DoubleExp:
|
||||
GameRepo.StartDoubleEXP(TimeSpan.FromSeconds(30));
|
||||
break;
|
||||
case ThrowableItemTag.TeleportToRandomLocation:
|
||||
_effectService.TeleportToRandomRoom(Player);
|
||||
InGameUI.CloseInventory();
|
||||
break;
|
||||
case ThrowableItemTag.CanChangeAffinity:
|
||||
_effectService.ChangeAffinity(throwableItem);
|
||||
break;
|
||||
case ThrowableItemTag.WarpToExitIfFound:
|
||||
_effectService.WarpToExit(Player);
|
||||
InGameUI.CloseInventory();
|
||||
break;
|
||||
}
|
||||
|
||||
if (throwableItem.HealHPAmount > 0)
|
||||
Player.HealHP(throwableItem.HealHPAmount);
|
||||
if (throwableItem.HealVTAmount > 0)
|
||||
Player.HealVT(throwableItem.HealVTAmount);
|
||||
|
||||
if (throwableItem.ThrowableItemTag == ThrowableItemTag.TeleportToRandomLocation)
|
||||
_effectService.TeleportToRandomRoom(Player);
|
||||
|
||||
if (throwableItem.ThrowableItemTag == ThrowableItemTag.CanChangeAffinity)
|
||||
_effectService.ChangeAffinity(throwableItem);
|
||||
|
||||
if (throwableItem.ThrowableItemTag == ThrowableItemTag.WarpToExitIfFound)
|
||||
_effectService.WarpToExit(Player);
|
||||
}
|
||||
|
||||
await ToSignal(GetTree().CreateTimer(1f), "timeout");
|
||||
@@ -427,8 +421,6 @@ public partial class Game : Node3D, IGame
|
||||
GameRepo.EndDoubleExp();
|
||||
}
|
||||
|
||||
private void InventoryMenu_CloseInventory() => GameLogic.Input(new GameLogic.Input.CloseInventory());
|
||||
|
||||
public void NextFloorLoaded()
|
||||
{
|
||||
GameLogic.Input(new GameLogic.Input.HideFloorClearMenu());
|
||||
|
||||
@@ -27,8 +27,6 @@ public interface IGame : IProvide<IGameRepo>, IProvide<IGameEventDepot>, IProvid
|
||||
|
||||
public void ThrowItem(IInventoryItem item);
|
||||
|
||||
public void ToggleInventory();
|
||||
|
||||
public void FloorExitReached();
|
||||
|
||||
public void NextFloorLoaded();
|
||||
|
||||
Reference in New Issue
Block a user