mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2025-12-24 09:02:27 +00:00
* Replace SSingulo with SScalamity; processing cleanup
- SScalamity now handles blobs as well as singularity-types.
- Processing subtypes have been simplified to not require a stop_processing definition.
* this is probably important
* Remove cascade disabling SSgarbage
* Fixed a bug where dust() did not qdel the target mob
* Misc fixes
* Fix decals surviving break-to-plating
* Subsystem flag tweaks
* Apparently subsystems are new'd before config is.
* Fix paper icons
* Speculative fix for insane lag
* Better machinery stat
* Make organs not use SSoverlay
* Misc bugfixes & tweaks
* Nightmode fixes
* Changelog for SMC
* Port /tg/'s improved MC crash handling
* Add some more SS Recover() procs
* supply_controller -> SScargo
* More New() -> Initialize()
* pAI and robot construction overlays
* Fix cargo unit tests
* Merge the DMM Suite's atom/New() into atoms_init
* Lighting pre-baking
* Lighting initialization logging
* Fix some bad SS init orders
* Fix SSlighting logging; rename Processes to MC
* Speculative fix for insane GC lag
* Prebaked openturf/icon_smooth & fix lighting prebake
* SS init status; SSatoms LATEQDEL
* Fix bug with MC init stat panel
* Fix parallax
* Misc
* Ignore SS_NO_DISPLAY during init
* apparently this is important
* REEEEEE
* Image GC fixes; broadcaster radio-new sanity
* RCON Cleanup
* Move pAI recruiter into subsystem
* Move global solars list into sun subsystem
* Make chickens not use a global
* Demote SSdisposals to SS_BACKGROUND; garbage-debug cleanup
* Speed up space init a little
* Fix bad timer flags on floor drying
* Subsystem panic-restart verb for mins
* Explosion speedup
* Minor subsystem & MC logging tweaks
* SSopenturf improvements
* Make pipenet actually initialize (whoops)
* Minor tweaks
* Implement lighting rounding
* comments are hard okay
* Minor lattice tweaks
* Fix some timer issues & better closet init
* Timer sanity
* Request console tweaks + Storage init sanity
* Minor SSmachiner RCON improvements
* Further reduce world-start timer count
* Standardize subsystem logging
* Garbage hard delete profiling from /tg/
* Timer hang detection & recovery
* Log machines that sleep in process() and fuck up SSmachinery
* Fix an issue with external airlocks sleeping in process()
* Failsafe logging
* Minor tweaks
* Revert "Request console tweaks + Storage init sanity"
This reverts commit 98d3579e35.
* Re-implement RC changes
* Fix SQL FT saving
* Fix SSmachinery sleep in disposals
* Minor SS tweaks
* Paper fixes
* Blood drying fixes
* Merge gameticker and SSticker
* Minor global list init cleanup
* Lagcheck biogenerator & bags
* Tweak SScargo init order; RIG Initialize()
* Caching tweaks
* Remove rogue comma
* Initialize fixes
* Lighting destroy cleanup
* Fix emagging airlocks
* Initial SSicon implementation
* Tweaks & Fixes
* Fire + Air alarm queued icon updates
* Overlays + Queued icon cleanup
* Runtime & background fixes
* Kill some meaningless set statements
* Kill some image qdels
* Bump up lighting rounding val
* Fix adv. scanner destroy runtimes
* Remove unneeded icon update limiting
* Move icon smoothing into helpers
* Show a warning if DM 510 compiles without memory leak hack enabled
* Re-organize subsystems & MC defines a little
* Airlock SFX
* Log of Changes
* Make SSicon_update disable itself when not doing anything
* Fix respawn verb runtime when used early in server-init
* Add more information to MC's stat_entry()
* Replace direct refernces to gcDestroyed with QDEL* macros
* plant_controller -> SSplants
* More plant tweaks
* Add more humor to changelog
* Move parallax globals into SSparallax
* Lighting responsiveness tweaks
* Fix parallax init order & better MC init panel stat
* Make mobs GC
* More overlays + Remove intercom spawn()
* SSfast_process; make pinpointers not use spawn-recursion to process
Also made the SM Cascade beach process with SSprocessing instead of a spawn loop.
* Update changelog
* Mob GC tweaks
* Del() cleanup
* Fix insomniac ZAS connection edges
* Minor pAI cleanup
* Convert more things to SSoverlay; fix duplicated overlay in field gens
* SM Bluespace turf tweaks
* Update SSgarbage debug globals list
* Human-type qdel tweaks
* Subsystem suspension; stat_entry improvements
* SQL Statistics cleanup
* Fix runtimes with ambrosia
* More disable() -> suspend(); fix nightmode again
* Human qdel fix; minor tweaks
* Update turbolift to work with StonedMC
* Make lifts use timers instead of a subsystem
* Make SSassets start earlier
* Convert the radio controller into a subsystem
* Fix some missing CHECK_TICKs in asteroid generation
* MC stat tweaks; make shouldnt_see a typecache
* Kill some redundant debug-controller entries
* radio_controller -> SSradio
* Better SSgarbage hard-del logging from /tg/ upstream
* Logging tweaks + GELF
* Misc client caching improvements
* Slime SSoverlay
* Oven icon fixes
* Implant fixes
- Death implants will no longer spam Common on death of user.
- Death implants should handle a deleted user better.
* Holder tweaks + Welding tool Initialize()
* Fix some bad subsystem logging
* Fix suit cooling units spawning without cells
* Starlight tweaks
* Gibber infinite gib fix
* More SSoverlay stuff
* Make crates use CUT_OVERLAY_IN
* Make SSarrivals suspend instead of disable
* Make openturf use split/phased tick checks
* Speculative fix for unwet timer runtimes
* Blood overlay tweaks/fixes
* Update crusher to play nice with SMC + SSoverlay
* Openturf improvements and fixes
* Minor turbolift tweaks
* Lighting performance improvements + ChangeTurf tweaks
* this is probably important
* Fix wall weld noises on changeturf
* More ChangeTurf tweaks
* Explosion tweaks
* Pre-game lobby tweaks
* Openturf tweaks
* Prevent admins from starting the game before init finishes
* Fix Travis
* Kill an unused var
* Fix ChangeTurf runtimes on openturfs
* Fixes
* Browser datum fixes, asset caching
* Update changelog
* Changelog
* Lobby tweaks
* Ticker tweaks; kill ticker var
* Further lobby tweaks
* Cascade tweaks
* air_master -> SSair
* Reduce overhead from radio autosay
* alarm_manager -> SSalarm
* bomb_processor -> SSexplosives
* corp_regs -> SSlaw
* ZAS overlay fixes
* Small wall icon optimization
* Fix effects master
* Assembly tweaks
* Megavend fixes
* Shuttle fixes
* Camera alert performance improvements
* Fix some world.log spam from lighting overlays
* Fix some Initialize() procs
* Openspace responsiveness tweaks
* Make HE pipes animate through openturfs
* Kill a spawn
245 lines
8.1 KiB
Plaintext
245 lines
8.1 KiB
Plaintext
/obj/machinery/power/generator
|
|
name = "thermoelectric generator"
|
|
desc = "It's a high efficiency thermoelectric generator."
|
|
icon_state = "teg"
|
|
density = 1
|
|
anchored = 0
|
|
|
|
use_power = 1
|
|
idle_power_usage = 100 //Watts, I hope. Just enough to do the computer and display things.
|
|
|
|
var/max_power = 500000
|
|
var/thermal_efficiency = 0.65
|
|
|
|
var/obj/machinery/atmospherics/binary/circulator/circ1
|
|
var/obj/machinery/atmospherics/binary/circulator/circ2
|
|
|
|
var/last_circ1_gen = 0
|
|
var/last_circ2_gen = 0
|
|
var/last_thermal_gen = 0
|
|
var/stored_energy = 0
|
|
var/lastgen1 = 0
|
|
var/lastgen2 = 0
|
|
var/effective_gen = 0
|
|
var/lastgenlev = 0
|
|
|
|
var/datum/effect_system/sparks/spark_system
|
|
|
|
/obj/machinery/power/generator/Initialize()
|
|
. = ..()
|
|
desc = initial(desc) + " Rated for [round(max_power/1000)] kW."
|
|
var/dirs
|
|
if (dir == NORTH || dir == SOUTH)
|
|
dirs = list(EAST,WEST)
|
|
else
|
|
dirs = list(NORTH,SOUTH)
|
|
|
|
spark_system = bind_spark(src, 3, dirs)
|
|
reconnect()
|
|
|
|
/obj/machinery/power/generator/Destroy()
|
|
QDEL_NULL(spark_system)
|
|
circ1 = null
|
|
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
|
|
/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,WEST)
|
|
circ2 = locate(/obj/machinery/atmospherics/binary/circulator) in get_step(src,EAST)
|
|
|
|
if(circ1 && circ2)
|
|
if(circ1.dir != NORTH || circ2.dir != SOUTH)
|
|
circ1 = null
|
|
circ2 = 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()
|
|
cut_overlays()
|
|
if(!(stat & (NOPOWER|BROKEN)) && lastgenlev)
|
|
add_overlay("teg-op[lastgenlev]")
|
|
|
|
/obj/machinery/power/generator/process()
|
|
if(!circ1 || !circ2 || !anchored || stat & (BROKEN|NOPOWER))
|
|
stored_energy = 0
|
|
return
|
|
|
|
updateDialog()
|
|
|
|
var/datum/gas_mixture/air1 = circ1.return_transfer_air()
|
|
var/datum/gas_mixture/air2 = circ2.return_transfer_air()
|
|
|
|
lastgen2 = lastgen1
|
|
lastgen1 = 0
|
|
last_thermal_gen = 0
|
|
last_circ1_gen = 0
|
|
last_circ2_gen = 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/energy_transfer = delta_temperature*air2_heat_capacity*air1_heat_capacity/(air2_heat_capacity+air1_heat_capacity)
|
|
var/heat = energy_transfer*(1-thermal_efficiency)
|
|
last_thermal_gen = energy_transfer*thermal_efficiency
|
|
|
|
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.network2)
|
|
circ1.network2.update = 1
|
|
if(circ2.network2)
|
|
circ2.network2.update = 1
|
|
|
|
//Exceeding maximum power leads to some power loss
|
|
if(effective_gen > max_power && prob(5))
|
|
spark_system.queue()
|
|
stored_energy *= 0.5
|
|
|
|
//Power
|
|
last_circ1_gen = circ1.return_stored_energy()
|
|
last_circ2_gen = circ2.return_stored_energy()
|
|
stored_energy += last_thermal_gen + last_circ1_gen + last_circ2_gen
|
|
lastgen1 = stored_energy*0.4 //smoothened power generation to prevent slingshotting as pressure is equalized, then restored by pumps
|
|
stored_energy -= lastgen1
|
|
effective_gen = (lastgen1 + lastgen2) / 2
|
|
|
|
// update icon overlays and power usage only if displayed level has changed
|
|
var/genlev = max(0, min( round(11*effective_gen / max_power), 11))
|
|
if(effective_gen > 100 && genlev == 0)
|
|
genlev = 1
|
|
if(genlev != lastgenlev)
|
|
lastgenlev = genlev
|
|
updateicon()
|
|
add_avail(effective_gen)
|
|
|
|
/obj/machinery/power/generator/attack_ai(mob/user)
|
|
attack_hand(user)
|
|
|
|
/obj/machinery/power/generator/attackby(obj/item/weapon/W as obj, mob/user as mob)
|
|
if(istype(W, /obj/item/weapon/wrench))
|
|
playsound(src.loc, 'sound/items/Ratchet.ogg', 75, 1)
|
|
anchored = !anchored
|
|
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")
|
|
use_power = anchored
|
|
if(anchored) // Powernet connection stuff.
|
|
connect_to_network()
|
|
else
|
|
disconnect_from_network()
|
|
reconnect()
|
|
else
|
|
..()
|
|
|
|
/obj/machinery/power/generator/attack_hand(mob/user)
|
|
add_fingerprint(user)
|
|
if(stat & (BROKEN|NOPOWER) || !anchored) return
|
|
if(!circ1 || !circ2) //Just incase the middle part of the TEG was not wrenched last.
|
|
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
|
|
|
|
var/data[0]
|
|
data["totalOutput"] = effective_gen/1000
|
|
data["maxTotalOutput"] = max_power/1000
|
|
data["thermalOutput"] = last_thermal_gen/1000
|
|
data["circConnected"] = 0
|
|
|
|
if(circ1)
|
|
//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
|
|
data["primaryInletPressure"] = circ1.air1.return_pressure()
|
|
data["primaryInletTemperature"] = circ1.air1.temperature
|
|
data["primaryOutletPressure"] = circ1.air2.return_pressure()
|
|
data["primaryOutletTemperature"] = circ1.air2.temperature
|
|
|
|
if(circ2)
|
|
//Now for 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
|
|
data["secondaryInletPressure"] = circ2.air1.return_pressure()
|
|
data["secondaryInletTemperature"] = circ2.air1.temperature
|
|
data["secondaryOutletPressure"] = circ2.air2.return_pressure()
|
|
data["secondaryOutletTemperature"] = circ2.air2.temperature
|
|
|
|
if(circ1 && circ2)
|
|
data["circConnected"] = 1
|
|
else
|
|
data["circConnected"] = 0
|
|
|
|
|
|
// update the ui if it exists, returns null if no ui is passed/found
|
|
ui = nanomanager.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)
|
|
|
|
/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.set_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.set_dir(turn(src.dir, -90))
|