diff --git a/code/game/machinery/computer/demo_sim.dm b/code/game/machinery/computer/demo_sim.dm index 15261cfc8f4b..f633e8f351d4 100644 --- a/code/game/machinery/computer/demo_sim.dm +++ b/code/game/machinery/computer/demo_sim.dm @@ -55,7 +55,6 @@ var/list/data = list() data["configuration"] = configuration - data["looking"] = simulation.looking_at_simulation data["dummy_mode"] = simulation.dummy_mode data["worldtime"] = world.time @@ -104,8 +103,7 @@ /obj/structure/machinery/computer/demo_sim/ui_close(mob/user) . = ..() - if(simulation.looking_at_simulation) - simulation.stop_watching(user) + simulation.stop_watching(user) // DEMOLITIONS TGUI SHIT END \\ diff --git a/code/game/machinery/computer/dropship_weapons.dm b/code/game/machinery/computer/dropship_weapons.dm index 2f9047abc63c..db376c40029c 100644 --- a/code/game/machinery/computer/dropship_weapons.dm +++ b/code/game/machinery/computer/dropship_weapons.dm @@ -152,8 +152,7 @@ /obj/structure/machinery/computer/dropship_weapons/ui_close(mob/user) . = ..() SEND_SIGNAL(src, COMSIG_CAMERA_UNREGISTER_UI, user) - if(simulation.looking_at_simulation) - simulation.stop_watching(user) + simulation.stop_watching(user) /obj/structure/machinery/computer/dropship_weapons/ui_status(mob/user, datum/ui_state/state) . = ..() @@ -239,7 +238,6 @@ .["firemission_selected_laser"] = firemission_envelope.recorded_loc ? firemission_envelope.recorded_loc.get_name() : "NOT SELECTED" .["configuration"] = configuration - .["looking"] = simulation.looking_at_simulation .["dummy_mode"] = simulation.dummy_mode .["worldtime"] = world.time .["nextdetonationtime"] = simulation.detonation_cooldown diff --git a/code/game/sim_manager/datums/simulator.dm b/code/game/sim_manager/datums/simulator.dm index bf99c65ee66f..1f1aedad8153 100644 --- a/code/game/sim_manager/datums/simulator.dm +++ b/code/game/sim_manager/datums/simulator.dm @@ -1,18 +1,21 @@ +#define GRID_CLEARING_SIZE 16 + /datum/simulator // Necessary to prevent multiple users from simulating at the same time. var/static/detonation_cooldown = 0 + var/static/detonation_cooldown_time = 2 MINUTES var/static/sim_reboot_state = TRUE - var/looking_at_simulation = FALSE - var/detonation_cooldown_time = 2 MINUTES var/dummy_mode = CLF_MODE var/obj/structure/machinery/camera/simulation/sim_camera - var/grid_clearing_size = 16 // garbage collection, var/static/list/delete_targets = list() + // list of users currently inside the simulator + var/static/list/users_in_sim = list() + /* unarmoured humans are unnencessary clutter as they tend to explode easily and litter the sim room with body parts, best left out. @@ -29,7 +32,7 @@ /datum/simulator/proc/start_watching(mob/living/user) - if(looking_at_simulation) + if(user in users_in_sim) to_chat(user, SPAN_WARNING("You are already looking at the simulation.")) return if(!sim_camera) @@ -41,13 +44,15 @@ to_chat(user, SPAN_WARNING("You're too busy looking at something else.")) return user.reset_view(sim_camera) - looking_at_simulation = TRUE + users_in_sim += user /datum/simulator/proc/stop_watching(mob/living/user) + if(!(user in users_in_sim)) + return user.unset_interaction() user.reset_view(null) user.cameraFollow = null - looking_at_simulation = FALSE + users_in_sim -= user /datum/simulator/proc/sim_turf_garbage_collection() @@ -67,8 +72,8 @@ y:2 | x: 1 2 3 4 ... 16 y:1 | x: 1 2 3 4 ... 16 */ - for (var/y_pos in 1 to grid_clearing_size)// outer y - for (var/x_pos in 1 to grid_clearing_size) // inner x + for (var/y_pos in 1 to GRID_CLEARING_SIZE)// outer y + for (var/x_pos in 1 to GRID_CLEARING_SIZE) // inner x var/turf/current_grid = locate(sim_grid_start_pos.x + x_pos,sim_grid_start_pos.y + y_pos,sim_grid_start_pos.z) current_grid.empty(/turf/open/floor/engine) @@ -101,3 +106,4 @@ addtimer(CALLBACK(src, PROC_REF(sim_turf_garbage_collection)), 30 SECONDS, TIMER_STOPPABLE) +#undef GRID_CLEARING_SIZE diff --git a/tgui/packages/tgui/interfaces/CasSim.tsx b/tgui/packages/tgui/interfaces/CasSim.tsx index b81e1baafe9c..ba5990bd81ce 100644 --- a/tgui/packages/tgui/interfaces/CasSim.tsx +++ b/tgui/packages/tgui/interfaces/CasSim.tsx @@ -1,4 +1,4 @@ -import { useBackend } from '../backend'; +import { useBackend, useLocalState } from '../backend'; import { Box, Button, Section, ProgressBar, NoticeBox, Stack } from '../components'; interface CasSimData { @@ -12,6 +12,11 @@ interface CasSimData { export const CasSim = (_props, context) => { const { act, data } = useBackend(context); + const [simulationView, setSimulationView] = useLocalState( + context, + 'simulation_view', + false + ); const timeLeft = data.nextdetonationtime - data.worldtime; const timeLeftPct = timeLeft / data.detonation_cooldown; @@ -48,13 +53,16 @@ export const CasSim = (_props, context) => {
- {(!data.looking && ( + {(!simulationView && (