Disaster Counters

This commit is contained in:
AffectedArc07
2021-02-15 20:47:15 +00:00
parent c7d01c9b57
commit 85ea77d01e
5 changed files with 87 additions and 8 deletions
+2 -2
View File
@@ -81119,10 +81119,10 @@
/turf/simulated/wall/r_wall,
/area/medical/chemistry)
"cXf" = (
/obj/machinery/status_display{
/obj/structure/closet/secure_closet/reagents,
/obj/structure/disaster_counter/chemistry{
pixel_x = -32
},
/obj/structure/closet/secure_closet/reagents,
/turf/simulated/floor/plasteel{
dir = 8;
icon_state = "whitegreen";
@@ -67017,6 +67017,9 @@
/obj/structure/closet/wardrobe/chemistry_white,
/obj/item/storage/backpack/satchel_chem,
/obj/effect/decal/warning_stripes/south,
/obj/structure/disaster_counter/chemistry{
pixel_y = 32
},
/turf/simulated/floor/plasteel{
icon_state = "white"
},
+6 -6
View File
@@ -43596,6 +43596,9 @@
/area/hallway/secondary/entry)
"bLD" = (
/obj/structure/closet/secure_closet/reagents,
/obj/structure/disaster_counter/chemistry{
pixel_x = -32
},
/turf/simulated/floor/plasteel{
dir = 8;
icon_state = "whiteyellow"
@@ -44752,12 +44755,6 @@
/area/medical/reception)
"bNA" = (
/obj/effect/decal/warning_stripes/northeast,
/obj/item/radio/intercom{
frequency = 1459;
name = "station intercom (General)";
pixel_x = -28;
pixel_y = 22
},
/turf/simulated/floor/plasteel,
/area/medical/chemistry)
"bNB" = (
@@ -78694,6 +78691,9 @@
},
/obj/machinery/meter,
/obj/machinery/light,
/obj/structure/disaster_counter/supermatter{
pixel_y = -32
},
/turf/simulated/floor/engine,
/area/engine/engineering)
"cVB" = (
@@ -0,0 +1,75 @@
/**
* # Disaster counter.
*
* Tracks how many shifts it has been since the counter with that ID was exploded.
*/
/obj/structure/disaster_counter
name = "disaster counter"
desc = "This magical device will count up how many shifts it has been since a major disaster in this area."
icon = 'icons/obj/status_display.dmi'
icon_state = "frame"
maptext_y = 10 // Offset by 10 so it renders properly
/// ID of the counter. Must be overriden
var/counter_id
/// Current count number
var/current_count = 0
/obj/structure/disaster_counter/examine(mob/user)
. = ..()
. += "The display reads 'Currently [current_count] shifts without an accident!'"
/obj/structure/disaster_counter/Initialize(mapload)
. = ..()
if(!counter_id)
stack_trace("Disaster counter at [x],[y],[z] does not have a counter_id set. Deleting...")
return INITIALIZE_HINT_QDEL
// If we still exist, put ourselves in
SSpersistent_data.register(src)
/obj/structure/disaster_counter/ex_act(severity)
if(severity < 2)
current_count = -1
persistent_save()
. = ..()
/obj/structure/disaster_counter/Destroy()
if(counter_id)
SSpersistent_data.registered_atoms -= src // Take us out the list
return ..()
/obj/structure/disaster_counter/persistent_load()
// Just incase some bad actor sets the counter ID to "../../../../Windows/System32"
// Yes I am that paranoid
if(counter_id != paranoid_sanitize(counter_id))
stack_trace("Counter ID did not pass sanitization for disaster counter at [x],[y],[z]. Potential attempt at filesystem manipulation.")
qdel(src)
var/savefile/S = new /savefile("data/disaster_counters/[counter_id].sav")
S["count"] >> current_count
if(isnull(current_count))
current_count = 0
else
current_count++ // Increase by 1 since this is the next shift without a disaster (yet)
log_debug("Persistent data for [src] loaded (current_count: [current_count])")
maptext = "<span class='maptext' style='text-align: center'>[current_count]</span>"
/obj/structure/disaster_counter/persistent_save()
if(counter_id != paranoid_sanitize(counter_id))
stack_trace("Counter ID did not pass sanitization for disaster counter at [x],[y],[z]. Potential attempt at filesystem manipulation.")
qdel(src)
var/savefile/S = new /savefile("data/disaster_counters/[counter_id].sav")
S["count"] << current_count
log_debug("Persistent data for [src] saved (current_count: [current_count])")
// Prefab definitions to make mapping easier
/obj/structure/disaster_counter/supermatter
name = "supermatter disaster counter"
counter_id = "supermatter"
/obj/structure/disaster_counter/chemistry
name = "chemistry disaster counter"
counter_id = "chemistry"
+1
View File
@@ -1085,6 +1085,7 @@
#include "code\game\objects\structures\coathanger.dm"
#include "code\game\objects\structures\curtains.dm"
#include "code\game\objects\structures\depot.dm"
#include "code\game\objects\structures\disaster_counter.dm"
#include "code\game\objects\structures\displaycase.dm"
#include "code\game\objects\structures\door_assembly.dm"
#include "code\game\objects\structures\door_assembly_types.dm"