Skip to content

Commit

Permalink
New mapping helper: Spaceproof/Group directional windows, new maint r…
Browse files Browse the repository at this point in the history
…oom (#10322)

* New mapper, new maint room

* change name

* Update random_rooms.dm

* Update mapping_helpers.dm

* Removes the wrong comment

* things updated

* dmi merge

* rename

* fixes wrong name

* plasteel path update
  • Loading branch information
EvilDragonfiend authored Aug 4, 2024
1 parent dd1df6b commit 65b53bd
Show file tree
Hide file tree
Showing 5 changed files with 375 additions and 2 deletions.
143 changes: 143 additions & 0 deletions _maps/RandomRooms/10x10/sk_rdm176_spacewindowroom.dmm

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 50 additions & 2 deletions code/game/objects/effects/spawners/roomspawner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,61 @@
room_width = 10
room_height = 5
icon_state = "random_room_alternative"
rooms = list("sk_rdm011_barbershop","sk_rdm031_deltarobotics","sk_rdm039_deltaclutter1","sk_rdm040_deltabotnis","sk_rdm045_deltacafeteria","sk_rdm046_deltaarcade","sk_rdm082_maintmedical","sk_rdm091_skidrow","sk_rdm100_meetingroom","sk_rdm105_phage","sk_rdm125_courtroom","sk_rdm126_gaschamber","sk_rdm127_oldaichamber","sk_rdm128_radiationtherapy","sk_rdm150_smallmedlobby","sk_rdm151_ratburger","sk_rdm152_geneticsoffice","sk_rdm153_hobowithpeter","sk_rdm154_butchersden","sk_rdm155_punjiconveyor","sk_rdm156_oldairlock_interchange","sk_rdm161_kilovault")
rooms = list(
"sk_rdm011_barbershop",
"sk_rdm031_deltarobotics",
"sk_rdm039_deltaclutter1",
"sk_rdm040_deltabotnis",
"sk_rdm045_deltacafeteria",
"sk_rdm046_deltaarcade",
"sk_rdm082_maintmedical",
"sk_rdm091_skidrow",
"sk_rdm100_meetingroom",
"sk_rdm105_phage",
"sk_rdm125_courtroom",
"sk_rdm126_gaschamber",
"sk_rdm127_oldaichamber",
"sk_rdm128_radiationtherapy",
"sk_rdm150_smallmedlobby",
"sk_rdm151_ratburger",
"sk_rdm152_geneticsoffice",
"sk_rdm153_hobowithpeter",
"sk_rdm154_butchersden",
"sk_rdm155_punjiconveyor",
"sk_rdm156_oldairlock_interchange",
"sk_rdm161_kilovault")
/obj/effect/spawner/room/special/tenxten_terrestrial
name = "10x10 terrestrial room"
room_width = 10
room_height = 10
icon_state = "random_room_alternative"
rooms = list("sk_rdm033_deltalibrary","sk_rdm060_snakefighter","sk_rdm062_roosterdome","sk_rdm070_pubbybar","sk_rdm083_bigtheatre","sk_rdm098_graffitiroom","sk_rdm102_podrepairbay","sk_rdm106_sanitarium","sk_rdm129_beach","sk_rdm130_benoegg","sk_rdm131_confinementroom","sk_rdm132_conveyorroom","sk_rdm133_oldoffice","sk_rdm134_snowforest","sk_rdm141_6sectorsdown","sk_rdm142_olddiner","sk_rdm143_gamercave","sk_rdm144_smallmagician","sk_rdm145_ladytesla_altar","sk_rdm146_blastdoor_interchange","sk_rdm147_advbotany","sk_rdm148_botany_apiary","sk_rdm157_chess","sk_rdm159_kilosnakepit","sk_rdm167_library_ritual")
rooms = list(
"sk_rdm033_deltalibrary",
"sk_rdm060_snakefighter",
"sk_rdm062_roosterdome",
"sk_rdm070_pubbybar",
"sk_rdm083_bigtheatre",
"sk_rdm098_graffitiroom",
"sk_rdm102_podrepairbay",
"sk_rdm106_sanitarium",
"sk_rdm129_beach",
"sk_rdm130_benoegg",
"sk_rdm131_confinementroom",
"sk_rdm132_conveyorroom",
"sk_rdm133_oldoffice",
"sk_rdm134_snowforest",
"sk_rdm141_6sectorsdown",
"sk_rdm142_olddiner",
"sk_rdm143_gamercave",
"sk_rdm144_smallmagician",
"sk_rdm145_ladytesla_altar",
"sk_rdm146_blastdoor_interchange",
"sk_rdm147_advbotany",
"sk_rdm148_botany_apiary",
"sk_rdm157_chess",
"sk_rdm159_kilosnakepit",
"sk_rdm167_library_ritual",
"sk_rdm176_spacewindowroom")
/obj/effect/spawner/room/fivexfour
name = "5x4 room spawner"
room_width = 5
Expand Down
173 changes: 173 additions & 0 deletions code/modules/mapping/mapping_helpers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -394,3 +394,176 @@ INITIALIZE_IMMEDIATE(/obj/effect/mapping_helpers/no_lava)
qdel(src)
return
CRASH("Failed to find a portable atmospherics or a portables connector at [AREACOORD(src)]")

// This will put directional windows to adjucant turfs if airs will likely be vaccuumed.
// Putting this on a space turf is recommended. If you put this on an open tile, it will place directional windows anyway.
// If a turf is not valid to put a tile, it will automatically make a turf for failsafe.
// NOTE: This helper is specialised for space-proof, not just for standard mapping.
/obj/effect/mapping_helpers/space_window_placer
name = "Placer: Spaceproof directional windows"
icon_state = "space_directional_window_placer"
late = TRUE

/** Mapper options **/
/// Determines which window type it will create
var/window_type = /obj/structure/window/reinforced

/** internal code variables - not for mappers **/
/// used to skip a direction on a turf
var/skip_direction
/// there are a few stuff that "CanAtmosPass()" is not reliable
var/static/list/unliable_atmos_blockers


/obj/effect/mapping_helpers/space_window_placer/Initialize(mapload)
. = ..()
if(!unliable_atmos_blockers)
unliable_atmos_blockers = typecacheof(list(/obj/machinery/door))

/obj/effect/mapping_helpers/space_window_placer/LateInitialize()
. = ..()
if(!z || !x || !y)
CRASH("It's not unable to place Spaceproof directional windoe placer - xyz is null.")

var/turf/my_turf = get_turf(src)
if(!my_turf)
CRASH("Spaceproof directional windoe placer failed to find a turf.")

// checks if turfs are fine to place a directional window
var/unliable_atmos_blocking
for(var/turf/each_turf in get_adjacent_open_turfs(my_turf))
if(isspaceturf(each_turf) || isopenspace(each_turf))
continue

if(!each_turf.CanAtmosPass(my_turf))
for(var/atom/movable/movable_content as anything in each_turf.contents)
if(is_type_in_typecache(movable_content, unliable_atmos_blockers))
unliable_atmos_blocking = TRUE
break
if(unliable_atmos_blocking)
break

var/list/nearby_turfs = list()
for(var/turf/each_turf in get_adjacent_open_turfs(my_turf))
if(unliable_atmos_blocking)
var/obj/effect/mapping_helpers/space_window_placer/nearby_placer = locate() in each_turf
if(nearby_placer) // we don't place windows there + give a value to skip directon
nearby_placer.skip_direction |= get_dir(each_turf, my_turf)
continue
if(skip_direction & get_dir(my_turf, each_turf))
continue
nearby_turfs += each_turf


// well, it's a bad idea to put a directional window here. Mapping failsafe process here.
if(unliable_atmos_blocking && (isspaceturf(my_turf) || isopenspace(my_turf)))
my_turf.PlaceOnTop(list(/turf/open/floor/plating, /turf/open/floor/iron), flags = CHANGETURF_INHERIT_AIR)
for(var/turf/each_turf in nearby_turfs)
if(isspaceturf(each_turf) || isopenspace(each_turf))
var/obj/d_glass = new window_type(my_turf)
d_glass.dir = get_dir(my_turf, each_turf)
else
var/improper_dir = get_dir(each_turf, my_turf)
for(var/obj/structure/window/d_glass in each_turf.contents)
if(d_glass.dir == improper_dir)
qdel(d_glass)
qdel(src)
return

// puts a directional window for each direction.
for(var/turf/each_turf in nearby_turfs)
if(!each_turf.CanAtmosPass(my_turf) || isspaceturf(each_turf) || isopenspace(each_turf))
continue

var/obj/d_glass = new window_type(each_turf)
d_glass.dir = get_dir(d_glass, my_turf)

qdel(src)

/obj/effect/mapping_helpers/group_window_placer
name = "Placer: Grouped directional windows"
icon_state = "group_directional_window_placer"
late = TRUE

/** Mapper options **/
/// Determines which window type it will create.
/// Make a subtype of this mapping helper to change this value instead of manual change in DMM.
var/window_type = /obj/structure/window/reinforced
/// Directional window will not be placed to a direction from the adjacent turf where a fulltile glass exists.
/// If you set this TRUE, the windows will be placed.
var/place_onto_fulltile_window
/// Set TRUE to ignore group chain initialization
var/single

/** internal code variables - not for mappers **/
/// failsafe var to prevent it to run a code
var/to_be_initialized
/// a list of mappers that will be initialized together.
var/list/init_group

/obj/effect/mapping_helpers/group_window_placer/LateInitialize()
. = ..()
if(to_be_initialized)
return

if(!z || !x || !y)
CRASH("It's not unable to use group_window_placer - xyz is null.")

var/turf/my_turf = get_turf(src)
if(!my_turf)
CRASH("group_window_placer failed to find a turf.")

if(single)
to_be_initialized = TRUE
finish_late_init(list(WEAKREF(src)))
return

init_group = list()
build_group(init_group)
finish_late_init()

/obj/effect/mapping_helpers/group_window_placer/proc/build_group(list/chain_init_group)
if(to_be_initialized) // shouldn't reach here but just in case
return
to_be_initialized = TRUE
chain_init_group[WEAKREF(src)] = TRUE
for(var/turf/each_turf in get_adjacent_open_turfs(get_turf(src)))
var/obj/effect/mapping_helpers/group_window_placer/placer = locate() in each_turf
if(!placer || chain_init_group[WEAKREF(placer)] || placer.to_be_initialized)
continue
placer.build_group(chain_init_group)

/obj/effect/mapping_helpers/group_window_placer/proc/finish_late_init()
for(var/datum/weakref/each_ref in init_group)
var/obj/effect/mapping_helpers/group_window_placer/each_placer = each_ref.resolve()
var/turf/my_turf = get_turf(each_placer)
var/list/nearby_turfs = list()
for(var/turf/each_turf in get_adjacent_open_turfs(my_turf))
if(each_turf.density)
continue
if(locate(/obj/effect/mapping_helpers/group_window_placer) in each_turf)
continue
// skip this - that direction should be connected
if(locate(/obj/effect/mapping_helpers/space_window_placer) in each_turf)
continue
// skip this - you won't want to have two directional window in the same directional spot.
// NOTE: this is "SPACE" window placer, not "GROUP"
if(place_onto_fulltile_window)
var/is_fulltile
for(var/obj/structure/window/window_on_turf in my_turf.contents)
if(window_on_turf.fulltile)
is_fulltile = TRUE
break
if(is_fulltile)
continue
nearby_turfs += each_turf

for(var/turf/each_turf in nearby_turfs)
var/obj/d_glass = new each_placer.window_type(my_turf)
d_glass.dir = get_dir(my_turf, each_turf)

for(var/datum/weakref/each_ref in init_group)
var/obj/effect/mapping_helpers/group_window_placer/each_placer = each_ref.resolve()
qdel(each_placer)
init_group.Cut()

Loading

0 comments on commit 65b53bd

Please sign in to comment.