mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
Yet Another Circuit Update (#5549)
* Circuit updates, adds new components, improves printer, new assemblies. * Finishes powernet circuit. * Adds wearable assemblies. * Finialization before merging with GLOB port. * Finishes circuit update, hopefully. * Forgot to undo map. * Removes debug output.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
origin_tech = list(TECH_POWER = 2, TECH_ENGINEERING = 2, TECH_DATA = 2)
|
||||
category_text = "Power - Passive"
|
||||
|
||||
/obj/item/integrated_circuit/passive/power/proc/make_energy()
|
||||
/obj/item/integrated_circuit/passive/power/proc/handle_passive_energy()
|
||||
return
|
||||
|
||||
// For calculators.
|
||||
@@ -20,7 +20,7 @@
|
||||
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
|
||||
var/max_power = 1
|
||||
|
||||
/obj/item/integrated_circuit/passive/power/solar_cell/make_energy()
|
||||
/obj/item/integrated_circuit/passive/power/solar_cell/handle_passive_energy()
|
||||
var/turf/T = get_turf(src)
|
||||
var/light_amount = T ? T.get_lumcount() : 0
|
||||
var/adjusted_power = max(max_power * light_amount, 0)
|
||||
@@ -39,7 +39,7 @@
|
||||
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
|
||||
var/is_charge=0
|
||||
|
||||
/obj/item/integrated_circuit/passive/power/starter/make_energy()
|
||||
/obj/item/integrated_circuit/passive/power/starter/handle_passive_energy()
|
||||
if(assembly.battery)
|
||||
if(assembly.battery.charge)
|
||||
if(!is_charge)
|
||||
@@ -67,7 +67,7 @@
|
||||
return FALSE // Robots and dead people don't have a metabolism.
|
||||
return TRUE
|
||||
|
||||
/obj/item/integrated_circuit/passive/power/metabolic_siphon/make_energy()
|
||||
/obj/item/integrated_circuit/passive/power/metabolic_siphon/handle_passive_energy()
|
||||
var/mob/living/carbon/human/host = null
|
||||
if(assembly && istype(assembly, /obj/item/device/electronic_assembly/implant))
|
||||
var/obj/item/device/electronic_assembly/implant/implant_assembly = assembly
|
||||
@@ -135,7 +135,7 @@
|
||||
set_pin_data(IC_OUTPUT, 1, reagents.total_volume)
|
||||
push_data()
|
||||
|
||||
/obj/item/integrated_circuit/passive/power/chemical_cell/make_energy()
|
||||
/obj/item/integrated_circuit/passive/power/chemical_cell/handle_passive_energy()
|
||||
if(assembly)
|
||||
for(var/I in fuel)
|
||||
if((assembly.battery.maxcharge-assembly.battery.charge) / CELLRATE > fuel[I])
|
||||
@@ -156,7 +156,7 @@
|
||||
spawn_flags = IC_SPAWN_RESEARCH
|
||||
power_amount = 2000
|
||||
|
||||
/obj/item/integrated_circuit/passive/power/relay/make_energy()
|
||||
/obj/item/integrated_circuit/passive/power/relay/handle_passive_energy()
|
||||
if(!assembly)
|
||||
return
|
||||
var/area/A = get_area(src)
|
||||
@@ -164,3 +164,78 @@
|
||||
if(A.powered(EQUIP) && assembly.give_power(power_amount))
|
||||
A.use_power(power_amount, EQUIP)
|
||||
// give_power() handles CELLRATE on its own.
|
||||
|
||||
// Interacts with the powernet.
|
||||
// Now you can make your own power generation (or poor man's powersink).
|
||||
|
||||
/obj/item/integrated_circuit/passive/power/powernet
|
||||
name = "power network interface"
|
||||
desc = "Gives or takes power from a wire underneath the machine."
|
||||
icon_state = "powernet"
|
||||
extended_desc = "The assembly must be anchored, with a wrench, and a wire node must be avaiable directly underneath.<br>\
|
||||
The first pin determines if power is moved at all. The second pin, if true, will draw from the powernet to charge the assembly's \
|
||||
cell, otherwise it will give power from the cell to the powernet."
|
||||
complexity = 20
|
||||
inputs = list(
|
||||
"active" = IC_PINTYPE_BOOLEAN,
|
||||
"draw power" = IC_PINTYPE_BOOLEAN
|
||||
)
|
||||
outputs = list(
|
||||
"power in grid" = IC_PINTYPE_NUMBER,
|
||||
"surplus power" = IC_PINTYPE_NUMBER,
|
||||
"load" = IC_PINTYPE_NUMBER
|
||||
)
|
||||
activators = list()
|
||||
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
|
||||
origin_tech = list(TECH_ENGINEERING = 2, TECH_POWER = 2)
|
||||
var/obj/machinery/power/circuit_io/IO = null // Dummy power machine to move energy in/out without a bunch of code duplication.
|
||||
var/throughput = 10000 // Give/take up to 10kW.
|
||||
|
||||
/obj/item/integrated_circuit/passive/power/powernet/initialize()
|
||||
IO = new(src)
|
||||
return ..()
|
||||
|
||||
/obj/item/integrated_circuit/passive/power/powernet/Destroy()
|
||||
qdel(IO)
|
||||
return ..()
|
||||
|
||||
/obj/item/integrated_circuit/passive/power/powernet/on_anchored()
|
||||
IO.connect_to_network()
|
||||
|
||||
/obj/item/integrated_circuit/passive/power/powernet/on_unanchored()
|
||||
IO.disconnect_from_network()
|
||||
|
||||
/obj/item/integrated_circuit/passive/power/powernet/handle_passive_energy()
|
||||
if(assembly && assembly.anchored && assembly.battery)
|
||||
var/should_act = get_pin_data(IC_INPUT, 1) // Even if this is false, we still need to update the output pins with powernet information.
|
||||
var/drawing = get_pin_data(IC_INPUT, 2)
|
||||
|
||||
if(should_act) // We're gonna give or take from the net.
|
||||
if(drawing)
|
||||
var/to_transfer = min(throughput, assembly.battery.amount_missing() / CELLRATE) // So we don't need to draw 10kW if the cell needs much less.
|
||||
var/amount = IO.draw_power(to_transfer)
|
||||
assembly.give_power(amount)
|
||||
else
|
||||
var/amount = assembly.draw_power(throughput)
|
||||
IO.add_avail(amount)
|
||||
|
||||
set_pin_data(IC_OUTPUT, 1, IO.avail())
|
||||
set_pin_data(IC_OUTPUT, 2, IO.surplus())
|
||||
set_pin_data(IC_OUTPUT, 3, IO.viewload())
|
||||
|
||||
// Internal power machine for interacting with the powernet.
|
||||
// It needs a bit of special code since base /machinery/power assumes loc will be a tile.
|
||||
/obj/machinery/power/circuit_io
|
||||
name = "embedded electrical I/O"
|
||||
|
||||
/obj/machinery/power/circuit_io/connect_to_network()
|
||||
var/turf/T = get_turf(src)
|
||||
if(!T || !istype(T))
|
||||
return FALSE
|
||||
|
||||
var/obj/structure/cable/C = T.get_cable_node()
|
||||
if(!C || !C.powernet)
|
||||
return FALSE
|
||||
|
||||
C.powernet.add_machine(src)
|
||||
return TRUE
|
||||
|
||||
Reference in New Issue
Block a user