In progress item changes

This commit is contained in:
2026-02-13 15:59:10 -08:00
parent d6faf8642a
commit 0ab6ef1343
180 changed files with 3552 additions and 2023 deletions

View File

@@ -228,14 +228,14 @@ public class EffectService
_player.TakeDamage(new AttackData(damage, ElementType.None, true, true));
}
public void RerollItem(InventoryItem itemToReroll)
public void RerollItem(IBaseInventoryItem itemToReroll)
{
var itemReroller = new ItemReroller(ItemDatabase.Instance);
itemReroller.RerollItem(itemToReroll, _player.Inventory);
}
public T GetRandomItemOfType<T>(T itemToExclude = null)
where T : InventoryItem => ItemDatabase.Instance.PickItem(itemToExclude);
public T GetRandomItemOfType<T>(params T[] itemsToExclude)
where T : IBaseInventoryItem => ItemDatabase.Instance.PickItem(itemsToExclude);
public void RandomSpell()
{
@@ -243,14 +243,14 @@ public class EffectService
}
public void DropTo1HPAndGainRareItem<T>()
where T : InventoryItem
where T : IBaseInventoryItem
{
_player.HealthComponent.SetCurrentHealth(1);
_player.Inventory.TryAdd(ItemDatabase.Instance.PickRareItem<T>());
}
public void TradeRandomItem<T>(BoxItem box)
where T : InventoryItem
where T : IBaseInventoryItem
{
var tradableItems = _player.Inventory.Items.OfType<T>().Where(x => x != box).ToList();
@@ -258,7 +258,7 @@ public class EffectService
rng.Randomize();
var randomIndex = rng.RandiRange(0, tradableItems.Count - 1);
var randomItem = tradableItems[randomIndex];
if (randomItem is EquipableItem equipableItem)
if (randomItem is IEquipableItem equipableItem)
{
if (_player.EquipmentComponent.IsItemEquipped(equipableItem))
_player.Unequip(equipableItem);
@@ -268,13 +268,12 @@ public class EffectService
GetRandomItemOfType<T>();
}
public IEnumerable<InventoryItem> TradeAllRandomItems<T>(BoxItem box)
where T : InventoryItem
public IEnumerable<IBaseInventoryItem> TradeAllRandomItems(BoxItem box)
{
var newInventory = new List<InventoryItem>();
var items = _player.Inventory.Items.OfType<T>().Where(x => x != box).ToList();
var newInventory = new List<IBaseInventoryItem>();
var items = _player.Inventory.Items.ToList();
foreach (var item in items)
newInventory.Add(GetRandomItemOfType<T>());
newInventory.Add(GetRandomItemOfType<IBaseInventoryItem>());
return newInventory;
}
@@ -294,7 +293,7 @@ public class EffectService
}
public void GetBasicItem<T>()
where T : InventoryItem
where T : IBaseInventoryItem
{
_player.Inventory.TryAdd(ItemDatabase.Instance.PickBasicItem<T>());
}