From 0146fd2c146b01ff6c511b227d1c27a578327218 Mon Sep 17 00:00:00 2001 From: paulrpg Date: Sat, 25 May 2024 21:35:38 +0100 Subject: [PATCH] review feedback --- .../shuttle/computers/dropship_computer.dm | 54 ++++++++++++++----- maps/map_files/USS_Almayer/USS_Almayer.dmm | 8 +-- .../tgui/interfaces/DropshipFlightControl.tsx | 44 ++++++++++++--- .../tgui/interfaces/NavigationShuttle.tsx | 2 +- 4 files changed, 83 insertions(+), 25 deletions(-) diff --git a/code/modules/shuttle/computers/dropship_computer.dm b/code/modules/shuttle/computers/dropship_computer.dm index 1d350c376981..7f857c1c32e8 100644 --- a/code/modules/shuttle/computers/dropship_computer.dm +++ b/code/modules/shuttle/computers/dropship_computer.dm @@ -134,7 +134,9 @@ .["max_refuel_duration"] = shuttle.rechargeTime / 10 .["max_engine_start_duration"] = shuttle.ignitionTime / 10 .["door_data"] = list("port", "starboard", "aft") - .["alternative_shuttles"] = alternative_shuttles() + .["alternative_shuttles"] = list() + if(can_change_shuttle) + .["alternative_shuttles"] = alternative_shuttles() /obj/structure/machinery/computer/shuttle/dropship/flight/proc/alternative_shuttles() . = list() @@ -208,6 +210,23 @@ var/obj/docking_port/mobile/shuttle = SSshuttle.getShuttle(shuttleId) if(linked_lz) + var/obj/docking_port/stationary/landing_zone = SSshuttle.getDock(linked_lz) + var/obj/docking_port/mobile/maybe_dropship = landing_zone.get_docked() + + if(maybe_dropship) + to_chat(xeno, SPAN_NOTICE("A metal bird already is here.")) + return + + var/conflicting_transit = FALSE + for(var/obj/docking_port/mobile/other_shuttle in SSshuttle.mobile) + if(landing_zone == other_shuttle.destination) + conflicting_transit = TRUE + break + + if(conflicting_transit) + to_chat(xeno, SPAN_NOTICE("A metal bird is already coming.")) + return + playsound(loc, 'sound/machines/terminal_success.ogg', KEYBOARD_SOUND_VOLUME, 1) if(shuttle.mode == SHUTTLE_IDLE && !is_ground_level(shuttle.z)) var/result = SSshuttle.moveShuttle(shuttleId, linked_lz, TRUE) @@ -235,7 +254,7 @@ /obj/structure/machinery/computer/shuttle/dropship/flight/attack_alien(mob/living/carbon/xenomorph/xeno) // if the shuttleid is null or the shuttleid references a shuttle that has been removed from play, pick one - if(!shuttleId || !SSshuttle.hasShuttle(shuttleId)) + if(!shuttleId || !SSshuttle.getShuttle(shuttleId, FALSE)) var/list/alternatives = alternative_shuttles() shuttleId = pick(alternatives)["id"] @@ -421,6 +440,10 @@ return var/obj/docking_port/mobile/marine_dropship/shuttle = SSshuttle.getShuttle(shuttleId) if(disabled || (shuttle && shuttle.is_hijacked)) + switch(action) + if ("change_shuttle") + var/new_shuttle = params["new_shuttle"] + return set_shuttle(new_shuttle) return var/mob/user = usr if (shuttle) @@ -560,19 +583,24 @@ stop_playing_launch_announcement_alarm() return TRUE if ("change_shuttle") - var/list/alternatives = alternative_shuttles() var/new_shuttle = params["new_shuttle"] - var/found = FALSE - for(var/alt_shuttle in alternatives) - if(alt_shuttle["id"] == new_shuttle) - found = TRUE - if(found) - shuttleId = new_shuttle - update_static_data(user, ui) - else - log_admin("Player [user] attempted to change shuttle illegally.") - return TRUE + return set_shuttle(new_shuttle) +/obj/structure/machinery/computer/shuttle/dropship/flight/proc/set_shuttle(new_shuttle) + var/mob/user = usr + if(!new_shuttle || shuttleId == new_shuttle) + return FALSE + var/found = FALSE + var/list/alternatives = alternative_shuttles() + for(var/alt_shuttle in alternatives) + if(alt_shuttle["id"] == new_shuttle) + found = TRUE + if(found) + shuttleId = new_shuttle + update_static_data(user) + else + log_admin("Player [user] attempted to change shuttle illegally.") + return TRUE /obj/structure/machinery/computer/shuttle/dropship/flight/proc/stop_playing_launch_announcement_alarm() var/obj/docking_port/mobile/marine_dropship/shuttle = SSshuttle.getShuttle(shuttleId) diff --git a/maps/map_files/USS_Almayer/USS_Almayer.dmm b/maps/map_files/USS_Almayer/USS_Almayer.dmm index 3d2d19d5693c..e6b6903458eb 100644 --- a/maps/map_files/USS_Almayer/USS_Almayer.dmm +++ b/maps/map_files/USS_Almayer/USS_Almayer.dmm @@ -29437,8 +29437,8 @@ }, /obj/structure/machinery/computer/shuttle/dropship/flight/remote_control{ dir = 4; - name = "Secondary Remote Control Console"; - pixel_y = -12 + pixel_y = -12; + name = "Remote dropship navigation computer" }, /turf/open/floor/almayer{ icon_state = "redfull" @@ -65347,9 +65347,9 @@ }, /obj/structure/machinery/computer/shuttle/dropship/flight/remote_control{ dir = 8; - name = "Primary Remote Control Console"; pixel_y = 12; - shuttleId = "dropship_alamo" + shuttleId = "dropship_alamo"; + name = "Remote dropship navigation computer" }, /turf/open/floor/almayer{ icon_state = "redfull" diff --git a/tgui/packages/tgui/interfaces/DropshipFlightControl.tsx b/tgui/packages/tgui/interfaces/DropshipFlightControl.tsx index 3bb323265398..62a68342772c 100644 --- a/tgui/packages/tgui/interfaces/DropshipFlightControl.tsx +++ b/tgui/packages/tgui/interfaces/DropshipFlightControl.tsx @@ -1,3 +1,4 @@ +import { useEffect, useState } from 'react'; import { useBackend, useSharedState } from '../backend'; import { Box, @@ -371,18 +372,20 @@ const LaunchAnnouncementAlarm = () => { ); }; -const DropshipButton = (props: { readonly ship: ShuttleRef }) => { +const DropshipButton = (props: { readonly shipId: string, readonly shipName: string, readonly disable, onClick: () => void }) => { const { act, data } = useBackend(); - const match = props.ship.id === data.shuttle_id; + const match = props.shipId === data.shuttle_id; + return ( ); @@ -390,13 +393,30 @@ const DropshipButton = (props: { readonly ship: ShuttleRef }) => { const DropshipSelector = () => { const { data } = useBackend(); + const [refreshTimeout, setRefreshTimeout] = useState(undefined); + + useEffect(() => { + if(refreshTimeout) { + return () => clearTimeout(refreshTimeout); + } + return () => {}; + }, [refreshTimeout]); + return (
{data.alternative_shuttles .sort((a, b) => a.id.localeCompare(b.id)) .map((x) => ( - + { + const freeze = setTimeout(() => setRefreshTimeout(undefined), 2000) + setRefreshTimeout(freeze); + }}/> ))}
@@ -427,12 +447,22 @@ const RenderScreen = () => { ); }; +const DropshipDisabledScreen = () => { + const { data } = useBackend(); + return ( + <> + {data.alternative_shuttles.length > 0 && } + + + ) +} + export const DropshipFlightControl = () => { const { data } = useBackend(); return ( - {data.is_disabled === 0 ? : } + {data.is_disabled === 0 ? : } ); diff --git a/tgui/packages/tgui/interfaces/NavigationShuttle.tsx b/tgui/packages/tgui/interfaces/NavigationShuttle.tsx index 239ce8f2601d..91f831137f1c 100644 --- a/tgui/packages/tgui/interfaces/NavigationShuttle.tsx +++ b/tgui/packages/tgui/interfaces/NavigationShuttle.tsx @@ -261,7 +261,7 @@ const DoorControls = () => { }; export const DisabledScreen = (props) => { - const { data, act } = useBackend(); + const { data } = useBackend(); const disabled_text = data.mission_accomplished ? 'Auto-navigation protocol completed - return home complete. Shuttle disabled.'