mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-31 20:11:56 +00:00
22 lines
814 B
Plaintext
22 lines
814 B
Plaintext
/// Prevents a movable atom from moving to somewhere which isn't an open turf with floor on it
|
|
/datum/element/floor_loving
|
|
|
|
/datum/element/floor_loving/Attach(datum/target)
|
|
. = ..()
|
|
if(!ismovable(target))
|
|
return ELEMENT_INCOMPATIBLE
|
|
RegisterSignal(target, COMSIG_MOVABLE_PRE_MOVE, PROC_REF(attempting_move))
|
|
|
|
/datum/element/floor_loving/Detach(datum/target)
|
|
UnregisterSignal(target, COMSIG_MOVABLE_PRE_MOVE)
|
|
return ..()
|
|
|
|
/// Block movement to any non-floor location
|
|
/datum/element/floor_loving/proc/attempting_move(atom/movable/parent, newloc)
|
|
SIGNAL_HANDLER
|
|
if (!isopenturf(newloc) || isspaceturf(newloc) || isopenspaceturf(newloc))
|
|
return COMPONENT_MOVABLE_BLOCK_PRE_MOVE
|
|
if (isliving(parent))
|
|
var/mob/living/living_parent = parent
|
|
living_parent.balloon_alert(living_parent, "can't move there!")
|