Add more spell effects

This commit is contained in:
2026-02-26 02:09:38 -08:00
parent a686ce2fbc
commit fadb1652d4
20 changed files with 163 additions and 49 deletions

View File

@@ -33,5 +33,7 @@ public enum UsableItemTag
Clone, Clone,
MeltAllEquipment, MeltAllEquipment,
RestoreStats, RestoreStats,
GlueAllEquipment GlueAllEquipment,
DoubleStackedItems,
IdentifyRandomItem
} }

View File

@@ -1,16 +1,38 @@
using Chickensoft.Introspection; using Chickensoft.Serialization;
using Chickensoft.Serialization;
namespace Zennysoft.Ma.Adapter; namespace Zennysoft.Ma.Adapter;
[Meta, Id("rescued_items")] public class RescuedItemDatabase
public partial class RescuedItemDatabase
{ {
[Save("rescued_item_list")] [Save("rescued_item_list")]
public List<IBaseInventoryItem> Items { get; init; } private List<IBaseInventoryItem> _items { get; init; }
private int _maxSize { get; init; } = 20;
public RescuedItemDatabase() public RescuedItemDatabase(int maxSize)
{ {
Items = new List<IBaseInventoryItem>(); _items = [];
_maxSize = maxSize;
} }
public RescuedItemDatabase(List<IBaseInventoryItem> 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<IBaseInventoryItem> GetItems() => _items;
public void Clear() => _items.Clear();
} }

View File

@@ -180,7 +180,11 @@ public abstract partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLo
{ {
_morphSFX.Play(); _morphSFX.Play();
SetPhysicsProcess(false); SetPhysicsProcess(false);
Die(); _player.ExperiencePointsComponent.Gain(ExpGiven);
EnemyModelView.PlayDeathAnimation();
var tweener = CreateTween();
tweener.TweenInterval(1.0f);
tweener.TweenCallback(Callable.From(QueueFree));
} }
public IDungeonRoom GetCurrentRoom(ImmutableList<IDungeonRoom> roomList) public IDungeonRoom GetCurrentRoom(ImmutableList<IDungeonRoom> roomList)

View File

@@ -15,13 +15,14 @@ height = 5.0
radius = 1.0 radius = 1.0
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_0h5s2"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_0h5s2"]
radius = 0.34933
height = 2.66932 height = 2.66932
[sub_resource type="CylinderShape3D" id="CylinderShape3D_eek1b"] [sub_resource type="CylinderShape3D" id="CylinderShape3D_eek1b"]
radius = 1.0 radius = 1.0
[sub_resource type="SphereShape3D" id="SphereShape3D_wrps7"] [sub_resource type="SphereShape3D" id="SphereShape3D_wrps7"]
radius = 1.0 radius = 0.552847
[node name="Michael" type="CharacterBody3D" groups=["enemy"]] [node name="Michael" type="CharacterBody3D" groups=["enemy"]]
process_mode = 1 process_mode = 1

View File

@@ -10,7 +10,7 @@
[ext_resource type="AudioStream" uid="uid://bf7adfdd857hw" path="res://src/audio/sfx/enemy_morph.ogg" id="8_jvw36"] [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"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_cwfph"]
radius = 1.6 radius = 0.90501
height = 3.2 height = 3.2
[sub_resource type="CylinderShape3D" id="CylinderShape3D_jbgmx"] [sub_resource type="CylinderShape3D" id="CylinderShape3D_jbgmx"]

View File

