mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-13 02:13:06 +00:00
* Fix movement turf changer element to check openspace (#65757) Fixes #65472 (The movement_turf_changer element allows creatures to step onto open space and fill them in ) This adds an openspace check for the movement_turf_changer element so that whatever mob is using it will fall through openspace properly. I don't know what a moonicorn is but it sounds cool. * Fix movement turf changer element to check openspace Co-authored-by: Tim <timothymtorres@gmail.com>
33 lines
928 B
Plaintext
33 lines
928 B
Plaintext
/**
|
|
* movement_turf_changer element; which makes the movement of a movable atom change the turf it moved to
|
|
*
|
|
* Used for moonicorns!
|
|
*/
|
|
/datum/element/movement_turf_changer
|
|
element_flags = ELEMENT_BESPOKE|ELEMENT_DETACH
|
|
id_arg_index = 2
|
|
///Path of the turf added on top
|
|
var/turf_type
|
|
|
|
/datum/element/movement_turf_changer/Attach(datum/target, turf_type)
|
|
. = ..()
|
|
|
|
if(!ismovable(target))
|
|
return ELEMENT_INCOMPATIBLE
|
|
|
|
src.turf_type = turf_type
|
|
RegisterSignal(target, COMSIG_MOVABLE_MOVED, .proc/on_moved)
|
|
|
|
/datum/element/movement_turf_changer/Detach(datum/target)
|
|
UnregisterSignal(target, COMSIG_MOVABLE_MOVED)
|
|
. = ..()
|
|
|
|
/datum/element/movement_turf_changer/proc/on_moved(atom/movable/target, atom/origin, direction, forced)
|
|
SIGNAL_HANDLER
|
|
|
|
var/turf/destination = target.loc
|
|
if(!isturf(destination) || istype(destination, turf_type) || isopenspaceturf(destination))
|
|
return
|
|
|
|
destination.PlaceOnTop(turf_type)
|