diff --git a/code/ATMOSPHERICS/components/binary_devices/circulator.dm b/code/ATMOSPHERICS/components/binary_devices/circulator.dm
index 8ce7b1ce0ba..b6c5d55e5a9 100644
--- a/code/ATMOSPHERICS/components/binary_devices/circulator.dm
+++ b/code/ATMOSPHERICS/components/binary_devices/circulator.dm
@@ -2,77 +2,84 @@
//node2, air2, network2 correspond to output
/obj/machinery/atmospherics/binary/circulator
name = "circulator/heat exchanger"
- desc = "A gas circulator pump and heat exchanger."
- icon = 'icons/obj/pipes.dmi'
- icon_state = "circ-off"
- anchored = 0
- density = 1
+ desc = "A gas circulator pump and heat exchanger. Its input port is on the south side, and its output port is on the north side."
+ icon = 'icons/obj/atmospherics/circulator.dmi'
+ icon_state = "circ1-off"
+
+ var/side = CIRC_LEFT
+
+ var/global/const/CIRC_LEFT = WEST
+ var/global/const/CIRC_RIGHT = EAST
- var/recent_moles_transferred = 0
- var/last_heat_capacity = 0
- var/last_temperature = 0
var/last_pressure_delta = 0
- var/last_worldtime_transfer = 0
+
+ var/obj/machinery/power/generator/generator
-/obj/machinery/atmospherics/binary/circulator/New()
- ..()
- desc = initial(desc) + " Its outlet port is to the [dir2text(dir)]."
+ layer = 2.45 // Just above wires
+
+ anchored = 1
+ density = 1
+
+ can_unwrench = 1
+
+// Creating a custom circulator pipe subtype to be delivered through cargo
+/obj/item/pipe/circulator
+ name = "circulator/heat exchanger fitting"
+
+/obj/item/pipe/circulator/New(loc)
+ var/obj/machinery/atmospherics/binary/circulator/C = new /obj/machinery/atmospherics/binary/circulator(null)
+ ..(loc, make_from = C)
+
+/obj/machinery/atmospherics/binary/circulator/Destroy()
+ if(generator && generator.cold_circ == src)
+ generator.cold_circ = null
+ else if(generator && generator.hot_circ == src)
+ generator.hot_circ = null
+ return ..()
/obj/machinery/atmospherics/binary/circulator/proc/return_transfer_air()
- var/datum/gas_mixture/removed
- if(anchored && !(stat & BROKEN))
- var/input_starting_pressure = air1.return_pressure()
- var/output_starting_pressure = air2.return_pressure()
- last_pressure_delta = max(input_starting_pressure - output_starting_pressure + 10, 0)
+ var/output_starting_pressure = air1.return_pressure()
+ var/input_starting_pressure = air2.return_pressure()
- //only circulate air if there is a pressure difference (plus 10 kPa to represent friction in the machine)
- if(air1.temperature > 0 && last_pressure_delta > 0)
+ if(output_starting_pressure >= input_starting_pressure - 10)
+ //Need at least 10 KPa difference to overcome friction in the mechanism
+ last_pressure_delta = 0
+ return null
- //Calculate necessary moles to transfer using PV = nRT
- recent_moles_transferred = last_pressure_delta*air2.volume/(air1.temperature * R_IDEAL_GAS_EQUATION)
+ //Calculate necessary moles to transfer using PV = nRT
+ if(air2.temperature > 0)
+ var/pressure_delta = (input_starting_pressure - output_starting_pressure) / 2
- //Actually transfer the gas
- removed = air1.remove(recent_moles_transferred)
- if(removed)
- last_heat_capacity = removed.heat_capacity()
- last_temperature = removed.temperature
+ var/transfer_moles = pressure_delta * air1.volume/(air2.temperature * R_IDEAL_GAS_EQUATION)
- //Update the gas networks.
- parent1.update = 1
+ last_pressure_delta = pressure_delta
- last_worldtime_transfer = world.time
- else
- recent_moles_transferred = 0
+ //log_debug("pressure_delta = [pressure_delta]; transfer_moles = [transfer_moles];")
+
+ //Actually transfer the gas
+ var/datum/gas_mixture/removed = air2.remove(transfer_moles)
+
+ parent1.update = 1
+ parent2.update = 1
- update_icon()
return removed
+ else
+ last_pressure_delta = 0
+
/obj/machinery/atmospherics/binary/circulator/process()
- if(!..())
- return 0
- if(last_worldtime_transfer < world.time - 50)
- recent_moles_transferred = 0
- update_icon()
+ ..()
+ update_icon()
/obj/machinery/atmospherics/binary/circulator/update_icon()
- if(stat & (BROKEN|NOPOWER) || !anchored)
- icon_state = "circ-p"
- else if(last_pressure_delta > 0 && recent_moles_transferred > 0)
- if(last_pressure_delta > 5*ONE_ATMOSPHERE)
- icon_state = "circ-run"
+ if(stat & (BROKEN|NOPOWER))
+ icon_state = "circ[side]-p"
+ else if(last_pressure_delta > 0)
+ if(last_pressure_delta > ONE_ATMOSPHERE)
+ icon_state = "circ[side]-run"
else
- icon_state = "circ-slow"
+ icon_state = "circ[side]-slow"
else
- icon_state = "circ-off"
+ icon_state = "circ[side]-off"
- return 1
-
-/obj/machinery/atmospherics/binary/circulator/attackby(var/obj/item/W as obj, var/mob/user as mob, params)
- if(istype(W, /obj/item/weapon/wrench))
- var/turf/T = get_turf(src)
- if(!istype(T, /turf/simulated))
- return ..()
- anchored = !anchored
- to_chat(user, "You [(anchored) ? "fasten" : "loosen"] \the [src] to the floor")
- playsound(loc, 'sound/items/Ratchet.ogg', 50, 1)
- else return ..()
+ return 1
\ No newline at end of file
diff --git a/code/datums/supplypacks.dm b/code/datums/supplypacks.dm
index 73c653369eb..7a8f05e08fc 100644
--- a/code/datums/supplypacks.dm
+++ b/code/datums/supplypacks.dm
@@ -581,7 +581,7 @@ var/list/all_supply_groups = list(supply_emergency,supply_security,supply_engine
/obj/item/clothing/head/helmet/space,
/obj/item/clothing/head/helmet/space,
/obj/item/clothing/mask/breath,
- /obj/item/clothing/mask/breath,)
+ /obj/item/clothing/mask/breath)
cost = 30
containertype = /obj/structure/closet/crate/secure
containername = "space suit crate"
@@ -607,9 +607,8 @@ var/list/all_supply_groups = list(supply_emergency,supply_security,supply_engine
name = "Thermo-Electric Generator Crate"
contains = list(
/obj/machinery/power/generator,
- /obj/machinery/atmospherics/binary/circulator,
- /obj/machinery/atmospherics/binary/circulator
- )
+ /obj/item/pipe/circulator,
+ /obj/item/pipe/circulator)
cost = 25
containertype = /obj/structure/closet/crate/secure
containername = "thermo-electric generator crate"
diff --git a/code/game/machinery/pipe/construction.dm b/code/game/machinery/pipe/construction.dm
index afe79ca48e3..bf2eedeaf23 100644
--- a/code/game/machinery/pipe/construction.dm
+++ b/code/game/machinery/pipe/construction.dm
@@ -37,6 +37,7 @@
#define PIPE_DP_VENT 36
#define PIPE_PASV_VENT 37
#define PIPE_DTVALVE 38
+#define PIPE_CIRCULATOR 39
/obj/item/pipe
name = "pipe"
@@ -150,10 +151,16 @@
src.pipe_type = PIPE_OMNI_MIXER
else if(istype(make_from, /obj/machinery/atmospherics/omni/filter))
src.pipe_type = PIPE_OMNI_FILTER
+ else if(istype(make_from, /obj/machinery/atmospherics/binary/circulator))
+ src.pipe_type = PIPE_CIRCULATOR
var/obj/machinery/atmospherics/trinary/triP = make_from
if(istype(triP) && triP.flipped)
src.flipped = 1
+
+ var/obj/machinery/atmospherics/binary/circulator/circP = make_from
+ if(istype(circP) && circP.side == circP.CIRC_RIGHT)
+ src.flipped = 1
else
src.pipe_type = pipe_type
@@ -214,6 +221,7 @@
"dual-port vent", \
"passive vent", \
"digital t-valve", \
+ "circulator/heat exchanger", \
)
name = nlist[pipe_type+1] + " fitting"
var/list/islist = list( \
@@ -256,11 +264,15 @@
"dual-port vent", \
"passive vent", \
"dtvalve", \
+ "circ", \
)
icon_state = islist[pipe_type + 1]
var/obj/machinery/atmospherics/trinary/triP = make_from
if(istype(triP) && triP.flipped)
icon_state = "m_[icon_state]"
+ var/obj/machinery/atmospherics/binary/circulator/circP = make_from
+ if(istype(circP) && circP.side == circP.CIRC_RIGHT)
+ icon_state = "m_[icon_state]"
// called by turf to know if should treat as bent or not on placement
/obj/item/pipe/proc/is_bent_pipe()
@@ -280,6 +292,10 @@
if( usr.stat || usr.restrained() )
return
+
+ if(pipe_type == PIPE_CIRCULATOR)
+ flip()
+ return
src.dir = turn(src.dir, -90)
@@ -295,7 +311,7 @@
if(usr.stat || usr.restrained())
return
- if(pipe_type in list(PIPE_GAS_FILTER, PIPE_GAS_MIXER, PIPE_TVALVE, PIPE_DTVALVE))
+ if(pipe_type in list(PIPE_GAS_FILTER, PIPE_GAS_MIXER, PIPE_TVALVE, PIPE_DTVALVE, PIPE_CIRCULATOR))
if(flipped)
icon_state = copytext(icon_state,3)
else
@@ -529,6 +545,14 @@
if(pipename)
P.name = pipename
P.construction(unflip(dir), pipe_dir, color)
+
+ if(PIPE_CIRCULATOR) //circulator
+ var/obj/machinery/atmospherics/binary/circulator/C = new(src.loc)
+ if(flipped)
+ C.side = C.CIRC_RIGHT
+ if(pipename)
+ C.name = pipename
+ C.construction(C.dir, C.initialize_directions, color)
if(PIPE_SCRUBBER) //scrubber
var/obj/machinery/atmospherics/unary/vent_scrubber/S = new(src.loc)
@@ -682,3 +706,4 @@
#undef PIPE_DP_VENT
#undef PIPE_PASV_VENT
#undef PIPE_DTVALVE
+#undef PIPE_CIRCULATOR
diff --git a/code/modules/power/generator.dm b/code/modules/power/generator.dm
index f86b17eaab7..0ff6289ea66 100644
--- a/code/modules/power/generator.dm
+++ b/code/modules/power/generator.dm
@@ -1,211 +1,241 @@
-
/obj/machinery/power/generator
name = "thermoelectric generator"
desc = "It's a high efficiency thermoelectric generator."
icon_state = "teg"
- density = 1
anchored = 0
+ density = 1
+ use_power = 0
- use_power = 1
- idle_power_usage = 100 //Watts, I hope. Just enough to do the computer and display things.
-
- var/obj/machinery/atmospherics/binary/circulator/circ1
- var/obj/machinery/atmospherics/binary/circulator/circ2
+ var/obj/machinery/atmospherics/binary/circulator/cold_circ
+ var/obj/machinery/atmospherics/binary/circulator/hot_circ
+ var/cold_dir = WEST
+ var/hot_dir = EAST
+
var/lastgen = 0
var/lastgenlev = -1
-
- var/image/overlay_image
-
- var/power_multiplier = 1 // This is so admins can tweak how good it is to find a good balance for effort -> power
- var/powercap = 500000 //Not a hard cap, but outputs above this have a 10% chance to cause the TeG to lose half it's power.
-
+ var/lastcirc = "00"
+
/obj/machinery/power/generator/New()
..()
+ update_desc()
+
+/obj/machinery/power/generator/proc/update_desc()
+ desc = initial(desc) + " Its cold circulator is located on the [dir2text(cold_dir)] side, and its heat circulator is located on the [dir2text(hot_dir)] side."
+
+/obj/machinery/power/generator/Destroy()
+ disconnect()
+ return ..()
+
+/obj/machinery/power/generator/proc/disconnect()
+ if(cold_circ)
+ cold_circ.generator = null
+ if(hot_circ)
+ hot_circ.generator = null
+ if(powernet)
+ disconnect_from_network()
- spawn(1)
- reconnect()
+/obj/machinery/power/generator/initialize()
+ ..()
+ connect()
+
+/obj/machinery/power/generator/proc/connect()
+ connect_to_network()
+
+ var/obj/machinery/atmospherics/binary/circulator/circpath = /obj/machinery/atmospherics/binary/circulator
+ cold_circ = locate(circpath) in get_step(src, cold_dir)
+ hot_circ = locate(circpath) in get_step(src, hot_dir)
-//generators connect in dir and reverse_dir(dir) directions
-//mnemonic to determine circulator/generator directions: the cirulators orbit clockwise around the generator
-//so a circulator to the NORTH of the generator connects first to the EAST, then to the WEST
-//and a circulator to the WEST of the generator connects first to the NORTH, then to the SOUTH
-//note that the circulator's outlet dir is it's always facing dir, and it's inlet is always the reverse
-/obj/machinery/power/generator/proc/reconnect()
- circ1 = null
- circ2 = null
- if(src.loc && anchored)
- if(src.dir & (EAST|WEST))
- circ1 = locate(/obj/machinery/atmospherics/binary/circulator) in get_step(src,EAST)
- circ2 = locate(/obj/machinery/atmospherics/binary/circulator) in get_step(src,WEST)
+ if(cold_circ && cold_circ.side == cold_dir)
+ cold_circ.generator = src
+ cold_circ.update_icon()
+ else
+ cold_circ = null
- if(circ1 && circ2)
- if(circ1.dir != SOUTH || circ2.dir != NORTH)
- circ1 = null
- circ2 = null
+ if(hot_circ && hot_circ.side == hot_dir)
+ hot_circ.generator = src
+ hot_circ.update_icon()
+ else
+ hot_circ = null
- else if(src.dir & (NORTH|SOUTH))
- circ1 = locate(/obj/machinery/atmospherics/binary/circulator) in get_step(src,NORTH)
- circ2 = locate(/obj/machinery/atmospherics/binary/circulator) in get_step(src,SOUTH)
-
- if(circ1 && circ2 && (circ1.dir != EAST || circ2.dir != WEST))
- circ1 = null
- circ2 = null
-
-/obj/machinery/power/generator/proc/updateicon()
- if(isnull(src.overlay_image))
- src.overlay_image = image('icons/obj/power.dmi')
-
- overlays.Cut()
- if(!(stat & (NOPOWER|BROKEN)))
+ power_change()
+ update_icon()
+ updateDialog()
+
+/obj/machinery/power/generator/power_change()
+ if(!anchored)
+ stat |= NOPOWER
+ else
+ ..()
+
+/obj/machinery/power/generator/update_icon()
+ if(stat & (NOPOWER|BROKEN))
+ overlays.Cut()
+ else
+ overlays.Cut()
if(lastgenlev != 0)
- src.overlay_image.icon_state = "teg-op[lastgenlev]"
- overlays += src.overlay_image
+ overlays += image('icons/obj/power.dmi', "teg-op[lastgenlev]")
-/obj/machinery/power/generator/process()
- if(!circ1 || !circ2 || !anchored || stat & (BROKEN|NOPOWER))
+ overlays += image('icons/obj/power.dmi', "teg-oc[lastcirc]")
+
+/obj/machinery/power/generator/process()
+ if(stat & (NOPOWER|BROKEN))
return
+ if(!cold_circ || !hot_circ)
+ return
+
+ lastgen = 0
+
+ if(powernet)
+
+ //log_debug("cold_circ and hot_circ pass")
+
+ var/datum/gas_mixture/cold_air = cold_circ.return_transfer_air()
+ var/datum/gas_mixture/hot_air = hot_circ.return_transfer_air()
+
+ //log_debug("hot_air = [hot_air]; cold_air = [cold_air];")
+
+ if(cold_air && hot_air)
+
+ //log_debug("hot_air = [hot_air] temperature = [hot_air.temperature]; cold_air = [cold_air] temperature = [hot_air.temperature];")
+
+ //log_debug("coldair and hotair pass")
+ var/cold_air_heat_capacity = cold_air.heat_capacity()
+ var/hot_air_heat_capacity = hot_air.heat_capacity()
+
+ var/delta_temperature = hot_air.temperature - cold_air.temperature
+
+ //log_debug("delta_temperature = [delta_temperature]; cold_air_heat_capacity = [cold_air_heat_capacity]; hot_air_heat_capacity = [hot_air_heat_capacity]")
+
+ if(delta_temperature > 0 && cold_air_heat_capacity > 0 && hot_air_heat_capacity > 0)
+ var/efficiency = 0.65
+
+ var/energy_transfer = delta_temperature * hot_air_heat_capacity * cold_air_heat_capacity / (hot_air_heat_capacity + cold_air_heat_capacity)
+
+ var/heat = energy_transfer * (1 - efficiency)
+ lastgen = energy_transfer * efficiency
+
+ //log_debug("lastgen = [lastgen]; heat = [heat]; delta_temperature = [delta_temperature]; hot_air_heat_capacity = [hot_air_heat_capacity]; cold_air_heat_capacity = [cold_air_heat_capacity];")
+
+ hot_air.temperature = hot_air.temperature - energy_transfer / hot_air_heat_capacity
+ cold_air.temperature = cold_air.temperature + heat / cold_air_heat_capacity
+
+ //log_debug("POWER: [lastgen] W generated at [efficiency * 100]% efficiency and sinks sizes [cold_air_heat_capacity], [hot_air_heat_capacity]")
+
+ add_avail(lastgen)
+ // update icon overlays only if displayed level has changed
+
+ if(hot_air)
+ var/datum/gas_mixture/hot_circ_air1 = hot_circ.air1
+ hot_circ_air1.merge(hot_air)
+
+ if(cold_air)
+ var/datum/gas_mixture/cold_circ_air1 = cold_circ.air1
+ cold_circ_air1.merge(cold_air)
+
+ var/genlev = max(0, min( round(11 * lastgen / 100000), 11))
+ var/circ = "[cold_circ && cold_circ.last_pressure_delta > 0 ? "1" : "0"][hot_circ && hot_circ.last_pressure_delta > 0 ? "1" : "0"]"
+ if((genlev != lastgenlev) || (circ != lastcirc))
+ lastgenlev = genlev
+ lastcirc = circ
+ update_icon()
+
updateDialog()
- var/datum/gas_mixture/air1 = circ1.return_transfer_air()
- var/datum/gas_mixture/air2 = circ2.return_transfer_air()
- lastgen = 0
-
- if(air1 && air2)
- var/air1_heat_capacity = air1.heat_capacity()
- var/air2_heat_capacity = air2.heat_capacity()
- var/delta_temperature = abs(air2.temperature - air1.temperature)
-
- if(delta_temperature > 0 && air1_heat_capacity > 0 && air2_heat_capacity > 0)
- var/efficiency = 0.65
- var/energy_transfer = delta_temperature*air2_heat_capacity*air1_heat_capacity/(air2_heat_capacity+air1_heat_capacity)
- var/heat = energy_transfer*(1-efficiency)
- lastgen = energy_transfer*efficiency*0.05*power_multiplier
-
- if(air2.temperature > air1.temperature)
- air2.temperature = air2.temperature - energy_transfer/air2_heat_capacity
- air1.temperature = air1.temperature + heat/air1_heat_capacity
- else
- air2.temperature = air2.temperature + heat/air2_heat_capacity
- air1.temperature = air1.temperature - energy_transfer/air1_heat_capacity
-
- //Transfer the air
- if(air1)
- circ1.air2.merge(air1)
- if(air2)
- circ2.air2.merge(air2)
-
- //Update the gas networks
- if(circ1.parent2)
- circ1.parent2.update = 1
- if(circ2.parent2)
- circ2.parent2.update = 1
-
- // update icon overlays and power usage only if displayed level has changed
- if(lastgen > powercap && prob(10))
- var/datum/effect/system/spark_spread/s = new /datum/effect/system/spark_spread
- s.set_up(3, 1, src)
- s.start()
- lastgen *= 0.5
- var/genlev = max(0, min( round(11*lastgen / powercap), 11))
- if(lastgen > 100 && genlev == 0)
- genlev = 1
- if(genlev != lastgenlev)
- lastgenlev = genlev
- updateicon()
- add_avail(lastgen)
-
/obj/machinery/power/generator/attack_ai(mob/user)
- if(stat & (BROKEN|NOPOWER)) return
+ return attack_hand(user)
+
+/obj/machinery/power/generator/attack_ghost(mob/user)
+ if(stat & (NOPOWER|BROKEN))
+ return
+ interact(user)
+
+/obj/machinery/power/generator/attack_hand(mob/user)
+ if(..())
+ user << browse(null, "window=teg")
+ return
interact(user)
/obj/machinery/power/generator/attackby(obj/item/weapon/W as obj, mob/user as mob, params)
if(istype(W, /obj/item/weapon/wrench))
anchored = !anchored
- to_chat(user, "\blue You [anchored ? "secure" : "unsecure"] the bolts holding [src] to the floor.")
- use_power = anchored
- reconnect()
+ if(!anchored)
+ disconnect()
+ power_change()
+ else
+ connect()
+ playsound(loc, 'sound/items/Ratchet.ogg', 50, 1)
+ to_chat(user, "You [anchored ? "secure" : "unsecure"] the bolts holding [src] to the floor.")
+ else if(istype(W, /obj/item/device/multitool))
+ if(cold_dir == WEST)
+ cold_dir = EAST
+ hot_dir = WEST
+ else
+ cold_dir = WEST
+ hot_dir = EAST
+ connect()
+ to_chat(user, "You reverse the generator's circulator settings. The cold circulator is now on the [dir2text(cold_dir)] side, and the heat circulator is now on the [dir2text(hot_dir)] side.")
+ update_desc()
else
- ..()
+ ..()
+
+/obj/machinery/power/generator/proc/get_menu(include_link = 1)
+ var/t = ""
+ if(!powernet)
+ t += "Unable to connect to the power network!"
+ t += "
Retry"
+ else if(cold_circ && hot_circ)
+ var/datum/gas_mixture/cold_circ_air1 = cold_circ.air1
+ var/datum/gas_mixture/cold_circ_air2 = cold_circ.air2
+ var/datum/gas_mixture/hot_circ_air1 = hot_circ.air1
+ var/datum/gas_mixture/hot_circ_air2 = hot_circ.air2
-/obj/machinery/power/generator/attack_hand(mob/user)
- add_fingerprint(user)
- if(stat & (BROKEN|NOPOWER) || !anchored) return
- interact(user)
+ t += "
Thermo-Electric Generator
" - - if(circ1 && circ2) - t += "Output : [round(lastgen)] W
" - - t += "Primary Circulator (top or right)
" - t += "Inlet Pressure: [round(circ1.air1.return_pressure(), 0.1)] kPa
" - t += "Inlet Temperature: [round(circ1.air1.temperature, 0.1)] K
" - t += "Outlet Pressure: [round(circ1.air2.return_pressure(), 0.1)] kPa
" - t += "Outlet Temperature: [round(circ1.air2.temperature, 0.1)] K
" - - t += "Secondary Circulator (bottom or left)
" - t += "Inlet Pressure: [round(circ2.air1.return_pressure(), 0.1)] kPa
" - t += "Inlet Temperature: [round(circ2.air1.temperature, 0.1)] K
" - t += "Outlet Pressure: [round(circ2.air2.return_pressure(), 0.1)] kPa
" - t += "Outlet Temperature: [round(circ2.air2.temperature, 0.1)] K
" - - else - t += "Unable to connect to circulators.
" - t += "Ensure both are in position and wrenched into place." - - t += "
" - t += "
" - t += "Refresh Close" - - user << browse(t, "window=teg;size=460x300") - onclose(user, "teg") + var/datum/browser/popup = new(user, "teg", "Thermo-Electric Generator", 460, 300) + popup.set_content(get_menu()) + popup.set_title_image(user.browse_rsc_icon(src.icon, src.icon_state)) + popup.open() return 1 - /obj/machinery/power/generator/Topic(href, href_list) - ..() + if(..()) + return 0 if( href_list["close"] ) usr << browse(null, "window=teg") usr.unset_machine() return 0 - - updateDialog() + if( href_list["check"] ) + if(!powernet || !cold_circ || !hot_circ) + connect() return 1 - /obj/machinery/power/generator/power_change() ..() - updateicon() - - -/obj/machinery/power/generator/verb/rotate_clock() - set category = "Object" - set name = "Rotate Generator (Clockwise)" - set src in view(1) - - if(usr.stat || usr.restrained() || anchored) - return - - src.dir = turn(src.dir, 90) - -/obj/machinery/power/generator/verb/rotate_anticlock() - set category = "Object" - set name = "Rotate Generator (Counterclockwise)" - set src in view(1) - - if(usr.stat || usr.restrained() || anchored) - return - - src.dir = turn(src.dir, -90) \ No newline at end of file + update_icon() \ No newline at end of file diff --git a/code/modules/power/generator_type2.dm b/code/modules/power/generator_type2.dm deleted file mode 100644 index d1ff1f1079c..00000000000 --- a/code/modules/power/generator_type2.dm +++ /dev/null @@ -1,143 +0,0 @@ -/obj/machinery/power/generator_type2 - name = "thermoelectric generator" - desc = "It's a high efficiency thermoelectric generator." - icon_state = "teg" - anchored = 1 - density = 1 - use_power = 0 - - var/obj/machinery/atmospherics/unary/generator_input/input1 - var/obj/machinery/atmospherics/unary/generator_input/input2 - - var/lastgen = 0 - var/lastgenlev = -1 - - var/image/overlay_image - -/obj/machinery/power/generator_type2/New() - ..() - spawn(5) - input1 = locate(/obj/machinery/atmospherics/unary/generator_input) in get_step(src,turn(dir, 90)) - input2 = locate(/obj/machinery/atmospherics/unary/generator_input) in get_step(src,turn(dir, -90)) - if(!input1 || !input2) - stat |= BROKEN - updateicon() - - -/obj/machinery/power/generator_type2/proc/updateicon() - - if(isnull(src.overlay_image)) - src.overlay_image = image('icons/obj/power.dmi') - - overlays.Cut() - if(!(stat & (NOPOWER|BROKEN))) - - if(lastgenlev != 0) - src.overlay_image.icon_state = "teg-op[lastgenlev]" - overlays += src.overlay_image - -#define GENRATE 800 // generator output coefficient from Q - - -/obj/machinery/power/generator_type2/process() - if(!input1 || !input2) - return - - var/datum/gas_mixture/air1 = input1.return_exchange_air() - var/datum/gas_mixture/air2 = input2.return_exchange_air() - - - lastgen = 0 - - if(air1 && air2) - var/datum/gas_mixture/hot_air = air1 - var/datum/gas_mixture/cold_air = air2 - if(hot_air.temperature < cold_air.temperature) - hot_air = air2 - cold_air = air1 - - var/hot_air_heat_capacity = hot_air.heat_capacity() - var/cold_air_heat_capacity = cold_air.heat_capacity() - - var/delta_temperature = hot_air.temperature - cold_air.temperature - - if(delta_temperature > 1 && cold_air_heat_capacity > 0.01 && hot_air_heat_capacity > 0.01) - var/efficiency = (1 - cold_air.temperature/hot_air.temperature)*0.65 //65% of Carnot efficiency - - var/energy_transfer = delta_temperature*hot_air_heat_capacity*cold_air_heat_capacity/(hot_air_heat_capacity+cold_air_heat_capacity) - - var/heat = energy_transfer*(1-efficiency) - lastgen = energy_transfer*efficiency - - hot_air.temperature = hot_air.temperature - energy_transfer/hot_air_heat_capacity - cold_air.temperature = cold_air.temperature + heat/cold_air_heat_capacity - -// to_chat(world, "POWER: [lastgen] W generated at [efficiency*100]% efficiency and sinks sizes [cold_air_heat_capacity], [hot_air_heat_capacity]") - - input1.parent.update = 1 - input2.parent.update = 1 - - add_avail(lastgen) - // update icon overlays only if displayed level has changed - - var/genlev = max(0, min( round(11*lastgen / 100000), 11)) - if(genlev != lastgenlev) - lastgenlev = genlev - updateicon() - - src.updateDialog() - - -/obj/machinery/power/generator_type2/attack_ai(mob/user) - if(stat & (BROKEN|NOPOWER)) return - interact(user) - - -/obj/machinery/power/generator_type2/attack_hand(mob/user) - add_fingerprint(user) - if(stat & (BROKEN|NOPOWER)) return - interact(user) - - -/obj/machinery/power/generator_type2/interact(mob/user) - if( (get_dist(src, user) > 1 ) && (!istype(user, /mob/living/silicon/ai))) - user.unset_machine() - user << browse(null, "window=teg") - return - - user.set_machine(src) - - var/t = "Thermo-Electric Generator" - user << browse(t, "window=teg;size=460x300") - onclose(user, "teg") - return 1 - - -/obj/machinery/power/generator_type2/Topic(href, href_list) - ..() - - if( href_list["close"] ) - usr << browse(null, "window=teg") - usr.unset_machine() - return 0 - - return 1 - - -/obj/machinery/power/generator_type2/power_change() - ..() - updateicon() \ No newline at end of file diff --git a/icons/obj/atmospherics/circulator.dmi b/icons/obj/atmospherics/circulator.dmi new file mode 100644 index 00000000000..45f7a626ef6 Binary files /dev/null and b/icons/obj/atmospherics/circulator.dmi differ diff --git a/icons/obj/pipe-item.dmi b/icons/obj/pipe-item.dmi index 34fedaa560f..73d62edfaa8 100644 Binary files a/icons/obj/pipe-item.dmi and b/icons/obj/pipe-item.dmi differ diff --git a/icons/obj/pipes.dmi b/icons/obj/pipes.dmi index 45f79d9e66b..99e6e84d185 100644 Binary files a/icons/obj/pipes.dmi and b/icons/obj/pipes.dmi differ diff --git a/paradise.dme b/paradise.dme index 17f48fd9dba..1c0d6119e87 100644 --- a/paradise.dme +++ b/paradise.dme @@ -1737,7 +1737,6 @@ #include "code\modules\power\cell.dm" #include "code\modules\power\engine.dm" #include "code\modules\power\generator.dm" -#include "code\modules\power\generator_type2.dm" #include "code\modules\power\gravitygenerator.dm" #include "code\modules\power\lighting.dm" #include "code\modules\power\port_gen.dm"
" - - t += "Output : [round(lastgen)] W
" - - t += "Cold loop
" - t += "Temperature: [round(input1.air_contents.temperature, 0.1)] K
" - t += "Pressure: [round(input1.air_contents.return_pressure(), 0.1)] kPa
" - - t += "Hot loop
" - t += "Temperature: [round(input2.air_contents.temperature, 0.1)] K
" - t += "Pressure: [round(input2.air_contents.return_pressure(), 0.1)] kPa
" - - t += "
Close" - - t += "