Skip to content

Commit

Permalink
don't mash this button
Browse files Browse the repository at this point in the history
  • Loading branch information
harryob committed Mar 1, 2024
1 parent 784836b commit 5953908
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 25 deletions.
67 changes: 43 additions & 24 deletions code/modules/shuttle/computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,14 @@
unslashable = TRUE
unacidable = TRUE
var/disabled = FALSE
var/must_launch_home = FALSE
var/compatible_landing_zones = list()

/// this interface is busy - used in [/obj/structure/machinery/computer/shuttle/ert/proc/launch_home] as this can take a second
var/spooling

/// if this shuttle only has the option to return home
var/must_launch_home = FALSE

/obj/structure/machinery/computer/shuttle/ert/broken
name = "nonfunctional shuttle control console"
disabled = TRUE
Expand All @@ -112,6 +117,40 @@
if(!dock.is_external)
. += list(dock)

/obj/structure/machinery/computer/shuttle/ert/proc/launch_home()
if(spooling)
return

var/obj/docking_port/mobile/emergency_response/ert = SSshuttle.getShuttle(shuttleId)

spooling = TRUE

var/datum/turf_reservation/loaded = SSmapping.lazy_load_template(ert.distress_beacon.home_base, force = TRUE)
var/turf/bottom_left = loaded.bottom_left_turfs[1]
var/turf/top_right = loaded.top_right_turfs[1]

var/obj/docking_port/stationary/emergency_response/target
for(var/obj/docking_port/stationary/emergency_response/shuttle in SSshuttle.stationary)
if(shuttle.z != bottom_left.z)
continue
if(shuttle.x >= top_right.x || shuttle.y >= top_right.y)
continue
if(shuttle.x <= bottom_left.x || shuttle.y <= bottom_left.y)
continue

target = shuttle
break

if(!target)
spooling = FALSE
return

SSshuttle.moveShuttleToDock(ert, target, TRUE)
target.lockdown_on_land = TRUE

spooling = FALSE
must_launch_home = FALSE


/obj/structure/machinery/computer/shuttle/ert/is_disabled()
return disabled
Expand Down Expand Up @@ -165,6 +204,7 @@
.["shuttle_mode"] = ert.mode
.["flight_time"] = ert.timeLeft(0)
.["is_disabled"] = disabled
.["spooling"] = spooling
.["must_launch_home"] = must_launch_home

var/door_count = length(ert.external_doors)
Expand Down Expand Up @@ -228,33 +268,12 @@

if(must_launch_home)
if(action == "launch_home")

if(ert.mode != SHUTTLE_IDLE)
to_chat(ui.user, SPAN_WARNING("Unable to return home."))
balloon_alert(ui.user, "can't go home!")
return

var/datum/turf_reservation/loaded = SSmapping.lazy_load_template(ert.distress_beacon.home_base, force = TRUE)
var/turf/bottom_left = loaded.bottom_left_turfs[1]
var/turf/top_right = loaded.top_right_turfs[1]

var/obj/docking_port/stationary/emergency_response/target
for(var/obj/docking_port/stationary/emergency_response/shuttle in SSshuttle.stationary)
if(shuttle.z != bottom_left.z)
continue
if(shuttle.x >= top_right.x || shuttle.y >= top_right.y)
continue
if(shuttle.x <= bottom_left.x || shuttle.y <= bottom_left.y)
continue

target = shuttle
break

if(!target)
return

SSshuttle.moveShuttleToDock(ert, target, TRUE)
target.lockdown_on_land = TRUE
must_launch_home = FALSE
launch_home()

return

Expand Down
16 changes: 15 additions & 1 deletion tgui/packages/tgui/interfaces/NavigationShuttle.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useBackend, useSharedState } from '../backend';
import { Box, Button, Icon, Flex, Section, Stack, ProgressBar } from '../components';
import { Box, Button, Icon, Flex, Section, Stack, ProgressBar, Dimmer } from '../components';
import { Window } from '../layouts';

export interface DockingPort {
Expand All @@ -20,6 +20,7 @@ export interface NavigationProps {
max_engine_start_duration: number;
max_pre_arrival_duration: number;
must_launch_home: boolean;
spooling: boolean;
is_disabled: 0 | 1;
locked_down: 0 | 1;
}
Expand Down Expand Up @@ -264,6 +265,18 @@ const LaunchHome = (props) => {
);
};

const SpoolingDimmer = (props) => {
const { data, act } = useBackend<NavigationProps>();

return (
<Dimmer>
<Section title="Spooling Up">
<ProgressBar value={0.5} />
</Section>
</Dimmer>
);
};

const DestinationOptions = (props) => {
const { data, act } = useBackend<NavigationProps>();

Expand All @@ -278,6 +291,7 @@ const RenderScreen = (props) => {
const { data } = useBackend<NavigationProps>();
return (
<>
{!!data.spooling && <SpoolingDimmer />}
{data.shuttle_mode === 'idle' && <DestinationOptions />}
{data.shuttle_mode === 'igniting' && <LaunchCountdown />}
{data.shuttle_mode === 'recharging' && <ShuttleRecharge />}
Expand Down

0 comments on commit 5953908

Please sign in to comment.