Skip to main content

Boatrace Seastack

Based on game build 714014 | Last updated: 2026-03-07

Overview

boatrace_seastack is a destructible environmental obstacle in boat races—designed to be broken by player attacks or tools and to yield throwable deployment kits upon destruction. It behaves like a boat (via boatphysics) while being buoyant and interactable via workable and combat components. It spawns from throwable kits created using boatrace_common.MakeThrowableBoatRaceKitPrefabs. The monkey variant has no persistence and self-removes upon spawning or landing, replacing itself with a "redpouch_yotd_unwrap" effect.

Usage example

-- Add to an entity (typically via prefab factory or in spawner code)
local inst = Prefab("boatrace_seastack", fn, assets, prefabs)
inst:AddComponent("workable")
inst.components.workable:SetWorkLeft(3)
inst.components.workable:SetOnWorkCallback(OnWork)

Dependencies & tags

Components used: boatphysics, floater, lootdropper, workable, combat, health, inspectable, waterphysics, inventoryitem Tags: Adds blocker, ignorewalkableplatforms, noauradamage, seastack Tags checked: Checks burnt, structure (in lootdropper:DropLoot), and uses likewateroffducksback (indirectly via floater logic)

Properties

PropertyTypeDefault ValueDescription
max_healthnumber1Health pool set via health:SetMaxHealth(1)
absorptionnumber1Used to absorb one hit of damage before destruction
work_leftnumber3Initial work units required to break the object
massnumberTUNING.BOAT.MASSPhysics mass
frictionnumber0Zero friction for realistic boat motion
dampingnumber5Damping factor for physics simulation
collision_groupenumCOLLISION.OBSTACLESPhysics collision group
collision_maskbitfieldCOLLISION.WORLD, COLLISION.OBSTACLESPhysics collision masks
restitutionnumber1.0 + TUNING.BOATRACE_SEASTACK_EXTRA_RESTITUTIONBounciness from waterphysics component
persistbooleantrue (default) / false for monkey variantWhether the object persists between sessions

Main functions

OnWorkFinished(inst)

  • Description: Finalizes work completion by dropping loot, creating a particle effect, and removing the instance. Called when workleft <= 0.
  • Parameters: inst (entity) — the instance being worked on.
  • Returns: Nothing.
  • Error states: Safe to call only on master simulation (checked implicitly via component presence).

OnWork(inst, worker, workleft)

  • Description: Handles ongoing work on the seastack, playing a sound and triggering OnWorkFinished when done.
  • Parameters: inst (entity), worker (entity), workleft (number) — remaining work units.
  • Returns: Nothing.
  • Error states: Does not validate ownership or tool validity—relies on workable system.

ShouldKeepTarget(_)

  • Description: Static callback that disables target retention for combat—ensuring the seastack is not pursued by AI.
  • Parameters: _ — unused parameter (通常为 entity).
  • Returns: false.

OnHitByAttack(inst, attacker, damage, specialdamage)

  • Description: Converts incoming damage into work units using TUNING.BOATRACE_SEASTACK_DAMAGE_TO_WORK, then processes via workable:WorkedBy.
  • Parameters: inst (entity), attacker (entity), damage (number), specialdamage (table or number, unused).
  • Returns: Nothing.
  • Error states: Skips work application if workable component is absent.

OnCollide(inst, data)

  • Description: Plays the hit sound on physics collision, regardless of cause.
  • Parameters: inst (entity), data (table, unused).
  • Returns: Nothing.

OnBuilt(inst, _)

  • Description: Plays initial animation (1_emerge) then transitions to 1_idle, and emits a placement sound.
  • Parameters: inst (entity), _ — unused event data.
  • Returns: Nothing.

OnPhysicsWake(inst)

  • Description: Starts boat physics update loop via boatphysics:StartUpdating.
  • Parameters: inst (entity).
  • Returns: Nothing.

OnPhysicsSleep(inst)

  • Description: Stops boat physics update loop via boatphysics:StopUpdating.
  • Parameters: inst (entity).
  • Returns: Nothing.

CLIENT_ResolveFloater(inst)

  • Description: Ensures floater state is resolved on client (calls OnLandedServer) after a brief delay to align with physics settling.
  • Parameters: inst (entity).
  • Returns: Nothing.

Events & listeners

  • Listens to: on_collide — triggers OnCollide.
  • Listens to: onbuilt — triggers OnBuilt.
  • Pushes: floater_startfloating — indirectly via floater:OnLandedServer() (see connected floater.lua).
  • Pushes: entity_droploot — indirectly via lootdropper:DropLoot() (see connected lootdropper.lua).
  • Pushes: Custom events are not defined in this file.