TradeItemAction

Agent action that places a carried item on the trading table and initiates a trade context. Cancels the CarryInteraction, moves the item to the table center, tags it as "AwaitingTrade", and waits for the trade to be accepted or resolved.

Definition

Namespace: Paragon.Townskeep.AgentSystem Assembly: Townskeep.dll

public class TradeItemAction : AgentAction

Inheritance: ActionAgentAction → TradeItemAction

Remarks

TradeItemAction is the culmination of the agent trade sequence: after WanderAction finds an item, GrabItemAction picks it up, and GoToTradeAction navigates to the table, this action places the item and waits for the player to complete the trade.

Execution Flow

spinner

Trade Sequence

  1. Tag item — Sets interactable.tag = "AwaitingTrade" to mark the item for the UI/shop system

  2. Cancel carry — Calls carryInteraction.Cancel() to release the item from the character's hands

  3. Position item — Uses item.Rigidbody.MovePosition() to place the item at the table center

  4. Start trade — Creates a TradeContext via tradingArea.StartTradeContext(agent, item)

  5. Wait — Blocks with Yield.WaitWhile until tradingArea.IsAwaitingTrade becomes false (trade accepted or cancelled)

Quick Lookup

Goal
How

Execute a trade

Add TradeItemAction to sequence after GoToTradeAction

Set the item to trade

Ensure "Item" variable is set in the sequence

Fields

Field
Type
Access
Description

item

Item

[Variable] private

The item to trade; bound from sequence variables

table

Table

private

Cached "Trading Table" reference

tradingArea

TradingArea

private

The trading area of the table

placeItemPosition

Vector3

private

Center of the table bounds — where the item is placed

interactable

Interactable

private

The item's Interactable component

Methods

OnBegin

Resolves the item's Interactable, finds the "Trading Table", caches the TradingArea, and calculates the item placement position from the table bounds center.

OnExecute

Cancels the carry interaction, repositions the item, starts the trade context, and waits for trade resolution.

Common Pitfalls

circle-exclamation
circle-exclamation
circle-exclamation
circle-exclamation
circle-exclamation
circle-exclamation

See Also

Last updated