Fix up item usage

This commit is contained in:
2025-03-07 18:40:14 -08:00
parent 93c04440d4
commit fe3c539a62
15 changed files with 125 additions and 65 deletions

View File

@@ -14,6 +14,7 @@ using Zennysoft.Game.Ma.Implementation;
using System.IO;
using SimpleInjector;
using static Zennysoft.Game.Ma.Implementation.GameLogic.State;
using System.Threading.Tasks;
[Meta(typeof(IAutoNode))]
public partial class Game : Node3D, IGame
@@ -266,7 +267,7 @@ public partial class Game : Node3D, IGame
GameEventDepot.OnTeleportEntered();
}
public void UseItem(InventoryItem item)
public async Task UseItem(IInventoryItem item)
{
if (item is ConsumableItem consumableItem)
{
@@ -338,9 +339,12 @@ public partial class Game : Node3D, IGame
if (throwableItem.ThrowableItemTag == ThrowableItemTag.WarpToExitIfFound)
_effectService.WarpToExit(Player);
}
await ToSignal(GetTree().CreateTimer(1f), "timeout");
GameRepo.RemoveItemFromInventory(item);
}
public void DropItem(InventoryItem item)
public void DropItem(IInventoryItem item)
{
var droppedScene = GD.Load<PackedScene>("res://src/items/dropped/DroppedItem.tscn");
var dropped = droppedScene.Instantiate<DroppedItem>();
@@ -349,7 +353,7 @@ public partial class Game : Node3D, IGame
dropped.Drop();
}
public void ThrowItem(InventoryItem item)
public void ThrowItem(IInventoryItem item)
{
var thrownScene = GD.Load<PackedScene>("res://src/items/thrown/ThrownItem.tscn");
var thrown = thrownScene.Instantiate<ThrownItem>();
@@ -359,11 +363,6 @@ public partial class Game : Node3D, IGame
thrown.Throw(_effectService);
}
public void AnnounceMessageOnInventoryScreen(string message)
{
InGameUI.InventoryMenu.ShowMessage(message);
}
public IDungeonFloor CurrentFloor => Map.CurrentFloor;
public void EnemyDefeated(Vector3 defeatedLocation, EnemyStatResource resource)

View File

@@ -5,6 +5,8 @@ using Chickensoft.AutoInject;
using Chickensoft.GodotNodeInterfaces;
using Chickensoft.SaveFileBuilder;
using Godot;
using System.Threading.Tasks;
using Zennysoft.Game.Abstractions;
using Zennysoft.Game.Ma.Implementation;
public interface IGame : IProvide<IGameRepo>, IProvide<IGameEventDepot>, IProvide<IGame>, IProvide<IPlayer>, IProvide<ISaveChunk<GameData>>, INode3D
@@ -19,18 +21,16 @@ public interface IGame : IProvide<IGameRepo>, IProvide<IGameEventDepot>, IProvid
public IDungeonFloor CurrentFloor { get; }
public void UseItem(InventoryItem item);
public Task UseItem(IInventoryItem item);
public void DropItem(InventoryItem item);
public void DropItem(IInventoryItem item);
public void ThrowItem(InventoryItem item);
public void ThrowItem(IInventoryItem item);
public void ToggleInventory();
public void ToggleMinimap();
public void AnnounceMessageOnInventoryScreen(string message);
public void FloorExitReached();
public void NextFloorLoaded();