Vixen
caa30e12
csharp
public readonly record struct ItemInstance

One copy of an item. Sixteen bytes, and that is the design rather than an outcome.

Read the guide page for this →

Remarks

A bank of ten thousand items is a real number. Doc 28 § Items: an instance carrying a materialised stat block is fifty times the memory for data that is a pure function of the seed. So an instance is a definition, a stack count, a durability, a roll seed and a bound state — and every affix, every stat and every tooltip line is recomputed from those when somebody actually looks.

⚠ The seed is the item's identity as far as its affixes are concerned. Two instances with the same definition and the same seed roll identically, in every process, for ever — which is what makes a trade window, a client's tooltip and a realm's damage calculation agree without any of them sending a stat block.

⚠ What is not here is anything of variable size — no socketed gems, no custom name, no transmog override. Those are per-copy extras that most copies do not have, and a side table kept by whatever owns the instance is where they belong; putting them here would cost every one of the ten thousand.

Fields and properties (8)

  • public static ItemInstance Empty

    The empty slot. A definition of None is nothing at all.

  • public DefId Definition

    Which item this is a copy of.

  • public uint Seed

    What its affixes rolled from. Zero is an unrolled copy — a stack of ore.

  • public ushort Stack

    How many are in this stack. Never zero for a real instance.

  • public ushort Durability

    How much wear is left. Meaningless when the definition is indestructible.

  • public ItemBinding Binding

    Whether it is still tradeable, and what will stop it being so.

  • public bool IsSome

    Whether this is a real item rather than an empty slot.

  • public bool IsTradeable

    Whether it can still change hands.

Methods (4)

  • public static ItemInstance Of(DefId definition, int stack = 1)

    Makes a stack of something with no affixes to roll.

  • public ItemInstance WithStack(int stack)

    The same item with a different stack count.

  • public ItemInstance Bind()

    The same item, bound.

  • public override string ToString()

    Returns the fully qualified type name of this instance.

Used by (16)

  • AtomicityTestsVixen.Gameplay.Inventory.Tests
  • BindingTestsVixen.Gameplay.Inventory.Tests
  • ConservationOracleTestsVixen.Gameplay.Inventory.Tests
  • ContainerVixen.Gameplay.Inventory
  • ContainerChangeVixen.Gameplay.Inventory
  • ContainerSetVixen.Gameplay.Inventory
  • ContainerTransactionVixen.Gameplay.Inventory
  • ContainerTransactionTestsVixen.Gameplay.Inventory.Tests
  • ContentVixen.Gameplay.Inventory.Tests
  • ItemInstanceTestsVixen.Gameplay.Items.Tests
  • ItemStatsVixen.Gameplay.Items
  • ItemStatsTestsVixen.Gameplay.Items.Tests
  • ItemTemplateVixen.Gameplay.Items
  • LootResultVixen.Gameplay.Loot
  • LootRollTestsVixen.Gameplay.Loot.Tests
  • StepVixen.Gameplay.Inventory