Files
Bubberstation/code/datums/elements/floorloving.dm
SkyratBot b6601a2405 [MIRROR] March into Mapness: Meateor [MDB IGNORE] (#20233)
* March into Mapness: Meateor (#74070)

* March into Mapness: Meateor

---------

Co-authored-by: Jacquerel <hnevard@gmail.com>
2023-04-01 05:39:55 -04:00

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!")