Struct representing a loot inventory entry, pairing a LootPrefab and LootRarity. It exposes computed Name and Price properties and implements value equality and hash code.
using System;
namespace BrickJam;
/// <summary>
/// A single inventory item identity (prefab + rarity). Ported from the legacy
/// <c>ItemEntry</c> struct in <c>ContainerComponent.cs</c>.
/// </summary>
public struct ItemEntry : IEquatable<ItemEntry>
{
public LootPrefab Prefab;
public LootRarity Rarity;
public string Name => $"{Rarity} {Prefab?.Name ?? "unknown"}";
public int Price => (int)((Prefab?.MonetaryValue ?? 0) * LootRarityTable.RarityMap[Rarity]);
public bool Equals( ItemEntry other ) => other.Prefab == Prefab && other.Rarity == Rarity;
public override bool Equals( object obj ) => obj is ItemEntry other && Equals( other );
public override int GetHashCode() => HashCode.Combine( Prefab, Rarity );
}