From 4ac4a0a70f146d523c1b5f007bfdaca933106fb8 Mon Sep 17 00:00:00 2001 From: lessthanthree <83487515+lessthnthree@users.noreply.github.com> Date: Sun, 19 Mar 2023 18:49:17 -0700 Subject: [PATCH] Tram signal process/destination improvements (#74072) ## About The Pull Request - Tram crossing signals now call process() much less often - Tram crossing signals don't turn amber/red needlessly - Tram destination landmarks are more generic to accommodate future maps, like Birdshot - Renames to_where and from_where, because those vars didn't always match tram position to/from ## Why It's Good For The Game Tram works better, uses less processing ## Changelog :cl: LT3 code: Tram crossing signal/platform logic improvements /:cl: --- .../SpaceRuins/hilbertresearchfacility.dmm | 17 +- _maps/map_files/tramstation/tramstation.dmm | 86 +++++--- code/__DEFINES/dcs/signals/signals_tram.dm | 2 +- code/__DEFINES/tram.dm | 13 +- code/modules/assembly/doorcontrol.dm | 16 +- .../industrial_lift/tram/tram_landmark.dm | 14 +- .../industrial_lift/tram/tram_lift_master.dm | 22 +-- .../industrial_lift/tram/tram_machinery.dm | 187 ++++++++---------- .../ruins/spaceruin_code/hilbertshotel.dm | 15 +- code/modules/mob/living/navigation.dm | 4 +- 10 files changed, 193 insertions(+), 183 deletions(-) diff --git a/_maps/RandomRuins/SpaceRuins/hilbertresearchfacility.dmm b/_maps/RandomRuins/SpaceRuins/hilbertresearchfacility.dmm index 58844495a2e..3fe2fffbba6 100644 --- a/_maps/RandomRuins/SpaceRuins/hilbertresearchfacility.dmm +++ b/_maps/RandomRuins/SpaceRuins/hilbertresearchfacility.dmm @@ -353,13 +353,13 @@ /turf/open/floor/mineral/titanium/tiled/yellow, /area/ruin/space/has_grav/powered/hilbertresearchfacility) "iS" = ( -/obj/effect/landmark/tram/middle_part/hilbert, /obj/machinery/light/floor{ brightness = 2; bulb_colour = "#deefff"; bulb_power = 0.6 }, /obj/structure/industrial_lift/tram/purple, +/obj/effect/landmark/tram/hilbert/middle, /turf/open/floor/engine, /area/ruin/space/has_grav/powered/hilbertresearchfacility) "iY" = ( @@ -1067,8 +1067,8 @@ }, /obj/structure/sign/departments/cargo/directional/north, /obj/machinery/button/tram{ - id = "middle_part_hilbert"; - pixel_y = 4; + id = 2; + pixel_y = 9; lift_id = "tram_hilbert" }, /obj/structure/table/reinforced/plastitaniumglass, @@ -1383,8 +1383,7 @@ /area/ruin/space/has_grav/powered/hilbertresearchfacility) "Fo" = ( /obj/machinery/button/tram{ - id = "left_part_hilbert"; - pixel_y = 4; + pixel_y = 9; lift_id = "tram_hilbert" }, /obj/structure/table/reinforced/rglass, @@ -1415,7 +1414,7 @@ /turf/open/floor/wood, /area/ruin/space/has_grav/powered/hilbertresearchfacility) "Gf" = ( -/obj/effect/landmark/tram/right_part/hilbert, +/obj/effect/landmark/tram/hilbert/right, /turf/open/floor/engine, /area/ruin/space/has_grav/powered/hilbertresearchfacility) "Gi" = ( @@ -1435,8 +1434,8 @@ }, /obj/structure/table/reinforced/rglass, /obj/machinery/button/tram{ - id = "right_part_hilbert"; - pixel_y = 4; + id = 3; + pixel_y = 9; lift_id = "tram_hilbert" }, /turf/open/floor/mineral/titanium/tiled/white, @@ -1526,7 +1525,7 @@ /turf/open/floor/grass/fairy, /area/ruin/space/has_grav/powered/hilbertresearchfacility) "It" = ( -/obj/effect/landmark/tram/left_part/hilbert, +/obj/effect/landmark/tram/hilbert/left, /turf/open/floor/engine, /area/ruin/space/has_grav/powered/hilbertresearchfacility) "Iv" = ( diff --git a/_maps/map_files/tramstation/tramstation.dmm b/_maps/map_files/tramstation/tramstation.dmm index 10a67d88ee1..5c6607460f8 100644 --- a/_maps/map_files/tramstation/tramstation.dmm +++ b/_maps/map_files/tramstation/tramstation.dmm @@ -5590,12 +5590,18 @@ /turf/open/floor/engine, /area/station/science/explab) "aFm" = ( -/obj/machinery/crossing_signal/northeast, +/obj/machinery/crossing_signal/northeast{ + inbound = 1; + outbound = 2 + }, /obj/effect/turf_decal/stripes/white/line, /turf/open/floor/iron, /area/station/hallway/primary/tram/left) "aFp" = ( -/obj/machinery/crossing_signal/northeast, +/obj/machinery/crossing_signal/northeast{ + inbound = 2; + outbound = 3 + }, /obj/effect/turf_decal/stripes/white/line, /turf/open/floor/iron, /area/station/hallway/primary/tram/center) @@ -5869,7 +5875,7 @@ dir = 1 }, /obj/machinery/button/tram/directional/north{ - id = "middle_part" + id = 2 }, /turf/open/floor/iron, /area/station/hallway/primary/tram/center) @@ -9442,7 +9448,10 @@ /turf/open/floor/iron/white, /area/station/science/research) "bJu" = ( -/obj/machinery/crossing_signal/southeast, +/obj/machinery/crossing_signal/southeast{ + inbound = 1; + outbound = 2 + }, /obj/effect/turf_decal/stripes/white/line{ dir = 1 }, @@ -17037,7 +17046,7 @@ /obj/effect/turf_decal/trimline/yellow/filled/line, /obj/effect/turf_decal/trimline/neutral/filled/warning, /obj/machinery/button/tram/directional/south{ - id = "right_part" + id = 3 }, /turf/open/floor/iron, /area/station/hallway/primary/tram/right) @@ -18892,7 +18901,9 @@ /obj/effect/turf_decal/trimline/neutral/filled/warning{ dir = 8 }, -/obj/machinery/vending/cigarette, +/obj/machinery/vending/cigarette{ + pixel_x = -5 + }, /turf/open/floor/iron, /area/station/hallway/primary/tram/center) "fja" = ( @@ -19913,7 +19924,7 @@ /area/station/security/office) "fBK" = ( /obj/structure/industrial_lift/tram/white, -/obj/effect/landmark/tram/middle_part, +/obj/effect/landmark/tram/tramstation/central, /turf/open/floor/noslip/tram_plate, /area/station/hallway/primary/tram/center) "fBX" = ( @@ -21248,9 +21259,7 @@ /obj/effect/turf_decal/trimline/neutral/filled/warning{ dir = 1 }, -/obj/machinery/button/tram/directional/north{ - id = "left_part" - }, +/obj/machinery/button/tram/directional/north, /turf/open/floor/iron, /area/station/hallway/primary/tram/left) "gel" = ( @@ -21626,7 +21635,9 @@ /obj/effect/turf_decal/trimline/neutral/filled/warning{ dir = 4 }, -/obj/machinery/vending/coffee, +/obj/machinery/vending/coffee{ + pixel_x = 5 + }, /turf/open/floor/iron, /area/station/hallway/primary/tram/center) "glp" = ( @@ -26090,7 +26101,10 @@ /turf/open/floor/iron, /area/station/security/office) "hYv" = ( -/obj/machinery/crossing_signal/northwest, +/obj/machinery/crossing_signal/northwest{ + inbound = 2; + outbound = 3 + }, /obj/effect/turf_decal/stripes/white/line, /turf/open/floor/iron, /area/station/hallway/primary/tram/right) @@ -27639,7 +27653,9 @@ /obj/effect/turf_decal/trimline/neutral/filled/warning{ dir = 4 }, -/obj/effect/spawner/random/vending/snackvend, +/obj/effect/spawner/random/vending/snackvend{ + pixel_x = 5 + }, /turf/open/floor/iron, /area/station/hallway/primary/tram/right) "iEl" = ( @@ -35163,7 +35179,7 @@ /turf/open/floor/iron, /area/station/security/prison/workout) "lkr" = ( -/obj/effect/landmark/tram/left_part, +/obj/effect/landmark/tram/tramstation/west, /turf/open/floor/noslip/tram_plate, /area/station/hallway/primary/tram/left) "lku" = ( @@ -35877,7 +35893,9 @@ /obj/effect/turf_decal/trimline/neutral/filled/warning{ dir = 4 }, -/obj/effect/spawner/random/vending/colavend, +/obj/effect/spawner/random/vending/colavend{ + pixel_x = 5 + }, /turf/open/floor/iron, /area/station/hallway/primary/tram/left) "lxW" = ( @@ -41388,7 +41406,9 @@ /obj/effect/turf_decal/trimline/neutral/filled/warning{ dir = 8 }, -/obj/effect/spawner/random/vending/snackvend, +/obj/effect/spawner/random/vending/snackvend{ + pixel_x = -5 + }, /turf/open/floor/iron, /area/station/hallway/primary/tram/left) "nAH" = ( @@ -42111,7 +42131,7 @@ /obj/effect/turf_decal/trimline/yellow/filled/line, /obj/effect/turf_decal/trimline/neutral/filled/warning, /obj/machinery/button/tram/directional/south{ - id = "middle_part" + id = 2 }, /turf/open/floor/iron, /area/station/hallway/primary/tram/center) @@ -44465,9 +44485,7 @@ }, /obj/effect/turf_decal/trimline/yellow/filled/line, /obj/effect/turf_decal/trimline/neutral/filled/warning, -/obj/machinery/button/tram/directional/south{ - id = "left_part" - }, +/obj/machinery/button/tram/directional/south, /turf/open/floor/iron, /area/station/hallway/primary/tram/left) "oNa" = ( @@ -45892,7 +45910,10 @@ /turf/open/floor/iron, /area/station/hallway/secondary/construction/engineering) "poG" = ( -/obj/machinery/crossing_signal/southwest, +/obj/machinery/crossing_signal/southwest{ + inbound = 1; + outbound = 2 + }, /obj/effect/turf_decal/stripes/white/line{ dir = 1 }, @@ -46136,7 +46157,10 @@ /turf/open/floor/iron, /area/station/maintenance/disposal/incinerator) "ptB" = ( -/obj/machinery/crossing_signal/southwest, +/obj/machinery/crossing_signal/southwest{ + inbound = 2; + outbound = 3 + }, /obj/effect/turf_decal/stripes/white/line{ dir = 1 }, @@ -49292,7 +49316,7 @@ /turf/open/floor/iron, /area/station/security/courtroom) "qyI" = ( -/obj/effect/landmark/tram/right_part, +/obj/effect/landmark/tram/tramstation/east, /turf/open/floor/noslip/tram_plate, /area/station/hallway/primary/tram/right) "qyK" = ( @@ -51542,7 +51566,9 @@ /obj/effect/turf_decal/trimline/neutral/filled/warning{ dir = 8 }, -/obj/effect/spawner/random/vending/colavend, +/obj/effect/spawner/random/vending/colavend{ + pixel_x = -5 + }, /turf/open/floor/iron, /area/station/hallway/primary/tram/right) "rmH" = ( @@ -51804,7 +51830,10 @@ /turf/open/floor/iron/white, /area/station/medical/pharmacy) "rqG" = ( -/obj/machinery/crossing_signal/northwest, +/obj/machinery/crossing_signal/northwest{ + inbound = 1; + outbound = 2 + }, /obj/effect/turf_decal/stripes/white/line, /turf/open/floor/iron, /area/station/hallway/primary/tram/center) @@ -55321,7 +55350,7 @@ dir = 1 }, /obj/machinery/button/tram/directional/north{ - id = "right_part" + id = 3 }, /turf/open/floor/iron, /area/station/hallway/primary/tram/right) @@ -69938,7 +69967,10 @@ /turf/open/floor/plating, /area/station/hallway/secondary/service) "xXb" = ( -/obj/machinery/crossing_signal/southeast, +/obj/machinery/crossing_signal/southeast{ + inbound = 2; + outbound = 3 + }, /obj/effect/turf_decal/stripes/white/line{ dir = 1 }, diff --git a/code/__DEFINES/dcs/signals/signals_tram.dm b/code/__DEFINES/dcs/signals/signals_tram.dm index 8ab27b36fac..8788a646749 100644 --- a/code/__DEFINES/dcs/signals/signals_tram.dm +++ b/code/__DEFINES/dcs/signals/signals_tram.dm @@ -1,7 +1,7 @@ /// Sent from /obj/structure/industrial_lift/tram when its travelling status updates. (travelling) #define COMSIG_TRAM_SET_TRAVELLING "tram_set_travelling" -/// Sent from /obj/structure/industrial_lift/tram when it begins to travel. (obj/effect/landmark/tram/from_where, obj/effect/landmark/tram/to_where) +/// Sent from /obj/structure/industrial_lift/tram when it begins to travel. (obj/effect/landmark/tram/idle_platform, obj/effect/landmark/tram/to_where) #define COMSIG_TRAM_TRAVEL "tram_travel" /// Sent from /obj/structure/industrial_lift/tram when it hits someone: () diff --git a/code/__DEFINES/tram.dm b/code/__DEFINES/tram.dm index d7b86793960..3717b289336 100644 --- a/code/__DEFINES/tram.dm +++ b/code/__DEFINES/tram.dm @@ -4,8 +4,17 @@ #define XING_STATE_RED 2 #define XING_STATE_MALF 3 -#define XING_DISTANCE_AMBER 45 -#define XING_DISTANCE_RED 44 +#define XING_DISTANCE_AMBER 70 +#define XING_DISTANCE_RED 40 #define XING_SIGNAL_DIRECTION_WEST "west-" #define XING_SIGNAL_DIRECTION_EAST "east-" + +/// Tram destinations/platforms +#define TRAMSTATION_WEST 1 +#define TRAMSTATION_CENTRAL 2 +#define TRAMSTATION_EAST 3 + +#define HILBERT_PORT 1 +#define HILBERT_CENTRAL 2 +#define HILBERT_STARBOARD 3 diff --git a/code/modules/assembly/doorcontrol.dm b/code/modules/assembly/doorcontrol.dm index 9d2b5bf45f0..a8c3fe70f77 100644 --- a/code/modules/assembly/doorcontrol.dm +++ b/code/modules/assembly/doorcontrol.dm @@ -185,7 +185,7 @@ ///ID to link to allow us to link to one specific tram in the world var/specific_lift_id = MAIN_STATION_TRAM ///this is our destination's landmark, so we only have to find it the first time. - var/datum/weakref/to_where + var/datum/weakref/destination_platform /obj/item/assembly/control/tram/Initialize(mapload) ..() @@ -195,12 +195,12 @@ . = ..() //find where the tram needs to go to (our destination). only needs to happen the first time for(var/obj/effect/landmark/tram/our_destination as anything in GLOB.tram_landmarks[specific_lift_id]) - if(our_destination.destination_id == initial_id) - to_where = WEAKREF(our_destination) + if(our_destination.platform_code == initial_id) + destination_platform = WEAKREF(our_destination) break /obj/item/assembly/control/tram/Destroy() - to_where = null + destination_platform = null return ..() /obj/item/assembly/control/tram/activate() @@ -219,14 +219,14 @@ say("The tram is not in service. Please send a technician to repair the internals of the tram.") return if(tram.travelling) //in use - say("The tram is already travelling to [tram.from_where].") + say("The tram is already travelling to [tram.idle_platform].") return - if(!to_where) + if(!destination_platform) return - var/obj/effect/landmark/tram/current_location = to_where.resolve() + var/obj/effect/landmark/tram/current_location = destination_platform.resolve() if(!current_location) return - if(tram.from_where == current_location) //already here + if(tram.idle_platform == current_location) //already here say("The tram is already here. Please board the tram and select a destination.") return diff --git a/code/modules/industrial_lift/tram/tram_landmark.dm b/code/modules/industrial_lift/tram/tram_landmark.dm index db855b58a5c..7aaa254d444 100644 --- a/code/modules/industrial_lift/tram/tram_landmark.dm +++ b/code/modules/industrial_lift/tram/tram_landmark.dm @@ -7,7 +7,7 @@ GLOBAL_LIST_EMPTY(tram_landmarks) ///the id of the tram we're linked to. var/specific_lift_id = MAIN_STATION_TRAM /// The ID of that particular destination. - var/destination_id + var/platform_code = null /// Icons for the tgui console to list out for what is at this location var/list/tgui_icons = list() @@ -20,19 +20,19 @@ GLOBAL_LIST_EMPTY(tram_landmarks) return ..() -/obj/effect/landmark/tram/left_part +/obj/effect/landmark/tram/tramstation/west name = "West Wing" - destination_id = "left_part" + platform_code = TRAMSTATION_WEST tgui_icons = list("Arrivals" = "plane-arrival", "Command" = "bullhorn", "Security" = "gavel") -/obj/effect/landmark/tram/middle_part +/obj/effect/landmark/tram/tramstation/central name = "Central Wing" - destination_id = "middle_part" + platform_code = TRAMSTATION_CENTRAL tgui_icons = list("Service" = "cocktail", "Medical" = "plus", "Engineering" = "wrench") -/obj/effect/landmark/tram/right_part +/obj/effect/landmark/tram/tramstation/east name = "East Wing" - destination_id = "right_part" + platform_code = TRAMSTATION_EAST tgui_icons = list("Departures" = "plane-departure", "Cargo" = "box", "Science" = "flask") /** diff --git a/code/modules/industrial_lift/tram/tram_lift_master.dm b/code/modules/industrial_lift/tram/tram_lift_master.dm index 9410e0fc553..79433c34f34 100644 --- a/code/modules/industrial_lift/tram/tram_lift_master.dm +++ b/code/modules/industrial_lift/tram/tram_lift_master.dm @@ -13,7 +13,7 @@ /// reference to the destination landmark we consider ourselves "at". since we potentially span multiple z levels we dont actually /// know where on us this platform is. as long as we know THAT its on us we can just move the distance and direction between this /// and the destination landmark. - var/obj/effect/landmark/tram/from_where + var/obj/effect/landmark/tram/idle_platform ///decisecond delay between horizontal movement. cannot make the tram move faster than 1 movement per world.tick_lag. ///this var is poorly named its actually horizontal movement delay but whatever. @@ -59,10 +59,10 @@ var/obj/effect/landmark/tram/initial_destination = locate() in platform_loc if(initial_destination) - from_where = initial_destination + idle_platform = initial_destination /datum/lift_master/tram/proc/check_starting_landmark() - if(!from_where) + if(!idle_platform) CRASH("a tram lift_master was initialized without any tram landmark to give it direction!") SStramprocess.can_fire = TRUE @@ -109,20 +109,20 @@ * incase multiple inputs get through, preventing conflicting directions and the tram * literally ripping itself apart. all of the actual movement is handled by SStramprocess */ -/datum/lift_master/tram/proc/tram_travel(obj/effect/landmark/tram/to_where) - if(to_where == from_where) +/datum/lift_master/tram/proc/tram_travel(obj/effect/landmark/tram/destination_platform) + if(destination_platform == idle_platform) return update_tram_doors(CLOSE_DOORS) - travel_direction = get_dir(from_where, to_where) - travel_distance = get_dist(from_where, to_where) - from_where = to_where + travel_direction = get_dir(idle_platform, destination_platform) + travel_distance = get_dist(idle_platform, destination_platform) + idle_platform = destination_platform set_travelling(TRUE) set_controls(LIFT_PLATFORM_LOCKED) - addtimer(CALLBACK(src, PROC_REF(dispatch_tram), to_where), 3 SECONDS) + addtimer(CALLBACK(src, PROC_REF(dispatch_tram), destination_platform), 3 SECONDS) -/datum/lift_master/tram/proc/dispatch_tram(obj/effect/landmark/tram/to_where) - SEND_SIGNAL(src, COMSIG_TRAM_TRAVEL, from_where, to_where) +/datum/lift_master/tram/proc/dispatch_tram(obj/effect/landmark/tram/destination_platform) + SEND_SIGNAL(src, COMSIG_TRAM_TRAVEL, idle_platform, destination_platform) update_tram_doors(UNLOCK_DOORS) for(var/obj/structure/industrial_lift/tram/tram_part as anything in lift_platforms) //only thing everyone needs to know is the new location. diff --git a/code/modules/industrial_lift/tram/tram_machinery.dm b/code/modules/industrial_lift/tram/tram_machinery.dm index 386bec813dd..fd187a646c8 100644 --- a/code/modules/industrial_lift/tram/tram_machinery.dm +++ b/code/modules/industrial_lift/tram/tram_machinery.dm @@ -69,7 +69,7 @@ GLOBAL_LIST_EMPTY(tram_doors) var/list/data = list() data["moving"] = tram_lift?.travelling data["broken"] = tram_lift ? FALSE : TRUE - var/obj/effect/landmark/tram/current_loc = tram_lift?.from_where + var/obj/effect/landmark/tram/current_loc = tram_lift?.idle_platform if(current_loc) data["tram_location"] = current_loc.name return data @@ -92,7 +92,7 @@ GLOBAL_LIST_EMPTY(tram_doors) var/list/this_destination = list() this_destination["name"] = destination.name this_destination["dest_icons"] = destination.tgui_icons - this_destination["id"] = destination.destination_id + this_destination["id"] = destination.platform_code . += list(this_destination) /obj/machinery/computer/tram_controls/ui_act(action, params) @@ -102,36 +102,36 @@ GLOBAL_LIST_EMPTY(tram_doors) switch (action) if ("send") - var/obj/effect/landmark/tram/to_where + var/obj/effect/landmark/tram/destination_platform for (var/obj/effect/landmark/tram/destination as anything in GLOB.tram_landmarks[specific_lift_id]) - if(destination.destination_id == params["destination"]) - to_where = destination + if(destination.platform_code == params["destination"]) + destination_platform = destination break - if (!to_where) + if (!destination_platform) return FALSE - return try_send_tram(to_where) + return try_send_tram(destination_platform) /// Attempts to sends the tram to the given destination -/obj/machinery/computer/tram_controls/proc/try_send_tram(obj/effect/landmark/tram/to_where) +/obj/machinery/computer/tram_controls/proc/try_send_tram(obj/effect/landmark/tram/destination_platform) var/datum/lift_master/tram/tram_part = tram_ref?.resolve() if(!tram_part) return FALSE if(tram_part.controls_locked || tram_part.travelling) // someone else started already return FALSE - tram_part.tram_travel(to_where) - say("The next station is: [to_where.name]") + tram_part.tram_travel(destination_platform) + say("The next station is: [destination_platform.name]") update_appearance() return TRUE -/obj/machinery/computer/tram_controls/proc/update_tram_display(obj/effect/landmark/tram/from_where, travelling) +/obj/machinery/computer/tram_controls/proc/update_tram_display(obj/effect/landmark/tram/idle_platform, travelling) SIGNAL_HANDLER var/datum/lift_master/tram/tram_part = tram_ref?.resolve() if(travelling) - icon_screen = "[base_icon_state][tram_part.from_where.name]_active" + icon_screen = "[base_icon_state][tram_part.idle_platform.name]_active" else - icon_screen = "[base_icon_state][tram_part.from_where.name]_idle" + icon_screen = "[base_icon_state][tram_part.idle_platform.name]_idle" update_appearance(UPDATE_ICON) return PROCESS_KILL @@ -226,9 +226,9 @@ GLOBAL_LIST_EMPTY(tram_doors) SIGNAL_HANDLER travelling_output.set_output(travelling) -/obj/item/circuit_component/tram_controls/proc/on_tram_travel(datum/source, obj/effect/landmark/tram/from_where, obj/effect/landmark/tram/to_where) +/obj/item/circuit_component/tram_controls/proc/on_tram_travel(datum/source, obj/effect/landmark/tram/idle_platform, obj/effect/landmark/tram/destination_platform) SIGNAL_HANDLER - location.set_output(to_where.name) + location.set_output(destination_platform.name) /// Pedestrian crossing signal for tram /obj/machinery/crossing_signal @@ -271,6 +271,10 @@ GLOBAL_LIST_EMPTY(tram_doors) var/red_distance_threshold = XING_DISTANCE_RED /// If the signal is facing east or west var/signal_direction + /// Inbound station + var/inbound + /// Outbound station + var/outbound /// Is the signal malfunctioning? var/malfunctioning = FALSE @@ -280,33 +284,28 @@ GLOBAL_LIST_EMPTY(tram_doors) * The distance is calculated from the bottom left corner of the tram, * so signals on the east side have their distance reduced by the tram length, in this case 10 for Tramstation. */ - -/obj/machinery/crossing_signal/tramstation/northeast - icon_state = "crossing-base-left" - signal_direction = XING_SIGNAL_DIRECTION_EAST - amber_distance_threshold = XING_DISTANCE_AMBER - 10 - red_distance_threshold = XING_DISTANCE_RED - 10 - pixel_x = -2 - pixel_y = -1 - -/obj/machinery/crossing_signal/tramstation/northwest +/obj/machinery/crossing_signal/northwest icon_state = "crossing-base-right" signal_direction = XING_SIGNAL_DIRECTION_WEST pixel_x = -32 pixel_y = -1 -/obj/machinery/crossing_signal/tramstation/southeast +/obj/machinery/crossing_signal/northeast icon_state = "crossing-base-left" signal_direction = XING_SIGNAL_DIRECTION_EAST - amber_distance_threshold = XING_DISTANCE_AMBER - 10 - red_distance_threshold = XING_DISTANCE_RED - 10 pixel_x = -2 + pixel_y = -1 + +/obj/machinery/crossing_signal/southwest + icon_state = "crossing-base-right" + signal_direction = XING_SIGNAL_DIRECTION_WEST + pixel_x = -32 pixel_y = 20 -/obj/machinery/crossing_signal/tramstation/southwest - icon_state = "crossing-base-right" - signal_direction = XING_SIGNAL_DIRECTION_WEST - pixel_x = -32 +/obj/machinery/crossing_signal/southeast + icon_state = "crossing-base-left" + signal_direction = XING_SIGNAL_DIRECTION_EAST + pixel_x = -2 pixel_y = 20 /obj/machinery/static_signal @@ -327,6 +326,26 @@ GLOBAL_LIST_EMPTY(tram_doors) light_color = COLOR_VIBRANT_LIME luminosity = 1 +/obj/machinery/static_signal/northwest + icon_state = "static-right-on" + base_icon_state = "static-right-" + pixel_x = -32 + pixel_y = -1 + +/obj/machinery/static_signal/northeast + pixel_x = -2 + pixel_y = -1 + +/obj/machinery/static_signal/southwest + icon_state = "static-right-on" + base_icon_state = "static-right-" + pixel_x = -32 + pixel_y = 20 + +/obj/machinery/static_signal/southeast + pixel_x = -2 + pixel_y = 20 + /obj/machinery/crossing_signal/Initialize(mapload) . = ..() return INITIALIZE_HINT_LATELOAD @@ -420,9 +439,9 @@ GLOBAL_LIST_EMPTY(tram_doors) var/datum/lift_master/tram/tram = tram_ref?.resolve() // Check for stopped states. - if(!tram || !is_operational || !tram.is_operational) - // Tram missing, or we lost power. - // Tram missing throw the error message (blue) + if(!tram || !is_operational || !tram.is_operational || !inbound || !outbound) + // Tram missing, we lost power, or something isn't right + // Throw the error message (blue) set_signal_state(XING_STATE_MALF, force = !is_operational) return PROCESS_KILL @@ -449,18 +468,11 @@ GLOBAL_LIST_EMPTY(tram_doors) tram_velocity_sign = tram.travel_direction & EAST ? 1 : -1 // How far away are we? negative if already passed. - var/approach_distance = tram_velocity_sign * (signal_pos - tram_pos) + var/approach_distance = tram_velocity_sign * (signal_pos - (tram_pos + 5)) // Check for stopped state. // Will kill the process since tram starting up will restart process. if(!tram.travelling) - // If super close, show red anyway since tram could suddenly start moving. If the tram could be approaching, show amber. - if(abs(approach_distance) < red_distance_threshold) - set_signal_state(XING_STATE_RED) - return PROCESS_KILL - if(abs(approach_distance) < amber_distance_threshold) - set_signal_state(XING_STATE_AMBER) - return PROCESS_KILL set_signal_state(XING_STATE_GREEN) return PROCESS_KILL @@ -470,7 +482,17 @@ GLOBAL_LIST_EMPTY(tram_doors) set_signal_state(XING_STATE_GREEN) return PROCESS_KILL - // OK so finally the interesting part where it's ACTUALLY approaching + // Check the tram's terminus station. + // INBOUND 1 < 2 < 3 + // OUTBOUND 1 > 2 > 3 + if(tram.travel_direction & WEST && inbound < tram.idle_platform.platform_code) + set_signal_state(XING_STATE_GREEN) + return PROCESS_KILL + if(tram.travel_direction & EAST && outbound > tram.idle_platform.platform_code) + set_signal_state(XING_STATE_GREEN) + return PROCESS_KILL + + // Finally the interesting part where it's ACTUALLY approaching if(approach_distance <= red_distance_threshold) set_signal_state(XING_STATE_RED) return @@ -537,61 +559,6 @@ GLOBAL_LIST_EMPTY(tram_doors) icon_state = "[base_icon_state]on" set_light(l_on = TRUE) -/// Shifted to NE corner for east side of northern passage. -/obj/machinery/crossing_signal/northeast - icon_state = "crossing-base-left" - signal_direction = XING_SIGNAL_DIRECTION_EAST - amber_distance_threshold = 35 - pixel_x = -2 - pixel_y = -1 - -/// Shifted to NW corner for west side of northern passage. -/obj/machinery/crossing_signal/northwest - icon_state = "crossing-base-right" - signal_direction = XING_SIGNAL_DIRECTION_WEST - pixel_x = -32 - pixel_y = -1 - -/// Shifted to SE corner for east side of northern passage. -/obj/machinery/crossing_signal/southeast - icon_state = "crossing-base-left" - signal_direction = XING_SIGNAL_DIRECTION_EAST - amber_distance_threshold = 35 - pixel_x = -2 - pixel_y = 20 - -/// Shifted to SW corner for west side of northern passage. -/obj/machinery/crossing_signal/southwest - icon_state = "crossing-base-right" - signal_direction = XING_SIGNAL_DIRECTION_WEST - pixel_x = -32 - pixel_y = 20 - -/obj/machinery/static_signal/northeast - icon_state = "static-left-on" - pixel_x = -2 - pixel_y = -1 - -/// Shifted to NW corner for west side of northern passage. -/obj/machinery/static_signal/northwest - icon_state = "static-right-on" - base_icon_state = "static-right-" - pixel_x = -32 - pixel_y = -1 - -/// Shifted to SE corner for east side of northern passage. -/obj/machinery/static_signal/southeast - icon_state = "static-left-on" - pixel_x = -2 - pixel_y = 20 - -/// Shifted to SW corner for west side of northern passage. -/obj/machinery/static_signal/southwest - icon_state = "static-right-on" - base_icon_state = "static-right-" - pixel_x = -32 - pixel_y = 20 - /obj/machinery/destination_sign name = "destination sign" desc = "A display to show you what direction the tram is travelling." @@ -680,44 +647,44 @@ GLOBAL_LIST_EMPTY(tram_doors) use_power(active_power_usage) if(!tram.travelling) - if(istype(tram.from_where, /obj/effect/landmark/tram/left_part)) + if(istype(tram.idle_platform, /obj/effect/landmark/tram/tramstation/west)) icon_state = "[base_icon_state][DESTINATION_WEST_IDLE]" light_mask = "[base_icon_state][DESTINATION_WEST_IDLE]_e" - previous_destination = tram.from_where + previous_destination = tram.idle_platform update_appearance() return PROCESS_KILL - if(istype(tram.from_where, /obj/effect/landmark/tram/middle_part)) + if(istype(tram.idle_platform, /obj/effect/landmark/tram/tramstation/central)) icon_state = "[base_icon_state][DESTINATION_CENTRAL_IDLE]" light_mask = "[base_icon_state][DESTINATION_CENTRAL_IDLE]_e" - previous_destination = tram.from_where + previous_destination = tram.idle_platform update_appearance() return PROCESS_KILL - if(istype(tram.from_where, /obj/effect/landmark/tram/right_part)) + if(istype(tram.idle_platform, /obj/effect/landmark/tram/tramstation/east)) icon_state = "[base_icon_state][DESTINATION_EAST_IDLE]" light_mask = "[base_icon_state][DESTINATION_EAST_IDLE]_e" - previous_destination = tram.from_where + previous_destination = tram.idle_platform update_appearance() return PROCESS_KILL - if(istype(tram.from_where, /obj/effect/landmark/tram/left_part)) + if(istype(tram.idle_platform, /obj/effect/landmark/tram/tramstation/west)) icon_state = "[base_icon_state][DESTINATION_WEST_ACTIVE]" light_mask = "[base_icon_state][DESTINATION_WEST_ACTIVE]_e" update_appearance() return PROCESS_KILL - if(istype(tram.from_where, /obj/effect/landmark/tram/middle_part)) - if(istype(previous_destination, /obj/effect/landmark/tram/left_part)) + if(istype(tram.idle_platform, /obj/effect/landmark/tram/tramstation/central)) + if(istype(previous_destination, /obj/effect/landmark/tram/tramstation/west)) icon_state = "[base_icon_state][DESTINATION_CENTRAL_EASTBOUND_ACTIVE]" light_mask = "[base_icon_state][DESTINATION_CENTRAL_EASTBOUND_ACTIVE]_e" - if(istype(previous_destination, /obj/effect/landmark/tram/right_part)) + if(istype(previous_destination, /obj/effect/landmark/tram/tramstation/east)) icon_state = "[base_icon_state][DESTINATION_CENTRAL_WESTBOUND_ACTIVE]" light_mask = "[base_icon_state][DESTINATION_CENTRAL_WESTBOUND_ACTIVE]_e" update_appearance() return PROCESS_KILL - if(istype(tram.from_where, /obj/effect/landmark/tram/right_part)) + if(istype(tram.idle_platform, /obj/effect/landmark/tram/tramstation/east)) icon_state = "[base_icon_state][DESTINATION_EAST_ACTIVE]" light_mask = "[base_icon_state][DESTINATION_EAST_ACTIVE]_e" update_appearance() diff --git a/code/modules/mapfluff/ruins/spaceruin_code/hilbertshotel.dm b/code/modules/mapfluff/ruins/spaceruin_code/hilbertshotel.dm index 8bf1ef24e9a..ced693283a6 100644 --- a/code/modules/mapfluff/ruins/spaceruin_code/hilbertshotel.dm +++ b/code/modules/mapfluff/ruins/spaceruin_code/hilbertshotel.dm @@ -500,19 +500,22 @@ GLOBAL_VAR_INIT(hhMysteryRoomNumber, rand(1, 999999)) /obj/effect/landmark/lift_id/hilbert specific_lift_id = HILBERT_TRAM -/obj/effect/landmark/tram/left_part/hilbert +/obj/effect/landmark/tram/hilbert/left + name = "Port" specific_lift_id = HILBERT_TRAM - destination_id = "left_part_hilbert" + platform_code = HILBERT_PORT tgui_icons = list("Reception" = "briefcase", "Botany" = "leaf", "Chemistry" = "flask") -/obj/effect/landmark/tram/middle_part/hilbert +/obj/effect/landmark/tram/hilbert/middle + name = "Central" specific_lift_id = HILBERT_TRAM - destination_id = "middle_part_hilbert" + platform_code = HILBERT_CENTRAL tgui_icons = list("Processing" = "cogs", "Xenobiology" = "paw") -/obj/effect/landmark/tram/right_part/hilbert +/obj/effect/landmark/tram/hilbert/right + name = "Starboard" specific_lift_id = HILBERT_TRAM - destination_id = "right_part_hilbert" + platform_code = HILBERT_STARBOARD tgui_icons = list("Ordnance" = "bullseye", "Office" = "user", "Dormitories" = "bed") /obj/item/keycard/hilbert diff --git a/code/modules/mob/living/navigation.dm b/code/modules/mob/living/navigation.dm index e1245bd231b..b97a01b5592 100644 --- a/code/modules/mob/living/navigation.dm +++ b/code/modules/mob/living/navigation.dm @@ -41,8 +41,8 @@ balloon_alert(src, "no navigation signals!") return - var/destination_id = tgui_input_list(src, "Select a location", "Navigate", sort_list(destination_list)) - var/navigate_target = destination_list[destination_id] + var/platform_code = tgui_input_list(src, "Select a location", "Navigate", sort_list(destination_list)) + var/navigate_target = destination_list[platform_code] if(isnull(navigate_target)) return