mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-10 02:16:05 +00:00
Optimization to canister's update_icon
Shamelessly rips off the APC's sweet ass method of dealing with overlay updates in update_icon and applies them to canisters, helping with the odd occasion where canister's starting chewing through cpu cycles.
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
#define OVERLAY_HOLDING 1
|
||||
#define OVERLAY_CONNECTED 2
|
||||
#define OVERLAY_NO_PRESSURE 4
|
||||
#define OVERLAY_LOW_PRESSURE 8
|
||||
#define OVERLAY_MEDIUM_PRESSURE 16
|
||||
#define OVERLAY_HIGH_PRESSURE 32
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister
|
||||
name = "canister"
|
||||
icon = 'icons/obj/atmos.dmi'
|
||||
@@ -11,6 +18,7 @@
|
||||
var/release_pressure = ONE_ATMOSPHERE
|
||||
|
||||
var/canister_color = "yellow"
|
||||
var/old_color = 0
|
||||
var/can_label = 1
|
||||
var/filled = 0.5 // Mapping var: Set to 0 for empty, 1 to full, anywhere between.
|
||||
pressure_resistance = 7*ONE_ATMOSPHERE
|
||||
@@ -23,8 +31,18 @@
|
||||
w_type = RECYK_METAL
|
||||
melt_temperature = MELTPOINT_STEEL
|
||||
|
||||
//Icon Update Code
|
||||
var/global/status_overlays = 0
|
||||
var/global/list/status_overlays_pressure
|
||||
var/global/list/status_overlays_other
|
||||
var/overlay_status = 0
|
||||
|
||||
var/log="" // Bad boys, bad boys.
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/New()
|
||||
..()
|
||||
old_color = canister_color
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/sleeping_agent
|
||||
name = "Canister: \[N2O\]"
|
||||
icon_state = "redws"
|
||||
@@ -62,33 +80,76 @@
|
||||
can_label = 0
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/update_icon()
|
||||
overlays = null
|
||||
|
||||
if(destroyed)
|
||||
icon_state = "[canister_color]-1"
|
||||
else
|
||||
icon_state = canister_color
|
||||
overlays = new/list()
|
||||
return
|
||||
|
||||
if (holding)
|
||||
overlays.Add("can-open")
|
||||
if(!status_overlays)
|
||||
status_overlays = 1
|
||||
|
||||
if (connected_port)
|
||||
overlays.Add("can-connector")
|
||||
status_overlays_pressure = new
|
||||
status_overlays_other = new
|
||||
|
||||
status_overlays_pressure.len = 4
|
||||
status_overlays_other.len = 2
|
||||
|
||||
status_overlays_pressure[1] = image(icon, "can-o0")
|
||||
status_overlays_pressure[2] = image(icon, "can-o1")
|
||||
status_overlays_pressure[3] = image(icon, "can-o2")
|
||||
status_overlays_pressure[4] = image(icon, "can-o3")
|
||||
|
||||
status_overlays_other[1] = image(icon, "can-open")
|
||||
status_overlays_other[2] = image(icon, "can-connector")
|
||||
|
||||
if (canister_color != old_color)
|
||||
icon_state = "[canister_color]"
|
||||
old_color = canister_color
|
||||
|
||||
var/tank_pressure = air_contents.return_pressure()
|
||||
if(check_updates(tank_pressure))
|
||||
if(overlays.len)
|
||||
overlays = 0
|
||||
|
||||
if (tank_pressure < 10)
|
||||
overlays.Add("can-o0")
|
||||
else if (tank_pressure < ONE_ATMOSPHERE)
|
||||
overlays.Add("can-o1")
|
||||
else if (tank_pressure < 15 * ONE_ATMOSPHERE)
|
||||
overlays.Add("can-o2")
|
||||
overlay_status = 0
|
||||
|
||||
if (holding)
|
||||
overlays += status_overlays_other[1]
|
||||
overlay_status |= OVERLAY_HOLDING
|
||||
|
||||
if (connected_port)
|
||||
overlays += status_overlays_other[2]
|
||||
overlay_status |= OVERLAY_CONNECTED
|
||||
|
||||
switch(tank_pressure)
|
||||
if(15 * ONE_ATMOSPHERE to INFINITY)
|
||||
overlays += status_overlays_pressure[4]
|
||||
overlay_status |= OVERLAY_HIGH_PRESSURE
|
||||
if(ONE_ATMOSPHERE to 15 * ONE_ATMOSPHERE)
|
||||
overlays += status_overlays_pressure[3]
|
||||
overlay_status |= OVERLAY_MEDIUM_PRESSURE
|
||||
if(10 to ONE_ATMOSPHERE)
|
||||
overlays += status_overlays_pressure[2]
|
||||
overlay_status |= OVERLAY_LOW_PRESSURE
|
||||
else
|
||||
overlays.Add("can-o3")
|
||||
|
||||
overlays += status_overlays_pressure[1]
|
||||
overlay_status |= OVERLAY_NO_PRESSURE
|
||||
return
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/proc/check_updates(tank_pressure = 0)
|
||||
if((overlay_status & OVERLAY_HOLDING) != holding)
|
||||
return 1
|
||||
if((overlay_status & OVERLAY_CONNECTED) != connected_port)
|
||||
return 1
|
||||
if((overlay_status & OVERLAY_HIGH_PRESSURE) && tank_pressure < 15*ONE_ATMOSPHERE)
|
||||
return 1
|
||||
if((overlay_status & OVERLAY_MEDIUM_PRESSURE) && (tank_pressure < ONE_ATMOSPHERE || tank_pressure > 15*ONE_ATMOSPHERE))
|
||||
return 1
|
||||
if((overlay_status & OVERLAY_LOW_PRESSURE) && (tank_pressure < 10 || tank_pressure > ONE_ATMOSPHERE))
|
||||
return 1
|
||||
if((overlay_status & OVERLAY_NO_PRESSURE) && tank_pressure > 10)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume)
|
||||
if(exposed_temperature > temperature_resistance)
|
||||
@@ -443,3 +504,10 @@
|
||||
for(var/obj/effect/beam/B in beams)
|
||||
apply_beam_damage(B)
|
||||
healthcheck()
|
||||
|
||||
#undef OVERLAY_HOLDING
|
||||
#undef OVERLAY_CONNECTED
|
||||
#undef OVERLAY_NO_PRESSURE
|
||||
#undef OVERLAY_LOW_PRESSURE
|
||||
#undef OVERLAY_MEDIUM_PRESSURE
|
||||
#undef OVERLAY_HIGH_PRESSURE
|
||||
@@ -254,7 +254,8 @@ var/global/floorIsLava = 0
|
||||
usr << "Error: you are not an admin!"
|
||||
return
|
||||
checkSessionKey()
|
||||
var/cid = input("Type computer ID", "CID", 0)
|
||||
var/cid = input("Type computer ID", "CID", 0) as num | null
|
||||
if(cid)
|
||||
usr << link(getVGPanel("rapsheet",admin=1,query=list("cid"=cid)))
|
||||
//usr << link("[config.vgws_base_url]/index.php/rapsheet/?s=[sessKey]&cid=[cid]")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user