Skip to content

Commit

Permalink
Gas injectors are now buildable (tgstation#26474)
Browse files Browse the repository at this point in the history
* Injectors are now constructable and deconstructable

* Gives injectors TG UI, fixes a bug with MAX button not working for volumetric pumps
  • Loading branch information
Core0verload authored and duncathan committed Apr 26, 2017
1 parent c8073a7 commit 0fd0c99
Show file tree
Hide file tree
Showing 15 changed files with 79 additions and 17 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/pipe_construction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Construction breaks otherwise
#define PIPE_CONNECTOR /obj/machinery/atmospherics/components/unary/portables_connector
#define PIPE_UVENT /obj/machinery/atmospherics/components/unary/vent_pump
#define PIPE_SCRUBBER /obj/machinery/atmospherics/components/unary/vent_scrubber
#define PIPE_INJECTOR /obj/machinery/atmospherics/components/unary/outlet_injector
#define PIPE_HEAT_EXCHANGE /obj/machinery/atmospherics/components/unary/heat_exchanger
//Binary
#define PIPE_PUMP /obj/machinery/atmospherics/components/binary/pump
Expand Down
3 changes: 3 additions & 0 deletions code/game/machinery/pipe/construction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Buildable meters
PIPE_CONNECTOR, \
PIPE_UVENT, \
PIPE_SCRUBBER, \
PIPE_INJECTOR, \
PIPE_HEAT_EXCHANGE, \
\
PIPE_PUMP, \
Expand Down Expand Up @@ -93,6 +94,7 @@ GLOBAL_LIST_INIT(pipeID2State, list(
"[PIPE_CONNECTOR]" = "connector", \
"[PIPE_UVENT]" = "uvent", \
"[PIPE_SCRUBBER]" = "scrubber", \
"[PIPE_INJECTOR]" = "injector", \
"[PIPE_HEAT_EXCHANGE]" = "heunary", \
\
"[PIPE_PUMP]" = "pump", \
Expand Down Expand Up @@ -120,6 +122,7 @@ GLOBAL_LIST_INIT(pipeID2State, list(
"[PIPE_CONNECTOR]" = "connector", \
"[PIPE_UVENT]" = "vent", \
"[PIPE_SCRUBBER]" = "scrubber", \
"[PIPE_INJECTOR]" = "injector", \
"[PIPE_HEAT_EXCHANGE]" = "heat exchanger", \
\
"[PIPE_PUMP]" = "pump", \
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/weapons/RPD.dm
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ GLOBAL_LIST_INIT(RPD_recipes, list(
"Passive Gate" = new /datum/pipe_info(PIPE_PASSIVE_GATE, 1, PIPE_UNARY),
"Volume Pump" = new /datum/pipe_info(PIPE_VOLUME_PUMP, 1, PIPE_UNARY),
"Scrubber" = new /datum/pipe_info(PIPE_SCRUBBER, 1, PIPE_UNARY),
"Injector" = new /datum/pipe_info(PIPE_INJECTOR, 1, PIPE_UNARY),
"Meter" = new /datum/pipe_info/meter(),
"Gas Filter" = new /datum/pipe_info(PIPE_GAS_FILTER, 1, PIPE_TRIN_M),
"Gas Mixer" = new /datum/pipe_info(PIPE_GAS_MIXER, 1, PIPE_TRIN_M),
// "Injector" = new /datum/pipe_info(PIPE_INJECTOR, 1, PIPE_UNARY),
),
"Heat Exchange" = list(
"Pipe" = new /datum/pipe_info(PIPE_HE, 1, PIPE_BENDABLE),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Passive gate is similar to the regular pump except:
/obj/machinery/atmospherics/components/binary/passive_gate/can_unwrench(mob/user)
if(..())
if(on)
to_chat(user, "<span class='warning'>You cannot unwrench this [src], turn it off first!</span>")
to_chat(user, "<span class='warning'>You cannot unwrench [src], turn it off first!</span>")
else
return 1

Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Thus, the two variables affect pump operation are set in New():
/obj/machinery/atmospherics/components/binary/pump/can_unwrench(mob/user)
if(..())
if(!(stat & NOPOWER) && on)
to_chat(user, "<span class='warning'>You cannot unwrench this [src], turn it off first!</span>")
to_chat(user, "<span class='warning'>You cannot unwrench [src], turn it off first!</span>")
else
return 1

Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Thus, the two variables affect pump operation are set in New():
/obj/machinery/atmospherics/components/binary/volume_pump/can_unwrench(mob/user)
if(..())
if(!(stat & NOPOWER) && on)
to_chat(user, "<span class='warning'>You cannot unwrench this [src], turn it off first!</span>")
to_chat(user, "<span class='warning'>You cannot unwrench [src], turn it off first!</span>")
else
return 1

Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/obj/machinery/atmospherics/components/unary/outlet_injector
icon_state = "inje_map"
use_power = 1

name = "air injector"
desc = "Has a valve and pump attached to it"
icon_state = "inje_map"
use_power = 1
can_unwrench = TRUE
resistance_flags = FIRE_PROOF | UNACIDABLE | ACID_PROOF //really helpful in building gas chambers for xenomorphs

var/on = 0
var/injecting = 0
Expand All @@ -22,9 +23,13 @@
return ..()

/obj/machinery/atmospherics/components/unary/outlet_injector/on
on = 1
on = TRUE

/obj/machinery/atmospherics/components/unary/outlet_injector/update_icon_nopipes()
cut_overlays()
if(showpipe)
add_overlay(getpipeimage(icon, "inje_cap", initialize_directions))

if(!NODE1 || !on || stat & (NOPOWER|BROKEN))
icon_state = "inje_off"
return
Expand All @@ -42,7 +47,7 @@
..()
injecting = 0

if(!on || stat & NOPOWER)
if(!on || stat & (NOPOWER|BROKEN))
return 0

var/datum/gas_mixture/air_contents = AIR1
Expand All @@ -60,7 +65,7 @@
return 1

/obj/machinery/atmospherics/components/unary/outlet_injector/proc/inject()
if(on || injecting)
if(on || injecting || stat & (NOPOWER|BROKEN))
return 0

var/datum/gas_mixture/air_contents = AIR1
Expand Down Expand Up @@ -139,3 +144,53 @@
spawn(2)
broadcast_status()
update_icon()


/obj/machinery/atmospherics/components/unary/outlet_injector/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, \
datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "atmos_pump", name, 310, 115, master_ui, state)
ui.open()

/obj/machinery/atmospherics/components/unary/outlet_injector/ui_data()
var/data = list()
data["on"] = on
data["rate"] = round(volume_rate)
data["max_rate"] = round(MAX_TRANSFER_RATE)
return data

/obj/machinery/atmospherics/components/unary/outlet_injector/ui_act(action, params)
if(..())
return

switch(action)
if("power")
on = !on
investigate_log("was turned [on ? "on" : "off"] by [key_name(usr)]", "atmos")
. = TRUE
if("rate")
var/rate = params["rate"]
if(rate == "max")
rate = MAX_TRANSFER_RATE
. = TRUE
else if(rate == "input")
rate = input("New transfer rate (0-[MAX_TRANSFER_RATE] L/s):", name, volume_rate) as num|null
if(!isnull(rate) && !..())
. = TRUE
else if(text2num(rate) != null)
rate = text2num(rate)
. = TRUE
if(.)
volume_rate = Clamp(rate, 0, MAX_TRANSFER_RATE)
investigate_log("was set to [volume_rate] L/s by [key_name(usr)]", "atmos")
update_icon()
broadcast_status()

/obj/machinery/atmospherics/components/unary/outlet_injector/can_unwrench(mob/user)
if(..())
if (!(stat & NOPOWER|BROKEN) && on)
to_chat(user, "<span class='warning'>You cannot unwrench [src], turn it off first!</span>")
else
return 1

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
/obj/machinery/atmospherics/components/unary/portables_connector/can_unwrench(mob/user)
if(..())
if(connected_device)
to_chat(user, "<span class='warning'>You cannot unwrench this [src], detach [connected_device] first!</span>")
to_chat(user, "<span class='warning'>You cannot unwrench [src], detach [connected_device] first!</span>")
else
return 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
/*
Iconnery
*/
/obj/machinery/atmospherics/components/unary/on_construction()
..()
update_icon()

/obj/machinery/atmospherics/components/unary/hide(intact)
update_icon()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
/obj/machinery/atmospherics/components/unary/vent_pump/update_icon_nopipes()
cut_overlays()
if(showpipe)
add_overlay(getpipeimage('icons/obj/atmospherics/components/unary_devices.dmi', "vent_cap", initialize_directions))
add_overlay(getpipeimage(icon, "vent_cap", initialize_directions))

if(welded)
icon_state = "vent_welded"
Expand Down Expand Up @@ -268,7 +268,7 @@
/obj/machinery/atmospherics/components/unary/vent_pump/can_unwrench(mob/user)
if(..())
if(!(stat & NOPOWER) && on)
to_chat(user, "<span class='warning'>You cannot unwrench this [src], turn it off first!</span>")
to_chat(user, "<span class='warning'>You cannot unwrench [src], turn it off first!</span>")
else
return 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
/obj/machinery/atmospherics/components/unary/vent_scrubber/update_icon_nopipes()
cut_overlays()
if(showpipe)
add_overlay(getpipeimage('icons/obj/atmospherics/components/unary_devices.dmi', "scrub_cap", initialize_directions))
add_overlay(getpipeimage(icon, "scrub_cap", initialize_directions))

if(welded)
icon_state = "scrub_welded"
Expand Down Expand Up @@ -361,7 +361,7 @@
/obj/machinery/atmospherics/components/unary/vent_scrubber/can_unwrench(mob/user)
if(..())
if (!(stat & NOPOWER) && on)
to_chat(user, "<span class='warning'>You cannot unwrench this [src], turn it off first!</span>")
to_chat(user, "<span class='warning'>You cannot unwrench [src], turn it off first!</span>")
else
return 1

Expand Down
Binary file modified icons/obj/atmospherics/components/unary_devices.dmi
Binary file not shown.
Binary file modified icons/obj/atmospherics/pipes/pipe_item.dmi
Binary file not shown.
2 changes: 1 addition & 1 deletion tgui/assets/tgui.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tgui/src/interfaces/atmos_pump.ract
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{{#if data.max_rate}}
<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='transfer' params='{"rate": "max"}'>Max</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>
{{else}}
Expand Down

0 comments on commit 0fd0c99

Please sign in to comment.