mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-22 12:29:46 +01:00
Update TEG NanoUI to TGUI, rename TEG to Stirling engine (#21933)
As title. TEGs are basically just thermopiles IRL; a Stirling engine more accurately reflects its functionality. <img width="551" height="303" alt="image" src="https://github.com/user-attachments/assets/eb0f0c73-c1cc-4a04-85bc-13a413d8ac48" /> --------- Signed-off-by: Batrachophreno <Batrochophreno@gmail.com> Co-authored-by: Cody Brittain <1779662+Generalcamo@users.noreply.github.com>
This commit is contained in:
co-authored by
Cody Brittain
parent
04d2cdd020
commit
eb6c7ff844
@@ -21,6 +21,8 @@
|
||||
var/volume_capacity_used = 0
|
||||
var/stored_energy = 0
|
||||
var/temperature_overlay
|
||||
/// When passing its status to the main Stirling generator, this informs labeling on the TGUI.
|
||||
var/is_hot_loop = FALSE
|
||||
|
||||
density = TRUE
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/obj/machinery/power/generator
|
||||
name = "thermoelectric generator"
|
||||
desc = "It's a high efficiency thermoelectric generator."
|
||||
name = "\improper Stirling engine"
|
||||
desc = "It's a high efficiency Stirling engine. This model produces electricity from the temperature and differential between two gas loops."
|
||||
icon_state = "teg-unassembled"
|
||||
density = TRUE
|
||||
anchored = FALSE
|
||||
@@ -44,11 +44,13 @@
|
||||
circ2 = null
|
||||
return ..()
|
||||
|
||||
//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
|
||||
/**
|
||||
* Circulators connect in dir and reverse_dir(dir) directions
|
||||
* A 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()
|
||||
if(circ1)
|
||||
circ1.temperature_overlay = null
|
||||
@@ -78,11 +80,11 @@
|
||||
/obj/machinery/power/generator/update_icon()
|
||||
icon_state = anchored ? "teg-assembled" : "teg-unassembled"
|
||||
ClearOverlays()
|
||||
if (circ1)
|
||||
if(circ1)
|
||||
circ1.temperature_overlay = null
|
||||
if (circ2)
|
||||
if(circ2)
|
||||
circ2.temperature_overlay = null
|
||||
if (stat & (NOPOWER|BROKEN))
|
||||
if(stat & (NOPOWER|BROKEN))
|
||||
return TRUE
|
||||
else
|
||||
if (lastgenlev != 0)
|
||||
@@ -91,10 +93,14 @@
|
||||
var/extreme = (lastgenlev > 9) ? "ex" : ""
|
||||
if (circ1.last_temperature < circ2.last_temperature)
|
||||
circ1.temperature_overlay = "circ-[extreme]cold"
|
||||
circ1.is_hot_loop = FALSE
|
||||
circ2.temperature_overlay = "circ-[extreme]hot"
|
||||
circ2.is_hot_loop = TRUE
|
||||
else
|
||||
circ1.temperature_overlay = "circ-[extreme]hot"
|
||||
circ1.is_hot_loop = TRUE
|
||||
circ2.temperature_overlay = "circ-[extreme]cold"
|
||||
circ2.is_hot_loop = FALSE
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/power/generator/process()
|
||||
@@ -102,8 +108,6 @@
|
||||
stored_energy = 0
|
||||
return
|
||||
|
||||
updateDialog()
|
||||
|
||||
var/datum/gas_mixture/air1 = circ1.return_transfer_air()
|
||||
var/datum/gas_mixture/air2 = circ2.return_transfer_air()
|
||||
|
||||
@@ -174,6 +178,7 @@
|
||||
if(attacking_item.tool_behaviour == TOOL_WRENCH)
|
||||
attacking_item.play_tool_sound(get_turf(src), 75)
|
||||
anchored = !anchored
|
||||
balloon_alert(user, "[anchored ? "secure" : "unsecure"]")
|
||||
user.visible_message("[user.name] [anchored ? "secures" : "unsecures"] the bolts holding [src.name] to the floor.", \
|
||||
"You [anchored ? "secure" : "unsecure"] the bolts holding [src] to the floor.", \
|
||||
"You hear a ratchet")
|
||||
@@ -193,20 +198,27 @@
|
||||
reconnect()
|
||||
ui_interact(user)
|
||||
|
||||
/obj/machinery/power/generator/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/vertical = 0
|
||||
if (dir == NORTH || dir == SOUTH)
|
||||
vertical = 1
|
||||
/obj/machinery/power/generator/ui_interact(mob/user, datum/tgui/ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!ui)
|
||||
// Interface ID should match your tgui route registration/name.
|
||||
ui = new(user, src, "StirlingEngine", "Stirling Engine")
|
||||
ui.open()
|
||||
|
||||
var/data[0]
|
||||
data["totalOutput"] = effective_gen/1000
|
||||
data["maxTotalOutput"] = max_power/1000
|
||||
data["thermalOutput"] = last_thermal_gen/1000
|
||||
data["circConnected"] = 0
|
||||
/obj/machinery/power/generator/ui_data(mob/user)
|
||||
var/list/data = list()
|
||||
|
||||
var/vertical = FALSE
|
||||
if(dir == NORTH || dir == SOUTH)
|
||||
vertical = TRUE
|
||||
|
||||
data["totalOutput"] = effective_gen / 1000
|
||||
data["maxTotalOutput"] = max_power / 1000
|
||||
data["thermalOutput"] = last_thermal_gen / 1000
|
||||
data["circConnected"] = FALSE
|
||||
|
||||
if(circ1)
|
||||
//The one on the left (or top)
|
||||
// The one on the left (or top)
|
||||
data["primaryDir"] = vertical ? "top" : "left"
|
||||
data["primaryOutput"] = last_circ1_gen/1000
|
||||
data["primaryFlowCapacity"] = circ1.volume_capacity_used*100
|
||||
@@ -214,9 +226,10 @@
|
||||
data["primaryInletTemperature"] = circ1.air1.temperature
|
||||
data["primaryOutletPressure"] = XGM_PRESSURE(circ1.air2)
|
||||
data["primaryOutletTemperature"] = circ1.air2.temperature
|
||||
data["primaryIsHot"] = circ1.is_hot_loop
|
||||
|
||||
if(circ2)
|
||||
//Now for the one on the right (or bottom)
|
||||
// The one on the right (or bottom)
|
||||
data["secondaryDir"] = vertical ? "bottom" : "right"
|
||||
data["secondaryOutput"] = last_circ2_gen/1000
|
||||
data["secondaryFlowCapacity"] = circ2.volume_capacity_used*100
|
||||
@@ -224,25 +237,11 @@
|
||||
data["secondaryInletTemperature"] = circ2.air1.temperature
|
||||
data["secondaryOutletPressure"] = XGM_PRESSURE(circ2.air2)
|
||||
data["secondaryOutletTemperature"] = circ2.air2.temperature
|
||||
data["secondaryIsHot"] = circ2.is_hot_loop
|
||||
|
||||
if(circ1 && circ2)
|
||||
data["circConnected"] = 1
|
||||
else
|
||||
data["circConnected"] = 0
|
||||
data["circConnected"] = (circ1 && circ2) ? TRUE : FALSE
|
||||
|
||||
|
||||
// update the ui if it exists, returns null if no ui is passed/found
|
||||
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, data, force_open)
|
||||
if(!ui)
|
||||
// the ui does not exist, so we'll create a new() one
|
||||
// for a list of parameters and their descriptions see the code docs in \code\modules\nano\nanoui.dm
|
||||
ui = new(user, src, ui_key, "generator.tmpl", "Thermoelectric Generator", 450, 500)
|
||||
// when the ui is first opened this is the data it will use
|
||||
ui.set_initial_data(data)
|
||||
// open the new ui window
|
||||
ui.open()
|
||||
// auto update every Master Controller tick
|
||||
ui.set_auto_update(1)
|
||||
return data
|
||||
|
||||
/obj/machinery/power/generator/power_change()
|
||||
..()
|
||||
|
||||
Reference in New Issue
Block a user