mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-27 15:17:01 +01:00
Add local APC cache to /area (#61655)
About The Pull Request for(var/obj/machinery/power/apc/APC in GLOB.apcs_list) in get_apc makes chuck norris shed a tear Why It's Good For The Game tears are bad Changelog cl code: /area now retains a local reference to the APC in the area, if any /cl
This commit is contained in:
@@ -51,6 +51,8 @@
|
||||
/// This gets overridden to 1 for space in area/.
|
||||
var/always_unpowered = FALSE
|
||||
|
||||
var/obj/machinery/power/apc/apc = null
|
||||
|
||||
var/power_equip = TRUE
|
||||
var/power_light = TRUE
|
||||
var/power_environ = TRUE
|
||||
|
||||
@@ -93,7 +93,7 @@
|
||||
return
|
||||
var/turf/T = get_turf(on_wall) //the user is not where it needs to be.
|
||||
var/area/A = get_area(user)
|
||||
if(A.get_apc())
|
||||
if(A.apc)
|
||||
to_chat(user, span_warning("This area already has an APC!"))
|
||||
return //only one APC per area
|
||||
if(!A.requires_power)
|
||||
|
||||
@@ -1,51 +1,50 @@
|
||||
/mob/living/silicon/ai/Life(delta_time = SSMOBS_DT, times_fired)
|
||||
if (stat == DEAD)
|
||||
return
|
||||
else //I'm not removing that shitton of tabs, unneeded as they are. -- Urist
|
||||
//Being dead doesn't mean your temperature never changes
|
||||
//Being dead doesn't mean your temperature never changes
|
||||
|
||||
update_gravity(mob_has_gravity())
|
||||
update_gravity(mob_has_gravity())
|
||||
|
||||
handle_status_effects(delta_time, times_fired)
|
||||
handle_status_effects(delta_time, times_fired)
|
||||
|
||||
handle_traits(delta_time, times_fired)
|
||||
handle_traits(delta_time, times_fired)
|
||||
|
||||
if(malfhack?.aidisabled)
|
||||
deltimer(malfhacking)
|
||||
// This proc handles cleanup of screen notifications and
|
||||
// messenging the client
|
||||
malfhacked(malfhack)
|
||||
if(malfhack?.aidisabled)
|
||||
deltimer(malfhacking)
|
||||
// This proc handles cleanup of screen notifications and
|
||||
// messenging the client
|
||||
malfhacked(malfhack)
|
||||
|
||||
if(isturf(loc) && (QDELETED(eyeobj) || !eyeobj.loc))
|
||||
view_core()
|
||||
if(isturf(loc) && (QDELETED(eyeobj) || !eyeobj.loc))
|
||||
view_core()
|
||||
|
||||
if(machine)
|
||||
machine.check_eye(src)
|
||||
if(machine)
|
||||
machine.check_eye(src)
|
||||
|
||||
// Handle power damage (oxy)
|
||||
if(aiRestorePowerRoutine)
|
||||
// Lost power
|
||||
if (!battery)
|
||||
to_chat(src, span_warning("Your backup battery's output drops below usable levels. It takes only a moment longer for your systems to fail, corrupted and unusable."))
|
||||
adjustOxyLoss(200)
|
||||
else
|
||||
battery--
|
||||
// Handle power damage (oxy)
|
||||
if(aiRestorePowerRoutine)
|
||||
// Lost power
|
||||
if (!battery)
|
||||
to_chat(src, span_warning("Your backup battery's output drops below usable levels. It takes only a moment longer for your systems to fail, corrupted and unusable."))
|
||||
adjustOxyLoss(200)
|
||||
else
|
||||
// Gain Power
|
||||
if (battery < 200)
|
||||
battery++
|
||||
battery--
|
||||
else
|
||||
// Gain Power
|
||||
if (battery < 200)
|
||||
battery++
|
||||
|
||||
if(!lacks_power())
|
||||
var/area/home = get_area(src)
|
||||
if(home.powered(AREA_USAGE_EQUIP))
|
||||
home.use_power(500 * delta_time, AREA_USAGE_EQUIP)
|
||||
if(!lacks_power())
|
||||
var/area/home = get_area(src)
|
||||
if(home.powered(AREA_USAGE_EQUIP))
|
||||
home.use_power(500 * delta_time, AREA_USAGE_EQUIP)
|
||||
|
||||
if(aiRestorePowerRoutine >= POWER_RESTORATION_SEARCH_APC)
|
||||
ai_restore_power()
|
||||
return
|
||||
if(aiRestorePowerRoutine >= POWER_RESTORATION_SEARCH_APC)
|
||||
ai_restore_power()
|
||||
return
|
||||
|
||||
else if(!aiRestorePowerRoutine)
|
||||
ai_lose_power()
|
||||
else if(!aiRestorePowerRoutine)
|
||||
ai_lose_power()
|
||||
|
||||
/mob/living/silicon/ai/proc/lacks_power()
|
||||
var/turf/T = get_turf(src)
|
||||
@@ -118,10 +117,7 @@
|
||||
T = get_turf(src)
|
||||
AIarea = get_area(src)
|
||||
if(AIarea)
|
||||
for (var/obj/machinery/power/apc/APC in AIarea)
|
||||
if (!(APC.machine_stat & BROKEN))
|
||||
theAPC = APC
|
||||
break
|
||||
theAPC = AIarea.apc
|
||||
if (!theAPC)
|
||||
switch(PRP)
|
||||
if(1)
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
var/area/A = get_area(computer) //if the computer isn't directly connected to a wire, attempt to find the APC powering it to pull it's powernet instead
|
||||
if(!A)
|
||||
return
|
||||
local_apc = A.get_apc()
|
||||
local_apc = A.apc
|
||||
if(!local_apc)
|
||||
return
|
||||
if(!local_apc.terminal) //this really shouldn't happen without badminnery.
|
||||
|
||||
@@ -264,6 +264,7 @@
|
||||
area.power_equip = FALSE
|
||||
area.power_environ = FALSE
|
||||
area.power_change()
|
||||
area.apc = null
|
||||
QDEL_NULL(alarm_manager)
|
||||
if(occupier)
|
||||
malfvacate(TRUE)
|
||||
@@ -315,6 +316,11 @@
|
||||
if(auto_name)
|
||||
name = "\improper [get_area_name(area, TRUE)] APC"
|
||||
|
||||
if (area)
|
||||
if (area.apc)
|
||||
WARNING("Duplicate APC created at [AREACOORD(src)]")
|
||||
area.apc = src
|
||||
|
||||
update_appearance()
|
||||
|
||||
make_terminal()
|
||||
@@ -1019,7 +1025,7 @@
|
||||
) \
|
||||
)
|
||||
if(!loud)
|
||||
to_chat(user, span_danger("\The [src] has eee disabled!"))
|
||||
to_chat(user, span_danger("\The [src] has been disabled!"))
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
|
||||
if(!mapload) //sync up nightshift lighting for player made lights
|
||||
var/area/local_area = get_area(src)
|
||||
var/obj/machinery/power/apc/temp_apc = local_area.get_apc()
|
||||
var/obj/machinery/power/apc/temp_apc = local_area.apc
|
||||
nightshift_enabled = temp_apc?.nightshift_lights
|
||||
|
||||
if(start_with_cell && !no_emergency)
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
var/area/A = get_area(src) //if the computer isn't directly connected to a wire, attempt to find the APC powering it to pull it's powernet instead
|
||||
if(!A)
|
||||
return
|
||||
local_apc = A.get_apc()
|
||||
local_apc = A.apc
|
||||
if(!local_apc)
|
||||
return
|
||||
if(!local_apc.terminal) //this really shouldn't happen without badminnery.
|
||||
|
||||
@@ -105,7 +105,7 @@
|
||||
var/obj/machinery/power/apc/local_apc
|
||||
if(!A)
|
||||
return FALSE
|
||||
local_apc = A.get_apc()
|
||||
local_apc = A.apc
|
||||
if(!local_apc)
|
||||
return FALSE
|
||||
if(!local_apc.cell)
|
||||
@@ -134,7 +134,7 @@
|
||||
if(!home.requires_power)
|
||||
return amount //Shuttles get free power, don't ask why
|
||||
|
||||
var/obj/machinery/power/apc/local_apc = home?.get_apc()
|
||||
var/obj/machinery/power/apc/local_apc = home?.apc
|
||||
if(!local_apc)
|
||||
return FALSE
|
||||
var/surplus = local_apc.surplus()
|
||||
@@ -326,7 +326,7 @@
|
||||
var/area/source_area
|
||||
if (isarea(power_source))
|
||||
source_area = power_source
|
||||
power_source = source_area.get_apc()
|
||||
power_source = source_area.apc
|
||||
else if (istype(power_source, /obj/structure/cable))
|
||||
var/obj/structure/cable/Cable = power_source
|
||||
power_source = Cable.powernet
|
||||
@@ -418,8 +418,3 @@
|
||||
C.update_appearance()
|
||||
return C
|
||||
return null
|
||||
|
||||
/area/proc/get_apc()
|
||||
for(var/obj/machinery/power/apc/APC in GLOB.apcs_list)
|
||||
if(APC.area == src)
|
||||
return APC
|
||||
|
||||
Reference in New Issue
Block a user