diff --git a/code/__DEFINES/shuttles.dm b/code/__DEFINES/shuttles.dm index 196e051b644..1200599e002 100644 --- a/code/__DEFINES/shuttles.dm +++ b/code/__DEFINES/shuttles.dm @@ -58,4 +58,9 @@ #define DOCKING_COMPLETE 1 #define DOCKING_BLOCKED 2 #define DOCKING_IMMOBILIZED 4 -#define DOCKING_AREA_EMPTY 8 \ No newline at end of file +#define DOCKING_AREA_EMPTY 8 + +//Docking turf movements +#define MOVE_TURF 1 +#define MOVE_AREA 2 +#define MOVE_CONTENTS 4 \ No newline at end of file diff --git a/code/modules/shuttle/on_move.dm b/code/modules/shuttle/on_move.dm index b09c38d7148..ce63b7f781f 100644 --- a/code/modules/shuttle/on_move.dm +++ b/code/modules/shuttle/on_move.dm @@ -4,15 +4,17 @@ All ShuttleMove procs go here /************************************Base procs************************************/ -// Called on every turf in the shuttle region, return false if it doesn't want to move -/turf/proc/fromShuttleMove(turf/newT, turf_type, baseturf_type) - if(type == turf_type && baseturf == baseturf_type) - return FALSE - return TRUE +// Called on every turf in the shuttle region, returns a bitflag for allowed movements of that turf +// returns the new move_mode (based on the old) +/turf/proc/fromShuttleMove(turf/newT, turf_type, list/baseturf_cache, move_mode) + if(!(move_mode & MOVE_AREA) || (istype(src, turf_type) && baseturf_cache[baseturf])) + return move_mode + return move_mode | MOVE_TURF | MOVE_CONTENTS // Called from the new turf before anything has been moved // Only gets called if fromShuttleMove returns true first -/turf/proc/toShuttleMove(turf/oldT, shuttle_dir) +// returns the new move_mode (based on the old) +/turf/proc/toShuttleMove(turf/oldT, shuttle_dir, move_mode) for(var/i in contents) var/atom/movable/thing = i if(ismob(thing)) @@ -38,7 +40,7 @@ All ShuttleMove procs go here else qdel(thing) - return TRUE + return move_mode // Called on the old turf to move the turf data /turf/proc/onShuttleMove(turf/newT, turf_type, baseturf_type, rotation, list/movement_force, move_dir) @@ -102,13 +104,16 @@ All ShuttleMove procs go here ///////////////////////////////////////////////////////////////////////////////////// // Called on areas before anything has been moved -/area/proc/beforeShuttleMove() - return TRUE +// returns the new move_mode (based on the old) +/area/proc/beforeShuttleMove(list/shuttle_areas) + if(!shuttle_areas[src]) + return NONE + return MOVE_AREA // Called on areas to move their turf between areas /area/proc/onShuttleMove(turf/oldT, turf/newT, area/underlying_old_area) if(newT == oldT) // In case of in place shuttle rotation shenanigans. - return + return TRUE contents -= oldT underlying_old_area.contents += oldT diff --git a/code/modules/shuttle/shuttle.dm b/code/modules/shuttle/shuttle.dm index d0d5952a0c8..6ae0d98dfe2 100644 --- a/code/modules/shuttle/shuttle.dm +++ b/code/modules/shuttle/shuttle.dm @@ -21,6 +21,10 @@ var/dwidth = 0 //position relative to covered area, perpendicular to dir var/dheight = 0 //position relative to covered area, parallel to dir + var/area_type + var/turf_type + var/baseturf_type + //these objects are indestructible /obj/docking_port/Destroy(force) // unless you assert that you know what you're doing. Horrible things @@ -119,6 +123,39 @@ else . += T +/obj/docking_port/proc/return_ordered_assoc_turfs(_x, _y, _z, _dir) + if(!_dir) + _dir = dir + if(!_x) + _x = x + if(!_y) + _y = y + if(!_z) + _z = z + var/cos = 1 + var/sin = 0 + switch(_dir) + if(WEST) + cos = 0 + sin = 1 + if(SOUTH) + cos = -1 + sin = 0 + if(EAST) + cos = 0 + sin = -1 + + . = list() + + var/xi + var/yi + for(var/dx=0, dx