diff --git a/Zennysoft.Game.Ma.Implementation/Equipment/Tags/UsableItemTag.cs b/Zennysoft.Game.Ma.Implementation/Equipment/Tags/UsableItemTag.cs index 9b5992395..0031765c7 100644 --- a/Zennysoft.Game.Ma.Implementation/Equipment/Tags/UsableItemTag.cs +++ b/Zennysoft.Game.Ma.Implementation/Equipment/Tags/UsableItemTag.cs @@ -33,5 +33,7 @@ public enum UsableItemTag Clone, MeltAllEquipment, RestoreStats, - GlueAllEquipment + GlueAllEquipment, + DoubleStackedItems, + IdentifyRandomItem } diff --git a/Zennysoft.Game.Ma.Implementation/Item/RescuedItemDatabase.cs b/Zennysoft.Game.Ma.Implementation/Item/RescuedItemDatabase.cs index 2fbb225f9..6e360af1b 100644 --- a/Zennysoft.Game.Ma.Implementation/Item/RescuedItemDatabase.cs +++ b/Zennysoft.Game.Ma.Implementation/Item/RescuedItemDatabase.cs @@ -1,16 +1,38 @@ -using Chickensoft.Introspection; -using Chickensoft.Serialization; +using Chickensoft.Serialization; namespace Zennysoft.Ma.Adapter; -[Meta, Id("rescued_items")] -public partial class RescuedItemDatabase +public class RescuedItemDatabase { [Save("rescued_item_list")] - public List Items { get; init; } + private List _items { get; init; } + private int _maxSize { get; init; } = 20; - public RescuedItemDatabase() + public RescuedItemDatabase(int maxSize) { - Items = new List(); + _items = []; + _maxSize = maxSize; } + + public RescuedItemDatabase(List items, int maxSize) + { + _items = items; + _maxSize = maxSize; + } + + public bool TryAdd(IBaseInventoryItem item) + { + if (_items.Count >= _maxSize) + return false; + if (item is IEquipableItem equipable) + equipable.Glued = false; + _items.Add(item); + return true; + } + + public void Remove(IBaseInventoryItem item) => _items.Remove(item); + + public List GetItems() => _items; + + public void Clear() => _items.Clear(); } diff --git a/Zennysoft.Game.Ma/src/enemy/Enemy.cs b/Zennysoft.Game.Ma/src/enemy/Enemy.cs index d491acd4a..c98110f2f 100644 --- a/Zennysoft.Game.Ma/src/enemy/Enemy.cs +++ b/Zennysoft.Game.Ma/src/enemy/Enemy.cs @@ -180,7 +180,11 @@ public abstract partial class Enemy : CharacterBody3D, IEnemy, IProvide roomList) diff --git a/Zennysoft.Game.Ma/src/enemy/enemy_types/02. michael/Michael.tscn b/Zennysoft.Game.Ma/src/enemy/enemy_types/02. michael/Michael.tscn index 2e635b5e1..c53b58250 100644 --- a/Zennysoft.Game.Ma/src/enemy/enemy_types/02. michael/Michael.tscn +++ b/Zennysoft.Game.Ma/src/enemy/enemy_types/02. michael/Michael.tscn @@ -15,13 +15,14 @@ height = 5.0 radius = 1.0 [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_0h5s2"] +radius = 0.34933 height = 2.66932 [sub_resource type="CylinderShape3D" id="CylinderShape3D_eek1b"] radius = 1.0 [sub_resource type="SphereShape3D" id="SphereShape3D_wrps7"] -radius = 1.0 +radius = 0.552847 [node name="Michael" type="CharacterBody3D" groups=["enemy"]] process_mode = 1 diff --git a/Zennysoft.Game.Ma/src/enemy/enemy_types/09. Agni/AgniDemon.tscn b/Zennysoft.Game.Ma/src/enemy/enemy_types/09. Agni/AgniDemon.tscn index 6722194aa..5e4c36179 100644 --- a/Zennysoft.Game.Ma/src/enemy/enemy_types/09. Agni/AgniDemon.tscn +++ b/Zennysoft.Game.Ma/src/enemy/enemy_types/09. Agni/AgniDemon.tscn @@ -10,7 +10,7 @@ [ext_resource type="AudioStream" uid="uid://bf7adfdd857hw" path="res://src/audio/sfx/enemy_morph.ogg" id="8_jvw36"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_cwfph"] -radius = 1.6 +radius = 0.90501 height = 3.2 [sub_resource type="CylinderShape3D" id="CylinderShape3D_jbgmx"] diff --git a/Zennysoft.Game.Ma/src/game/Game.cs b/Zennysoft.Game.Ma/src/game/Game.cs index 3c79992e7..224b7714d 100644 --- a/Zennysoft.Game.Ma/src/game/Game.cs +++ b/Zennysoft.Game.Ma/src/game/Game.cs @@ -91,7 +91,7 @@ public partial class Game : Node3D, IGame GameState = _container.GetInstance(); QuestData = new QuestData(); - RescuedItems = new RescuedItemDatabase(); + RescuedItems = new RescuedItemDatabase(20); ItemDatabase = ItemDatabase.Instance; GameChunk = new SaveChunk( @@ -99,10 +99,7 @@ public partial class Game : Node3D, IGame { var gameData = new GameData() { - RescuedItems = new RescuedItemDatabase() - { - Items = RescuedItems.Items - }, + RescuedItems = new RescuedItemDatabase(RescuedItems.GetItems(), 20), QuestData = new QuestData() { DeathCount = QuestData.DeathCount, @@ -462,6 +459,9 @@ public partial class Game : Node3D, IGame case ItemTag.ContainsBox: _player.Inventory.TryAdd(_effectService.GetRandomItemOfType()); break; + case ItemTag.RandomSpell: + _player.Inventory.TryAdd(_effectService.GetRandomItemOfType()); + break; case ItemTag.ContainsRestorative: _player.Inventory.TryAdd(_effectService.GetRandomItemOfType()); break; @@ -502,7 +502,6 @@ public partial class Game : Node3D, IGame ThrowItem(item); _player.Inventory.Items.Clear(); GameRepo.CloseInventory(); - break; } } @@ -581,7 +580,7 @@ public partial class Game : Node3D, IGame _effectService.LowerCurrentArmorDefense(); break; case UsableItemTag.RandomEffect: - _effectService.RandomEffect(effectItem); + _effectService.RandomEffect(); break; case UsableItemTag.DoubleExp: _effectService.DoubleExp(); @@ -641,7 +640,23 @@ public partial class Game : Node3D, IGame _player.HealthComponent.SetCurrentHealth(1); SfxDatabase.Instance.Play(SoundEffect.DecreaseStat); break; + case UsableItemTag.DoubleStackedItems: + var stackableItems = _player.Inventory.Items.OfType().ToList(); + stackableItems.ForEach(x => x.Count.OnNext(x.Count.Value * 2)); + break; + case UsableItemTag.IdentifyRandomItem: + var unidentifiedItems = _player.Inventory.Items.Where(x => x.ItemTag == ItemTag.MysteryItem).ToList(); + if (!unidentifiedItems.Any()) + return; + var rng = new RandomNumberGenerator(); + rng.Randomize(); + var index = rng.RandiRange(0, unidentifiedItems.Count - 1); + _player.IdentifyItem(unidentifiedItems[index]); + break; } + _player.EquipmentComponent.UpdateEquipment(_player.EquipmentComponent.EquippedWeapon.Value); + _player.EquipmentComponent.UpdateEquipment(_player.EquipmentComponent.EquippedArmor.Value); + _player.EquipmentComponent.UpdateEquipment(_player.EquipmentComponent.EquippedAccessory.Value); } private void RemoveItemOrSubtractFromItemCount(IBaseInventoryItem item) diff --git a/Zennysoft.Game.Ma/src/item_rescue/RescuedItems.cs b/Zennysoft.Game.Ma/src/item_rescue/RescuedItems.cs index 47913b8ad..25ed9babc 100644 --- a/Zennysoft.Game.Ma/src/item_rescue/RescuedItems.cs +++ b/Zennysoft.Game.Ma/src/item_rescue/RescuedItems.cs @@ -41,7 +41,7 @@ public partial class RescuedItems : Node3D public void SpawnRescuedItems() { - foreach (var item in Game.RescuedItems.Items) + foreach (var item in Game.RescuedItems.GetItems().ToList()) { var droppedScene = GD.Load("res://src/items/dropped/DroppedItem.tscn"); var dropped = droppedScene.Instantiate(); @@ -51,7 +51,7 @@ public partial class RescuedItems : Node3D SpawnLocations.Remove(SpawnLocations.First()); } - Game.RescuedItems.Items.Clear(); + Game.RescuedItems.Clear(); } public override void _ExitTree() => base._ExitTree(); diff --git a/Zennysoft.Game.Ma/src/items/EffectService.cs b/Zennysoft.Game.Ma/src/items/EffectService.cs index 449d54ee4..43059a987 100644 --- a/Zennysoft.Game.Ma/src/items/EffectService.cs +++ b/Zennysoft.Game.Ma/src/items/EffectService.cs @@ -95,6 +95,7 @@ public class EffectService currentRoom.EnemiesInRoom.ForEach(e => e.HealthComponent.SetCurrentHealth(e.HealthComponent.MaximumHP.Value)); _player.HealthComponent.SetCurrentHealth(_player.HealthComponent.MaximumHP.Value); + SfxDatabase.Instance.Play(SoundEffect.HealHP); } public void AbsorbHPFromAllEnemiesInRoom() @@ -108,7 +109,7 @@ public class EffectService var hpToAbsorb = 0.0; foreach (var enemy in currentEnemies) { - var absorbAmount = enemy.HealthComponent.MaximumHP.Value * 0.05; + var absorbAmount = enemy.HealthComponent.CurrentHP.Value * 0.25; enemy.HealthComponent.Damage((int)absorbAmount); hpToAbsorb += absorbAmount; enemy.OnAbsorb(); @@ -134,22 +135,24 @@ public class EffectService public void SwapHPandVT() { - var oldHp = _player.HealthComponent.CurrentHP.Value; - var oldVt = _player.VTComponent.CurrentVT.Value; + var oldHp = Mathf.Max(1, _player.HealthComponent.CurrentHP.Value); + var oldVt = Mathf.Max(1, _player.VTComponent.CurrentVT.Value); _player.HealthComponent.SetCurrentHealth(oldVt); _player.VTComponent.SetVT(oldHp); SfxDatabase.Instance.Play(SoundEffect.SwapHPAndVT); } - public void RandomEffect(EffectItem item) + public void RandomEffect() { - var itemEffects = Enum.GetValues().ToList(); - itemEffects.Remove(UsableItemTag.RandomEffect); - itemEffects.Remove(UsableItemTag.None); - var randomEffect = new Godot.Collections.Array(itemEffects).PickRandom(); - item.SetEffectTag(randomEffect); - _game.UseItem(item); + var spells = _player.Inventory.Items.OfType().Where(x => x.UsableItemTag != UsableItemTag.RandomEffect).ToList(); + if (spells.Count > 0) + { + var rng = new RandomNumberGenerator(); + rng.Randomize(); + var index = rng.RandiRange(0, spells.Count - 1); + _game.UseItem(spells[index]); + } } public void DoubleExp() @@ -308,7 +311,7 @@ public class EffectService var roomsGodotCollection = new Godot.Collections.Array(validRooms); var randomRoom = roomsGodotCollection.PickRandom(); var spawnPoint = randomRoom.PlayerSpawn; - player.TeleportPlayer((spawnPoint.Rotation, new Vector3(spawnPoint.Position.X, 0, spawnPoint.Position.Z))); + player.TeleportPlayer((spawnPoint.Rotation, new Vector3(spawnPoint.GlobalPosition.X, _player.GlobalPosition.Y, spawnPoint.GlobalPosition.Z))); SfxDatabase.Instance.Play(SoundEffect.TeleportToRandomRoom); } @@ -318,7 +321,8 @@ public class EffectService if (exitRoom.PlayerDiscoveredRoom) { SfxDatabase.Instance.Play(SoundEffect.TeleportToExit); - _player.TeleportPlayer((exitRoom.PlayerSpawn.Rotation, exitRoom.PlayerSpawn.Position)); + var exitPoint = exitRoom.PlayerSpawn.GlobalPosition; + _player.TeleportPlayer((exitRoom.PlayerSpawn.Rotation, new Vector3(exitPoint.X, _player.GlobalPosition.Y, exitPoint.Z))); } } @@ -336,9 +340,14 @@ public class EffectService public T GetRandomItemOfType(params T[] itemsToExclude) where T : IBaseInventoryItem => ItemDatabase.Instance.PickItem(itemsToExclude); - public void RandomSpell() + public void RandomSpell(EffectItem item) { - throw new NotImplementedException("Spells not implemented yet."); + var itemEffects = Enum.GetValues().ToList(); + itemEffects.Remove(UsableItemTag.RandomEffect); + itemEffects.Remove(UsableItemTag.None); + var randomEffect = new Godot.Collections.Array(itemEffects).PickRandom(); + item.SetEffectTag(randomEffect); + _game.UseItem(item); } public void DropTo1HPAndGainRareItem() diff --git a/Zennysoft.Game.Ma/src/items/ItemDatabase.cs b/Zennysoft.Game.Ma/src/items/ItemDatabase.cs index 57c6fe047..efa9a61ad 100644 --- a/Zennysoft.Game.Ma/src/items/ItemDatabase.cs +++ b/Zennysoft.Game.Ma/src/items/ItemDatabase.cs @@ -44,7 +44,9 @@ public class ItemDatabase rng.Randomize(); if (itemsToExclude.Any()) - itemsToSelectFrom.Except(itemsToExclude); + itemsToSelectFrom = itemsToSelectFrom.Except(itemsToExclude); + + itemsToSelectFrom = itemsToSelectFrom.Where(x => x.ItemTag != ItemTag.MysteryItem); var weights = itemsToSelectFrom.Select(x => x.SpawnRate).ToArray(); var selectedItem = itemsToSelectFrom.ToArray()[rng.RandWeighted(weights)]; diff --git a/Zennysoft.Game.Ma/src/items/dropped/DroppedItem.cs b/Zennysoft.Game.Ma/src/items/dropped/DroppedItem.cs index 081a850bd..86ddfdda3 100644 --- a/Zennysoft.Game.Ma/src/items/dropped/DroppedItem.cs +++ b/Zennysoft.Game.Ma/src/items/dropped/DroppedItem.cs @@ -48,12 +48,13 @@ public partial class DroppedItem : RigidBody3D, IDroppedItem public void RescueItem() { + if (!Game.RescuedItems.TryAdd(Item)) + return; ContactMonitor = false; Pickup.SetDeferred(Area3D.PropertyName.Monitorable, false); Pickup.SetDeferred(Area3D.PropertyName.Monitoring, false); SfxDatabase.Instance.Play(SoundEffect.Transfer); PlayRescueAnimation(); - Game.RescuedItems.Items.Add(Item); } private void PlayRescueAnimation() diff --git a/Zennysoft.Game.Ma/src/items/effect/resources/SpellSignEntropicSeal.tres b/Zennysoft.Game.Ma/src/items/effect/resources/SpellSignEntropicSeal.tres index af7cc45a7..d9313b9cb 100644 --- a/Zennysoft.Game.Ma/src/items/effect/resources/SpellSignEntropicSeal.tres +++ b/Zennysoft.Game.Ma/src/items/effect/resources/SpellSignEntropicSeal.tres @@ -8,8 +8,8 @@ script = ExtResource("2_pixk1") UsableItemTag = 15 ElementalDamageType = 0 Name = "Spell Sign: Entropic Seal" -StatDescription = "Uses a random item in the inventory. -No effect if no usable items exist." +StatDescription = "Uses a random spell in the inventory. +No effect if no usable spells exist." FlavorText = "" SpawnRate = 0.5 BonusAttack = 0 diff --git a/Zennysoft.Game.Ma/src/items/effect/resources/SpellSignFortune.tres b/Zennysoft.Game.Ma/src/items/effect/resources/SpellSignFortune.tres new file mode 100644 index 000000000..4c541f60e --- /dev/null +++ b/Zennysoft.Game.Ma/src/items/effect/resources/SpellSignFortune.tres @@ -0,0 +1,30 @@ +[gd_resource type="Resource" script_class="EffectItemStats" load_steps=3 format=3 uid="uid://cofh755qjlkn0"] + +[ext_resource type="Texture2D" uid="uid://prsafwfaxnda" path="res://src/items/effect/textures/Entropic Seal.png" id="1_y1nwh"] +[ext_resource type="Script" uid="uid://b5w4iw4iqmxtn" path="res://src/items/effect/EffectItemStats.cs" id="2_cov8h"] + +[resource] +script = ExtResource("2_cov8h") +UsableItemTag = 32 +ElementalDamageType = 0 +Name = "Spell Sign: Fortune" +StatDescription = "Doubles the amount of stack items." +FlavorText = "" +SpawnRate = 0.5 +BonusAttack = 0 +BonusDefense = 0 +BonusLuck = 5 +BonusHP = 0 +BonusVT = 0 +AeolicResistance = 0 +TelluricResistance = 0 +HydricResistance = 0 +IgneousResistance = 0 +FerrumResistance = 0 +HolyResistance = 0 +CurseResistance = 0 +ThrowSpeed = 12.0 +ThrowDamage = 5 +ItemTag = 22 +Texture = ExtResource("1_y1nwh") +metadata/_custom_type_script = "uid://b5w4iw4iqmxtn" diff --git a/Zennysoft.Game.Ma/src/items/effect/resources/SpellSignRecall.tres b/Zennysoft.Game.Ma/src/items/effect/resources/SpellSignRecall.tres index aebc1c930..1d42c9edf 100644 --- a/Zennysoft.Game.Ma/src/items/effect/resources/SpellSignRecall.tres +++ b/Zennysoft.Game.Ma/src/items/effect/resources/SpellSignRecall.tres @@ -5,7 +5,7 @@ [resource] script = ExtResource("2_4qksk") -UsableItemTag = 0 +UsableItemTag = 33 ElementalDamageType = 0 Name = "Spell Sign: Recall" StatDescription = "Identifies a random unknown item in inventory." diff --git a/Zennysoft.Game.Ma/src/items/throwable/resources/MysteryDice.tres b/Zennysoft.Game.Ma/src/items/throwable/resources/MysteryDice.tres index 59e188dd1..656c07dec 100644 --- a/Zennysoft.Game.Ma/src/items/throwable/resources/MysteryDice.tres +++ b/Zennysoft.Game.Ma/src/items/throwable/resources/MysteryDice.tres @@ -29,6 +29,6 @@ HolyResistance = 0 CurseResistance = 0 ThrowSpeed = 12.0 ThrowDamage = 5 -ItemTag = 0 +ItemTag = 2 Texture = ExtResource("1_r4wv3") metadata/_custom_type_script = "uid://d3wlunkcuv2w2" diff --git a/Zennysoft.Game.Ma/src/items/thrown/ThrownItem.cs b/Zennysoft.Game.Ma/src/items/thrown/ThrownItem.cs index 976185022..5f3a966a4 100644 --- a/Zennysoft.Game.Ma/src/items/thrown/ThrownItem.cs +++ b/Zennysoft.Game.Ma/src/items/thrown/ThrownItem.cs @@ -68,10 +68,12 @@ public partial class ThrownItem : RigidBody3D, IThrownItem public void RescueItem() { + if (!Game.RescuedItems.TryAdd(ItemThatIsThrown)) + return; ContactMonitor = false; Freeze = true; PlayRescueAnimation(); - Game.RescuedItems.Items.Add(ItemThatIsThrown); + SfxDatabase.Instance.Play(SoundEffect.Transfer); } private void PlayRescueAnimation() diff --git a/Zennysoft.Game.Ma/src/player/Player.cs b/Zennysoft.Game.Ma/src/player/Player.cs index d8a07680d..9d4c2d6d6 100644 --- a/Zennysoft.Game.Ma/src/player/Player.cs +++ b/Zennysoft.Game.Ma/src/player/Player.cs @@ -7,7 +7,6 @@ using System; using System.Linq; using Zennysoft.Ma.Adapter; using Zennysoft.Ma.Adapter.Entity; -using static Zennysoft.Ma.Adapter.AppLogic; namespace Zennysoft.Game.Ma; @@ -19,6 +18,8 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide IPlayer IProvide.Value() => this; + [Dependency] public IGame _game => this.DependOn(); + private PlayerLogic.IBinding PlayerBinding { get; set; } = default!; #endregion @@ -391,7 +392,7 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide ApplyNewAugment((dynamic)augmentableItem, jewel as Jewel); - if (augmentableItem is IEquipableItem equipable && EquipmentComponent.IsItemEquipped(equipable)) + if (augmentableItem.Augment != null && augmentableItem is IEquipableItem equipable && EquipmentComponent.IsItemEquipped(equipable)) augmentableItem.Augment.AugmentType.Apply(); } @@ -423,7 +424,12 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide weapon.Augment = new Augment(JewelTags.LowerEXPGain, new LowerEXPRateAugment(this), jewel.ItemName, jewel.StatDescription, jewel.GetTexture()); break; case JewelTags.ItemRescue: + if (!_game.RescuedItems.TryAdd(weapon)) + break; + if (EquipmentComponent.IsItemEquipped(weapon)) + Unequip(weapon); Inventory.Remove(weapon); + SfxDatabase.Instance.Play(SoundEffect.Transfer); break; case JewelTags.Glue: if (!EquipmentComponent.IsItemEquipped(weapon)) @@ -480,7 +486,12 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide armor.Augment = new Augment(JewelTags.LowerEXPGain, new LowerEXPRateAugment(this), jewel.ItemName, jewel.StatDescription, jewel.GetTexture()); break; case JewelTags.ItemRescue: + if (!_game.RescuedItems.TryAdd(armor)) + break; + if (EquipmentComponent.IsItemEquipped(armor)) + Unequip(armor); Inventory.Remove(armor); + SfxDatabase.Instance.Play(SoundEffect.Transfer); break; case JewelTags.Glue: if (!EquipmentComponent.IsItemEquipped(armor)) @@ -537,7 +548,12 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide accessory.Augment = new Augment(JewelTags.LowerEXPGain, new LowerEXPRateAugment(this), jewel.ItemName, jewel.StatDescription, jewel.GetTexture()); break; case JewelTags.ItemRescue: + if (!_game.RescuedItems.TryAdd(accessory)) + break; + if (EquipmentComponent.IsItemEquipped(accessory)) + Unequip(accessory); Inventory.Remove(accessory); + SfxDatabase.Instance.Play(SoundEffect.Transfer); break; case JewelTags.Glue: if (!EquipmentComponent.IsItemEquipped(accessory)) diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/AugmentableItemsMenu.cs b/Zennysoft.Game.Ma/src/ui/inventory_menu/AugmentableItemsMenu.cs index 90f559cb6..54b49a37c 100644 --- a/Zennysoft.Game.Ma/src/ui/inventory_menu/AugmentableItemsMenu.cs +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/AugmentableItemsMenu.cs @@ -73,7 +73,10 @@ public partial class AugmentableItemsMenu : Control foreach (var item in inventory) { if (item is IAugmentableItem augmentable && augmentable.Augment == null) - ItemSlots[slotIndex++].SetItemToSlot(item); + { + ItemSlots[slotIndex].SetItemToSlot(item); + ItemSlots[slotIndex++].EnableItem(); + } } Show(); diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/IItemSlot.cs b/Zennysoft.Game.Ma/src/ui/inventory_menu/IItemSlot.cs index 687a2f511..db09771e7 100644 --- a/Zennysoft.Game.Ma/src/ui/inventory_menu/IItemSlot.cs +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/IItemSlot.cs @@ -14,6 +14,8 @@ public interface IItemSlot : IControl public void FocusItem(); + public void EnableItem(); + public event Action ItemPressed; public event Action ItemSelected; diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemRescueMenu.cs b/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemRescueMenu.cs index 5e2a557fa..5fe2ba77d 100644 --- a/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemRescueMenu.cs +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemRescueMenu.cs @@ -66,7 +66,7 @@ public partial class ItemRescueMenu : Control, IInventoryMenu if (Input.IsActionJustPressed(GameInputs.Inventory)) GetViewport().SetInputAsHandled(); - var validSelectableItems = _game.RescuedItems.Items; + var validSelectableItems = _game.RescuedItems.GetItems().ToList(); if (Input.IsActionJustPressed(GameInputs.MoveUp) && _currentlySelected != null && _currentlySelected.Item.Value != validSelectableItems.First()) SfxDatabase.Instance.Play(SoundEffect.MoveUI); @@ -110,7 +110,7 @@ public partial class ItemRescueMenu : Control, IInventoryMenu private void ResetInventoryState() { - var inventory = _game.RescuedItems.Items; + var inventory = _game.RescuedItems.GetItems().ToList(); ItemSlots.ForEach(x => x.SetEmpty()); ClearDescriptionBox(); @@ -141,7 +141,7 @@ public partial class ItemRescueMenu : Control, IInventoryMenu private void ActionPanel_ActionPanelClosing() { ActionPanel.Hide(); - if (_currentlySelected != null && !_game.RescuedItems.Items.Contains(_currentlySelected.Item.Value)) + if (_currentlySelected != null && !_game.RescuedItems.GetItems().ToList().Contains(_currentlySelected.Item.Value)) _currentlySelected = null; ResetInventoryState(); } @@ -151,7 +151,7 @@ public partial class ItemRescueMenu : Control, IInventoryMenu if (_currentlySelected != null) { _player.Inventory.PickUpItem(_currentlySelected.Item.Value); - _game.RescuedItems.Items.Remove(_currentlySelected.Item.Value); + _game.RescuedItems.Remove(_currentlySelected.Item.Value); ResetInventoryState(); ActionPanel_ActionPanelClosing(); } @@ -159,7 +159,7 @@ public partial class ItemRescueMenu : Control, IInventoryMenu private void DropButton_Pressed() { - _game.RescuedItems.Items.Remove(_currentlySelected.Item.Value); + _game.RescuedItems.Remove(_currentlySelected.Item.Value); ResetInventoryState(); ActionPanel_ActionPanelClosing(); } diff --git a/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemSlot.cs b/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemSlot.cs index 6b2713f84..8fe952a3b 100644 --- a/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemSlot.cs +++ b/Zennysoft.Game.Ma/src/ui/inventory_menu/ItemSlot.cs @@ -65,6 +65,11 @@ public partial class ItemSlot : Control, IItemSlot Show(); } + public void EnableItem() + { + ItemName.Disabled = false; + } + public void SetEmpty() { Hide();