Table
Root MonoBehaviour for a shop surface. Coordinates an Interactable, a TableNetwork, and a TableArea to provide item availability queries and interactable shop behavior. Serves as the entry point for game code to query which items are on the table and available for trade.
Definition
Namespace: Paragon.Townskeep.ShopSystem
Assembly: Townskeep.dll
public class Table : MonoBehaviourInherits: MonoBehaviour
Remarks
Table is a thin coordination layer. It discovers its child components in Awake():
Interactable— on the same GameObject, provides interaction system integrationTableNetwork— on the same GameObject, handles network trigger registrationTableArea— on a child GameObject, manages the physical item detection zone
All item queries delegate to tableArea.Items with filtering. GetItem() returns the first unreserved ShopItem, while HasAvailableItem checks if any unreserved items exist. HasAnyItem checks for any items regardless of reservation state.
Quick Lookup
Check if table has items
table.HasAnyItem
Check if unreserved items exist
table.HasAvailableItem
Get first available item
table.GetItem() — returns null if none
Access the trigger area
table.Area
Access the Interactable
table.Interactable
Properties
Interactable
The Interactable component on this GameObject, used by the interaction system.
Area
The child TableArea that detects items entering/leaving the table bounds.
HasAnyItem
Whether the table has any items (reserved or unreserved). Delegates to tableArea.Items.Any().
HasAvailableItem
Whether the table has at least one unreserved item. Delegates to tableArea.Items.Any(item => !item.IsReserved).
Methods
GetItem
Returns the first unreserved ShopItem on the table, or null if no available items exist.
Returns: The first ShopItem where !IsReserved, or null.
Lifecycle
Common Pitfalls
TableArea must be a child
GetComponentInChildren<TableArea>() discovers the area in children. The TableArea must be on a child GameObject, not a sibling or parent.
GetItem() returns null when empty
FirstOrDefault() returns null when no unreserved items exist. Always null-check the result before using it.
All three components required
Table expects Interactable, TableNetwork, and TableArea to be present. Missing any of them causes a NullReferenceException in Awake().
See Also
TableArea — trigger zone managing items
ShopItem — item wrapper with reservation
TableNetwork — network trigger registration
Last updated