From 1ad915beed82c52bf9366ce66287ffffcbde9339 Mon Sep 17 00:00:00 2001 From: Jack Edge Date: Sat, 2 Jul 2016 00:03:04 +0100 Subject: [PATCH] Now working, let's do this --- code/__DEFINES/shuttles.dm | 2 + code/controllers/subsystem/shuttles.dm | 87 +++++++++++++++++++++----- code/game/objects/effects/landmarks.dm | 23 +++++++ code/game/turfs/space/transit.dm | 12 ++++ code/modules/shuttle/shuttle.dm | 8 ++- 5 files changed, 113 insertions(+), 19 deletions(-) diff --git a/code/__DEFINES/shuttles.dm b/code/__DEFINES/shuttles.dm index 03212bb81b3d6..caf1723a3d4ed 100644 --- a/code/__DEFINES/shuttles.dm +++ b/code/__DEFINES/shuttles.dm @@ -35,3 +35,5 @@ #define TRANSIT_REQUEST 1 #define TRANSIT_READY 2 #define TRANSIT_FULL 3 + +#define SHUTTLE_TRANSIT_BORDER 8 diff --git a/code/controllers/subsystem/shuttles.dm b/code/controllers/subsystem/shuttles.dm index 259ff9170daec..57bc234893532 100644 --- a/code/controllers/subsystem/shuttles.dm +++ b/code/controllers/subsystem/shuttles.dm @@ -14,6 +14,7 @@ var/datum/subsystem/shuttle/SSshuttle var/list/turf/transit_turfs = list() var/list/transit_requesters = list() + var/clear_transit = FALSE //emergency shuttle stuff var/obj/docking_port/mobile/emergency/emergency @@ -66,6 +67,7 @@ var/datum/subsystem/shuttle/SSshuttle var/turf/B = get_turf(transit_markers[2]) for(var/i in block(A, B)) var/turf/T = i + T.ChangeTurf(/turf/open/space) transit_turfs += T T.flags |= UNUSED_TRANSIT_TURF #ifdef HIGHLIGHT_DYNAMIC_TRANSIT @@ -75,10 +77,16 @@ var/datum/subsystem/shuttle/SSshuttle T.color = "#00ffff" #endif - world.log << "[transit_turfs.len] transit turfs registered" + //world.log << "[transit_turfs.len] transit turfs registered" /datum/subsystem/shuttle/fire() - if(transit_requesters.len) + if(clear_transit) + transit_requesters.Cut() + for(var/i in transit) + qdel(i, force=TRUE) + setup_transit_zone() + clear_transit = FALSE + else if(transit_requesters.len) var/requester = popleft(transit_requesters) var/success = generate_transit_dock(requester) if(!success) // BACK OF THE QUEUE @@ -254,20 +262,25 @@ var/datum/subsystem/shuttle/SSshuttle // Because of shuttle rotation, the "width" of the shuttle is not // always x. var/travel_dir = M.preferred_direction - //var/coords = M.return_coords(0, 0, travel_dir) + var/dock_angle = dir2angle(M.preferred_direction) + M.port_angle + 180 + var/dock_dir = angle2dir(dock_angle) - var/transit_width = 14 - var/transit_height = 14 + var/transit_width = SHUTTLE_TRANSIT_BORDER * 2 + var/transit_height = SHUTTLE_TRANSIT_BORDER * 2 // Shuttles travelling on their side have their dimensions swapped // from our perspective - switch(travel_dir) + switch(dock_dir) if(NORTH, SOUTH) transit_width += M.width transit_height += M.height if(EAST, WEST) transit_width += M.height transit_height += M.width +/* + world << "The attempted transit dock will be [transit_width] width, and \ + [transit_height] in height. The travel dir is [travel_dir]." +*/ // Then find a place to put the zone @@ -291,33 +304,75 @@ var/datum/subsystem/shuttle/SSshuttle continue for(var/j in proposed_zone) var/turf/T = j + if(!T) + continue base if(!(T.flags & UNUSED_TRANSIT_TURF)) continue base - break + world << "[COORD(topleft)] and [COORD(bottomright)]" + break base if((!proposed_zone) || (!proposed_zone.len)) return FALSE var/turf/topleft = proposed_zone[1] + world << "[COORD(topleft)] is TOPLEFT" // Then create a transit docking port in the middle - var/mid_x = 7 + M.dwidth + topleft.x - var/mid_y = 7 + M.dheight + topleft.y - - var/turf/midpoint = locate(mid_x, mid_y, topleft.z) + var/coords = M.return_coords(0, 0, dock_dir) + world << json_encode(coords) + /* 0------2 + | | + | | + | x | + 3------1 + */ + + var/x0 = coords[1] + var/y0 = coords[2] + var/x1 = coords[3] + var/y1 = coords[4] + // Then we want the point closest to -infinity,-infinity + var/x2 = min(x0, x1) + var/y2 = min(y0, y1) +/* + var/lowx = topleft.x + SHUTTLE_TRANSIT_BORDER + var/lowy = topleft.y + SHUTTLE_TRANSIT_BORDER + + var/turf/low_point = locate(lowx, lowy, topleft.z) + new /obj/effect/landmark/stationary(low_point) + world << "Starting at the low point, we go [x2],[y2]" +*/ + // Then invert the numbers + var/transit_x = topleft.x + SHUTTLE_TRANSIT_BORDER + abs(x2) + var/transit_y = topleft.y + SHUTTLE_TRANSIT_BORDER + abs(y2) + + var/transit_path = /turf/open/space/transit + switch(travel_dir) + if(NORTH) + transit_path = /turf/open/space/transit/north + if(SOUTH) + transit_path = /turf/open/space/transit/south + if(EAST) + transit_path = /turf/open/space/transit/east + if(WEST) + transit_path = /turf/open/space/transit/west + + //world << "Docking port at [transit_x], [transit_y], [topleft.z]" + var/turf/midpoint = locate(transit_x, transit_y, topleft.z) + if(!midpoint) + return FALSE + //world << "Making transit dock at [COORD(midpoint)]" var/obj/docking_port/stationary/transit/new_transit_dock = new(midpoint) new_transit_dock.assigned_turfs = proposed_zone new_transit_dock.name = "Transit for [M.id]/[M.name]" + new_transit_dock.turf_type = transit_path - var/dock_angle = dir2angle(M.preferred_direction) + M.port_angle + 180 // Add 180, because ports point inwards, rather than outwards new_transit_dock.setDir(angle2dir(dock_angle)) for(var/i in new_transit_dock.assigned_turfs) - var/turf/open/space/transit/T = i + var/turf/T = i + T.ChangeTurf(transit_path) T.flags &= ~(UNUSED_TRANSIT_TURF) - T.ChangeTurf(/turf/open/space/transit) - T.setDir(travel_dir) - T.update_icon() M.assigned_transit = new_transit_dock return TRUE diff --git a/code/game/objects/effects/landmarks.dm b/code/game/objects/effects/landmarks.dm index d3f42f00d5998..97d12a567ffb4 100644 --- a/code/game/objects/effects/landmarks.dm +++ b/code/game/objects/effects/landmarks.dm @@ -286,3 +286,26 @@ ruin_landmarks -= src ruin_template = null . = ..() + +/obj/effect/landmark/stationary + name = "stationary landmark" + desc = "This doesn't seem to move." + invisibility = 0 + layer = GHOST_LAYER + var/trueLoc + +/obj/effect/landmark/stationary/New(loc) + . = ..() + trueLoc = loc + START_PROCESSING(SSfastprocess, src) + +/obj/effect/landmark/stationary/Destroy() + trueLoc = null + STOP_PROCESSING(SSfastprocess, src) + +/obj/effect/landmark/stationary/process() + if(loc != trueLoc) + forceMove(trueLoc) + +/obj/effect/landmark/stationary/onShuttleMove() + return FALSE diff --git a/code/game/turfs/space/transit.dm b/code/game/turfs/space/transit.dm index 13e75be6634a4..353d3f0ffdbcb 100644 --- a/code/game/turfs/space/transit.dm +++ b/code/game/turfs/space/transit.dm @@ -3,9 +3,21 @@ dir = SOUTH baseturf = /turf/open/space/transit +/turf/open/space/transit/south + dir = SOUTH + +/turf/open/space/transit/north + dir = NORTH + /turf/open/space/transit/horizontal dir = WEST +/turf/open/space/transit/west + dir = WEST + +/turf/open/space/transit/east + dir = EAST + /turf/open/space/transit/Entered(atom/movable/AM, atom/OldLoc) if(!AM) return diff --git a/code/modules/shuttle/shuttle.dm b/code/modules/shuttle/shuttle.dm index d84655cccbd57..938f11ad7987c 100644 --- a/code/modules/shuttle/shuttle.dm +++ b/code/modules/shuttle/shuttle.dm @@ -37,11 +37,11 @@ return //we don't rotate with shuttles via this code. //returns a list(x0,y0, x1,y1) where points 0 and 1 are bounding corners of the projected rectangle /obj/docking_port/proc/return_coords(_x, _y, _dir) - if(!_dir) + if(_dir == null) _dir = dir - if(!_x) + if(_x == null) _x = x - if(!_y) + if(_y == null) _y = y //byond's sin and cos functions are inaccurate. This is faster and perfectly accurate @@ -136,6 +136,7 @@ var/turf_type = /turf/open/space var/area_type = /area/space + var/last_dock_time /obj/docking_port/stationary/New() ..() @@ -481,6 +482,7 @@ SSair.add_to_active(T0,1) check_poddoors() + S1.last_dock_time = world.time loc = S1.loc setDir(S1.dir)