I fear for my powernet

This commit is contained in:
Ghommie
2019-12-10 15:33:15 +01:00
parent f637e1e060
commit 19a3aca619
36 changed files with 386 additions and 248 deletions
+23 -1
View File
@@ -403,7 +403,6 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
/area/crew_quarters/dorms
name = "Dormitories"
icon_state = "Sleep"
safe = TRUE
/area/crew_quarters/dorms/male
name = "Male Dorm"
@@ -413,6 +412,29 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
name = "Female Dorm"
icon_state = "Sleep"
/area/crew_quarters/dorms/cabin
name = "Dorms Cabin One"
icon_state = "sleep_cabin"
safe = TRUE
/area/crew_quarters/dorms/cabin/two
name = "Dorms Cabin Two"
/area/crew_quarters/dorms/cabin/three
name = "Dorms Cabin Three"
/area/crew_quarters/dorms/cabin/four
name = "Dorms Cabin Four"
/area/crew_quarters/dorms/cabin/five
name = "Dorms Cabin Five"
/area/crew_quarters/dorms/cabin/six
name = "Dorms Cabin Six"
/area/crew_quarters/dorms/cabin/seven
name = "Dorms Cabin Seven"
/area/crew_quarters/rehab_dome
name = "Rehabilitation Dome"
icon_state = "Sleep"
+77 -28
View File
@@ -63,6 +63,15 @@
var/xenobiology_compatible = FALSE //Can the Xenobio management console transverse this area by default?
var/list/canSmoothWithAreas //typecache to limit the areas that atoms in this area can smooth with
/**
* These two vars allow for multiple unique areas to be linked to a master area
* for reasons such as APC powernet nodes, fire alarms and similar, without sacrificing
* their own flags, statuses, variables and uniqueness.
* Friendly reminder: don't varedit area paths, make new typepaths instead.
*/
var/list/area/sub_areas //list of typepaths of the areas you wish to link here, will be replaced with a list of references on mapload.
var/area/master_area //The area we wish to use in place of src for certain actions such as APC area linking.
/*Adding a wizard area teleport list because motherfucking lag -- Urist*/
/*I am far too lazy to make it a proper list of areas so I'll just make it run the usual telepot routine at the start of the game*/
GLOBAL_LIST_EMPTY(teleportlocs)
@@ -121,10 +130,31 @@ GLOBAL_LIST_EMPTY(teleportlocs)
reg_in_areas_in_z()
//so far I'm only implementing it on mapped unique areas, it's easier this way.
if(unique && LAZYLEN(sub_areas))
var/paths = sub_areas.Copy()
sub_areas = null
for(var/type in paths)
var/area/A = GLOB.areas_by_type[type]
if(!A)
/* By chance an area not loaded in the station, ruin or map, let's not bother for now.
WARNING("No area of type [type] found in GLOB.areas_by_type for [src]'s linked areas.")
*/
continue
if(A == src)
WARNING("\"[src]\" area a attempted to link with itself.")
continue
if(A.master_area)
WARNING("[src] attempted to link with [A] while the latter is already linked to another area ([A.master_area]).")
continue
LAZYADD(sub_areas, A)
A.master_area = src
return INITIALIZE_HINT_LATELOAD
/area/LateInitialize()
power_change() // all machines set to current power level, also updates icon
if(!master_area) //we don't want to run it twice.
power_change() // all machines set to current power level, also updates icon
/area/proc/reg_in_areas_in_z()
if(contents.len)
@@ -147,6 +177,19 @@ GLOBAL_LIST_EMPTY(teleportlocs)
/area/Destroy()
if(GLOB.areas_by_type[type] == src)
GLOB.areas_by_type[type] = null
if(master_area)
LAZYREMOVE(master_area, src)
master_area = null
if(sub_areas)
for(var/i in sub_areas)
var/area/A = i
A.master_area = null
sub_areas -= A
if(A.requires_power)
A.power_light = FALSE
A.power_equip = FALSE
A.power_environ = FALSE
INVOKE_ASYNC(A, .proc/power_change)
STOP_PROCESSING(SSobj, src)
return ..()
@@ -212,9 +255,11 @@ GLOBAL_LIST_EMPTY(teleportlocs)
var/datum/computer_file/program/alarm_monitor/p = item
p.cancelAlarm("Atmosphere", src, source)
src.atmosalm = danger_level
return 1
return 0
atmosalm = danger_level
for(var/i in sub_areas)
sub_areas[i].atmosalm = danger_level
return TRUE
return FALSE
/area/proc/ModifyFiredoors(opening)
if(firedoors)
@@ -239,7 +284,7 @@ GLOBAL_LIST_EMPTY(teleportlocs)
return
if (!fire)
set_fire_alarm_effect()
set_fire_alarm_effects(TRUE)
ModifyFiredoors(FALSE)
for(var/item in firealarms)
var/obj/machinery/firealarm/F = item
@@ -262,7 +307,7 @@ GLOBAL_LIST_EMPTY(teleportlocs)
/area/proc/firereset(obj/source)
if (fire)
unset_fire_alarm_effects()
set_fire_alarm_effects(FALSE)
ModifyFiredoors(TRUE)
for(var/item in firealarms)
var/obj/machinery/firealarm/F = item
@@ -298,9 +343,9 @@ GLOBAL_LIST_EMPTY(teleportlocs)
return
//Trigger alarm effect
set_fire_alarm_effect()
set_fire_alarm_effects(TRUE)
//Lockdown airlocks
for(var/obj/machinery/door/DOOR in src)
for(var/obj/machinery/door/DOOR in get_sub_areas_contents(src))
close_and_lock_door(DOOR)
for (var/i in GLOB.silicon_mobs)
@@ -309,23 +354,16 @@ GLOBAL_LIST_EMPTY(teleportlocs)
//Cancel silicon alert after 1 minute
addtimer(CALLBACK(SILICON, /mob/living/silicon.proc/cancelAlarm,"Burglar",src,trigger), 600)
/area/proc/set_fire_alarm_effect()
fire = TRUE
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
for(var/alarm in firealarms)
var/obj/machinery/firealarm/F = alarm
F.update_fire_light(fire)
for(var/obj/machinery/light/L in src)
L.update()
/area/proc/unset_fire_alarm_effects()
fire = FALSE
/area/proc/set_fire_alarm_effects(boolean)
fire = boolean
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
for(var/alarm in firealarms)
var/obj/machinery/firealarm/F = alarm
F.update_fire_light(fire)
for(var/obj/machinery/light/L in src)
L.update()
for(var/i in sub_areas)
sub_areas[i].fire = boolean
/area/proc/updateicon()
var/weather_icon
@@ -370,26 +408,34 @@ GLOBAL_LIST_EMPTY(teleportlocs)
/area/proc/power_change()
for(var/obj/machinery/M in src) // for each machine in the area
M.power_change() // reverify power status (to update icons etc.)
if(sub_areas)
for(var/i in sub_areas)
var/area/A = i
A.power_light = power_light
A.power_equip = power_equip
A.power_environ = power_environ
INVOKE_ASYNC(A, .proc/power_change)
updateicon()
/area/proc/usage(chan)
var/used = 0
switch(chan)
if(LIGHT)
used += used_light
. += used_light
if(EQUIP)
used += used_equip
. += used_equip
if(ENVIRON)
used += used_environ
. += used_environ
if(TOTAL)
used += used_light + used_equip + used_environ
. += used_light + used_equip + used_environ
if(STATIC_EQUIP)
used += static_equip
. += static_equip
if(STATIC_LIGHT)
used += static_light
. += static_light
if(STATIC_ENVIRON)
used += static_environ
return used
. += static_environ
if(sub_areas)
for(var/i in sub_areas)
. += sub_areas[i].usage(chan)
/area/proc/addStaticPower(value, powerchannel)
switch(powerchannel)
@@ -404,6 +450,9 @@ GLOBAL_LIST_EMPTY(teleportlocs)
used_equip = 0
used_light = 0
used_environ = 0
if(sub_areas)
for(var/i in sub_areas)
sub_areas[i].clear_usage()
/area/proc/use_power(amount, chan)
+3 -2
View File
@@ -12,7 +12,7 @@
var/list/skipped_areas = list(/area/engine/engineering, /area/engine/supermatter, /area/engine/atmospherics_engine, /area/ai_monitored/turret_protected/ai)
for(var/area/A in world)
if( !A.requires_power || A.always_unpowered )
if( !A.requires_power || A.always_unpowered || A.master_area)
continue
var/skip = 0
@@ -61,8 +61,9 @@
S.output_attempt = 1
S.update_icon()
S.power_change()
for(var/area/A in world)
if(!istype(A, /area/space) && !istype(A, /area/shuttle) && !istype(A, /area/arrival))
if(!istype(A, /area/space) && !istype(A, /area/shuttle) && !istype(A, /area/arrival) && !A.always_unpowered && !A.master_area)
A.power_light = TRUE
A.power_equip = TRUE
A.power_environ = TRUE
+1 -1
View File
@@ -44,7 +44,7 @@
var/area/a = loc.loc // Gets our locations location, like a dream within a dream
if(!isarea(a))
return
if(a.power_equip == 0) // There's no APC in this area, don't try to cheat power!
if(!a.powered(EQUIP)) // There's no APC in this area, don't try to cheat power!
to_chat(user, "<span class='warning'>[src] blinks red as you try to insert the cell!</span>")
return
if(!user.transferItemToLoc(W,src))
+1 -1
View File
@@ -44,7 +44,7 @@
/obj/machinery/door/firedoor/proc/CalculateAffectingAreas()
remove_from_areas()
affecting_areas = get_adjacent_open_areas(src) | get_area(src)
affecting_areas = get_adjacent_open_areas(src) | get_base_area(src)
for(var/I in affecting_areas)
var/area/A = I
LAZYADD(A.firedoors, src)
+7 -7
View File
@@ -44,7 +44,7 @@
pixel_x = (dir & 3)? 0 : (dir == 4 ? -24 : 24)
pixel_y = (dir & 3)? (dir ==1 ? -24 : 24) : 0
update_icon()
myarea = get_area(src)
myarea = get_base_area(src)
LAZYADD(myarea.firealarms, src)
/obj/machinery/firealarm/Destroy()
@@ -116,14 +116,14 @@
if(!is_operational() && (last_alarm+FIREALARM_COOLDOWN < world.time))
return
last_alarm = world.time
var/area/A = get_area(src)
var/area/A = get_base_area(src)
A.firealert(src)
playsound(src.loc, 'goon/sound/machinery/FireAlarm.ogg', 75)
/obj/machinery/firealarm/proc/reset()
if(!is_operational())
return
var/area/A = get_area(src)
var/area/A = get_base_area(src)
A.firereset(src)
/obj/machinery/firealarm/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \
@@ -142,7 +142,7 @@
else
data["seclevel"] = "green"
var/area/A = get_area(src)
var/area/A = get_base_area(src)
data["alarm"] = A.fire
return data
@@ -306,7 +306,7 @@
/obj/machinery/firealarm/partyalarm/reset()
if (stat & (NOPOWER|BROKEN))
return
var/area/A = get_area(src)
var/area/A = get_base_area(src)
if (!A || !A.party)
return
A.party = FALSE
@@ -315,7 +315,7 @@
/obj/machinery/firealarm/partyalarm/alarm()
if (stat & (NOPOWER|BROKEN))
return
var/area/A = get_area(src)
var/area/A = get_base_area(src)
if (!A || A.party || A.name == "Space")
return
A.party = TRUE
@@ -325,5 +325,5 @@
/obj/machinery/firealarm/partyalarm/ui_data(mob/user)
. = ..()
var/area/A = get_area(src)
var/area/A = get_base_area(src)
.["alarm"] = A && A.party
+1 -1
View File
@@ -53,7 +53,7 @@
//Checks to make sure he's not in space doing it, and that the area got proper power.
var/area/a = get_area(src)
if(!isarea(a) || a.power_equip == 0)
if(!a || !a.powered(EQUIP))
to_chat(user, "<span class='notice'>[src] blinks red as you try to insert [G].</span>")
return 1
@@ -283,7 +283,7 @@
/obj/item/mecha_parts/mecha_equipment/tesla_energy_relay/proc/get_charge()
if(equip_ready) //disabled
return
var/area/A = get_area(chassis)
var/area/A = get_base_area(chassis)
var/pow_chan = get_power_channel(A)
if(pow_chan)
return 1000 //making magic
@@ -328,7 +328,7 @@
occupant_message("No powercell detected.")
return
if(cur_charge < chassis.cell.maxcharge)
var/area/A = get_area(chassis)
var/area/A = get_base_area(chassis)
if(A)
var/pow_chan
for(var/c in list(EQUIP,ENVIRON,LIGHT))
@@ -126,7 +126,7 @@
T.PlaceOnTop(/turf/open/floor/plating/foam)
for(var/direction in GLOB.cardinals)
var/turf/cardinal_turf = get_step(T, direction)
if(get_area(cardinal_turf) != get_area(T)) //We're at an area boundary, so let's block off this turf!
if(get_base_area(cardinal_turf) != get_area(T)) //We're at an area boundary, so let's block off this turf!
new/obj/structure/foamedmetal(T)
break
flick("[icon_state]-disolve", src)
+2 -2
View File
@@ -425,7 +425,7 @@
/obj/item/toy/crayon/proc/can_claim_for_gang(mob/user, atom/target)
// Check area validity.
// Reject space, player-created areas, and non-station z-levels.
var/area/A = get_area(target)
var/area/A = get_base_area(target)
if(!A || (!is_station_level(A.z)) || !A.valid_territory)
to_chat(user, "<span class='warning'>[A] is unsuitable for tagging.</span>")
return FALSE
@@ -459,7 +459,7 @@
qdel(old_marking)
var/datum/antagonist/gang/G = user.mind.has_antag_datum(/datum/antagonist/gang)
var/area/territory = get_area(target)
var/area/territory = get_base_area(target)
new /obj/effect/decal/cleanable/crayon/gang(target,G.gang,"graffiti",0,user) // Heres the gang tag.
to_chat(user, "<span class='notice'>You tagged [territory] for your gang!</span>")
+1 -1
View File
@@ -52,7 +52,7 @@
var/area/A = get_area(src)
if(!A.blob_allowed)
return FALSE
if(!A.power_equip)
if(!A.powered(EQUIP))
return FALSE
if(!SSmapping.level_trait(T.z,ZTRAIT_STATION))
return FALSE
+1 -1
View File
@@ -80,7 +80,7 @@
/obj/structure/displaycase/proc/trigger_alarm()
//Activate Anti-theft
if(alert)
var/area/alarmed = get_area(src)
var/area/alarmed = get_base_area(src)
alarmed.burglaralert(src)
playsound(src, 'sound/effects/alert.ogg', 50, 1)