Socket Shadow Harvester
Based on game build 722832 | Last updated: 2026-04-28
Overview
Socket_Shadow_Harvester enables automated harvesting of nearby pickable entities and traps through shadow tendril projectiles. It is primarily used for WX-78's skill system passive harvesting ability. Player entities trigger ticks via pickup/pick events, while non-player entities use periodic task-based ticking. The component spawns visual tendrils that travel to target items and harvest them upon arrival.
Usage example
local inst = CreateEntity()
inst:AddComponent("socket_shadow_harvester")
inst.components.socket_shadow_harvester:SetHarvestRadius(6)
inst.components.socket_shadow_harvester:SetMaxTendrils(3)
inst.components.socket_shadow_harvester:SetTravelSpeed(3)
Dependencies & tags
External dependencies:
TUNING.SKILLS.WX78.HARVEST_PASSIVE_TICK_PERIOD-- tick period constant for passive harvestingFindPickupableItem-- external function to locate harvestable items in rangeLaunch2-- external function to launch loot items after harvestingmath2d.DistSq-- distance calculation utility
Components used:
trap-- callsHarvest()on trap componentspickable-- callsPick()on pickable componentsinventoryitem-- checks owner status to validate targetsstackable-- callsGet()to extract single items from stacksinventoryorcontainer-- callsGiveItem()to transfer harvested itemsminigame_participator-- callsGetMinigame()to push cheat eventsupdatelooper-- adds update function for tendril movementSoundEmitter-- plays pick sounds on successful harvests
Tags:
pickable-- required tag for valid harvest targetsplant,lichen,oceanvine,kelp-- one of these tags required for valid targetsINLIMBO,FX-- entities with these tags are excluded from harvesting
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
harvestradius | number | 4 | Maximum distance in units to search for harvestable items. |
travelspeed | number | 2 | Speed at which shadow tendrils travel toward targets. |
maxtendrils | number | 1 | Maximum number of concurrent tendrils allowed. |
tendrilscount | number | 0 | Current count of active tendrils. |
tendrils | table | {} | Maps tendril entities to their target items. |
items | table | {} | Inverted lookup table mapping items to their tendrils. |
periodictask | task | nil | Periodic task handle for non-player entity ticking. |
item | entity | nil | Currently tracked item entity. |
removeontendrilsfinished | boolean | nil | If true, entity removes itself after all tendrils complete. |
onusedfn | function | nil | Callback hook fired after successful harvest. Signature: fn(inst). Set by owning prefab. |
ontendrilremoved | function | nil | Callback assigned in constructor. Handles tendril cleanup when a tendril entity is removed. |
onitemremoved | function | nil | Callback assigned in constructor. Handles item cleanup when a tracked item entity is removed. |
OnTick | function | nil | Callback assigned in constructor. Triggers DoTick() when called. |
OnAoETick | function | nil | Player-only callback assigned in constructor. Handles picksomethingfromaoe event by calling DoTick() for each harvested item. |
Main functions
OnRemoveFromEntity()
- Description: Cleanup function called when component is removed from entity. Cancels periodic tasks, removes event listeners, and removes all active tendrils.
- Parameters: None
- Returns: nil
- Error states: None
SetHarvestRadius(harvestradius)
- Description: Sets the maximum search radius for harvestable items.
- Parameters:
harvestradius-- number representing search radius in units - Returns: nil
- Error states: None
SetTravelSpeed(travelspeed)
- Description: Sets the movement speed of shadow tendrils traveling to targets.
- Parameters:
travelspeed-- number representing units per second - Returns: nil
- Error states: None
SetMaxTendrils(maxtendrils)
- Description: Sets the maximum number of concurrent tendrils that can be active.
- Parameters:
maxtendrils-- number representing maximum concurrent tendrils - Returns: nil
- Error states: None
RemoveOnTendrilsFinished()
- Description: Sets the flag to remove the owning entity after all tendrils complete their harvesting.
- Parameters: None
- Returns: nil
- Error states: None
ClearItem()
- Description: Clears the currently tracked item and removes its onremove event listener.
- Parameters: None
- Returns: nil
- Error states: None
SetItem(item)
- Description: Sets a specific item to track and registers an onremove event listener. Automatically clears any previously tracked item.
- Parameters:
item-- entity instance to track - Returns: nil
- Error states: None
HarvestItem_Internal(tendril, item)
- Description: Executes the harvest logic on a target item. Handles traps via
trap:Harvest(), pickables viapickable:Pick(), and generic items via inventory transfer. Plays pick sounds and launches loot. Pushespickupcheatevent to minigame if participator exists. Callsonusedfncallback after completion. - Parameters:
tendril-- shadow tendril entity that reached the targetitem-- target item entity to harvest
- Returns: nil
- Error states: Errors if
self.inst.components.inventoryandself.inst.components.containerare both nil when attempting to give harvested items (no nil guard present).
TryToFindItem()
- Description: Searches for valid harvestable items within the harvest radius. Uses
FindPickupableItemwith component tag filters. - Parameters: None
- Returns: Entity instance of found item, or
nilif no valid target exists. - Error states: Errors if
self.inst.components.inventoryandself.inst.components.containerare both nil (passed toFindPickupableItemwithout nil guard).
DoTick()
- Description: Main tick function that spawns a shadow tendril toward a found item. Checks tendril count against maximum, finds a target item, spawns a
shadow_harvester_trailprefab, and sets up an updatelooper to move the tendril toward the target. When the tendril reaches the target, callsHarvestItem_Internal(). Increments tendril count and registers onremove listeners for cleanup. - Parameters: None
- Returns: nil
- Error states: Errors if
self.inst.Transformis nil when getting position for tendril spawn (no nil guard present).
OnAoETick(data)
- Description: Player-only. Handles the
picksomethingfromaoeevent by iterating through the harvested count and callingDoTick()for each harvested item. - Parameters:
data-- table containingharvestedcountfield indicating number of items harvested - Returns: nil
- Error states: None
Events & listeners
Listens to:
onpickupitem(player only) -- triggersOnTickwhen player picks up an itempicksomething(player only) -- triggersOnTickwhen player picks somethingpicksomethingfromaoe(player only) -- triggersOnAoETickwith harvest count dataonremove(tendril) -- triggersontendrilremovedcallback when tendril is removedonremove(item) -- triggersonitemremovedcallback when tracked item is removed
Pushes:
pickupcheat-- pushed to minigame component ifminigame_participatorexists. Data:{cheater = entity, item = entity}