using System.Collections.Generic;
using System;
using Terraria;
namespace SoulHarvest.Common;
public readonly record struct DeathAltarItemReference(DeathAltarItemStorage Storage, byte Slot, int ExpectedItemType)
{
public bool TryGetSlotItem(Player player, out Item item)
{
item = new Item();
if (Storage == DeathAltarItemStorage.CharacterDeathDomain)
{
item.SetDefaults(ExpectedItemType);
return item.type == ExpectedItemType;
}
Item[] container = Storage == DeathAltarItemStorage.Inventory ? player.inventory : player.armor;
int accessibleSlots = Storage == DeathAltarItemStorage.Inventory ? Math.Min(58, container.Length) : container.Length;
if (Slot >= accessibleSlots)
return false;
item = container[Slot];
return true;
}
public bool TryResolve(Player player, out Item item)
{
return TryGetSlotItem(player, out item)
&& item.type == ExpectedItemType
&& item.ModItem is IDeathAltarUpgradeable;
}
}
using System.Collections.Generic;
using System;
using Terraria;
namespace SoulHarvest.Common;
public readonly record struct DeathAltarItemReference(DeathAltarItemStorage Storage, byte Slot, int ExpectedItemType)
{
public bool TryGetSlotItem(Player player, out Item item)
{
item = new Item();
if (Storage == DeathAltarItemStorage.CharacterDeathDomain)
{
item.SetDefaults(ExpectedItemType);
return item.type == ExpectedItemType;
}
Item[] container = Storage == DeathAltarItemStorage.Inventory ? player.inventory : player.armor;
int accessibleSlots = Storage == DeathAltarItemStorage.Inventory ? Math.Min(58, container.Length) : container.Length;
if (Slot >= accessibleSlots)
return false;
item = container[Slot];
return true;
}
public bool TryResolve(Player player, out Item item)
{
return TryGetSlotItem(player, out item)
&& item.type == ExpectedItemType
&& item.ModItem is IDeathAltarUpgradeable;
}
}