Files
Bubberstation/code/controllers/subsystem/minor_mapping.dm
SkyratBot b6ffb1e31b [MIRROR] Refactor /turf/var/intact [MDB IGNORE] (#9114)
* Refactor /turf/var/intact (#62331)

Turfs have a variable, intact, which conflates three meanings:

    Determining whether there's something that can be pried out, such as directly with a crowbar or indirectly with a tile stack and a crowbar off-hand.
    Determining whether underfloor pieces are visible.
    Determining whether underfloor pieces can be interacted with - by players with tools, through interaction with effects like chemical acid, or foam.

When plating is hit with a stack of tiles, /turf/open/floor/attackby checks whether the turf is intact, and if so, ends the attack chain regardless of whether or not the attempt to hotswap a turf (with a crowbar) is successful or not. However, turfs which want the underfloor to be visible - such as catwalks and glass - set the intact variable to FALSE, and so can be repeatedly placed over one another, as if they were the first tile to be placed over the plating.

This refactors /turf/var/intact into two distinct variables:

    /turf/var/overfloor_placed, for whether or not there is something over plating.
    /turf/var/underfloor_visible, for whether or not the various underfloor pieces should be invisible, visible, or both visible and interactable.

All references to /turf/var/intact have been replaced with an equivalent overfloor_placed or underfloor_visible reference, depending on which check is appropriate. underfloor_accessibility can take one of UNDERFLOOR_HIDDEN, UNDERFLOOR_VISIBLE, or UNDERFLOOR_INTERACTABLE. This prevents cases such as acid foam or tools phasing through glass floors to affect the underfloor pieces underneath, and covers all kinds of unusual, not-wiring-visiblity usage such as Holodeck completeness, Revenant interaction, or station integrity checking.

* Refactor /turf/var/intact

* Thank

Co-authored-by: esainane <esainane+github@gmail.com>
Co-authored-by: Funce <funce.973@gmail.com>
2021-10-30 00:19:21 +13:00

72 lines
1.9 KiB
Plaintext

#define PROB_MOUSE_SPAWN 98
SUBSYSTEM_DEF(minor_mapping)
name = "Minor Mapping"
init_order = INIT_ORDER_MINOR_MAPPING
flags = SS_NO_FIRE
/datum/controller/subsystem/minor_mapping/Initialize(timeofday)
trigger_migration(CONFIG_GET(number/mice_roundstart))
place_satchels()
return ..()
/datum/controller/subsystem/minor_mapping/proc/trigger_migration(num_mice=10)
var/list/exposed_wires = find_exposed_wires()
var/mob/living/simple_animal/mouse/mouse
var/turf/open/proposed_turf
while((num_mice > 0) && exposed_wires.len)
proposed_turf = pick_n_take(exposed_wires)
if(!istype(proposed_turf))
continue
if(prob(PROB_MOUSE_SPAWN))
if(!mouse)
mouse = new(proposed_turf)
else
mouse.forceMove(proposed_turf)
else
mouse = new /mob/living/simple_animal/hostile/regalrat/controlled(proposed_turf)
if(proposed_turf.air.has_gas(/datum/gas/oxygen, 5))
num_mice -= 1
mouse = null
/datum/controller/subsystem/minor_mapping/proc/place_satchels(amount=10)
var/list/turfs = find_satchel_suitable_turfs()
while(turfs.len && amount > 0)
var/turf/T = pick_n_take(turfs)
var/obj/item/storage/backpack/satchel/flat/F = new(T)
SEND_SIGNAL(F, COMSIG_OBJ_HIDE, T.underfloor_accessibility < UNDERFLOOR_VISIBLE)
amount--
/proc/find_exposed_wires()
var/list/exposed_wires = list()
var/list/all_turfs
for(var/z in SSmapping.levels_by_trait(ZTRAIT_STATION))
all_turfs += block(locate(1,1,z), locate(world.maxx,world.maxy,z))
for(var/turf/open/floor/plating/T in all_turfs)
if(T.is_blocked_turf())
continue
if(locate(/obj/structure/cable) in T)
exposed_wires += T
return shuffle(exposed_wires)
/proc/find_satchel_suitable_turfs()
var/list/suitable = list()
for(var/z in SSmapping.levels_by_trait(ZTRAIT_STATION))
for(var/t in block(locate(1,1,z), locate(world.maxx,world.maxy,z)))
if(isfloorturf(t) && !isplatingturf(t))
suitable += t
return shuffle(suitable)
#undef PROB_MOUSE_SPAWN