From ee56453ca3c24980993d48d399836183a1e22a78 Mon Sep 17 00:00:00 2001 From: mwerezak Date: Sun, 7 Sep 2014 17:07:53 -0400 Subject: [PATCH] Allows heater/freezer construction dir to be set --- .../components/unary/cold_sink.dm | 26 +++++++-------- .../components/unary/heat_source.dm | 30 ++++++++--------- .../game/machinery/computer/buildandrepair.dm | 27 +++++++-------- code/game/machinery/computer/computer.dm | 2 +- code/game/machinery/constructable_frame.dm | 33 ++++++++++++++++--- code/game/machinery/pipe/construction.dm | 1 + code/modules/power/power_monitor.dm | 6 ++-- 7 files changed, 76 insertions(+), 49 deletions(-) diff --git a/code/ATMOSPHERICS/components/unary/cold_sink.dm b/code/ATMOSPHERICS/components/unary/cold_sink.dm index 2998e87a039..24cb7f72df0 100644 --- a/code/ATMOSPHERICS/components/unary/cold_sink.dm +++ b/code/ATMOSPHERICS/components/unary/cold_sink.dm @@ -9,12 +9,12 @@ var/heatsink_temperature = T20C //the constant temperature resevoir into which the freezer pumps heat. Probably the hull of the station or something. var/internal_volume = 600 //L - + var/on = 0 use_power = 0 idle_power_usage = 5 //5 Watts for thermostat related circuitry active_power_usage = 50000 //50 kW. The power rating of the freezer - + var/set_temperature = T20C //thermostat var/cooling = 0 var/opened = 0 //for deconstruction @@ -23,9 +23,9 @@ ..() air_contents.volume = internal_volume initialize_directions = dir - + component_parts = list() - component_parts += new /obj/item/weapon/circuitboard/gas_cooler(src) + component_parts += new /obj/item/weapon/circuitboard/unary_atmos/cooler(src) component_parts += new /obj/item/weapon/stock_parts/matter_bin(src) component_parts += new /obj/item/weapon/stock_parts/capacitor(src) component_parts += new /obj/item/weapon/stock_parts/capacitor(src) @@ -72,7 +72,7 @@ data["minGasTemperature"] = 0 data["maxGasTemperature"] = round(T20C+500) data["targetGasTemperature"] = round(set_temperature) - + var/temp_class = "good" if (air_contents.temperature > (T0C - 20)) temp_class = "bad" @@ -115,11 +115,11 @@ update_use_power(0) update_icon() return - + if (network && air_contents.temperature > set_temperature) cooling = 1 update_use_power(2) - + var/heat_transfer = max( -air_contents.get_thermal_energy_change(set_temperature - 5), 0 ) //Assume the heat is being pumped into the hull which is fixed at heatsink_temperature @@ -130,16 +130,16 @@ var/removed = -air_contents.add_thermal_energy(-heat_transfer) //remove the heat if (debug) visible_message("[src]: Removing [removed] W.") - + network.update = 1 else cooling = 0 update_use_power(1) - + update_icon() //upgrading parts -/obj/machinery/atmospherics/unary/freezer/RefreshParts() +/obj/machinery/atmospherics/unary/freezer/RefreshParts() ..() var/cap_rating = 0 var/cap_count = 0 @@ -147,7 +147,7 @@ var/manip_count = 0 var/bin_rating = 0 var/bin_count = 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 @@ -161,7 +161,7 @@ cap_rating /= cap_count bin_rating /= bin_count manip_rating /= manip_count - + active_power_usage = initial(active_power_usage)*cap_rating //more powerful heatsink_temperature = initial(heatsink_temperature)/((manip_rating+bin_rating)/2) //more efficient air_contents.volume = max(initial(internal_volume) - 200, 0) + 200*bin_rating @@ -176,7 +176,7 @@ if (opened && istype(O, /obj/item/weapon/crowbar)) dismantle() return - + ..() /obj/machinery/atmospherics/unary/freezer/examine() diff --git a/code/ATMOSPHERICS/components/unary/heat_source.dm b/code/ATMOSPHERICS/components/unary/heat_source.dm index ab474a31367..26481ff539b 100644 --- a/code/ATMOSPHERICS/components/unary/heat_source.dm +++ b/code/ATMOSPHERICS/components/unary/heat_source.dm @@ -15,7 +15,7 @@ use_power = 0 idle_power_usage = 5 //5 Watts for thermostat related circuitry active_power_usage = 50000 //50 kW. The power rating of the heater - + var/heating = 0 //mainly for icon updates var/opened = 0 //for deconstruction @@ -23,9 +23,9 @@ ..() air_contents.volume = internal_volume initialize_directions = dir - + component_parts = list() - component_parts += new /obj/item/weapon/circuitboard/gas_heater(src) + component_parts += new /obj/item/weapon/circuitboard/unary_atmos/heater(src) component_parts += new /obj/item/weapon/stock_parts/matter_bin(src) component_parts += new /obj/item/weapon/stock_parts/capacitor(src) component_parts += new /obj/item/weapon/stock_parts/capacitor(src) @@ -52,27 +52,27 @@ else icon_state = "heater_0" return - + /obj/machinery/atmospherics/unary/heater/process() ..() - + if(stat & (NOPOWER|BROKEN) || !on) heating = 0 update_use_power(0) update_icon() return - + if (network && air_contents.total_moles && air_contents.temperature < set_temperature) update_use_power(2) air_contents.add_thermal_energy(active_power_usage) - + heating = 1 network.update = 1 else heating = 0 update_use_power(1) - + update_icon() /obj/machinery/atmospherics/unary/heater/attack_ai(mob/user as mob) @@ -83,7 +83,7 @@ /obj/machinery/atmospherics/unary/heater/attack_hand(mob/user as mob) src.ui_interact(user) - + /obj/machinery/atmospherics/unary/heater/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) // this is the data which will be sent to the ui var/data[0] @@ -93,7 +93,7 @@ data["minGasTemperature"] = 0 data["maxGasTemperature"] = round(max_temperature) data["targetGasTemperature"] = round(set_temperature) - + var/temp_class = "normal" if (air_contents.temperature > (T20C+40)) temp_class = "bad" @@ -123,14 +123,14 @@ src.set_temperature = min(src.set_temperature+amount, max_temperature) else src.set_temperature = max(src.set_temperature+amount, 0) - + src.add_fingerprint(usr) return 1 //upgrading parts -/obj/machinery/atmospherics/unary/heater/RefreshParts() +/obj/machinery/atmospherics/unary/heater/RefreshParts() ..() - + var/cap_rating = 0 var/cap_count = 0 var/bin_rating = 0 @@ -144,7 +144,7 @@ bin_count++ cap_rating /= cap_count bin_rating /= bin_count - + active_power_usage = initial(active_power_usage)*cap_rating max_temperature = max(initial(max_temperature) - T20C, 0)*((bin_rating*2 + cap_rating)/3) + T20C air_contents.volume = max(initial(internal_volume) - 200, 0) + 200*bin_rating @@ -159,7 +159,7 @@ if (opened && istype(O, /obj/item/weapon/crowbar)) dismantle() return - + ..() /obj/machinery/atmospherics/unary/heater/examine() diff --git a/code/game/machinery/computer/buildandrepair.dm b/code/game/machinery/computer/buildandrepair.dm index 222f6d63c98..7a115b8810c 100644 --- a/code/game/machinery/computer/buildandrepair.dm +++ b/code/game/machinery/computer/buildandrepair.dm @@ -25,15 +25,16 @@ var/frame_desc = null var/contain_parts = 1 -//Called when the circuitboard is used to contruct a new computer. -/obj/item/weapon/circuitboard/proc/construct_computer(var/obj/machinery/computer/C) - if (istype(C, build_path)) +//Called when the circuitboard is used to contruct a new machine. +/obj/item/weapon/circuitboard/proc/construct(var/obj/machinery/M) + if (istype(M, build_path)) return 1 return 0 -//Called when a computer is deconstructed to produce a circuitboard -/obj/item/weapon/circuitboard/proc/deconstruct_computer(var/obj/machinery/computer/C) - if (istype(C, build_path)) +//Called when a computer is deconstructed to produce a circuitboard. +//Only used by computers, as other machines store their circuitboard instance. +/obj/item/weapon/circuitboard/proc/deconstruct(var/obj/machinery/M) + if (istype(M, build_path)) return 1 return 0 @@ -55,11 +56,11 @@ var/locked = 1 var/emagged = 0 -/obj/item/weapon/circuitboard/security/construct_computer(var/obj/machinery/computer/security/C) +/obj/item/weapon/circuitboard/security/construct(var/obj/machinery/computer/security/C) if (..(C)) C.network = network -/obj/item/weapon/circuitboard/security/deconstruct_computer(var/obj/machinery/computer/security/C) +/obj/item/weapon/circuitboard/security/deconstruct(var/obj/machinery/computer/security/C) if (..(C)) network = C.network @@ -141,11 +142,11 @@ name = "Circuit board (Injector Control)" build_path = "/obj/machinery/computer/general_air_control/fuel_injection" -/obj/item/weapon/circuitboard/air_management/construct_computer(var/obj/machinery/computer/general_air_control/C) +/obj/item/weapon/circuitboard/air_management/construct(var/obj/machinery/computer/general_air_control/C) if (..(C)) C.frequency = frequency -/obj/item/weapon/circuitboard/air_management/deconstruct_computer(var/obj/machinery/computer/general_air_control/C) +/obj/item/weapon/circuitboard/air_management/deconstruct(var/obj/machinery/computer/general_air_control/C) if (..(C)) frequency = C.frequency @@ -221,11 +222,11 @@ origin_tech = "programming=3" var/contraband_enabled = 0 -/obj/item/weapon/circuitboard/supplycomp/construct_computer(var/obj/machinery/computer/supplycomp/SC) +/obj/item/weapon/circuitboard/supplycomp/construct(var/obj/machinery/computer/supplycomp/SC) if (..(SC)) SC.can_order_contraband = contraband_enabled -/obj/item/weapon/circuitboard/supplycomp/deconstruct_computer(var/obj/machinery/computer/supplycomp/SC) +/obj/item/weapon/circuitboard/supplycomp/deconstruct(var/obj/machinery/computer/supplycomp/SC) if (..(SC)) contraband_enabled = SC.can_order_contraband @@ -446,5 +447,5 @@ playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) user << "\blue You connect the monitor." var/B = new src.circuit.build_path ( src.loc ) - src.circuit.construct_computer(B) + src.circuit.construct(B) del(src) \ No newline at end of file diff --git a/code/game/machinery/computer/computer.dm b/code/game/machinery/computer/computer.dm index 23e764efe4f..ff88f89c5a2 100644 --- a/code/game/machinery/computer/computer.dm +++ b/code/game/machinery/computer/computer.dm @@ -120,7 +120,7 @@ user << "\blue You disconnect the monitor." A.state = 4 A.icon_state = "4" - M.deconstruct_computer(src) + M.deconstruct(src) del(src) else src.attack_hand(user) diff --git a/code/game/machinery/constructable_frame.dm b/code/game/machinery/constructable_frame.dm index 7e7fcc5a59c..0acf4100f4f 100644 --- a/code/game/machinery/constructable_frame.dm +++ b/code/game/machinery/constructable_frame.dm @@ -115,6 +115,7 @@ playsound(src.loc, 'sound/items/Screwdriver.ogg', 50, 1) var/obj/machinery/new_machine = new src.circuit.build_path(src.loc) new_machine.component_parts.Cut() + src.circuit.construct(new_machine) for(var/obj/O in src) if(circuit.contain_parts) // things like disposal don't want their parts in them O.loc = new_machine @@ -275,10 +276,35 @@ obj/item/weapon/circuitboard/rdserver "/obj/item/weapon/stock_parts/console_screen" = 1, "/obj/item/weapon/cable_coil" = 2,) -/obj/item/weapon/circuitboard/gas_heater +/obj/item/weapon/circuitboard/unary_atmos + board_type = "machine" + var/machine_dir = SOUTH + var/init_dirs = SOUTH + +/obj/item/weapon/circuitboard/unary_atmos/attackby(obj/item/I as obj, mob/user as mob) + if(istype(I,/obj/item/weapon/screwdriver)) + machine_dir = turn(machine_dir, 90) + init_dirs = machine_dir + user.visible_message("\blue \The [user] adjusts the jumper on the [src]'s port configuration pins.", "\blue You adjust the jumper on the port configuration pins. Now set to [dir2text(machine_dir)].") + return + +/obj/item/weapon/circuitboard/unary_atmos/examine() + ..() + usr << "The jumper is connecting the [dir2text(machine_dir)] pins." + +/obj/item/weapon/circuitboard/unary_atmos/construct(var/obj/machinery/atmospherics/unary/U) + //TODO: Move this stuff into the relevant constructor when pipe/construction.dm is cleaned up. + U.dir = src.machine_dir + U.initialize_directions = src.init_dirs + U.initialize() + U.build_network() + if (U.node) + U.node.initialize() + U.node.build_network() + +/obj/item/weapon/circuitboard/unary_atmos/heater name = "Circuit Board (Gas Heating System)" build_path = "/obj/machinery/atmospherics/unary/heater" - board_type = "machine" origin_tech = "powerstorage=2;engineering=1" frame_desc = "Requires 5 Pieces of Cable, 1 Matter Bin, and 2 Capacitors." req_components = list( @@ -286,10 +312,9 @@ obj/item/weapon/circuitboard/rdserver "/obj/item/weapon/stock_parts/matter_bin" = 1, "/obj/item/weapon/stock_parts/capacitor" = 2) -/obj/item/weapon/circuitboard/gas_cooler +/obj/item/weapon/circuitboard/unary_atmos/cooler name = "Circuit Board (Gas Cooling System)" build_path = "/obj/machinery/atmospherics/unary/freezer" - board_type = "machine" origin_tech = "magnets=2;engineering=2" frame_desc = "Requires 2 Pieces of Cable, 1 Matter Bin, 1 Micro Manipulator, and 2 Capacitors." req_components = list( diff --git a/code/game/machinery/pipe/construction.dm b/code/game/machinery/pipe/construction.dm index 7177c468447..0a5c83648dd 100644 --- a/code/game/machinery/pipe/construction.dm +++ b/code/game/machinery/pipe/construction.dm @@ -326,6 +326,7 @@ Buildable meters var/pipefailtext = "\red There's nothing to connect this pipe section to!" //(with how the pipe code works, at least one end needs to be connected to something, otherwise the game deletes the segment)" + //TODO: Move all of this stuff into the various pipe constructors. switch(pipe_type) if(PIPE_SIMPLE_STRAIGHT, PIPE_SIMPLE_BENT) var/obj/machinery/atmospherics/pipe/simple/P = new( src.loc ) diff --git a/code/modules/power/power_monitor.dm b/code/modules/power/power_monitor.dm index bd6d8529422..e1920471a3c 100644 --- a/code/modules/power/power_monitor.dm +++ b/code/modules/power/power_monitor.dm @@ -5,7 +5,7 @@ desc = "It monitors power levels across the station." icon = 'icons/obj/computer.dmi' icon_state = "power" - + //computer stuff density = 1 anchored = 1.0 @@ -107,7 +107,7 @@ src.icon_state = "c_unpowered" else icon_state = initial(icon_state) - + //copied from computer.dm /obj/machinery/power/monitor/attackby(I as obj, user as mob) @@ -129,7 +129,7 @@ user << "\blue You disconnect the monitor." A.state = 4 A.icon_state = "4" - M.deconstruct_computer(src) + M.deconstruct(src) del(src) else src.attack_hand(user)