GoToTradeAction
Agent action that navigates the character to the trading table's outer spot. Finds the "Trading Table" in the scene, resolves its TradingArea, and delegates movement to a MoveToTargetAction.
Definition
Namespace: Paragon.Townskeep.AgentSystem
Assembly: Townskeep.dll
public class GoToTradeAction : AgentActionInheritance: Action → AgentAction → GoToTradeAction
Remarks
GoToTradeAction is used in the agent's trade sequence to walk the character to the trading table before placing an item for trade. It follows the same sub-action composition pattern as GoToStoreAction and FollowPathAction.
Execution Flow
Variable Binding
The item field is marked [Variable], meaning it can be set from the ActionSequence variable system (e.g., by a preceding WanderAction that sets "Item"). However, item is not used in this action's execution — it is declared but only the trading table location matters for navigation.
Quick Lookup
Navigate to trading table
Add GoToTradeAction to an ActionSequence
Change the target table
Modify the scene object named "Trading Table"
Fields
item
Item
[Variable] private
Bound from sequence variables; not used in this action
table
Table
private
Cached reference to the "Trading Table"
tradingArea
TradingArea
private
The trading area of the table (provides OuterSpot)
moveAction
MoveToTargetAction
private
Sub-action for NavMesh-based movement
nextPosition
Vector3
private
Declared but unused in current implementation
Methods
OnBegin
Finds the "Trading Table" via FindObjectsByType<Table>, casts its Area to TradingArea, and creates + initializes a MoveToTargetAction.
OnExecute
Sets the move target to tradingArea.OuterSpot.position and awaits movement completion.
Common Pitfalls
Scene-dependent table lookup
OnBegin() uses FindObjectsByType<Table>() filtered by gameObject.name == "Trading Table". If no table with that exact name exists in the scene, FirstOrDefault() returns null and the null-forgiving operator (!) will suppress the warning but cause a NullReferenceException on the next line.
TradingArea cast assumption
table.Area is cast directly to TradingArea without a type check. If the "Trading Table" has a different Area type, this will throw an InvalidCastException.
Sub-action created in OnBegin
The MoveToTargetAction is created and initialized in OnBegin(), following the established pattern. If OnBegin() is somehow skipped, moveAction will be null in OnExecute().
See Also
AgentAction — abstract base with agent context
TradeItemAction — the follow-up action that places and trades the item
MoveToTargetAction — the movement primitive used internally
GoToStoreAction — similar pattern for navigating to display tables
Actions Overview — subsystem architecture
Last updated