mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 10:21:11 +00:00
Removed update_values(). RIP, shine on you CPU diamond. Removed get_moles_by_id and get_archived_moles_by_id, all moles are now accessed directly to reduce call cost. Added set_temperature and set_volume procs which recalc pressure when temperature or pressure change. Heat_capacity is now a var updated when gases update. Modified adjust_gas to use set_gas, modified set_gas to alter heat_capacity, total_moles, and pressure as needed.
42 lines
1.3 KiB
Plaintext
42 lines
1.3 KiB
Plaintext
/obj/machinery/atmospherics/unary/cold_sink
|
|
icon = 'icons/obj/atmospherics/cold_sink.dmi'
|
|
icon_state = "on_cool"
|
|
density = 1
|
|
use_power = 1
|
|
|
|
name = "Cold Sink"
|
|
desc = "Cools gas when connected to pipe network"
|
|
|
|
var/on = 0
|
|
|
|
var/current_temperature = T20C
|
|
var/current_heat_capacity = 50000 //totally random
|
|
|
|
/obj/machinery/atmospherics/unary/cold_sink/update_icon()
|
|
if(node)
|
|
icon_state = "intact_[on?("on"):("off")]"
|
|
else
|
|
icon_state = "exposed"
|
|
|
|
on = 0
|
|
|
|
return
|
|
|
|
/obj/machinery/atmospherics/unary/cold_sink/process()
|
|
. = ..()
|
|
if(!on || !network)
|
|
return
|
|
var/air_heat_capacity = air_contents.heat_capacity
|
|
var/combined_heat_capacity = current_heat_capacity + air_heat_capacity
|
|
var/old_temperature = air_contents.temperature
|
|
|
|
if(combined_heat_capacity > 0)
|
|
var/combined_energy = current_temperature*current_heat_capacity + air_heat_capacity*air_contents.temperature
|
|
if(air_contents.temperature > current_temperature) //if it's hotter than we can cool it, cool it
|
|
air_contents.temperature = combined_energy/combined_heat_capacity
|
|
|
|
//todo: have current temperature affected. require power to bring down current temperature again
|
|
|
|
if(abs(old_temperature-air_contents.temperature) > 1)
|
|
network.update = 1
|
|
return 1 |