Files
Bubberstation/code/game/objects/effects/spawners/random/maintenance.dm
T
LemonInTheDark 85b2d5043d Optimizes qdel related things (slight init time savings) (#70729)
* Moves spawners and decals to a different init/delete scheme

Rather then fully creating and then immediately deleting these things,
we instead do the bare minimum.

This is faster, if in theory more fragile. We should be safe since any
errors should be caught in compile since this is very close to a
"static" action. It does mean these atoms cannot use signals, etc.

* Potentially saves init time, mostly cleans up a silly pattern

We use sleeps and INVOKE_ASYNC to ensure that handing back turfs doesn't
block a space reservation, but this by nature consumes up to the
threshold and a bit more of whatever working block we were in.

This is silly. Should just be a subsystem, so I made it one, with
support for awaiting its finish if you want to

* Optimizes garbage/proc/Queue slightly

Queue takes about 1.6 seconds to process 26k items right now.
The MASSIVE majority of this time is spent on using \ref
This is because \ref returns a string, and that string requires being
inserted into the global cache of strings we store

What I'm doing is caching the result of ANY \ref on the datum it's
applied to. This ensures previous uses will never decay from the string
tree.

This saves about 0.2 seconds of init
2022-10-30 00:09:15 -07:00

67 lines
2.0 KiB
Plaintext

/obj/effect/spawner/random/maintenance
name = "maintenance loot spawner"
desc = "Come on Lady Luck, spawn me a pair of sunglasses."
icon_state = "loot"
// see code/_globalvars/lists/maintenance_loot.dm for loot table
/obj/effect/spawner/random/maintenance/examine(mob/user)
. = ..()
. += span_info("This spawner has an effective loot count of [get_effective_lootcount()].")
/obj/effect/spawner/random/maintenance/Initialize(mapload)
loot = GLOB.maintenance_loot
return ..()
/obj/effect/spawner/random/maintenance/proc/hide()
invisibility = INVISIBILITY_OBSERVER
alpha = 100
/obj/effect/spawner/random/maintenance/proc/get_effective_lootcount()
var/effective_lootcount = spawn_loot_count
if(HAS_TRAIT(SSstation, STATION_TRAIT_FILLED_MAINT))
effective_lootcount = FLOOR(spawn_loot_count * 1.5, 1)
else if(HAS_TRAIT(SSstation, STATION_TRAIT_EMPTY_MAINT))
effective_lootcount = FLOOR(spawn_loot_count * 0.5, 1)
return effective_lootcount
/obj/effect/spawner/random/maintenance/spawn_loot(lootcount_override)
if(isnull(lootcount_override))
lootcount_override = get_effective_lootcount()
. = ..()
// In addition, closets that are closed will have the maintenance loot inserted inside.
for(var/obj/structure/closet/closet in get_turf(src))
if(!closet.opened)
closet.take_contents()
/obj/effect/spawner/random/maintenance/two
name = "2 x maintenance loot spawner"
spawn_loot_count = 2
/obj/effect/spawner/random/maintenance/three
name = "3 x maintenance loot spawner"
spawn_loot_count = 3
/obj/effect/spawner/random/maintenance/four
name = "4 x maintenance loot spawner"
spawn_loot_count = 4
/obj/effect/spawner/random/maintenance/five
name = "5 x maintenance loot spawner"
spawn_loot_count = 5
/obj/effect/spawner/random/maintenance/six
name = "6 x maintenance loot spawner"
spawn_loot_count = 6
/obj/effect/spawner/random/maintenance/seven
name = "7 x maintenance loot spawner"
spawn_loot_count = 7
/obj/effect/spawner/random/maintenance/eight
name = "8 x maintenance loot spawner"
spawn_loot_count = 8