Skip to content

Commit

Permalink
finish up the MANCROWAVE
Browse files Browse the repository at this point in the history
  • Loading branch information
Kapu1178 committed Aug 27, 2024
1 parent 91b5c9c commit 6f25cb8
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 11 deletions.
2 changes: 1 addition & 1 deletion code/game/machinery/Sleeper.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
processing_flags = START_PROCESSING_MANUALLY

light_color = LIGHT_COLOR_CYAN
light_inner_range = 1
light_outer_range = 1
light_power = 1
light_on = FALSE

Expand Down
46 changes: 40 additions & 6 deletions code/game/machinery/mancrowave.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#define MANCROWAVE_HOMEOSTATIS "Homeostasis"
#define MANCROWAVE_RARE "Rare"
#define MANCROWAVE_WELL_DONE "Well Done"

/obj/machinery/sleeper/mancrowave
name = "thermal homeostasis regulator"
Expand Down Expand Up @@ -62,18 +64,24 @@
refresh_light()

/obj/machinery/sleeper/mancrowave/set_occupant(atom/movable/new_occupant)
. = ..()
if(isnull(occupant))
if(isnull(new_occupant))
end_cookin()
return ..()

/obj/machinery/sleeper/mancrowave/emag_act(mob/user, obj/item/card/emag/emag_card)
if(obj_flags & EMAGGED)
return

obj_flags |= EMAGGED
name = "THE MANCROWAVE"
cook_options += list(
MANCROWAVE_RARE = 50 SECONDS,
MANCROWAVE_WELL_DONE = 70 SECONDS,
)

refresh_light()
update_appearance(UPDATE_ICON_STATE)
SStgui.update_uis(src)

if(user)
to_chat(user, span_warning("The electromagnet shorts the safeties of [src]."))
Expand All @@ -92,6 +100,8 @@
data["cook_start"] = cook_start_time
data["now"] = world.time
data["cook_end"] = cook_timer
data["cook_options"] = cook_options
data["current_setting"] = current_setting

var/list/occupant_data = list()
data["occupant"] = occupant_data
Expand Down Expand Up @@ -143,16 +153,33 @@
start_cookin(current_setting)
return TRUE

if("mancrowave-cook-setting")
var/setting = params["setting"]
if(is_cookin)
return
if(!(setting in cook_options))
return

current_setting = setting
return TRUE

/obj/machinery/sleeper/mancrowave/process()
if(!is_cookin)
CRASH("Mancrowave was processing but not cookin'")

var/mob/living/carbon/human/human_occupant = occupant
var/desired_temp
if(current_setting == MANCROWAVE_HOMEOSTATIS)
desired_temp = human_occupant.get_body_temp_normal()
else
desired_temp = text2num(current_setting)
switch(current_setting)
if(MANCROWAVE_HOMEOSTATIS)
desired_temp = human_occupant.get_body_temp_normal()

if(MANCROWAVE_RARE)
human_occupant.add_body_temperature_change("MANCROWAVE", 100)
desired_temp = human_occupant.get_body_temp_normal()

if(MANCROWAVE_WELL_DONE)
human_occupant.add_body_temperature_change("MANCROWAVE", 250)
desired_temp = human_occupant.get_body_temp_normal()

if(COOLDOWN_FINISHED(src, cook_timer))
end_cookin(TRUE)
Expand Down Expand Up @@ -187,6 +214,10 @@
update_use_power(IDLE_POWER_USE)
end_processing()

var/mob/living/carbon/human/human_occupant = occupant
if(ishuman(human_occupant))
human_occupant.remove_body_temperature_change("MANCROWAVE")

if(!times_up)
return

Expand All @@ -195,3 +226,6 @@
if(auto_eject)
open_machine()

#undef MANCROWAVE_HOMEOSTATIS
#undef MANCROWAVE_RARE
#undef MANCROWAVE_WELL_DONE
37 changes: 33 additions & 4 deletions tgui/packages/tgui/interfaces/Mancrowave.jsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
import { useBackend } from '../backend';
import { Box, Button, LabeledList, ProgressBar, Section } from '../components';
import {
Box,
Button,
Dropdown,
LabeledList,
ProgressBar,
Section,
} from '../components';
import { Window } from '../layouts';

export const Mancrowave = (props) => {
const { act, data } = useBackend();
const { open, occupant = {}, occupied, on, cook_start, cook_end, now } = data;
const {
open,
occupant = {},
occupied,
on,
cook_start,
cook_end,
now,
cook_options = [],
current_setting,
} = data;
return (
<Window width={340} height={240}>
<Window width={340} height={360}>
<Window.Content>
<Section
title={occupant.name ? occupant.name : 'No Occupant'}
Expand All @@ -30,7 +47,7 @@ export const Mancrowave = (props) => {
</LabeledList>
</>
</Section>
<Section title="Controls">
<Section title="Controls" minHeight="200px">
<>
<Box mt={1} />
<LabeledList>
Expand All @@ -44,6 +61,18 @@ export const Mancrowave = (props) => {
</LabeledList.Item>
</LabeledList>
<Box mt={1} />
<Dropdown
width="100%"
options={Object.keys(cook_options)}
selected={current_setting}
onSelected={(value) =>
act('mancrowave-cook-setting', {
setting: value,
})
}
disabled={!!on}
/>
<Box mt={1} />
<Button
icon={open ? 'door-open' : 'door-closed'}
content={open ? 'Open' : 'Closed'}
Expand Down

0 comments on commit 6f25cb8

Please sign in to comment.