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

GM infesting subpanel #134

Merged
merged 2 commits into from
Mar 18, 2024
Merged
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
1 change: 1 addition & 0 deletions code/modules/admin/game_master/game_master.dm
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ GLOBAL_VAR_INIT(radio_communication_clarity, 100)
var/list/submenu_types = list(
/obj/structure/pipes/vents = /datum/game_master_submenu/ambush/vents,
/obj/structure/tunnel = /datum/game_master_submenu/ambush/tunnels,
/mob/living/carbon/human = /datum/game_master_submenu/infest,
)

/// List of current submenus
Expand Down
97 changes: 97 additions & 0 deletions code/modules/admin/game_master/game_master_submenu/infest.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#define DEFAULT_SPAWN_HIVE_STRING XENO_HIVE_NORMAL

/datum/game_master_submenu/infest
tgui_menu_name = "GameMasterSubmenuInfest"
tgui_menu_title = "Infest Control"

/// Current selected hive for the embryo
var/selected_hive = DEFAULT_SPAWN_HIVE_STRING

/// Target growth stage for the embryo
var/embryo_stage = 0

/datum/game_master_submenu/infest/ui_data(mob/user)
. = ..()

var/list/data = list()

data["selected_hive"] = selected_hive
data["embryo_stage"] = embryo_stage

return data

/datum/game_master_submenu/infest/ui_static_data(mob/user)
. = ..()

var/list/data = list()

data["selectable_hives"] = ALL_XENO_HIVES

return data

/datum/game_master_submenu/infest/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()

switch(action)
if("set_selected_hive")
selected_hive = params["new_hive"]
return TRUE
morrowwolf marked this conversation as resolved.
Show resolved Hide resolved

if("set_embryo_stage")
embryo_stage = params["stage"]
return TRUE

if("infest")
setup_embryo()
return TRUE

if("clear_infest")
remove_embryo()
return TRUE

if("burst")
force_burst()
return TRUE

/datum/game_master_submenu/infest/proc/setup_embryo()
var/obj/item/alien_embryo/infesting_embryo
for(var/obj/item/alien_embryo/embryo in referenced_atom) //if this hive's embryo already exists, convert to larva and use it
if(embryo.hivenumber == selected_hive)
infesting_embryo = embryo
else
qdel(embryo)

if(!infesting_embryo) //else, make a new one
infesting_embryo = new /obj/item/alien_embryo(referenced_atom)
infesting_embryo.hivenumber = selected_hive

var/mob/living/carbon/human/infested_host = referenced_atom
infested_host.species?.larva_impregnated(infesting_embryo) //Yautja handling

infesting_embryo.stage = embryo_stage

/datum/game_master_submenu/infest/proc/remove_embryo()
for(var/obj/item/alien_embryo/embryo in referenced_atom)
qdel(embryo)

/datum/game_master_submenu/infest/proc/force_burst()
var/mob/living/carbon/xenomorph/larva/infesting_larva = locate() in referenced_atom //if a larva already exists, use it
if(infesting_larva)
infesting_larva.chest_burst(referenced_atom)
return

for(var/obj/item/alien_embryo/embryo in referenced_atom) //else if this hive's embryo already exists, convert to larva and use it
if(embryo.hivenumber == selected_hive)
embryo.become_larva()
infesting_larva = locate() in referenced_atom
break
if(infesting_larva)
infesting_larva.chest_burst(referenced_atom)
return

infesting_larva = new /mob/living/carbon/xenomorph/larva(referenced_atom, null, selected_hive) //else, make a new larva
var/mob/living/carbon/human/infested_host = referenced_atom
infesting_larva.ckey = infested_host.ckey
infesting_larva.chest_burst(referenced_atom)

#undef DEFAULT_SPAWN_HIVE_STRING
1 change: 1 addition & 0 deletions colonialmarines.dme
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,7 @@
#include "code\modules\admin\game_master\extra_buttons\toggle_join_xeno.dm"
#include "code\modules\admin\game_master\extra_buttons\toggle_vehicle_blockers.dm"
#include "code\modules\admin\game_master\game_master_submenu\ambush.dm"
#include "code\modules\admin\game_master\game_master_submenu\infest.dm"
#include "code\modules\admin\game_master\game_master_submenu\tunnels.dm"
#include "code\modules\admin\game_master\game_master_submenu\vents.dm"
#include "code\modules\admin\medal_panel\medals_panel.dm"
Expand Down
85 changes: 85 additions & 0 deletions tgui/packages/tgui/interfaces/GameMasterSubmenuInfest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { useBackend } from '../backend';
import { Stack, Dropdown, Button, Section, Slider } from '../components';
import { Window } from '../layouts';

export const GameMasterSubmenuInfest = (props, context) => {
const { data, act } = useBackend(context);

return (
<Window width={400} height={400}>
<Window.Content scrollable>
<Stack direction="column" vertical>
<GameMasterSubmenuInfestInfestingPanel />
</Stack>
</Window.Content>
</Window>
);
};

export const GameMasterSubmenuInfestInfestingPanel = (props, context) => {
const { data, act } = useBackend(context);

return (
<Section title="Infesting">
<Stack direction="column" vertical>
<Stack.Item>
<Stack>
<Stack.Item>
<Dropdown
options={data.selectable_hives}
selected={data.selected_hive}
width="15rem"
onSelected={(new_hive) => {
act('set_selected_hive', { new_hive });
}}
/>
</Stack.Item>
</Stack>
</Stack.Item>
<Stack.Item mt={1}>Embryo Stage</Stack.Item>
<Stack.Item>
<Slider
maxValue={5}
minValue={0}
stepPixelSize={40}
value={data.embryo_stage}
onChange={(e, stage) => {
act('set_embryo_stage', { stage });
}}
/>
</Stack.Item>
<Stack.Item>
<Stack>
<Stack.Item>
<Button
middle
content="Set"
onClick={() => {
act('infest');
}}
/>
</Stack.Item>
<Stack.Item>
<Button
middle
content="Clear"
onClick={() => {
act('clear_infest');
}}
/>
</Stack.Item>
</Stack>
</Stack.Item>
<Stack.Item>
<Button
middle
content="Burst Now"
onClick={() => {
act('burst');
}}
/>
</Stack.Item>
</Stack>
</Section>
);
};
Loading