mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-27 02:22:26 +00:00
Replaces the volume gas pump
This commit is contained in:
@@ -17,7 +17,7 @@ Thus, the two variables affect pump operation are set in New():
|
||||
icon_state = "map"
|
||||
level = 1
|
||||
|
||||
name = "Gas pump"
|
||||
name = "gas pump"
|
||||
desc = "A pump"
|
||||
|
||||
var/on = 0
|
||||
@@ -31,22 +31,17 @@ Thus, the two variables affect pump operation are set in New():
|
||||
|
||||
var/last_power_draw = 0 //for UI
|
||||
var/last_flow_rate = 0 //for UI
|
||||
var/max_pressure_setting = 9000 //kPa
|
||||
var/max_pressure_setting = 15000 //kPa
|
||||
|
||||
var/frequency = 0
|
||||
var/id = null
|
||||
var/datum/radio_frequency/radio_connection
|
||||
|
||||
/obj/machinery/atmospherics/binary/pump/highcap
|
||||
name = "High capacity gas pump"
|
||||
desc = "A high capacity pump"
|
||||
|
||||
target_pressure = 15000000 //15 GPa? Really?
|
||||
active_power_usage = 112500 //150 Horsepower
|
||||
|
||||
/obj/machinery/atmospherics/binary/pump/on
|
||||
on = 1
|
||||
|
||||
|
||||
|
||||
/obj/machinery/atmospherics/binary/pump/update_icon()
|
||||
if(!powered())
|
||||
icon_state = "off"
|
||||
@@ -103,8 +98,12 @@ Thus, the two variables affect pump operation are set in New():
|
||||
transfer_moles = min(transfer_moles, active_power_usage / specific_power)
|
||||
|
||||
//Actually transfer the gas
|
||||
var/input_pressure = air1.return_pressure()
|
||||
|
||||
var/datum/gas_mixture/removed = air1.remove(transfer_moles)
|
||||
last_flow_rate = output_starting_pressure? transfer_moles*R_IDEAL_GAS_EQUATION*removed.temperature/air1.return_pressure() : 0 //need to calculate this here because gas_mixture/remove() is dumb
|
||||
if (input_pressure > 0)
|
||||
last_flow_rate = removed.total_moles()*R_IDEAL_GAS_EQUATION*removed.temperature/input_pressure
|
||||
|
||||
air2.merge(removed)
|
||||
|
||||
//if specific_entropy >= 0 then gas is flowing naturally and we don't need to use extra power
|
||||
@@ -178,9 +177,9 @@ Thus, the two variables affect pump operation are set in New():
|
||||
|
||||
data = list(
|
||||
"on" = on,
|
||||
"pressure_set" = round(target_pressure, 0.05),
|
||||
"pressure_set" = round(target_pressure*100), //Nano UI can't handle rounded non-integers, apparently.
|
||||
"max_pressure" = max_pressure_setting,
|
||||
"last_flow_rate" = round(last_flow_rate),
|
||||
"last_flow_rate" = round(last_flow_rate*10),
|
||||
"last_power_draw" = round(last_power_draw),
|
||||
"max_power_draw" = active_power_usage,
|
||||
)
|
||||
|
||||
@@ -1,193 +1,18 @@
|
||||
/*
|
||||
Every cycle, the pump uses the air in air_in to try and make air_out the perfect pressure.
|
||||
|
||||
node1, air1, network1 correspond to input
|
||||
node2, air2, network2 correspond to output
|
||||
|
||||
Thus, the two variables affect pump operation are set in New():
|
||||
air1.volume
|
||||
This is the volume of gas available to the pump that may be transfered to the output
|
||||
air2.volume
|
||||
Higher quantities of this cause more air to be perfected later
|
||||
but overall network volume is also increased as this increases...
|
||||
*/
|
||||
|
||||
/obj/machinery/atmospherics/binary/volume_pump
|
||||
/obj/machinery/atmospherics/binary/pump/high_power
|
||||
icon = 'icons/atmos/volume_pump.dmi'
|
||||
icon_state = "map"
|
||||
level = 1
|
||||
|
||||
name = "Volumetric gas pump"
|
||||
desc = "A volumetric pump"
|
||||
name = "high power gas pump"
|
||||
desc = "A pump. Has double the power rating of the standard gas pump."
|
||||
|
||||
var/on = 0
|
||||
var/transfer_rate = 200
|
||||
active_power_usage = 15000 //This also doubles as a measure of how powerful the pump is, in Watts. 15000 W ~ 20 HP
|
||||
|
||||
var/frequency = 0
|
||||
var/id = null
|
||||
var/datum/radio_frequency/radio_connection
|
||||
|
||||
/obj/machinery/atmospherics/binary/volume_pump/on
|
||||
/obj/machinery/atmospherics/binary/pump/high_power/on
|
||||
on = 1
|
||||
|
||||
/obj/machinery/atmospherics/binary/volume_pump/update_icon()
|
||||
/obj/machinery/atmospherics/binary/pump/high_power/update_icon()
|
||||
if(!powered())
|
||||
icon_state = "off"
|
||||
else
|
||||
icon_state = "[on ? "on" : "off"]"
|
||||
|
||||
/obj/machinery/atmospherics/binary/volume_pump/update_underlays()
|
||||
if(..())
|
||||
underlays.Cut()
|
||||
var/turf/T = get_turf(src)
|
||||
if(!istype(T))
|
||||
return
|
||||
add_underlay(T, node1, turn(dir, -180))
|
||||
add_underlay(T, node2, dir)
|
||||
|
||||
/obj/machinery/atmospherics/binary/volume_pump/hide(var/i)
|
||||
update_underlays()
|
||||
|
||||
/obj/machinery/atmospherics/binary/volume_pump/process()
|
||||
// ..()
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return
|
||||
if(!on)
|
||||
return 0
|
||||
|
||||
// Pump mechanism just won't do anything if the pressure is too high/too low
|
||||
|
||||
var/input_starting_pressure = air1.return_pressure()
|
||||
var/output_starting_pressure = air2.return_pressure()
|
||||
|
||||
if((input_starting_pressure < 0.01) || (output_starting_pressure > 9000))
|
||||
return 1
|
||||
|
||||
var/transfer_ratio = max(1, transfer_rate/air1.volume)
|
||||
|
||||
var/datum/gas_mixture/removed = air1.remove_ratio(transfer_ratio)
|
||||
|
||||
air2.merge(removed)
|
||||
|
||||
if(network1)
|
||||
network1.update = 1
|
||||
|
||||
if(network2)
|
||||
network2.update = 1
|
||||
|
||||
return 1
|
||||
|
||||
/obj/machinery/atmospherics/binary/volume_pump/proc/set_frequency(new_frequency)
|
||||
radio_controller.remove_object(src, frequency)
|
||||
frequency = new_frequency
|
||||
if(frequency)
|
||||
radio_connection = radio_controller.add_object(src, frequency)
|
||||
|
||||
/obj/machinery/atmospherics/binary/volume_pump/proc/broadcast_status()
|
||||
if(!radio_connection)
|
||||
return 0
|
||||
|
||||
var/datum/signal/signal = new
|
||||
signal.transmission_method = 1 //radio signal
|
||||
signal.source = src
|
||||
|
||||
signal.data = list(
|
||||
"tag" = id,
|
||||
"device" = "APV",
|
||||
"power" = on,
|
||||
"transfer_rate" = transfer_rate,
|
||||
"sigtype" = "status"
|
||||
)
|
||||
radio_connection.post_signal(src, signal)
|
||||
|
||||
return 1
|
||||
|
||||
/obj/machinery/atmospherics/binary/volume_pump/interact(mob/user as mob)
|
||||
var/dat = {"<b>Power: </b><a href='?src=\ref[src];power=1'>[on?"On":"Off"]</a><br>
|
||||
<b>Desirable output flow: </b>
|
||||
[round(transfer_rate,1)]l/s | <a href='?src=\ref[src];set_transfer_rate=1'>Change</a>
|
||||
"}
|
||||
|
||||
user << browse("<HEAD><TITLE>[src.name] control</TITLE></HEAD><TT>[dat]</TT>", "window=atmo_pump")
|
||||
onclose(user, "atmo_pump")
|
||||
|
||||
/obj/machinery/atmospherics/binary/volume_pump/initialize()
|
||||
..()
|
||||
set_frequency(frequency)
|
||||
|
||||
/obj/machinery/atmospherics/binary/volume_pump/receive_signal(datum/signal/signal)
|
||||
if(!signal.data["tag"] || (signal.data["tag"] != id) || (signal.data["sigtype"]!="command"))
|
||||
return 0
|
||||
|
||||
if(signal.data["power"])
|
||||
on = text2num(signal.data["power"])
|
||||
|
||||
if(signal.data["power_toggle"])
|
||||
on = !on
|
||||
|
||||
if(signal.data["set_transfer_rate"])
|
||||
transfer_rate = between(
|
||||
0,
|
||||
text2num(signal.data["set_transfer_rate"]),
|
||||
air1.volume
|
||||
)
|
||||
|
||||
if(signal.data["status"])
|
||||
spawn(2)
|
||||
broadcast_status()
|
||||
return //do not update_icon
|
||||
|
||||
spawn(2)
|
||||
broadcast_status()
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/atmospherics/binary/volume_pump/attack_hand(user as mob)
|
||||
if(..())
|
||||
return
|
||||
src.add_fingerprint(usr)
|
||||
if(!src.allowed(user))
|
||||
user << "\red Access denied."
|
||||
return
|
||||
usr.set_machine(src)
|
||||
interact(user)
|
||||
return
|
||||
|
||||
/obj/machinery/atmospherics/binary/volume_pump/Topic(href,href_list)
|
||||
if(..()) return
|
||||
if(href_list["power"])
|
||||
on = !on
|
||||
if(href_list["set_transfer_rate"])
|
||||
var/new_transfer_rate = input(usr,"Enter new output volume (0-200l/s)","Flow control",src.transfer_rate) as num
|
||||
src.transfer_rate = max(0, min(200, new_transfer_rate))
|
||||
usr.set_machine(src)
|
||||
src.update_icon()
|
||||
src.updateUsrDialog()
|
||||
return
|
||||
|
||||
/obj/machinery/atmospherics/binary/volume_pump/power_change()
|
||||
var/old_stat = stat
|
||||
..()
|
||||
if(old_stat != stat)
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/atmospherics/binary/volume_pump/attackby(var/obj/item/weapon/W as obj, var/mob/user as mob)
|
||||
if (!istype(W, /obj/item/weapon/wrench))
|
||||
return ..()
|
||||
if (!(stat & NOPOWER) && on)
|
||||
user << "\red You cannot unwrench this [src], turn it off first."
|
||||
return 1
|
||||
var/datum/gas_mixture/int_air = return_air()
|
||||
var/datum/gas_mixture/env_air = loc.return_air()
|
||||
if ((int_air.return_pressure()-env_air.return_pressure()) > 2*ONE_ATMOSPHERE)
|
||||
user << "\red You cannot unwrench this [src], it too exerted due to internal pressure."
|
||||
add_fingerprint(user)
|
||||
return 1
|
||||
playsound(src.loc, 'sound/items/Ratchet.ogg', 50, 1)
|
||||
user << "\blue You begin to unfasten \the [src]..."
|
||||
if (do_after(user, 40))
|
||||
user.visible_message( \
|
||||
"[user] unfastens \the [src].", \
|
||||
"\blue You have unfastened \the [src].", \
|
||||
"You hear ratchet.")
|
||||
new /obj/item/pipe(loc, make_from=src)
|
||||
del(src)
|
||||
icon_state = "[on ? "on" : "off"]"
|
||||
Reference in New Issue
Block a user