Overhaul item and inventory and clean up bits and pieces

This commit is contained in:
2026-02-15 01:19:27 -08:00
parent a1f4a29eb3
commit 69b25aacb9
219 changed files with 4378 additions and 2355 deletions

View File

@@ -7,7 +7,6 @@ using Chickensoft.SaveFileBuilder;
using Godot;
using System;
using System.Text.Json;
using Zennysoft.Game.Abstractions;
using Zennysoft.Ma.Adapter;
using System.IO;
using System.Threading.Tasks;
@@ -158,9 +157,7 @@ public partial class Game : Node3D, IGame
GameState.Set(_player);
GameState.Set(_map);
GameState.Set(InGameUI);
GameRepo.Resume();
InGameUI.Show();
HandleGameLogic();
GameState.Start();
this.Provide();
@@ -189,6 +186,8 @@ public partial class Game : Node3D, IGame
GameRepo.IsPaused.Sync += IsPaused_Sync;
InGameUI.PlayerInfoUI.Activate();
InGameUI.Show();
GameRepo.Resume();
}
private void GameRepo_EnemyDied(IEnemy obj)
@@ -210,14 +209,13 @@ public partial class Game : Node3D, IGame
_effectService = new EffectService(this, _player, _map);
_player.Activate();
await _map.LoadFloor();
GameLoaded?.Invoke();
}
public async Task Save() => await SaveFile.Save();
public void FloorExitReached() => GameState.Input(new GameState.Input.FloorExitEntered());
public async Task UseItem(InventoryItem item)
public async Task UseItem(IBaseInventoryItem item)
{
if (item.ItemTag == ItemTag.MysteryItem)
_effectService.RerollItem(item);
@@ -234,13 +232,10 @@ public partial class Game : Node3D, IGame
EnactEffectItemEffects(effectItem);
break;
}
await ToSignal(GetTree().CreateTimer(0.3f), "timeout");
RemoveItemOrSubtractFromItemCount(item);
}
public void DropItem(InventoryItem item)
public void DropItem(IBaseInventoryItem item)
{
var droppedScene = GD.Load<PackedScene>("res://src/items/dropped/DroppedItem.tscn");
var dropped = droppedScene.Instantiate<DroppedItem>();
@@ -250,7 +245,7 @@ public partial class Game : Node3D, IGame
_player.Inventory.Remove(item);
}
public void SetItem(InventoryItem item)
public void SetItem(IBaseInventoryItem item)
{
var setScene = GD.Load<PackedScene>("res://src/items/misc/SetItem.tscn");
var setItem = setScene.Instantiate<SetItem>();
@@ -259,7 +254,7 @@ public partial class Game : Node3D, IGame
_player.Inventory.Remove(item);
}
public void ThrowItem(InventoryItem item)
public void ThrowItem(IBaseInventoryItem item)
{
var thrownScene = GD.Load<PackedScene>("res://src/items/thrown/ThrownItem.tscn");
var thrown = thrownScene.Instantiate<ThrownItem>();
@@ -399,7 +394,10 @@ public partial class Game : Node3D, IGame
InGameUI.InventoryMenu.SetProcessInput(false);
}
private async void LoadLevel() => await _map.LoadFloor();
private async void LoadLevel()
{
await _map.LoadFloor();
}
private void FloorClearMenu_GoToNextFloor() => GameState.Input(new GameState.Input.LoadNextFloor());
@@ -420,7 +418,6 @@ public partial class Game : Node3D, IGame
private void UseTeleportPrompt_TeleportToNextFloor()
{
//_player.LookUp();
GameState.Input(new GameState.Input.UseTeleport());
}
@@ -459,10 +456,10 @@ public partial class Game : Node3D, IGame
_player.Inventory.TryAdd(_effectService.GetRandomItemOfType<ConsumableItem>());
break;
case ItemTag.DropTo1HPAndGainRareItem:
_effectService.DropTo1HPAndGainRareItem<InventoryItem>();
_effectService.DropTo1HPAndGainRareItem<IBaseInventoryItem>();
break;
case ItemTag.TradeAllRandomItems:
var newInventory = _effectService.TradeAllRandomItems<InventoryItem>(boxItem);
var newInventory = _effectService.TradeAllRandomItems(boxItem);
_player.Inventory.Items.Clear();
_player.Inventory.TryAdd(boxItem);
foreach (var item in newInventory)
@@ -472,7 +469,7 @@ public partial class Game : Node3D, IGame
_effectService.GetUnobtainedItem();
break;
case ItemTag.ContainsBasicItem:
_effectService.GetBasicItem<InventoryItem>();
_effectService.GetBasicItem<IBaseInventoryItem>();
break;
case ItemTag.UnequipAllItems:
_player.EquipmentComponent.Unequip(_player.EquipmentComponent.EquippedWeapon.Value);
@@ -567,7 +564,7 @@ public partial class Game : Node3D, IGame
}
}
private void RemoveItemOrSubtractFromItemCount(InventoryItem item)
private void RemoveItemOrSubtractFromItemCount(IBaseInventoryItem item)
{
if (item is IStackable stackableItem && stackableItem.Count.Value > 1)
stackableItem.SetCount(stackableItem.Count.Value - 1);
@@ -589,6 +586,8 @@ public partial class Game : Node3D, IGame
private void OnFloorLoadFinished()
{
LoadNextLevel.Hide();
GameLoaded?.Invoke();
_map.FadeIn();
}
private void OnQuit() => GameExitRequested?.Invoke();

View File

@@ -11,11 +11,11 @@ process_mode = 3
script = ExtResource("1_ytcii")
[node name="SubViewportContainer" type="SubViewportContainer" parent="."]
custom_minimum_size = Vector2(1440, 1080)
custom_minimum_size = Vector2(1456, 1080)
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = -480.0
offset_right = -464.0
grow_horizontal = 2
grow_vertical = 2
stretch = true
@@ -23,7 +23,7 @@ stretch = true
[node name="SubViewport" type="SubViewport" parent="SubViewportContainer"]
handle_input_locally = false
audio_listener_enable_3d = true
size = Vector2i(1440, 1080)
size = Vector2i(1456, 1080)
render_target_update_mode = 4
[node name="PauseContainer" type="Node3D" parent="SubViewportContainer/SubViewport"]

View File

@@ -18,13 +18,13 @@ public interface IGame : IProvide<IGame>, IProvide<IGameRepo>, IProvide<IPlayer>
public IDungeonFloor CurrentFloor { get; }
public Task UseItem(InventoryItem item);
public Task UseItem(IBaseInventoryItem item);
public void DropItem(InventoryItem item);
public void DropItem(IBaseInventoryItem item);
public void SetItem(InventoryItem item);
public void SetItem(IBaseInventoryItem item);
public void ThrowItem(InventoryItem item);
public void ThrowItem(IBaseInventoryItem item);
public void FloorExitReached();