mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-22 19:47:22 +01:00
The NGCR: Nuclear Fission Reactor (#30493)
* coefficient balancing * damage and meltdowns * meltdown stuff * alert stuff * lots of work - whew * some enrichment code * rod encrichmnt * working on enrichment * more fabrication * rod fab * start to the nuke * overload sprites * overload code work * some overload tweaking * small tweak * coolant ejections and QOL things * overheat events + ripley gripper * rebase + venting code * save before rebase * some pre-work for rods * finishing the base rods * fixed my dme * de linting * tiny lint fix * more lint fixes * linting * linting * linting * linting * linting * temp delint * temp delint * undo TM stuff + minor fix * didnt save * some fixes * fixes * fixes and engine repair * fixed broken durability decay * LOTS of things * tgui * lint * linter * linter * minor shit * Update boxstation.dmm * major refactors and fixes * saved this * critical testing tweaks and fixes * fixes and tweaks * smithing start * forgot to save * craftables + grill start * saved * fix * more grill work * Update tgui.bundle.js * linter * linter * fixes * rod fabricator initial * cooking work * push * soundwork * sound work tweak * comments + sounds + toxins gen rework * lots of work * sprite stuff * deconflicting * delinting * bundle rebuild * prettier * feex * fuck you OD * who asked? * update to tgui * another edit to tgui * finish tgui * remove debug metadata button * rod tweaks for tgui * Update code/datums/uplink_items/uplink_traitor.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/game/mecha/equipment/tools/work_tools.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/game/mecha/equipment/tools/work_tools.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/game/objects/items/robot/cyborg_gripper.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/mob/living/simple_animal/parrot.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/mob/living/simple_animal/parrot.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/mob/living/simple_animal/parrot.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/mob/living/simple_animal/parrot.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/power/engines/fission/nuclear_misc.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/power/engines/fission/nuclear_misc.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/power/engines/fission/nuclear_misc.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/power/engines/fission/nuclear_rods.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/power/engines/fission/nuclear_rods.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/power/engines/fission/reactor.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/power/engines/fission/reactor.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/power/engines/fission/nuclear_rods.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/power/engines/fission/nuclear_rods.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/power/engines/fission/nuclear_rods.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/power/engines/fission/reactor.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/smithing/components/misc_components.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/power/engines/fission/nuclear_rods.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update tgui/packages/tgui/interfaces/NuclearRodFabricator.jsx Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Spans * tgui build * rod redo * improve tgui for fabricator * sprites and centrifuge/fab work * tgui update * spritework * cyberiad + hydrogen conversion * kerberos + counter * Update code/modules/power/engines/fission/nuclear_rods.dm Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * sprite + fab tweak * tgui bundle * lintering * bugfixing * linting * linting * event tweak * add missing gases to fission monitor * issue fixing * sprite/overlay fixes * mapping * stations again * space lattice * tine tweak * linter * no rod alerts * buttons * loose wire * make it so you can interact through rod casings and the uhh big thing in the center, what's that called again * fixes * door fix * many bug fixes + crates * fab ghost touch * water convert + maint sprite + fixes * pack changes + neighbor fix * doors rename * didnt save * hydrogen fix * map tweaks * repair fixes + corium LETHALITY * upped broken rad damage * pipe rename + overload icons * more roundstart moderators * rod tree tweaks * tweaks * pack and enrichment fixes * misc tweaks and fixes * fixes: Density, circuits, coolant offline negation * Apply suggestions from code review Co-authored-by: warriorstar-orion <orion@snowfrost.garden> Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * review changes * linter + fix * reviews and fixes * LOTS of tweaks and changes * supermatter kit * spacematter balance * tgui * fixes and tweaks * didnt save this * mapping + smith fix * cargo rods arnt radioactive til opened * Apply suggestions from code review Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * review items * fixes * linters * moving components out of nullspace * examine fix * Update tgui.bundle.js * explosion nerf and minor fix * Apply suggestions from code review Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * reviews * map fix + ripley rad immune * Apply suggestions from code review Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * review * fix chamber examine * tweaks + rod fab disk drop * Apply suggestions from code review Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * review changes * Update code/modules/power/engines/fission/nuclear_rods.dm Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * fixes * tgui bundle * small rod tweaks * Update code/game/machinery/computer/buildandrepair.dm Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/smithing/components/reactor_components.dm Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/power/engines/fission/reactor_machines.dm Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * Update code/modules/power/engines/fission/reactor_machines.dm Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com> Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> * reviews * Update code/modules/power/engines/fission/reactor_machines.dm Signed-off-by: DGamerL <108773801+DGamerL@users.noreply.github.com> --------- Signed-off-by: Kyani <65205627+EmeraldCandy@users.noreply.github.com> Signed-off-by: DGamerL <108773801+DGamerL@users.noreply.github.com> Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> Co-authored-by: Paul <pmerkamp@gmail.com> Co-authored-by: Pooble <90473506+poobsie@users.noreply.github.com> Co-authored-by: warriorstar-orion <orion@snowfrost.garden> Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com>
This commit is contained in:
co-authored by
Pooble
warriorstar-orion
DGamerL
Burzah
Paul
parent
6611476bdb
commit
f81ef075f1
@@ -0,0 +1,317 @@
|
||||
import { useState } from 'react';
|
||||
import { Box, Button, Divider, NoticeBox, Section, Stack, Table, Tabs } from 'tgui-core/components';
|
||||
|
||||
import { useBackend } from '../backend';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
const TABS = {
|
||||
FABRICATE: 'fabricate',
|
||||
MATERIALS: 'materials',
|
||||
};
|
||||
|
||||
export const NuclearRodFabricator = (props) => {
|
||||
const { data, act } = useBackend(props);
|
||||
|
||||
const categories = [
|
||||
{ key: 'fuel_rods', title: 'Fuel Rods' },
|
||||
{ key: 'moderator_rods', title: 'Moderator Rods' },
|
||||
{ key: 'coolant_rods', title: 'Coolant Rods' },
|
||||
];
|
||||
|
||||
const [selectedRod, setSelectedRod] = useState(null);
|
||||
const [hoveredRod, setHoveredRod] = useState(null);
|
||||
const [activeTab, setActiveTab] = useState(TABS.FABRICATE);
|
||||
const [categoryTab, setCategoryTab] = useState('fuel_rods');
|
||||
|
||||
return (
|
||||
<Window width={850} height={600}>
|
||||
<Window.Content>
|
||||
<Stack fill vertical>
|
||||
{/* Tab Navigation */}
|
||||
<Stack.Item>
|
||||
<Tabs>
|
||||
<Tabs.Tab selected={activeTab === TABS.FABRICATE} onClick={() => setActiveTab(TABS.FABRICATE)}>
|
||||
Fabricate
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab selected={activeTab === TABS.MATERIALS} onClick={() => setActiveTab(TABS.MATERIALS)}>
|
||||
Materials
|
||||
</Tabs.Tab>
|
||||
</Tabs>
|
||||
</Stack.Item>
|
||||
|
||||
{/* Tab Content */}
|
||||
<Stack.Item grow>
|
||||
{activeTab === TABS.FABRICATE && (
|
||||
<Stack fill stretch>
|
||||
{/* Left Side */}
|
||||
<Stack.Item width="50%">
|
||||
<Section title={`Available Designs`} fill scrollable>
|
||||
{/* Category Tabs */}
|
||||
<Tabs>
|
||||
<Tabs.Tab
|
||||
icon="atom"
|
||||
selected={categoryTab === 'fuel_rods'}
|
||||
onClick={() => setCategoryTab('fuel_rods')}
|
||||
>
|
||||
Fuel Rods
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab
|
||||
icon="cubes"
|
||||
selected={categoryTab === 'moderator_rods'}
|
||||
onClick={() => setCategoryTab('moderator_rods')}
|
||||
>
|
||||
Moderator Rods
|
||||
</Tabs.Tab>
|
||||
<Tabs.Tab
|
||||
icon="snowflake"
|
||||
selected={categoryTab === 'coolant_rods'}
|
||||
onClick={() => setCategoryTab('coolant_rods')}
|
||||
>
|
||||
Coolant Rods
|
||||
</Tabs.Tab>
|
||||
</Tabs>
|
||||
|
||||
{/* Rod List */}
|
||||
<Box mt={1}>
|
||||
{(() => {
|
||||
const list = data[categoryTab] || [];
|
||||
|
||||
if (list.length === 0) {
|
||||
return (
|
||||
<Box color="average" p={1}>
|
||||
No {categories.find((c) => c.key === categoryTab)?.title.toLowerCase()} available.
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
return list.map((rod, i) => (
|
||||
<Box
|
||||
key={i}
|
||||
p={1}
|
||||
mb={0.5}
|
||||
style={{
|
||||
cursor: 'pointer',
|
||||
backgroundColor:
|
||||
selectedRod?.type_path === rod.type_path
|
||||
? 'rgba(80, 140, 255, 0.25)'
|
||||
: hoveredRod?.type_path === rod.type_path
|
||||
? 'rgba(255,255,255,0.08)'
|
||||
: 'rgba(255,255,255,0.03)',
|
||||
border: '1px solid rgba(255,255,255,0.08)',
|
||||
}}
|
||||
onClick={() => setSelectedRod(rod)}
|
||||
onMouseEnter={() => setHoveredRod(rod)}
|
||||
onMouseLeave={() => setHoveredRod(null)}
|
||||
>
|
||||
<Box bold>{rod.name}</Box>
|
||||
<Box fontSize="0.85em" color="label">
|
||||
{rod.desc}
|
||||
</Box>
|
||||
</Box>
|
||||
));
|
||||
})()}
|
||||
</Box>
|
||||
</Section>
|
||||
</Stack.Item>
|
||||
|
||||
{/* Right Side */}
|
||||
<Stack.Item grow>
|
||||
<Section title="Rod Information" fill>
|
||||
{!selectedRod && <NoticeBox>Please select a rod design from the left.</NoticeBox>}
|
||||
|
||||
{selectedRod && (
|
||||
<Stack vertical fill>
|
||||
{/* Rod Statistics */}
|
||||
<Section title={selectedRod.name}>
|
||||
<Table>
|
||||
<Table.Row>
|
||||
<Table.Cell bold>Power Generation:</Table.Cell>
|
||||
<Table.Cell>{(selectedRod.power_amount || 0) / 1000} KW</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell bold>Power Amplification:</Table.Cell>
|
||||
<Table.Cell>{selectedRod.power_amp_mod || 1}</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell colSpan={2} style={{ paddingTop: '8px' }} />
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell bold>Heat Generation:</Table.Cell>
|
||||
<Table.Cell>{selectedRod.heat_amount || 0} joules</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell bold>Heat Amplification:</Table.Cell>
|
||||
<Table.Cell>{selectedRod.heat_amp_mod || 1}</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell colSpan={2} style={{ paddingTop: '8px' }} />
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell bold>Lifespan:</Table.Cell>
|
||||
<Table.Cell>{selectedRod.max_durability || 0} cycles</Table.Cell>
|
||||
</Table.Row>
|
||||
{selectedRod.heat_enrichment && (
|
||||
<>
|
||||
<Table.Row>
|
||||
<Table.Cell colSpan={2} style={{ paddingTop: '8px' }} />
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell bold>Heat Enrichment:</Table.Cell>
|
||||
<Table.Cell>{selectedRod.heat_enrichment}</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell bold>Heat Enrichment Requirement:</Table.Cell>
|
||||
<Table.Cell>{selectedRod.heat_enrichment_requirement || 0}</Table.Cell>
|
||||
</Table.Row>
|
||||
</>
|
||||
)}
|
||||
{selectedRod.power_enrichment && (
|
||||
<>
|
||||
<Table.Row>
|
||||
<Table.Cell colSpan={2} style={{ paddingTop: '8px' }} />
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell bold>Power Enrichment:</Table.Cell>
|
||||
<Table.Cell>{selectedRod.power_enrichment}</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell bold>Power Enrichment Requirement:</Table.Cell>
|
||||
<Table.Cell>{selectedRod.power_enrichment_requirement || 0}</Table.Cell>
|
||||
</Table.Row>
|
||||
</>
|
||||
)}
|
||||
</Table>
|
||||
|
||||
{/* Neighbor Requirements */}
|
||||
{selectedRod.neighbor_requirements && selectedRod.neighbor_requirements.length > 0 ? (
|
||||
<>
|
||||
<Box mt={1} bold>
|
||||
Neighbor Requirements:
|
||||
</Box>
|
||||
<Box ml={2}>
|
||||
{selectedRod.neighbor_requirements.map((requirement, idx) => (
|
||||
<Box key={idx}>{requirement}</Box>
|
||||
))}
|
||||
</Box>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<Box mt={1} bold>
|
||||
Neighbor Requirements:
|
||||
</Box>
|
||||
<Box ml={2}>None</Box>
|
||||
</>
|
||||
)}
|
||||
</Section>
|
||||
|
||||
<Divider />
|
||||
|
||||
{/* Required Materials */}
|
||||
<Section title="Required Materials">
|
||||
{!selectedRod.materials || Object.keys(selectedRod.materials).length === 0 ? (
|
||||
<Box color="average">No materials required.</Box>
|
||||
) : (
|
||||
<Table>
|
||||
{Object.entries(selectedRod.materials).map(([matName, matAmt], i) => {
|
||||
// Check if we have enough of this material
|
||||
const availableResource = Object.entries(data.resources || {}).find(
|
||||
([resName, resData]) => resName === matName
|
||||
);
|
||||
const availableAmount = availableResource ? availableResource[1].amount : 0;
|
||||
const hasEnough = availableAmount >= matAmt;
|
||||
|
||||
return (
|
||||
<Table.Row key={i}>
|
||||
<Table.Cell bold className={!hasEnough ? 'color-red' : null}>
|
||||
{matName}
|
||||
</Table.Cell>
|
||||
<Table.Cell className={!hasEnough ? 'color-red' : null}>{matAmt}</Table.Cell>
|
||||
<Table.Cell className={!hasEnough ? 'color-red' : null}>
|
||||
({Math.round(matAmt / 2000)} sheets)
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
);
|
||||
})}
|
||||
</Table>
|
||||
)}
|
||||
</Section>
|
||||
|
||||
<Divider />
|
||||
|
||||
{/* Fabricate Button */}
|
||||
<Button
|
||||
icon="wrench"
|
||||
content={`Fabricate`}
|
||||
color="good"
|
||||
onClick={() => act('fabricate_rod', { type_path: selectedRod.type_path })}
|
||||
/>
|
||||
</Stack>
|
||||
)}
|
||||
</Section>
|
||||
</Stack.Item>
|
||||
</Stack>
|
||||
)}
|
||||
|
||||
{activeTab === TABS.MATERIALS && (
|
||||
<Section title="Material Storage" fill>
|
||||
{!data.resources || Object.keys(data.resources).length === 0 ? (
|
||||
<Box color="average">No materials loaded.</Box>
|
||||
) : (
|
||||
<Table>
|
||||
{Object.entries(data.resources).map(([resName, resData], i) => (
|
||||
<Table.Row key={i}>
|
||||
<Table.Cell bold>{resName}</Table.Cell>
|
||||
<Table.Cell>{resData.amount} units</Table.Cell>
|
||||
<Table.Cell>({resData.sheets} sheets)</Table.Cell>
|
||||
<Table.Cell>
|
||||
<Button
|
||||
content="1"
|
||||
onClick={() =>
|
||||
act('eject_material', {
|
||||
id: resData.id,
|
||||
amount: '1',
|
||||
})
|
||||
}
|
||||
/>
|
||||
<Button
|
||||
content="C"
|
||||
onClick={() =>
|
||||
act('eject_material', {
|
||||
id: resData.id,
|
||||
amount: 'custom',
|
||||
})
|
||||
}
|
||||
/>
|
||||
{resData.sheets >= 5 && (
|
||||
<Button
|
||||
content="5"
|
||||
onClick={() =>
|
||||
act('eject_material', {
|
||||
id: resData.id,
|
||||
amount: '5',
|
||||
})
|
||||
}
|
||||
/>
|
||||
)}
|
||||
<Button
|
||||
content="All"
|
||||
onClick={() =>
|
||||
act('eject_material', {
|
||||
id: resData.id,
|
||||
amount: resData.sheets.toString(),
|
||||
})
|
||||
}
|
||||
/>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
)}
|
||||
</Section>
|
||||
)}
|
||||
</Stack.Item>
|
||||
</Stack>
|
||||
</Window.Content>
|
||||
</Window>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,199 @@
|
||||
import { Button, Knob, LabeledList, ProgressBar, Section, Stack } from 'tgui-core/components';
|
||||
import { toFixed } from 'tgui-core/math';
|
||||
|
||||
import { useBackend } from '../backend';
|
||||
import { getGasColor, getGasLabel } from '../constants';
|
||||
import { Window } from '../layouts';
|
||||
|
||||
interface FissionReactorData {
|
||||
active: number;
|
||||
supermatters?: Array<{
|
||||
supermatter_id: string;
|
||||
area_name: string;
|
||||
integrity: number;
|
||||
}>;
|
||||
venting: boolean;
|
||||
NGCR_integrity: number;
|
||||
NGCR_power: number;
|
||||
NGCR_ambienttemp: number;
|
||||
NGCR_ambientpressure: number;
|
||||
NGCR_coefficient: number;
|
||||
NGCR_operatingpower: number;
|
||||
NGCR_throttle: number;
|
||||
gases?: Array<{
|
||||
name: string;
|
||||
amount: number;
|
||||
portion: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
export const ReactorMonitor = (props) => {
|
||||
const logScale = (value: number): number => Math.log2(16 + Math.max(0, value)) - 4;
|
||||
const { act, data } = useBackend<FissionReactorData>();
|
||||
const {
|
||||
venting,
|
||||
NGCR_integrity,
|
||||
NGCR_power,
|
||||
NGCR_ambienttemp,
|
||||
NGCR_ambientpressure,
|
||||
NGCR_coefficient,
|
||||
NGCR_operatingpower,
|
||||
NGCR_throttle,
|
||||
gases = [],
|
||||
} = data;
|
||||
const filteredGases = (gases ?? []).filter((gas) => gas.amount >= 0.01).sort((a, b) => b.amount - a.amount);
|
||||
const gasMaxAmount = Math.max(1, ...filteredGases.map((gas) => gas.portion));
|
||||
return (
|
||||
<Window width={550} height={500}>
|
||||
<Window.Content>
|
||||
<Stack fill>
|
||||
<Stack.Item width="270px">
|
||||
<Section fill scrollable title="Metrics">
|
||||
<LabeledList>
|
||||
<LabeledList.Item label="Integrity">
|
||||
<ProgressBar
|
||||
value={NGCR_integrity / 100}
|
||||
ranges={{
|
||||
good: [0.9, Infinity],
|
||||
average: [0.5, 0.9],
|
||||
bad: [-Infinity, 0.5],
|
||||
}}
|
||||
/>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Power Generation">
|
||||
<ProgressBar
|
||||
value={NGCR_power}
|
||||
minValue={0}
|
||||
maxValue={2000}
|
||||
ranges={
|
||||
NGCR_power <= 10000
|
||||
? {
|
||||
good: [400, Infinity],
|
||||
average: [200, 400],
|
||||
bad: [-Infinity, 200],
|
||||
}
|
||||
: {
|
||||
good: [-Infinity, Infinity],
|
||||
}
|
||||
}
|
||||
>
|
||||
{toFixed(NGCR_power < 10000 ? NGCR_power : NGCR_power / 1000) +
|
||||
(NGCR_power < 10000 ? ' KW' : ' MW')}
|
||||
</ProgressBar>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Reactivity Coefficient">
|
||||
<ProgressBar
|
||||
value={NGCR_coefficient}
|
||||
minValue={1}
|
||||
maxValue={5.25}
|
||||
ranges={{
|
||||
bad: [1, 1.55],
|
||||
average: [1.55, 5.25],
|
||||
good: [5.25, Infinity],
|
||||
}}
|
||||
>
|
||||
{NGCR_coefficient.toFixed(2)}
|
||||
</ProgressBar>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Temperature">
|
||||
<ProgressBar
|
||||
value={logScale(NGCR_ambienttemp)}
|
||||
minValue={0}
|
||||
maxValue={logScale(10000)}
|
||||
ranges={{
|
||||
teal: [-Infinity, logScale(80)],
|
||||
good: [logScale(80), logScale(373)],
|
||||
average: [logScale(373), logScale(1000)],
|
||||
bad: [logScale(1000), Infinity],
|
||||
}}
|
||||
>
|
||||
{toFixed(NGCR_ambienttemp) + ' K'}
|
||||
</ProgressBar>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Pressure">
|
||||
<ProgressBar
|
||||
value={logScale(NGCR_ambientpressure)}
|
||||
minValue={0}
|
||||
maxValue={logScale(50000)}
|
||||
ranges={{
|
||||
good: [logScale(1), logScale(1000)],
|
||||
average: [-Infinity, logScale(3000)],
|
||||
bad: [logScale(3000), Infinity],
|
||||
}}
|
||||
>
|
||||
{toFixed(NGCR_ambientpressure) + ' kPa'}
|
||||
</ProgressBar>
|
||||
</LabeledList.Item>
|
||||
<LabeledList.Item label="Control Rod Limiter">
|
||||
<ProgressBar
|
||||
value={NGCR_operatingpower}
|
||||
minValue={0}
|
||||
maxValue={100}
|
||||
ranges={{
|
||||
teal: [100, Infinity],
|
||||
good: [70, 99],
|
||||
average: [30, 70],
|
||||
bad: [-Infinity, 30],
|
||||
}}
|
||||
>
|
||||
{toFixed(NGCR_operatingpower) + ' %'}
|
||||
</ProgressBar>
|
||||
</LabeledList.Item>
|
||||
</LabeledList>
|
||||
<Section title="Desired Control Rod Limit" textAlign="center">
|
||||
<Knob
|
||||
size={5}
|
||||
value={NGCR_throttle}
|
||||
unit="%"
|
||||
minValue={0}
|
||||
maxValue={100}
|
||||
step={1}
|
||||
stepPixelSize={2}
|
||||
onChange={(e, value) =>
|
||||
act('set_throttle', {
|
||||
NGCR_throttle: value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</Section>
|
||||
</Section>
|
||||
</Stack.Item>
|
||||
<Stack.Item grow basis={0}>
|
||||
<Stack fill vertical>
|
||||
<Stack.Item grow>
|
||||
<Section
|
||||
fill
|
||||
scrollable
|
||||
title="Gases"
|
||||
buttons={
|
||||
<Button
|
||||
icon={'power-off'}
|
||||
content={venting ? 'Vent Open' : 'Vent Closed'}
|
||||
selected={venting}
|
||||
onClick={() => act('toggle_vent')}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<LabeledList>
|
||||
{filteredGases.map((gas) => (
|
||||
<LabeledList.Item key={gas.name} label={getGasLabel(gas.name, gas.name)}>
|
||||
<ProgressBar
|
||||
color={getGasColor(gas.name)}
|
||||
value={gas.portion}
|
||||
minValue={0}
|
||||
maxValue={gasMaxAmount}
|
||||
>
|
||||
{toFixed(gas.amount) + ' mol (' + gas.portion + '%)'}
|
||||
</ProgressBar>
|
||||
</LabeledList.Item>
|
||||
))}
|
||||
</LabeledList>
|
||||
</Section>
|
||||
</Stack.Item>
|
||||
</Stack>
|
||||
</Stack.Item>
|
||||
</Stack>
|
||||
</Window.Content>
|
||||
</Window>
|
||||
);
|
||||
};
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user