Files
Bubberstation/code/datums/components/strong_pull.dm
SkyratBot 1ca81d9b86 [MIRROR] adds #cargobus and gauntlets (also modernizes ntchat) (#5458)
* adds #cargobus and gauntlets (also modernizes ntchat)

* Update quartermaster.dm

* Update DeltaStation2_skyrat.dmm

* mirrors changes

Co-authored-by: tralezab <40974010+tralezab@users.noreply.github.com>
Co-authored-by: KathrinBailey <53862927+KathrinBailey@users.noreply.github.com>
Co-authored-by: KathrinBailey <evesovereign@hotmail.co.uk>
2021-05-08 14:25:24 +01:00

44 lines
1.7 KiB
Plaintext

/*
This component attaches to mobs, and makes their pulls !strong!
Basically, the items they pull cannot be pulled (except by the puller)
*/
/datum/component/strong_pull
var/atom/movable/strongpulling
/datum/component/strong_pull/Initialize()
if(!isliving(parent))
return COMPONENT_INCOMPATIBLE
RegisterSignal(parent, COMSIG_LIVING_START_PULL, .proc/on_pull)
/**
* Called when the parent grabs something, adds signals to the object to reject interactions
*/
/datum/component/strong_pull/proc/on_pull(datum/source, atom/movable/pulled, state, force)
SIGNAL_HANDLER
strongpulling = pulled
RegisterSignal(strongpulling, COMSIG_ATOM_CAN_BE_PULLED, .proc/reject_further_pulls)
RegisterSignal(strongpulling, COMSIG_ATOM_NO_LONGER_PULLED, .proc/lost_strong_grip)
if(istype(strongpulling, /obj/structure/closet) && !istype(strongpulling, /obj/structure/closet/body_bag))
var/obj/structure/closet/grabbed_closet = strongpulling
grabbed_closet.strong_grab = TRUE
/**
* Signal for rejecting further grabs
*/
/datum/component/strong_pull/proc/reject_further_pulls(datum/source, mob/living/puller)
SIGNAL_HANDLER
if(puller != parent)//for increasing grabs, you need to have a valid pull. thus, parent should be able to pull the same object again
return COMSIG_ATOM_CANT_PULL
/**
* Called when the hooked object is no longer pulled, and unhooks it
*/
/datum/component/strong_pull/proc/lost_strong_grip(datum/source, atom/movable/last_puller)
SIGNAL_HANDLER
UnregisterSignal(strongpulling, list(COMSIG_ATOM_CAN_BE_PULLED, COMSIG_ATOM_NO_LONGER_PULLED))
if(istype(strongpulling, /obj/structure/closet))
var/obj/structure/closet/ungrabbed_closet = strongpulling
ungrabbed_closet.strong_grab = FALSE
strongpulling = null