@@ -91,7 +91,7 @@ public partial class Game : Node3D, IGame
GameState = _container.GetInstance<IGameState>(); GameState = _container.GetInstance<IGameState>();
QuestData = new QuestData(); QuestData = new QuestData();
RescuedItems = new RescuedItemDatabase(); RescuedItems = new RescuedItemDatabase(20);
ItemDatabase = ItemDatabase.Instance; ItemDatabase = ItemDatabase.Instance;
GameChunk = new SaveChunk<GameData>( GameChunk = new SaveChunk<GameData>(
@@ -99,10 +99,7 @@ public partial class Game : Node3D, IGame
{ {
var gameData = new GameData() var gameData = new GameData()
{ {
RescuedItems = new RescuedItemDatabase() RescuedItems = new RescuedItemDatabase(RescuedItems.GetItems(), 20),
{
Items = RescuedItems.Items
},
QuestData = new QuestData() QuestData = new QuestData()
{ {
DeathCount = QuestData.DeathCount, DeathCount = QuestData.DeathCount,
@@ -462,6 +459,9 @@ public partial class Game : Node3D, IGame
case ItemTag.ContainsBox: case ItemTag.ContainsBox:
_player.Inventory.TryAdd(_effectService.GetRandomItemOfType<BoxItem>()); _player.Inventory.TryAdd(_effectService.GetRandomItemOfType<BoxItem>());
break; break;
case ItemTag.RandomSpell:
_player.Inventory.TryAdd(_effectService.GetRandomItemOfType<EffectItem>());
break;
case ItemTag.ContainsRestorative: case ItemTag.ContainsRestorative:
_player.Inventory.TryAdd(_effectService.GetRandomItemOfType<ConsumableItem>()); _player.Inventory.TryAdd(_effectService.GetRandomItemOfType<ConsumableItem>());
break; break;
@@ -502,7 +502,6 @@ public partial class Game : Node3D, IGame
ThrowItem(item); ThrowItem(item);
_player.Inventory.Items.Clear(); _player.Inventory.Items.Clear();
GameRepo.CloseInventory(); GameRepo.CloseInventory();
break; break;
} }
} }
@@ -581,7 +580,7 @@ public partial class Game : Node3D, IGame
_effectService.LowerCurrentArmorDefense(); _effectService.LowerCurrentArmorDefense();
break; break;
case UsableItemTag.RandomEffect: case UsableItemTag.RandomEffect:
_effectService.RandomEffect(effectItem); _effectService.RandomEffect();
break; break;
case UsableItemTag.DoubleExp: case UsableItemTag.DoubleExp:
_effectService.DoubleExp(); _effectService.DoubleExp();
@@ -641,7 +640,23 @@ public partial class Game : Node3D, IGame
_player.HealthComponent.SetCurrentHealth(1); _player.HealthComponent.SetCurrentHealth(1);
SfxDatabase.Instance.Play(SoundEffect.DecreaseStat); SfxDatabase.Instance.Play(SoundEffect.DecreaseStat);
break; break;
case UsableItemTag.DoubleStackedItems:
var stackableItems = _player.Inventory.Items.OfType<IStackable>().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) private void RemoveItemOrSubtractFromItemCount(IBaseInventoryItem item)

View File

@@ -41,7 +41,7 @@ public partial class RescuedItems : Node3D
public void SpawnRescuedItems() public void SpawnRescuedItems()
{ {
foreach (var item in Game.RescuedItems.Items) foreach (var item in Game.RescuedItems.GetItems().ToList())
{ {
var droppedScene = GD.Load<PackedScene>("res://src/items/dropped/DroppedItem.tscn"); var droppedScene = GD.Load<PackedScene>("res://src/items/dropped/DroppedItem.tscn");
var dropped = droppedScene.Instantiate<DroppedItem>(); var dropped = droppedScene.Instantiate<DroppedItem>();
@@ -51,7 +51,7 @@ public partial class RescuedItems : Node3D
SpawnLocations.Remove(SpawnLocations.First()); SpawnLocations.Remove(SpawnLocations.First());
} }
Game.RescuedItems.Items.Clear(); Game.RescuedItems.Clear();
} }
public override void _ExitTree() => base._ExitTree(); public override void _ExitTree() => base._ExitTree();

View File

@@ -95,6 +95,7 @@ public class EffectService
currentRoom.EnemiesInRoom.ForEach(e => e.HealthComponent.SetCurrentHealth(e.HealthComponent.MaximumHP.Value)); currentRoom.EnemiesInRoom.ForEach(e => e.HealthComponent.SetCurrentHealth(e.HealthComponent.MaximumHP.Value));
_player.HealthComponent.SetCurrentHealth(_player.HealthComponent.MaximumHP.Value); _player.HealthComponent.SetCurrentHealth(_player.HealthComponent.MaximumHP.Value);
SfxDatabase.Instance.Play(SoundEffect.HealHP);
} }
public void AbsorbHPFromAllEnemiesInRoom() public void AbsorbHPFromAllEnemiesInRoom()
@@ -108,7 +109,7 @@ public class EffectService
var hpToAbsorb = 0.0; var hpToAbsorb = 0.0;
foreach (var enemy in currentEnemies) 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); enemy.HealthComponent.Damage((int)absorbAmount);
hpToAbsorb += absorbAmount; hpToAbsorb += absorbAmount;
enemy.OnAbsorb(); enemy.OnAbsorb();
@@ -134,22 +135,24 @@ public class EffectService
public void SwapHPandVT() public void SwapHPandVT()
{ {
var oldHp = _player.HealthComponent.CurrentHP.Value; var oldHp = Mathf.Max(1, _player.HealthComponent.CurrentHP.Value);
var oldVt = _player.VTComponent.CurrentVT.Value; var oldVt = Mathf.Max(1, _player.VTComponent.CurrentVT.Value);
_player.HealthComponent.SetCurrentHealth(oldVt); _player.HealthComponent.SetCurrentHealth(oldVt);
_player.VTComponent.SetVT(oldHp); _player.VTComponent.SetVT(oldHp);
SfxDatabase.Instance.Play(SoundEffect.SwapHPAndVT); SfxDatabase.Instance.Play(SoundEffect.SwapHPAndVT);
} }
public void RandomEffect(EffectItem item) public void RandomEffect()
{ {
var itemEffects = Enum.GetValues<UsableItemTag>().ToList(); var spells = _player.Inventory.Items.OfType<EffectItem>().Where(x => x.UsableItemTag != UsableItemTag.RandomEffect).ToList();
itemEffects.Remove(UsableItemTag.RandomEffect); if (spells.Count > 0)
itemEffects.Remove(UsableItemTag.None); {
var randomEffect = new Godot.Collections.Array<UsableItemTag>(itemEffects).PickRandom(); var rng = new RandomNumberGenerator();
item.SetEffectTag(randomEffect); rng.Randomize();
_game.UseItem(item); var index = rng.RandiRange(0, spells.Count - 1);
_game.UseItem(spells[index]);
}
} }
public void DoubleExp() public void DoubleExp()
@@ -308,7 +311,7 @@ public class EffectService
var roomsGodotCollection = new Godot.Collections.Array<MonsterRoom>(validRooms); var roomsGodotCollection = new Godot.Collections.Array<MonsterRoom>(validRooms);
var randomRoom = roomsGodotCollection.PickRandom(); var randomRoom = roomsGodotCollection.PickRandom();
var spawnPoint = randomRoom.PlayerSpawn; 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); SfxDatabase.Instance.Play(SoundEffect.TeleportToRandomRoom);
} }
@@ -318,7 +321,8 @@ public class EffectService
if (exitRoom.PlayerDiscoveredRoom) if (exitRoom.PlayerDiscoveredRoom)
{ {
SfxDatabase.Instance.Play(SoundEffect.TeleportToExit); 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<T>(params T[] itemsToExclude) public T GetRandomItemOfType<T>(params T[] itemsToExclude)
where T : IBaseInventoryItem => ItemDatabase.Instance.PickItem(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<UsableItemTag>().ToList();
itemEffects.Remove(UsableItemTag.RandomEffect);
itemEffects.Remove(UsableItemTag.None);
var randomEffect = new Godot.Collections.Array<UsableItemTag>(itemEffects).PickRandom();
item.SetEffectTag(randomEffect);
_game.UseItem(item);
} }
public void DropTo1HPAndGainRareItem<T>() public void DropTo1HPAndGainRareItem<T>()

View File

@@ -44,7 +44,9 @@ public class ItemDatabase
rng.Randomize(); rng.Randomize();
if (itemsToExclude.Any()) 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 weights = itemsToSelectFrom.Select(x => x.SpawnRate).ToArray();
var selectedItem = itemsToSelectFrom.ToArray()[rng.RandWeighted(weights)]; var selectedItem = itemsToSelectFrom.ToArray()[rng.RandWeighted(weights)];

View File

@@ -48,12 +48,13 @@ public partial class DroppedItem : RigidBody3D, IDroppedItem
public void RescueItem() public void RescueItem()
{ {
if (!Game.RescuedItems.TryAdd(Item))
return;
ContactMonitor = false; ContactMonitor = false;
Pickup.SetDeferred(Area3D.PropertyName.Monitorable, false); Pickup.SetDeferred(Area3D.PropertyName.Monitorable, false);
Pickup.SetDeferred(Area3D.PropertyName.Monitoring, false); Pickup.SetDeferred(Area3D.PropertyName.Monitoring, false);
SfxDatabase.Instance.Play(SoundEffect.Transfer); SfxDatabase.Instance.Play(SoundEffect.Transfer);
PlayRescueAnimation(); PlayRescueAnimation();
Game.RescuedItems.Items.Add(Item);
} }
private void PlayRescueAnimation() private void PlayRescueAnimation()

View File

@@ -8,8 +8,8 @@ script = ExtResource("2_pixk1")
UsableItemTag = 15 UsableItemTag = 15
ElementalDamageType = 0 ElementalDamageType = 0
Name = "Spell Sign: Entropic Seal" Name = "Spell Sign: Entropic Seal"
StatDescription = "Uses a random item in the inventory. StatDescription = "Uses a random spell in the inventory.
No effect if no usable items exist." No effect if no usable spells exist."
FlavorText = "" FlavorText = ""
SpawnRate = 0.5 SpawnRate = 0.5
BonusAttack = 0 BonusAttack = 0

View File

@@ -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"

View File

@@ -5,7 +5,7 @@
[resource] [resource]
script = ExtResource("2_4qksk") script = ExtResource("2_4qksk")
UsableItemTag = 0 UsableItemTag = 33
ElementalDamageType = 0 ElementalDamageType = 0
Name = "Spell Sign: Recall" Name = "Spell Sign: Recall"
StatDescription = "Identifies a random unknown item in inventory." StatDescription = "Identifies a random unknown item in inventory."

View File

@@ -29,6 +29,6 @@ HolyResistance = 0
CurseResistance = 0 CurseResistance = 0
ThrowSpeed = 12.0 ThrowSpeed = 12.0
ThrowDamage = 5 ThrowDamage = 5
ItemTag = 0 ItemTag = 2
Texture = ExtResource("1_r4wv3") Texture = ExtResource("1_r4wv3")
metadata/_custom_type_script = "uid://d3wlunkcuv2w2" metadata/_custom_type_script = "uid://d3wlunkcuv2w2"

View File

@@ -68,10 +68,12 @@ public partial class ThrownItem : RigidBody3D, IThrownItem
public void RescueItem() public void RescueItem()
{ {
if (!Game.RescuedItems.TryAdd(ItemThatIsThrown))
return;
ContactMonitor = false; ContactMonitor = false;
Freeze = true; Freeze = true;
PlayRescueAnimation(); PlayRescueAnimation();
Game.RescuedItems.Items.Add(ItemThatIsThrown); SfxDatabase.Instance.Play(SoundEffect.Transfer);
} }
private void PlayRescueAnimation() private void PlayRescueAnimation()

View File

@@ -7,7 +7,6 @@ using System;
using System.Linq; using System.Linq;
using Zennysoft.Ma.Adapter; using Zennysoft.Ma.Adapter;
using Zennysoft.Ma.Adapter.Entity; using Zennysoft.Ma.Adapter.Entity;
using static Zennysoft.Ma.Adapter.AppLogic;
namespace Zennysoft.Game.Ma; namespace Zennysoft.Game.Ma;
@@ -19,6 +18,8 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
IPlayer IProvide<IPlayer>.Value() => this; IPlayer IProvide<IPlayer>.Value() => this;
[Dependency] public IGame _game => this.DependOn<IGame>();
private PlayerLogic.IBinding PlayerBinding { get; set; } = default!; private PlayerLogic.IBinding PlayerBinding { get; set; } = default!;
#endregion #endregion
@@ -391,7 +392,7 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
ApplyNewAugment((dynamic)augmentableItem, jewel as Jewel); 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(); augmentableItem.Augment.AugmentType.Apply();
} }
@@ -423,7 +424,12 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
weapon.Augment = new Augment(JewelTags.LowerEXPGain, new LowerEXPRateAugment(this), jewel.ItemName, jewel.StatDescription, jewel.GetTexture()); weapon.Augment = new Augment(JewelTags.LowerEXPGain, new LowerEXPRateAugment(this), jewel.ItemName, jewel.StatDescription, jewel.GetTexture());
break; break;
case JewelTags.ItemRescue: case JewelTags.ItemRescue:
if (!_game.RescuedItems.TryAdd(weapon))
break;
if (EquipmentComponent.IsItemEquipped(weapon))
Unequip(weapon);
Inventory.Remove(weapon); Inventory.Remove(weapon);
SfxDatabase.Instance.Play(SoundEffect.Transfer);
break; break;
case JewelTags.Glue: case JewelTags.Glue:
if (!EquipmentComponent.IsItemEquipped(weapon)) if (!EquipmentComponent.IsItemEquipped(weapon))
@@ -480,7 +486,12 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
armor.Augment = new Augment(JewelTags.LowerEXPGain, new LowerEXPRateAugment(this), jewel.ItemName, jewel.StatDescription, jewel.GetTexture()); armor.Augment = new Augment(JewelTags.LowerEXPGain, new LowerEXPRateAugment(this), jewel.ItemName, jewel.StatDescription, jewel.GetTexture());
break; break;
case JewelTags.ItemRescue: case JewelTags.ItemRescue:
if (!_game.RescuedItems.TryAdd(armor))
break;
if (EquipmentComponent.IsItemEquipped(armor))
Unequip(armor);
Inventory.Remove(armor); Inventory.Remove(armor);
SfxDatabase.Instance.Play(SoundEffect.Transfer);
break; break;
case JewelTags.Glue: case JewelTags.Glue:
if (!EquipmentComponent.IsItemEquipped(armor)) if (!EquipmentComponent.IsItemEquipped(armor))
@@ -537,7 +548,12 @@ public partial class Player : CharacterBody3D, IPlayer, IProvide<IPlayer>
accessory.Augment = new Augment(JewelTags.LowerEXPGain, new LowerEXPRateAugment(this), jewel.ItemName, jewel.StatDescription, jewel.GetTexture()); accessory.Augment = new Augment(JewelTags.LowerEXPGain, new LowerEXPRateAugment(this), jewel.ItemName, jewel.StatDescription, jewel.GetTexture());
break; break;
case JewelTags.ItemRescue: case JewelTags.ItemRescue:
if (!_game.RescuedItems.TryAdd(accessory))
break;
if (EquipmentComponent.IsItemEquipped(accessory))
Unequip(accessory);
Inventory.Remove(accessory); Inventory.Remove(accessory);
SfxDatabase.Instance.Play(SoundEffect.Transfer);
break; break;
case JewelTags.Glue: case JewelTags.Glue:
if (!EquipmentComponent.IsItemEquipped(accessory)) if (!EquipmentComponent.IsItemEquipped(accessory))

