mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Oxygen Generator improvements
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
circuit = /obj/item/weapon/circuitboard/algae_farm
|
||||
anchored = 1
|
||||
density = 1
|
||||
power_channel = EQUIP
|
||||
use_power = 2
|
||||
idle_power_usage = 100 // Minimal lights to keep algae alive
|
||||
active_power_usage = 5000 // Powerful grow lights to stimulate oxygen production
|
||||
@@ -37,7 +38,7 @@
|
||||
desc = initial(desc) + " Its outlet port is to the [dir2text(dir)]."
|
||||
default_apply_parts()
|
||||
update_icon()
|
||||
// TODO - Make these in acutal icon states so its not silly like this
|
||||
// TODO - Make these in actual icon states so its not silly like this
|
||||
var/image/I = image(icon = icon, icon_state = "algae-pipe-overlay", dir = dir)
|
||||
I.color = PIPE_COLOR_BLUE
|
||||
overlays += I
|
||||
@@ -54,18 +55,28 @@
|
||||
recent_moles_transferred = 0
|
||||
|
||||
if(inoperable() || use_power < 2)
|
||||
ui_error = null
|
||||
if(use_power == 1)
|
||||
last_power_draw = idle_power_usage
|
||||
else
|
||||
last_power_draw = 0
|
||||
update_icon()
|
||||
return 0
|
||||
|
||||
last_power_draw = active_power_usage
|
||||
|
||||
// STEP 1 - Check material resources
|
||||
if(stored_material[MATERIAL_ALGAE] < algae_per_mole)
|
||||
ui_error = "Insufficient [material_display_name(MATERIAL_ALGAE)] to process."
|
||||
update_icon()
|
||||
return
|
||||
if(stored_material[MATERIAL_CARBON] + carbon_per_mole > storage_capacity[MATERIAL_CARBON])
|
||||
ui_error = "[material_display_name(MATERIAL_CARBON)] output storage is full."
|
||||
update_icon()
|
||||
return
|
||||
var/moles_to_convert = min(moles_per_tick,\
|
||||
stored_material[MATERIAL_ALGAE] * algae_per_mole,\
|
||||
storage_capacity[MATERIAL_CARBON] - stored_material[MATERIAL_CARBON] * carbon_per_mole)
|
||||
storage_capacity[MATERIAL_CARBON] - stored_material[MATERIAL_CARBON])
|
||||
|
||||
// STEP 2 - Take the CO2 out of the input!
|
||||
var/power_draw = scrub_gas(src, list(input_gas), air1, internal, moles_to_convert)
|
||||
@@ -79,6 +90,7 @@
|
||||
var/co2_moles = internal.gas[input_gas]
|
||||
if(co2_moles < MINIMUM_MOLES_TO_FILTER)
|
||||
ui_error = "Insufficient [gas_data.name[input_gas]] to process."
|
||||
update_icon()
|
||||
return
|
||||
|
||||
// STEP 4 - Consume the resources
|
||||
@@ -98,7 +110,7 @@
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/atmospherics/binary/algae_farm/update_icon()
|
||||
if(inoperable() || !anchored)
|
||||
if(inoperable() || !anchored || use_power < 2)
|
||||
icon_state = "algae-off"
|
||||
else if(recent_moles_transferred >= moles_per_tick)
|
||||
icon_state = "algae-full"
|
||||
@@ -109,21 +121,47 @@
|
||||
return 1
|
||||
|
||||
/obj/machinery/atmospherics/binary/algae_farm/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
||||
src.add_fingerprint(user)
|
||||
add_fingerprint(user)
|
||||
if(default_deconstruction_screwdriver(user, W))
|
||||
return
|
||||
if(default_deconstruction_crowbar(user, W))
|
||||
return
|
||||
if(default_part_replacement(user, W))
|
||||
return
|
||||
if(try_load_materials(user, W))
|
||||
return
|
||||
else
|
||||
user << "<span class='notice'>You cannot insert this item into \the [src]!</span>"
|
||||
to_chat(user, "<span class='notice'>You cannot insert this item into \the [src]!</span>")
|
||||
return
|
||||
|
||||
/obj/machinery/atmospherics/binary/algae_farm/attack_hand(mob/user)
|
||||
if(..()) return 1
|
||||
if(..())
|
||||
return 1
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/atmospherics/binary/algae_farm/RefreshParts()
|
||||
..()
|
||||
|
||||
var/cap_rating = 0
|
||||
var/bin_rating = 0
|
||||
var/manip_rating = 0
|
||||
|
||||
for(var/obj/item/weapon/stock_parts/P in component_parts)
|
||||
if(istype(P, /obj/item/weapon/stock_parts/capacitor))
|
||||
cap_rating += P.rating
|
||||
if(istype(P, /obj/item/weapon/stock_parts/matter_bin))
|
||||
bin_rating += P.rating
|
||||
if(istype(P, /obj/item/weapon/stock_parts/manipulator))
|
||||
manip_rating += P.rating
|
||||
|
||||
power_per_mole = round(initial(power_per_mole) / cap_rating)
|
||||
|
||||
var/storage = 5000 * (bin_rating**2)/2
|
||||
for(var/mat in storage_capacity)
|
||||
storage_capacity[mat] = storage
|
||||
|
||||
moles_per_tick = initial(moles_per_tick) + (manip_rating**2 - 1)
|
||||
|
||||
/obj/machinery/atmospherics/binary/algae_farm/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/nano_ui/master_ui = null, var/datum/topic_state/state = default_state)
|
||||
var/data[0]
|
||||
data["panelOpen"] = panel_open
|
||||
@@ -217,7 +255,7 @@
|
||||
if(!istype(S))
|
||||
return 0
|
||||
if(!(S.material.name in stored_material))
|
||||
user << "<span class='warning'>\The [src] doesn't accept [material_display_name(S.material)]!</span>"
|
||||
to_chat(user, "<span class='warning'>\The [src] doesn't accept [material_display_name(S.material)]!</span>")
|
||||
return 1
|
||||
var/max_res_amount = storage_capacity[S.material.name]
|
||||
if(stored_material[S.material.name] + S.perunit <= max_res_amount)
|
||||
@@ -229,7 +267,7 @@
|
||||
user.visible_message("\The [user] inserts [S.name] into \the [src].", "<span class='notice'>You insert [count] [S.name] into \the [src].</span>")
|
||||
updateUsrDialog()
|
||||
else
|
||||
user << "<span class='warning'>\The [src] cannot hold more [S.name].</span>"
|
||||
to_chat(user, "<span class='warning'>\The [src] cannot hold more [S.name].</span>")
|
||||
return 1
|
||||
|
||||
/material/algae
|
||||
@@ -248,6 +286,9 @@
|
||||
color = "#557722"
|
||||
default_type = MATERIAL_ALGAE
|
||||
|
||||
/obj/item/stack/material/algae/ten
|
||||
amount = 10
|
||||
|
||||
/material/carbon
|
||||
name = MATERIAL_CARBON
|
||||
stack_type = /obj/item/stack/material/carbon
|
||||
|
||||
Reference in New Issue
Block a user