Pocketwatch Dismantler
Based on game build 722832 | Last updated: 2026-04-18
Overview
PocketWatch_Dismantler provides the logic for dismantling pocketwatch items back into their constituent recipe ingredients. This component is typically added to pocketwatch prefabs and works alongside inventoryitem, lootdropper, rechargeable, and itemmimic components. It validates dismantling conditions including cooldown status and doer qualifications before processing the item conversion.
Usage example
local inst = CreateEntity()
inst:AddComponent("pocketwatch_dismantler")
inst:AddComponent("inventoryitem")
inst:AddComponent("lootdropper")
local can_dismantle, reason = inst.components.pocketwatch_dismantler:CanDismantle(target, doer)
if can_dismantle then
inst.components.pocketwatch_dismantler:Dismantle(target, doer)
end
Dependencies & tags
Components used:
rechargeable-- checksIsCharged()to validate cooldown statusinventoryitem-- callsGetGrandOwner()to find the item owneritemmimic-- callsTurnEvil()if target is a mimic itemlootdropper-- callsGetFullRecipeLoot()andSpawnLootPrefab()for ingredient spawninginventory-- used as receiver for returned itemscontainer-- alternative receiver for returned itemssoundemitter-- callsPlaySound()on doer when dismantling mimic items
Tags:
clockmaker-- checked on doer; required to perform dismantlingpocketdimension_container-- checked on owner; affects item receiver logic
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | Entity | nil | The entity instance that owns this component. |
Main functions
CanDismantle(target, doer)
- Description: Validates whether a target item can be dismantled by the given doer. Checks rechargeable cooldown status and verifies the doer has the clockmaker tag.
- Parameters:
target-- entity instance of the item to dismantledoer-- entity instance attempting the dismantling action
- Returns: Boolean
trueif dismantling is allowed, orfalsewith optional string reason"ONCOOLDOWN"if on cooldown. - Error states: Errors if
doeris nil when callingdoer:HasTag()-- no nil guard present. Therechargeablecomponent check includes a nil guard and will not error if missing.
Dismantle(target, doer)
- Description: Performs the actual dismantling operation. For item mimics, triggers the reveal transformation. For regular items, spawns recipe ingredients as loot and removes the target entity. Plays a sound effect for mimic items.
- Parameters:
target-- entity instance of the item to dismantledoer-- entity instance performing the dismantling action
- Returns: None
- Error states: Errors if
targetlacksinventoryitemcomponent (nil dereference ontarget.components.inventoryitem:GetGrandOwner()-- no guard present), or iftargetlackslootdroppercomponent when not an item mimic (nil dereference ontarget.components.lootdropper:GetFullRecipeLoot()). Errors ifAllRecipes[target.prefab]is nil when accessing recipe data. Errors ifdoeris nil when accessingdoer.Transform(no guard in non-mimic branch);doer.SoundEmitteraccess is guarded byif doer and doer.SoundEmitter then.
Events & listeners
- Listens to: None identified.
- Pushes: None identified.