Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

branch screw up. #5324

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions code/game/machinery/computer/demo_sim.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 \\

Expand Down
4 changes: 1 addition & 3 deletions code/game/machinery/computer/dropship_weapons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
. = ..()
Expand Down Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions code/game/machinery/doors/firedoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
A.all_doors.Add(src)
areas_added = list(A)

for(var/direction in GLOB.cardinals)
A = get_area(get_step(src,direction))
if(istype(A) && !(A in areas_added))
A.all_doors.Add(src)
areas_added += A
// for(var/direction in GLOB.cardinals) // why are even adding adjacent doors?!
// A = get_area(get_step(src,direction))
// if(istype(A) && !(A in areas_added))
// A.all_doors.Add(src)
// areas_added += A

/obj/structure/machinery/door/firedoor/Destroy()
for(var/area/A in areas_added)
Expand Down
22 changes: 14 additions & 8 deletions code/game/sim_manager/datums/simulator.dm
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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)
Expand All @@ -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()

Expand All @@ -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)
Expand Down Expand Up @@ -101,3 +106,4 @@

addtimer(CALLBACK(src, PROC_REF(sim_turf_garbage_collection)), 30 SECONDS, TIMER_STOPPABLE)

#undef GRID_CLEARING_SIZE
19 changes: 15 additions & 4 deletions tgui/packages/tgui/interfaces/CasSim.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useBackend } from '../backend';
import { useBackend, useLocalState } from '../backend';
import { Box, Button, Section, ProgressBar, NoticeBox, Stack } from '../components';

interface CasSimData {
Expand All @@ -12,6 +12,11 @@ interface CasSimData {

export const CasSim = (_props, context) => {
const { act, data } = useBackend<CasSimData>(context);
const [simulationView, setSimulationView] = useLocalState(
context,
'simulation_view',
false
);

const timeLeft = data.nextdetonationtime - data.worldtime;
const timeLeftPct = timeLeft / data.detonation_cooldown;
Expand Down Expand Up @@ -48,21 +53,27 @@ export const CasSim = (_props, context) => {
<Section title="Cas Simulation Controls">
<Stack>
<Stack.Item grow>
{(!data.looking && (
{(!simulationView && (
<Button
fluid={1}
icon="eye"
color="good"
content="Enter simulation"
onClick={() => act('start_watching')}
onClick={() => {
act('start_watching');
setSimulationView(true);
}}
/>
)) || (
<Button
fluid={1}
icon="eye-slash"
color="good"
content="Exit simulation"
onClick={() => act('stop_watching')}
onClick={() => {
act('stop_watching');
setSimulationView(false);
}}
/>
)}
</Stack.Item>
Expand Down
19 changes: 15 additions & 4 deletions tgui/packages/tgui/interfaces/DemoSim.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { useBackend } from '../backend';
import { useBackend, useLocalState } from '../backend';
import { Button, Section, ProgressBar, NoticeBox, Box, Stack } from '../components';
import { Window } from '../layouts';

export const DemoSim = (_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;
Expand Down Expand Up @@ -45,14 +50,17 @@ export const DemoSim = (_props, context) => {
<Section title="Detonation controls">
<Stack>
<Stack.Item grow>
{(!data.looking && (
{(!simulationView && (
<Button
fontSize="16px"
fluid={1}
icon="eye"
color="good"
content="Enter simulation"
onClick={() => act('start_watching')}
onClick={() => {
act('start_watching');
setSimulationView(true);
}}
/>
)) || (
<Button
Expand All @@ -61,7 +69,10 @@ export const DemoSim = (_props, context) => {
icon="eye-slash"
color="good"
content="Exit simulation"
onClick={() => act('stop_watching')}
onClick={() => {
act('stop_watching');
setSimulationView(false);
}}
/>
)}
</Stack.Item>
Expand Down
Loading