Deployable
Based on game build 714014 | Last updated: 2026-03-03
Overview
Deployable defines how an entity can be deployed (placed) into the world, including constraints on who can deploy it, where it can be placed, and how placement is validated. It works closely with inventoryitem_replica to sync deployment settings to the client and integrates with inventory, rider, and complexprojectile components to enforce context-sensitive deployment rules. It also interacts with TheWorld.Map functions to validate spatial constraints.
Usage example
local inst = CreateEntity()
inst:AddComponent("deployable")
inst.components.deployable:SetDeployMode(DEPLOYMODE.TURF)
inst.components.deployable:SetDeploySpacing(DEPLOYSPACING.BIG)
inst.components.deployable:SetUseGridPlacer(true)
inst.components.deployable.ondeploy = function(inst, pt, deployer, rot)
-- custom logic during deployment
end
Dependencies & tags
Components used: inventory, rider, complexprojectile (for IsRiding and IsFloaterHeld checks), inventoryitem_replica (via self.inst.replica.inventoryitem).
Tags: Adds deployable on attachment; removes it on component removal.
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
mode | DEPLOYMODE | DEPLOYMODE.DEFAULT | Deployment mode (e.g., TURF, WATER, CUSTOM). Controls placement rules. |
spacing | DEPLOYSPACING | DEPLOYSPACING.DEFAULT | Spacing constraint used for radius checks during placement. |
restrictedtag | string or nil | nil | If set, only entities with this tag may deploy this item. |
usegridplacer | boolean or nil | nil | If truthy, uses grid-based placement instead of freehand. |
ondeploy | function or nil | nil | Optional callback fired during deployment: function(inst, pt, deployer, rot). |
deploytoss_symbol_override | table or nil | nil | Symbol override data for the deploytoss_pre animation. |
Main functions
SetDeployMode(mode)
- Description: Sets the deployment mode, which determines the placement logic (e.g.,
TURF,WATER,CUSTOM). - Parameters:
mode(DEPLOYMODE) — the deployment behavior mode. - Returns: Nothing.
GetDeployMode()
- Description: Returns the current deployment mode.
- Parameters: None.
- Returns:
DEPLOYMODE— the currently configured mode.
SetDeploySpacing(spacing)
- Description: Sets the spacing constraint for radius-based placement checks.
- Parameters:
spacing(DEPLOYSPACING) — spacing level (e.g.,DEFAULT,BIG). - Returns: Nothing.
SetUseGridPlacer(usegridplacer)
- Description: Enables or disables grid-based placement for this item.
- Parameters:
usegridplacer(boolean or truthy/falsy value) — whether to use grid snapping. - Returns: Nothing.
DeploySpacingRadius()
- Description: Returns the placement radius (in world units) corresponding to the current
spacing. - Parameters: None.
- Returns:
number— radius used for collision and spacing checks during placement.
IsDeployable(deployer)
- Description: Checks whether the given entity (
deployer) is allowed to deploy this item, based on tag restrictions and contextual state (e.g., riding or floating). - Parameters:
deployer(Entityornil) — the entity attempting deployment. - Returns:
boolean—trueif deployment is allowed,falseotherwise. - Error states: Returns
falseifrestrictedtagis set anddeployerlacks it; returnsfalseif deployed by a rider but the item is not acomplexprojectile; returnsfalseif deployed by a floater-held item but the item lacks theboatbuildertag.
CanDeploy(pt, mouseover, deployer, rot)
- Description: Validates whether the item can be placed at the given world point
pt, according tomodeand world geometry. - Parameters:
pt(VectororVectorReplica) — world position to attempt placement.mouseover(Entityornil) — the entity under the mouse (used inDEFAULTmode).deployer(Entityornil) — the deploying entity.rot(numberornil) — rotation angle (used inCUSTOMmode).
- Returns:
boolean—trueif placement is valid atpt,falseotherwise. - Error states: Returns
falseifIsDeployable(deployer)returnsfalse; delegates placement validation toTheWorld.Mapfunctions based onmode.
Deploy(pt, deployer, rot)
- Description: Attempts to deploy the item at
pt, calling validation and custom logic, then removes the item from the world (assumes it is consumed or converted to a placed entity). - Parameters:
pt(Vector) — deployment position.deployer(Entityornil) — deploying entity.rot(numberornil) — rotation at placement.
- Returns:
success(boolean),reason(string ornil) —successistrueonly ifCanDeploypasses and deployment logic completes;reasonmay contain a failure message on failure. - Error states: Returns
false, reasonifCanDeployfails;self.instmay be removed during theondeploycallback, so callers must avoid referencing it afterward.
SetDeployTossSymbolOverride(data)
- Description: Sets symbol override data for the deployment toss animation (
deploytoss_pre). Used to visually customize the toss (e.g., show a boat icon while deploying a boat). - Parameters:
data(table ornil) — symbol override configuration; structure matchesanim:GetSymbol()usage. - Returns: Nothing.
Events & listeners
- Listens to: None explicitly (internal callbacks via property setters).
- Pushes:
deployitem— fired viadeployer:PushEvent("deployitem", { prefab = self.inst.prefab })during successful deployment;itemplanted— fired viaTheWorld:PushEvent("itemplanted", { doer = deployer, pos = pt })if the item has thedeployedplanttag.
Additional notes
- The constructor automatically adds the
deployabletag toself.inst. - On removal from entity (
OnRemoveFromEntity), it resetsinventoryitem_replicadeployment properties and removes thedeployabletag. - Property setters for
mode,spacing,restrictedtag, andusegridplacertrigger corresponding updates oninventoryitem_replica, ensuring client-side sync.