Struct CharacterItemData
One item belonging to a character, in whichever container currently holds it.
public struct CharacterItemData : IVersioned<CharacterItemData>
- Implements
- Inherited Members
- Extension Methods
Remarks
Replaces CharacterInventoryData, CharacterEquipmentData and
CharacterBankData, which were three copies of one shape distinguished only by the
table they were written to. Container is what that distinction became.
ID identifies the ITEM, not the slot. That is the whole point of the
merge. Under the previous schema a row was keyed (character_id, slot), so moving an
item between two slots produced two different rows with two different ids and passing two
items through one slot gave them the same id. Here the row is keyed by ID and
Container and Slot are ordinary mutable columns, so an item keeps
its number from the moment it is first written until it is destroyed — across slot moves,
across container moves, and across sessions.
An ID of zero means "not yet written": the database assigns one on first
insert and returns it, and the caller writes it back onto the runtime item. See
ICharacterItemService.PersistAsync.
Constructors
CharacterItemData(long, long, ItemContainerType, int, int, int, uint)
public CharacterItemData(long id, long characterID, ItemContainerType container, int templateID, int slot, int seed, uint amount)
Parameters
CharacterItemData(long, long, long, ItemContainerType, int, int, int, uint)
public CharacterItemData(long id, long version, long characterID, ItemContainerType container, int templateID, int slot, int seed, uint amount)
Parameters
idlongversionlongcharacterIDlongcontainerItemContainerTypetemplateIDintslotintseedintamountuint
Fields
Amount
Stack amount.
public readonly uint Amount
Field Value
CharacterID
Character that owns this item.
public readonly long CharacterID
Field Value
Container
Which container holds it.
public readonly ItemContainerType Container
Field Value
ID
Primary key, and the item's durable identity. Zero until the first insert.
public readonly long ID
Field Value
Seed
Randomization seed for a generated item, or zero.
public readonly int Seed
Field Value
Slot
Slot index within Container.
public readonly int Slot
Field Value
TemplateID
Item template ID.
public readonly int TemplateID
Field Value
Version
Optimistic concurrency version.
public readonly long Version
Field Value
Methods
WithID(long)
The same row with a database-assigned ID filled in.
public CharacterItemData WithID(long newID)
Parameters
newIDlong
Returns
Remarks
For the caller that has just received RETURNING id from a first insert and wants
to hand the completed row on. The runtime item is updated separately; this exists so a
DTO in a batch can be completed without rebuilding it field by field.
WithVersion(long)
Returns a new instance of this DTO with the specified version. Used by extension methods to create incremented copies.
public CharacterItemData WithVersion(long newVersion)
Parameters
newVersionlongThe new version value.
Returns
- CharacterItemData
A new instance with the updated version.