View File

@@ -73,7 +73,10 @@ public partial class AugmentableItemsMenu : Control
foreach (var item in inventory) foreach (var item in inventory)
{ {
if (item is IAugmentableItem augmentable && augmentable.Augment == null) if (item is IAugmentableItem augmentable && augmentable.Augment == null)
ItemSlots[slotIndex++].SetItemToSlot(item); {
ItemSlots[slotIndex].SetItemToSlot(item);
ItemSlots[slotIndex++].EnableItem();
}
} }
Show(); Show();

View File

@@ -14,6 +14,8 @@ public interface IItemSlot : IControl
public void FocusItem(); public void FocusItem();
public void EnableItem();
public event Action<IItemSlot> ItemPressed; public event Action<IItemSlot> ItemPressed;
public event Action<IItemSlot> ItemSelected; public event Action<IItemSlot> ItemSelected;

View File

@@ -66,7 +66,7 @@ public partial class ItemRescueMenu : Control, IInventoryMenu
if (Input.IsActionJustPressed(GameInputs.Inventory)) if (Input.IsActionJustPressed(GameInputs.Inventory))
GetViewport().SetInputAsHandled(); 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()) if (Input.IsActionJustPressed(GameInputs.MoveUp) && _currentlySelected != null && _currentlySelected.Item.Value != validSelectableItems.First())
SfxDatabase.Instance.Play(SoundEffect.MoveUI); SfxDatabase.Instance.Play(SoundEffect.MoveUI);
@@ -110,7 +110,7 @@ public partial class ItemRescueMenu : Control, IInventoryMenu
private void ResetInventoryState() private void ResetInventoryState()
{ {
var inventory = _game.RescuedItems.Items; var inventory = _game.RescuedItems.GetItems().ToList();
ItemSlots.ForEach(x => x.SetEmpty()); ItemSlots.ForEach(x => x.SetEmpty());
ClearDescriptionBox(); ClearDescriptionBox();
@@ -141,7 +141,7 @@ public partial class ItemRescueMenu : Control, IInventoryMenu
private void ActionPanel_ActionPanelClosing() private void ActionPanel_ActionPanelClosing()
{ {
ActionPanel.Hide(); 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; _currentlySelected = null;
ResetInventoryState(); ResetInventoryState();
} }
@@ -151,7 +151,7 @@ public partial class ItemRescueMenu : Control, IInventoryMenu
if (_currentlySelected != null) if (_currentlySelected != null)
{ {
_player.Inventory.PickUpItem(_currentlySelected.Item.Value); _player.Inventory.PickUpItem(_currentlySelected.Item.Value);
_game.RescuedItems.Items.Remove(_currentlySelected.Item.Value); _game.RescuedItems.Remove(_currentlySelected.Item.Value);
ResetInventoryState(); ResetInventoryState();
ActionPanel_ActionPanelClosing(); ActionPanel_ActionPanelClosing();
} }
@@ -159,7 +159,7 @@ public partial class ItemRescueMenu : Control, IInventoryMenu
private void DropButton_Pressed() private void DropButton_Pressed()
{ {
_game.RescuedItems.Items.Remove(_currentlySelected.Item.Value); _game.RescuedItems.Remove(_currentlySelected.Item.Value);
ResetInventoryState(); ResetInventoryState();
ActionPanel_ActionPanelClosing(); ActionPanel_ActionPanelClosing();
} }

View File

@@ -65,6 +65,11 @@ public partial class ItemSlot : Control, IItemSlot
Show(); Show();
} }
public void EnableItem()
{
ItemName.Disabled = false;
}
public void SetEmpty() public void SetEmpty()
{ {
Hide(); Hide();