diff --git a/code/game/machinery/computer/tram_controls.dm b/code/game/machinery/computer/tram_controls.dm
index 1df9853cca2..d73f807ee69 100644
--- a/code/game/machinery/computer/tram_controls.dm
+++ b/code/game/machinery/computer/tram_controls.dm
@@ -23,15 +23,13 @@
* Locates tram parts in the lift global list after everything is done.
*/
/obj/machinery/computer/tram_controls/proc/find_tram()
- var/obj/structure/industrial_lift/tram/central/tram_loc = locate() in GLOB.lifts
- tram_part = tram_loc //possibly setting to something null, that's fine, but
- tram_part.find_our_location()
+ tram_part = GLOB.central_tram //possibly setting to something null, that's fine
/obj/machinery/computer/tram_controls/ui_state(mob/user)
return GLOB.not_incapacitated_state
/obj/machinery/computer/tram_controls/ui_status(mob/user,/datum/tgui/ui)
- if(tram_part.travelling)
+ if(tram_part?.travelling)
return UI_CLOSE
if(!in_range(user, src) && !isobserver(user))
return UI_CLOSE
@@ -45,8 +43,11 @@
/obj/machinery/computer/tram_controls/ui_data(mob/user)
var/list/data = list()
- data["moving"] = tram_part.travelling
+ data["moving"] = tram_part?.travelling
data["broken"] = tram_part ? FALSE : TRUE
+ var/obj/effect/landmark/tram/current_loc = tram_part?.from_where
+ if(current_loc)
+ data["tram_location"] = current_loc.name
return data
/obj/machinery/computer/tram_controls/ui_static_data(mob/user)
@@ -63,9 +64,8 @@
*/
/obj/machinery/computer/tram_controls/proc/get_destinations()
. = list()
- for(var/obj/effect/landmark/tram/destination in GLOB.landmarks_list)
+ for(var/obj/effect/landmark/tram/destination as anything in GLOB.tram_landmarks)
var/list/this_destination = list()
- this_destination["here"] = destination == tram_part.from_where
this_destination["name"] = destination.name
this_destination["dest_icons"] = destination.tgui_icons
this_destination["id"] = destination.destination_id
@@ -75,14 +75,15 @@
. = ..()
if(. || tram_part.travelling)
return
- var/destination_name = params["destination"]
+ var/destination_id = params["destination"]
var/obj/effect/landmark/tram/to_where
- for(var/obj/effect/landmark/tram/destination in GLOB.landmarks_list)
- if(destination.name == destination_name)
+ for(var/obj/effect/landmark/tram/destination as anything in GLOB.tram_landmarks)
+ if(destination.destination_id == destination_id)
to_where = destination
+ break
if(!to_where)
- CRASH("Controls couldn't find the destination \"[destination_name]\"!")
+ return
if(tram_part.controls_locked || tram_part.travelling) // someone else started
return
- tram_part.tram_travel(tram_part.from_where, to_where)
- update_static_data(usr) //show new location of tram
+ tram_part.tram_travel(to_where)
+ return TRUE
diff --git a/code/game/objects/structures/industrial_lift.dm b/code/game/objects/structures/industrial_lift.dm
index d911da268f1..d0fe329d190 100644
--- a/code/game/objects/structures/industrial_lift.dm
+++ b/code/game/objects/structures/industrial_lift.dm
@@ -172,6 +172,7 @@ GLOBAL_LIST_EMPTY(lifts)
if(!lift_master_datum)
lift_master_datum = new(src)
+
/obj/structure/industrial_lift/proc/UncrossedRemoveItemFromLift(datum/source, atom/movable/potential_rider)
SIGNAL_HANDLER
RemoveItemFromLift(potential_rider)
@@ -411,14 +412,23 @@ GLOBAL_LIST_EMPTY(lifts)
var/initial_id = "middle_part"
var/obj/effect/landmark/tram/from_where
var/travel_direction
- var/time_inbetween_moves = 1
+GLOBAL_DATUM(central_tram, /obj/structure/industrial_lift/tram/central)
+
+/obj/structure/industrial_lift/tram/Initialize(mapload)
+ . = ..()
+ return INITIALIZE_HINT_LATELOAD
/obj/structure/industrial_lift/tram/central//that's a surprise tool that can help us later
/obj/structure/industrial_lift/tram/central/Initialize(mapload)
+ if(GLOB.central_tram)
+ return INITIALIZE_HINT_QDEL
+
. = ..()
+
SStramprocess.can_fire = TRUE
+ GLOB.central_tram = src
/obj/structure/industrial_lift/tram/LateInitialize()
. = ..()
@@ -435,20 +445,10 @@ GLOBAL_LIST_EMPTY(lifts)
* even in the worst cast scenario.
*/
/obj/structure/industrial_lift/tram/proc/find_our_location()
- if(!from_where)
- for(var/obj/effect/landmark/tram/our_location in GLOB.landmarks_list)
- if(our_location.destination_id == initial_id)
- from_where = our_location
- break
-
-/obj/structure/industrial_lift/tram/central/find_our_location() //the tram knows where it is by knowing where it isn't
- ..()
- for(var/location in lift_master_datum.lift_platforms)
- var/obj/structure/industrial_lift/tram/tram_location = location
- var/turf/turf = get_turf(src)
- var/where_we_are = locate(/obj/effect/landmark/tram) in turf.contents
- if(where_we_are)
- tram_location.from_where = where_we_are //this gets set by the tram movement too but this actually makes sure we're at the dock we were moved to to prevent blender mode
+ for(var/obj/effect/landmark/tram/our_location as anything in GLOB.tram_landmarks)
+ if(our_location.destination_id == initial_id)
+ from_where = our_location
+ break
/obj/structure/industrial_lift/tram/use(mob/user) //dont click the floor dingus we use computers now
return
@@ -469,18 +469,21 @@ GLOBAL_LIST_EMPTY(lifts)
* literally ripping itself apart. The proc handles the first move before the subsystem
* takes over to keep moving it in process()
*/
-/obj/structure/industrial_lift/tram/proc/tram_travel(obj/effect/landmark/tram/from_where, obj/effect/landmark/tram/to_where)
+/obj/structure/industrial_lift/tram/proc/tram_travel(obj/effect/landmark/tram/to_where)
+ if(to_where == from_where)
+ return
+
visible_message("[src] has been called to the [to_where]![src]'s controls are now unlocked. {
);
};
-const MovingTramDimmer = () => {
- return (
-
-
-
-
-
-
- The tram is travelling to {current_loc[0].name}!
-
-
-
- );
-};
-
export const TramControl = (props, context) => {
const { act, data } = useBackend(context);
const {
broken,
moving,
destinations,
+ tram_location,
} = data;
- const current_loc = (destinations ? destinations.filter(
- dest => dest.here === 1) : null);
const [
transitIndex,
setTransitIndex,
@@ -96,7 +75,7 @@ export const TramControl = (props, context) => {
/>
- The tram is travelling to {current_loc[0].name}!
+ The tram is travelling to {tram_location}!
@@ -105,9 +84,10 @@ export const TramControl = (props, context) => {
const Destination = props => {
const { dest } = props;
const getDestColor = dest => {
- const here = dest.name === current_loc[0].name;
+ if (!tram_location) return "bad";
+ const here = dest.name === tram_location;
const selected = transitIndex === destinations.indexOf(dest);
- return !current_loc ? "bad" : here ? "blue" : selected ? "green" : "transparent";
+ return !tram_location ? "bad" : here ? "blue" : selected ? "green" : "transparent";
};
return (
@@ -185,11 +165,11 @@ export const TramControl = (props, context) => {