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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

partially reverts reaction chamber #57855

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 12 additions & 4 deletions code/datums/components/plumbing/reaction_chamber.dm
Expand Up @@ -18,10 +18,18 @@
if(RC.emptying)
return

process_request(amount = min(MACHINE_REAGENT_TRANSFER, RC.target_volume - reagents.total_volume), dir = dir)

if(RC.target_volume > round(reagents.total_volume, CHEMICAL_VOLUME_ROUNDING)) //not enough yet
return
for(var/RT in RC.required_reagents)
Time-Green marked this conversation as resolved.
Show resolved Hide resolved
var/has_reagent = FALSE
for(var/A in reagents.reagent_list)
var/datum/reagent/RD = A
Time-Green marked this conversation as resolved.
Show resolved Hide resolved
if(RT == RD.type)
has_reagent = TRUE
if(RD.volume < RC.required_reagents[RT])
process_request(min(RC.required_reagents[RT] - RD.volume, MACHINE_REAGENT_TRANSFER) , RT, dir)
return
if(!has_reagent)
process_request(min(RC.required_reagents[RT], MACHINE_REAGENT_TRANSFER), RT, dir)
return

reagents.flags &= ~NO_REACT
reagents.handle_reactions()
Expand Down
25 changes: 20 additions & 5 deletions code/modules/plumbing/plumbers/reaction_chamber.dm
Expand Up @@ -6,8 +6,10 @@
buffer = 200
reagent_flags = TRANSPARENT | NO_REACT

///At what volume do we start reacting?
var/target_volume = 200
/**list of set reagents that the reaction_chamber allows in, and must all be present before mixing is enabled.
* example: list(/datum/reagent/water = 20, /datum/reagent/fuel/oil = 50)
Time-Green marked this conversation as resolved.
Show resolved Hide resolved
*/
var/list/required_reagents = list()
///If above this pH, we start dumping buffer into it
var/acidic_limit = 9
///If below this pH, we start dumping buffer into it
Expand Down Expand Up @@ -80,12 +82,17 @@
/obj/machinery/plumbing/reaction_chamber/ui_data(mob/user)
var/list/data = list()

var/list/text_reagents = list()
for(var/A in required_reagents) //make a list where the key is text, because that looks alot better in the ui than a typepath
var/datum/reagent/R = A
Time-Green marked this conversation as resolved.
Show resolved Hide resolved
text_reagents[initial(R.name)] = required_reagents[R]

data["reagents"] = text_reagents
data["emptying"] = emptying
data["temperature"] = round(reagents.chem_temp, 0.1)
data["ph"] = round(reagents.ph, 0.01)
data["targetTemp"] = target_temperature
data["isReacting"] = reagents.is_reacting
data["reagentQuantity"] = target_volume
data["reagentAcidic"] = acidic_limit
data["reagentAlkaline"] = alkaline_limit
return data
Expand All @@ -96,15 +103,23 @@
return
. = TRUE
switch(action)
if("remove")
var/reagent = get_chem_id(params["chem"])
if(reagent)
required_reagents.Remove(reagent)
if("add")
var/input_reagent = get_chem_id(params["chem"])
if(input_reagent && !required_reagents.Find(input_reagent))
var/input_amount = text2num(params["amount"])
if(input_amount)
required_reagents[input_reagent] = input_amount
if("temperature")
var/target = params["target"]
if(text2num(target) != null)
target = text2num(target)
. = TRUE
if(.)
target_temperature = clamp(target, 0, 1000)
if("volume")
target_volume = round(text2num(params["target"]))
if("acidic")
acidic_limit = round(text2num(params["target"]))
if("alkaline")
Expand Down
82 changes: 58 additions & 24 deletions tgui/packages/tgui/interfaces/ChemReactionChamber.js
Expand Up @@ -8,19 +8,28 @@ import { round, toFixed } from 'common/math';
export const ChemReactionChamber = (props, context) => {
const { act, data } = useBackend(context);

const [
reagentName,
setReagentName,
] = useLocalState(context, 'reagentName', '');
const [
reagentQuantity,
setReagentQuantity,
] = useLocalState(context, 'reagentQuantity', 1);

const {
emptying,
temperature,
ph,
targetTemp,
isReacting,
reagentQuantity,
reagentAcidic,
reagentAlkaline,
} = data;
const reagents = data.reagents || [];
return (
<Window
width={250}
width={290}
height={280}>
<Window.Content scrollable>
<Section
Expand Down Expand Up @@ -105,28 +114,6 @@ export const ChemReactionChamber = (props, context) => {
)
)}>
<LabeledList>
<tr className="LabledList__row">
<LabeledList.Item label="Reaction Volume">
<td
className={classes([
"LabeledList__buttons",
"LabeledList__cell",
])}>
<NumberInput
value={reagentQuantity}
minValue={1}
maxValue={200}
step={1}
stepPixelSize={3}
width="39px"
onDrag={(e, value) => act('volume', {
target: value,
})} />

<Box inline mr={1} />
</td>
</LabeledList.Item>
</tr>
<tr className="LabledList__row">
<LabeledList.Item label="Acidic pH limit">
<td
Expand Down Expand Up @@ -169,6 +156,53 @@ export const ChemReactionChamber = (props, context) => {
</td>
</LabeledList.Item>
</tr>
<tr className="LabledList__row">
<td
colSpan="2"
className="LabeledList__cell">
<Input
fluid
value=""
placeholder="Reagent Name"
onInput={(e, value) => setReagentName(value)} />
</td>
<td
className={classes([
"LabeledList__buttons",
"LabeledList__cell",
])}>
<NumberInput
value={reagentQuantity}
minValue={1}
maxValue={100}
step={1}
stepPixelSize={3}
width="39px"
onDrag={(e, value) => setReagentQuantity(value)} />
<Box inline mr={1} />
<Button
icon="plus"
onClick={() => act('add', {
chem: reagentName,
amount: reagentQuantity,
})} />
</td>
</tr>
{map((amount, reagent) => (
<LabeledList.Item
key={reagent}
label={reagent}
buttons={(
<Button
icon="minus"
color="bad"
onClick={() => act('remove', {
chem: reagent,
})} />
)}>
{amount}
</LabeledList.Item>
))(reagents)}
</LabeledList>
</Section>
</Window.Content>
Expand Down