Files
CHOMPStation2/code/ATMOSPHERICS/components/binary_devices/volume_pump.dm
Loganbacca 0dd2397ef7 Atmos update tweaks
- Updated pump and volume pump icons
- Reverted air scrubber icon
- Fixed passive gate icon
- Updated pipe_item sprites
- Fixed an oversight in the pipe color check
- Cleaned up the map
2014-07-16 21:37:43 +12:00

194 lines
5.4 KiB
Plaintext

/*
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
icon = 'icons/atmos/volume_pump.dmi'
icon_state = "map_off"
level = 1
name = "Volumetric gas pump"
desc = "A volumetric pump"
var/on = 0
var/transfer_rate = 200
var/frequency = 0
var/id = null
var/datum/radio_frequency/radio_connection
/obj/machinery/atmospherics/binary/volume_pump/on
on = 1
icon_state = "map_on"
/obj/machinery/atmospherics/binary/volume_pump/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)