ShopItem

Lightweight wrapper around an Item that adds a reservation flag for trade coordination. Items on a shop Table are tracked as ShopItem instances, allowing the system to prevent multiple agents from claiming the same item simultaneously.

Definition

Namespace: Paragon.Townskeep.ShopSystem Assembly: Townskeep.dll

public class ShopItem

Remarks

ShopItem is a simple POCO (not a MonoBehaviour) that wraps an Item reference with reservation state. It is created by TableArea when an item enters the trigger zone and removed when the item exits.

The reservation flag is the key coordination mechanism: when an agent selects an item for trade via Table.GetItem(), the returned ShopItem can be marked as reserved to prevent other agents from selecting it. Table.HasAvailableItem and Table.GetItem() both filter by !IsReserved.

An implicit conversion operator allows ShopItem to be used anywhere an Item is expected, making it transparent for downstream code.

Quick Lookup

Goal
How

Create from an Item

new ShopItem(item)

Reserve for trade

shopItem.SetReserve(true)

Release reservation

shopItem.SetReserve(false)

Check if reserved

shopItem.IsReserved

Get underlying Item

Item item = shopItem (implicit conversion)

Properties

IsReserved

Whether this item is currently reserved by an agent for trading. Reserved items are excluded from Table.GetItem() queries.

Constructor

Parameter
Type
Description

item

Item

The item to wrap. Stored as a readonly field.

Methods

SetReserve

Sets the reservation state. When true, the item will be skipped by Table.GetItem() and Table.HasAvailableItem.

Parameter
Type
Description

isReserved

bool

Whether to reserve (true) or release (false)

Operators

Implicit to Item

Allows ShopItem to be used as an Item without explicit casting. Returns the wrapped item reference.

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation

See Also

  • Table — queries items by reservation state

  • TableArea — creates and removes ShopItem instances

Last updated