Filters are now volume-based.

This commit is contained in:
Putnam
2019-11-29 21:23:08 -08:00
parent 81977819ac
commit 1b310d41bf
3 changed files with 42 additions and 44 deletions

View File

@@ -4,7 +4,7 @@
desc = "Very useful for filtering gasses."
density = FALSE
can_unwrench = TRUE
var/target_pressure = ONE_ATMOSPHERE
var/transfer_rate = MAX_TRANSFER_RATE
var/filter_type = null
var/frequency = 0
var/datum/radio_frequency/radio_connection
@@ -15,7 +15,7 @@
/obj/machinery/atmospherics/components/trinary/filter/examine(mob/user)
. = ..()
. += "<span class='notice'>You can hold <b>Ctrl</b> and click on it to toggle it on and off.</span>"
. += "<span class='notice'>You can hold <b>Alt</b> and click on it to maximize its pressure.</span>"
. += "<span class='notice'>You can hold <b>Alt</b> and click on it to maximize its flow rate.</span>"
/obj/machinery/atmospherics/components/trinary/filter/CtrlClick(mob/user)
var/area/A = get_area(src)
@@ -31,8 +31,8 @@
var/area/A = get_area(src)
var/turf/T = get_turf(src)
if(user.canUseTopic(src, BE_CLOSE, FALSE,))
target_pressure = MAX_OUTPUT_PRESSURE
to_chat(user,"<span class='notice'>You maximize the pressure on the [src].</span>")
transfer_rate = MAX_TRANSFER_RATE
to_chat(user,"<span class='notice'>You maximize the flow rate on the [src].</span>")
investigate_log("Filter, [src.name], was maximized by [key_name(usr)] at [x], [y], [z], [A]", INVESTIGATE_ATMOS)
message_admins("Filter, [src.name], was maximized by [ADMIN_LOOKUPFLW(usr)] at [ADMIN_COORDJMP(T)], [A]")
@@ -150,24 +150,19 @@
var/datum/gas_mixture/air2 = airs[2]
var/datum/gas_mixture/air3 = airs[3]
var/output_starting_pressure = air3.return_pressure()
var/input_starting_pressure = air1.return_pressure()
if(output_starting_pressure >= target_pressure)
//No need to transfer if target is already full!
if((input_starting_pressure < 0.01))
return
//Calculate necessary moles to transfer using PV=nRT
var/pressure_delta = target_pressure - output_starting_pressure
var/transfer_moles
if(air1.temperature > 0)
transfer_moles = pressure_delta*air3.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
var/transfer_ratio = transfer_rate/air1.volume
//Actually transfer the gas
if(transfer_moles > 0)
var/datum/gas_mixture/removed = air1.remove(transfer_moles)
if(transfer_ratio > 0)
var/datum/gas_mixture/removed = air1.remove_ratio(transfer_ratio)
if(!removed)
return
@@ -188,10 +183,13 @@
removed.gases[filter_type] = 0
GAS_GARBAGE_COLLECT(removed.gases)
var/datum/gas_mixture/target = (air2.return_pressure() < target_pressure ? air2 : air1) //if there's no room for the filtered gas; just leave it in air1
var/datum/gas_mixture/target = (air2.return_pressure() < 9000 ? air2 : air1)
target.merge(filtered_out)
air3.merge(removed)
if(air3.return_pressure() <= 9000)
air3.merge(removed)
else
air1.merge(removed) // essentially just leaving it in
update_parents()
@@ -209,8 +207,8 @@
/obj/machinery/atmospherics/components/trinary/filter/ui_data()
var/data = list()
data["on"] = on
data["pressure"] = round(target_pressure)
data["max_pressure"] = round(MAX_OUTPUT_PRESSURE)
data["rate"] = round(transfer_rate)
data["max_rate"] = round(MAX_TRANSFER_RATE)
data["filter_types"] = list()
data["filter_types"] += list(list("name" = "Nothing", "path" = "", "selected" = !filter_type))
@@ -227,21 +225,21 @@
on = !on
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", INVESTIGATE_ATMOS)
. = TRUE
if("pressure")
var/pressure = params["pressure"]
if(pressure == "max")
pressure = MAX_OUTPUT_PRESSURE
if("rate")
var/rate = params["rate"]
if(rate == "max")
rate = MAX_TRANSFER_RATE
. = TRUE
else if(pressure == "input")
pressure = input("New output pressure (0-[MAX_OUTPUT_PRESSURE] kPa):", name, target_pressure) as num|null
if(!isnull(pressure) && !..())
else if(rate == "input")
rate = input("New transfer rate (0-[MAX_TRANSFER_RATE] L/s):", name, transfer_rate) as num|null
if(!isnull(rate) && !..())
. = TRUE
else if(text2num(pressure) != null)
pressure = text2num(pressure)
else if(text2num(rate) != null)
rate = text2num(rate)
. = TRUE
if(.)
target_pressure = CLAMP(pressure, 0, MAX_OUTPUT_PRESSURE)
investigate_log("was set to [target_pressure] kPa by [key_name(usr)]", INVESTIGATE_ATMOS)
transfer_rate = CLAMP(rate, 0, MAX_TRANSFER_RATE)
investigate_log("was set to [transfer_rate] L/s by [key_name(usr)]", INVESTIGATE_ATMOS)
if("filter")
filter_type = null
var/filter_name = "nothing"

File diff suppressed because one or more lines are too long

View File

@@ -3,10 +3,10 @@
<ui-button icon='{{data.on ? "power-off" : "close"}}' style='{{data.on ? "selected" : null}}'
action='power'>{{data.on ? "On" : "Off"}}</ui-button>
</ui-section>
<ui-section label='Output Pressure'>
<ui-button icon='pencil' action='pressure' params='{"pressure": "input"}'>Set</ui-button>
<ui-button icon='plus' state='{{data.pressure == data.max_pressure ? "disabled" : null}}' action='pressure' params='{"pressure": "max"}'>Max</ui-button>
<span>{{Math.round(adata.pressure)}} kPa</span>
<ui-section label='Transfer Rate'>
<ui-button icon='pencil' action='rate' params='{"rate": "input"}'>Set</ui-button>
<ui-button icon='plus' state='{{data.rate == data.max_rate ? "disabled" : null}}' action='rate' params='{"rate": "max"}'>Max</ui-button>
<span>{{Math.round(adata.rate)}} L/s</span>
</ui-section>
<ui-section label='Filter'>
{{#each data.filter_types}}