Massive optimization for sink objective. (#11563)

This commit is contained in:
Putnam3145
2020-03-22 05:01:36 -07:00
committed by GitHub
parent 7744e34b79
commit ab1274c832
2 changed files with 13 additions and 10 deletions

View File

@@ -41,16 +41,9 @@
var/count = 0 var/count = 0
/datum/sabotage_objective/processing/power_sink/check_condition_processing() /datum/sabotage_objective/processing/power_sink/check_condition_processing()
count += 1 for(var/s in GLOB.power_sinks)
if(count==10 || sink_found) // doesn't need to fire that often unless a sink exists var/obj/item/powersink/sink = s
var/sink_found_this_time = FALSE
for(var/datum/powernet/PN in GLOB.powernets)
for(var/obj/item/powersink/sink in PN.nodes)
sink_found_this_time = TRUE
won = max(won,sink.power_drained/1e8) won = max(won,sink.power_drained/1e8)
sink_found = sink_found_this_time
count = 0
return FALSE
/obj/item/paper/guides/antag/supermatter_sabotage /obj/item/paper/guides/antag/supermatter_sabotage
info = "Ways to sabotage a supermatter:<br>\ info = "Ways to sabotage a supermatter:<br>\

View File

@@ -1,5 +1,7 @@
// Powersink - used to drain station power // Powersink - used to drain station power
GLOBAL_LIST_EMPTY(power_sinks)
/obj/item/powersink /obj/item/powersink
desc = "A nulling power sink which drains energy from electrical systems." desc = "A nulling power sink which drains energy from electrical systems."
name = "power sink" name = "power sink"
@@ -26,6 +28,14 @@
var/obj/structure/cable/attached // the attached cable var/obj/structure/cable/attached // the attached cable
/obj/item/powersink/Initialize()
. = ..()
GLOB.power_sinks += src
/obj/item/powersink/Destroy()
GLOB.power_sinks -= src
. = ..()
/obj/item/powersink/update_icon_state() /obj/item/powersink/update_icon_state()
icon_state = "powersink[mode == OPERATING]" icon_state = "powersink[mode == OPERATING]"