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
+18 -19
View File
@@ -172,7 +172,11 @@ public class EffectService
SfxDatabase.Instance.Play(SoundEffect.IncreaseStat);
}
public void RaiseLevel() => _player.LevelUp();
public void RaiseLevel()
{
var expToNextLevel = _player.ExperiencePointsComponent.ExpToNextLevel.Value - _player.ExperiencePointsComponent.CurrentExp.Value;
_player.ExperiencePointsComponent.GainUnmodified(expToNextLevel);
}
public void TeleportToRandomRoom(IEnemy enemy)
{
@@ -228,14 +232,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,38 +247,33 @@ 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();
var tradableItems = _player.Inventory.Items.OfType<T>().ToList();
var rng = new RandomNumberGenerator();
rng.Randomize();
var randomIndex = rng.RandiRange(0, tradableItems.Count - 1);
var randomItem = tradableItems[randomIndex];
if (randomItem is EquipableItem equipableItem)
{
if (_player.EquipmentComponent.IsItemEquipped(equipableItem))
_player.Unequip(equipableItem);
}
if (randomItem is IEquipableItem equipableItem && _player.EquipmentComponent.IsItemEquipped(equipableItem))
_player.Unequip(equipableItem);
_player.Inventory.Remove(randomItem);
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>());
}