Waterpump
Based on game build 714014 | Last updated: 2026-03-07
Overview
waterpump is a static structure prefab that functions as a water pump, primarily used on boats to remove water leaks. When activated via channeling (e.g., by a player), it launches water projectiles (waterstreak_projectile) within a circular radius, with speed and direction determined by a linear easing function and nearest valid target. It integrates with components such as burnable, channelable, workable, and lootdropper, and supports serialization and placement helper visuals.
Usage example
--典型用法:在主世界中生成水泵实体
local pump = SpawnPrefab("waterpump")
if pump and pump.Transform then
pump.Transform:SetPosition(x, y, z)
-- 水泵会自动处理频道和项目发射逻辑
end
-- 注意:该实体由游戏预设系统自动管理,通常通过放置器(placer)创建
Dependencies & tags
Components used: burnable, channelable, complexprojectile, deployhelper, lootdropper, placer, workable, propagator
Tags added: structure, pump
Tags checked/ignored during target search: FX, NOCLICK, DECOR, INLIMBO, burnt, player, monster
Tag exclusions (ONEOFTAGS): fire, smolder
Properties
No public properties are directly exposed as modifiable fields in this file.
Main functions
LaunchProjectile(inst)
- Description: Launches a
waterstreak_projectiletoward a target withinTUNING.WATERPUMP.MAXRANGErange. If no valid entities are found, a random position is chosen. Speed is computed using a linear easing function based on distance. - Parameters:
inst(Entity) — the waterpump instance. - Returns: Nothing.
- Error states: Projectile only launches if
TheWorld.Map:IsVisualGroundAtPoint(x,y,z)returnsfalse(i.e., the pump is over water). Targets must be within range and avoid forbidden tags.
OnStartChanneling(inst, channeler)
- Description: Initiates the channeling interaction. Plays the
use_preanimation and schedules projectile launch after a delay. Listens foranimoverto triggerstartprojectilelaunch. - Parameters:
inst(Entity),channeler(Entity) — the entity initiating channeling (e.g., player). - Returns: Nothing.
OnStopChanneling(inst)
- Description: Stops the channeling interaction. Cancels pending tasks, resets animation, kills looping sound, and clears
channelerreference. - Parameters:
inst(Entity). - Returns: Nothing.
onhammered(inst, worker)
- Description: Called when the waterpump is hammered (e.g., destroyed or dismantled). Extinguishes any active fire, spawns a
collapse_smallFX, drops loot, notifies linked boat of a leak if on a platform, and removes the entity. - Parameters:
inst(Entity),worker(Entity) — the entity performing the hammer action. - Returns: Nothing.
onsave(inst, data), onload(inst, data)
- Description: Serialization hooks.
onsavestoresburntstate;onloadrestores it by invokingonburntlogic if marked burnt. - Parameters:
inst(Entity),data(table) — save/load state. - Returns: Nothing.
OnEnableHelper(inst, enabled)
- Description: Manages the visual placement helper (used only on client). Shows/hides a scaled proxy entity when the waterpump is being placed or removed from inventory.
- Parameters:
inst(Entity),enabled(boolean). - Returns: Nothing.
Events & listeners
- Listens to:
onburnt— triggers cleanup and removeschannelablecomponent.channel_finished— triggersOnStopChanneling.animover— triggersstartprojectilelaunch(scheduled fromuse_preanimation end).onbuilt— playsplaceanimation and sounds, callstestforland.onremove— cancels channeling if entity is removed while being channeled.
- Pushes:
spawnnewboatleak— via linked boat when hammered while burning or leaking.onextinguish,onburnt,onbuilt— standard events passed through.cancel_channel_longaction— if channeling is interrupted (e.g., burnt).entity_droploot— after loot drop.