Wobycourier
Overview
This component tracks and synchronizes the XZ-world coordinates of a Woby courier chest on a per-shard basis. It enables persistent storage and dynamic network synchronization of the chest position—primarily for UI updates and world alignment—by interfacing with the shard-specific positioning system and the woby_commands_classified component.
Dependencies & Tags
inst.woby_commands_classified: Requires thewoby_commands_classifiedcomponent to be present on the entity (assumed to exposechest_posxandchest_poszprops).- Uses
TheShard:GetShardId()to identify the current shard. - Uses
TheWorld.Map,TheWorld.components.undertile, andTileGroupManager:IsLandTile()for coordinate validation.
No explicit entity tags are added or removed by this component.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | N/A | Reference to the entity this component is attached to. |
shardid | string | Current shard ID from TheShard:GetShardId() | Unique identifier for the active shard, used as a key in positions. |
positions | table | {} | Dictionary mapping shard IDs to {x, z} coordinate tables. Stores last known chest position per shard. |
Main Functions
NetworkLocation()
- Description: Updates the
chest_posxandchest_poszproperties on thewoby_commands_classifiedcomponent with the stored position for the current shard, or sets them toWOBYCOURIER_NO_CHEST_COORDif no position is stored. If the entity is the player (server is client), it pushes anupdatewobycourierchesticonevent to refresh the UI. - Parameters: None.
CanStoreXZ(x, z)
- Description: Validates whether the given world coordinates fall on a valid land tile (non-ocean).
- Parameters:
x(number): World X coordinate.z(number): World Z coordinate.
StoreXZ(x, z)
- Description: Validates and stores the world coordinates for the current shard, then updates networked UI via
NetworkLocation(). Returnstrueon success,falseif the tile is invalid. - Parameters:
x(number): World X coordinate.z(number): World Z coordinate.
ClearXZ()
- Description: Removes the stored position for the current shard and triggers
NetworkLocation()to clear the UI indicators. Returnstrueif a position was cleared;falseotherwise. - Parameters: None.
OnSave()
- Description: Returns a serializable table containing the
positionsdata for persistence. Returnsnilif no positions are stored. - Parameters: None.
OnLoad(data)
- Description: Restores the
positionstable from save data and refreshes networked location state viaNetworkLocation(). - Parameters:
data(table|nil): Saved component state, expected to contain apositionskey.
GetDebugString()
- Description: Returns a debug string for in-game debugging tools, showing the stored chest position as
"Pos: x z"or"NPOS"if unavailable. - Parameters: None.
Events & Listeners
- Listens for no events explicitly (no
inst:ListenForEventcalls). - Triggers/pushes:
"updatewobycourierchesticon"— Pushed viainst:PushEvent()fromNetworkLocation()when the entity isThePlayer(i.e., server is client), to signal UI updates.