mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-20 06:32:56 +00:00
* ONLY SKYRAT CHANGES * ACTUALLY SKYRAT CHANGES * yolo, revert later * Update alternate_byond_versions.txt Co-authored-by: AnturK <AnturK@users.noreply.github.com>
31 lines
1.2 KiB
Plaintext
31 lines
1.2 KiB
Plaintext
/// When a movable has this component AND they are in the contents of a container, they will no longer be able to use their hands and be immobilized until they are removed from the container. So far, this is only useful for smites.
|
|
/datum/component/itembound
|
|
/// Weak reference to the container that the movable is inside of.
|
|
var/datum/weakref/containerref
|
|
/// Detect any movement of the container
|
|
var/datum/movement_detector/move_tracker
|
|
|
|
/datum/component/itembound/Initialize(atom/movable/passed_container)
|
|
if(!ismovable(parent))
|
|
return COMPONENT_INCOMPATIBLE
|
|
if(QDELETED(passed_container))
|
|
return
|
|
containerref = WEAKREF(passed_container)
|
|
move_tracker = new(parent, CALLBACK(src, PROC_REF(verify_containment)))
|
|
|
|
ADD_TRAIT(parent, TRAIT_INCAPACITATED, SMITE_TRAIT)
|
|
|
|
/// Ensure that when we move, we still are in the container. If not in the container, remove all the traits.
|
|
/datum/component/itembound/proc/verify_containment()
|
|
var/atom/movable/container = containerref.resolve()
|
|
if(!QDELETED(container) && container.contains(parent))
|
|
return
|
|
REMOVE_TRAIT(parent, TRAIT_INCAPACITATED, SMITE_TRAIT)
|
|
qdel(src)
|
|
|
|
/datum/component/itembound/Destroy(force, silent)
|
|
containerref = null
|
|
QDEL_NULL(move_tracker)
|
|
return ..()
|
|
|