Files
Yogstation/code/modules/mapping/mapping_helpers.dm
zxaber ffdb861fb8 [READY] Adds ability to give airlocks one-way unrestricted access (#39147)
* Code to doors.dm for airlocks with unrestricted sides

* Code to airlock_electronics.dm supporting airlocks with unrestricted sides

* Code to door_assembly.dm supporting airlocks with unrestricted sides

* Adding buttons to airlock electronic gui for unrestricted direction access

* Update airlock_electronics.dm

typos in comments are still typos

* Tgui support for arbitrary unrestricted access

* Cleaner way of calling unrestricted_sides()

Moved the call to unrestricted_sides() to run from allowed(), and added a recursive check for if the user is inside an object (like a mech).

* Missed a test variable

* Replaced a block of if statements with get_dir

Re: SpaceManiac

* Simplified XOR operation

Re: SpaceManiac

* Changes order from NESW to NSEW (for get_dir)

Re: SpaceManiac

* Re-built using changes to airlock_electronics.ract

* Added unres overlays, fixes overlay/power actions

Small lights that shine out to indicate open directions. They're not super pretty, but they aren't *that* horrible I think.
Because it's a light, it acts as a weak light source.

Also, all door overlays respond to power changes now, including area power loss. There was code in the overlay section for checking power states, but nothing to actually trigger it outside players opening the panel or something. This was broken before I made any changes.

* Makes overlays respond to power outages

The airlock overlay (bolt lights, etc) would not respond to the area power going out or coming back, even though it had code for it. This was broken before I added my code.

* Makes the Airlock update overlays when built

Long story short, the unres_sides variable wasn't getting set before the airlock spawned and did its first overlay update, meaning the unres indicators would be invisible until the door's state changed the first time. This makes the airlock run the update again just before the construction airlock object is removed.

* overlays.dmi -- removing to replace

I can't just edit the code of an image file, can I?

* new overlay file with the four unres indicators

* Set medical doors to use this feature

Removed medical door buttons, and set the unres variable on Meta, Box, Delta, Pubby, and Omega.

* Revert "Set medical doors to use this feature"

This reverts commit 53122ce63240ff0660226c8d2c6ed7eb814ec054.

* Updates medi-doors in maps

let's try this again...

* Did this tgui.js get overwritten?

juggling too many testing build folders is hard

* reverting momentarily

* Re-adding tgui.js changes

* pushing tgui.css too

Didn't realize this file also got changed by the script

* rebuilt the tgui.js file

* repushing the unchanged tgui.js again

I hope I'm not email-spamming people with this

* .css too

* Re-applying tgui.js changes

* added mapping helpers

little green arrows that set unres settings on airlocks and then poof

* removal of comments

unneeded code

* Adding helpers to all maps

Removed the var edit, as well

* Changed airlock.dm to use defines

Also removed an unneeded "src" from four lines.

* New .js and .css file to fix RPD issue

Boy I love tgui

* Removing define defines

Didn't know these were coded elsewhere. Neat.

* Mapmerged again, as requested

* Clean up maps
2018-08-14 21:13:16 +01:00

212 lines
6.3 KiB
Plaintext

//Landmarks and other helpers which speed up the mapping process and reduce the number of unique instances/subtypes of items/turf/ect
/obj/effect/baseturf_helper //Set the baseturfs of every turf in the /area/ it is placed.
name = "baseturf editor"
icon = 'icons/effects/mapping_helpers.dmi'
icon_state = ""
var/list/baseturf_to_replace
var/baseturf
layer = POINT_LAYER
/obj/effect/baseturf_helper/Initialize()
. = ..()
return INITIALIZE_HINT_LATELOAD
/obj/effect/baseturf_helper/LateInitialize()
if(!baseturf_to_replace)
baseturf_to_replace = typecacheof(/turf/open/space)
else if(!length(baseturf_to_replace))
baseturf_to_replace = list(baseturf_to_replace = TRUE)
else if(baseturf_to_replace[baseturf_to_replace[1]] != TRUE) // It's not associative
var/list/formatted = list()
for(var/i in baseturf_to_replace)
formatted[i] = TRUE
baseturf_to_replace = formatted
var/area/our_area = get_area(src)
for(var/i in get_area_turfs(our_area, z))
replace_baseturf(i)
qdel(src)
/obj/effect/baseturf_helper/proc/replace_baseturf(turf/thing)
var/list/baseturf_cache = thing.baseturfs
if(length(baseturf_cache))
for(var/i in baseturf_cache)
if(baseturf_to_replace[i])
baseturf_cache -= i
else if(baseturf_to_replace[thing.baseturfs])
thing.assemble_baseturfs(baseturf)
return
thing.PlaceOnBottom(null, baseturf)
/obj/effect/baseturf_helper/space
name = "space baseturf editor"
baseturf = /turf/open/space
/obj/effect/baseturf_helper/asteroid
name = "asteroid baseturf editor"
baseturf = /turf/open/floor/plating/asteroid
/obj/effect/baseturf_helper/asteroid/airless
name = "asteroid airless baseturf editor"
baseturf = /turf/open/floor/plating/asteroid/airless
/obj/effect/baseturf_helper/asteroid/basalt
name = "asteroid basalt baseturf editor"
baseturf = /turf/open/floor/plating/asteroid/basalt
/obj/effect/baseturf_helper/asteroid/snow
name = "asteroid snow baseturf editor"
baseturf = /turf/open/floor/plating/asteroid/snow
/obj/effect/baseturf_helper/beach/sand
name = "beach sand baseturf editor"
baseturf = /turf/open/floor/plating/beach/sand
/obj/effect/baseturf_helper/beach/water
name = "water baseturf editor"
baseturf = /turf/open/floor/plating/beach/water
/obj/effect/baseturf_helper/lava
name = "lava baseturf editor"
baseturf = /turf/open/lava/smooth
/obj/effect/baseturf_helper/lava_land/surface
name = "lavaland baseturf editor"
baseturf = /turf/open/lava/smooth/lava_land_surface
/obj/effect/mapping_helpers
icon = 'icons/effects/mapping_helpers.dmi'
icon_state = ""
var/late = FALSE
/obj/effect/mapping_helpers/Initialize()
..()
return late ? INITIALIZE_HINT_LATELOAD : INITIALIZE_HINT_QDEL
//airlock helpers
/obj/effect/mapping_helpers/airlock
layer = DOOR_HELPER_LAYER
/obj/effect/mapping_helpers/airlock/cyclelink_helper
name = "airlock cyclelink helper"
icon_state = "airlock_cyclelink_helper"
/obj/effect/mapping_helpers/airlock/cyclelink_helper/Initialize(mapload)
. = ..()
if(!mapload)
log_world("### MAP WARNING, [src] spawned outside of mapload!")
return
var/obj/machinery/door/airlock/airlock = locate(/obj/machinery/door/airlock) in loc
if(airlock)
if(airlock.cyclelinkeddir)
log_world("### MAP WARNING, [src] at [AREACOORD(src)] tried to set [airlock] cyclelinkeddir, but it's already set!")
else
airlock.cyclelinkeddir = dir
else
log_world("### MAP WARNING, [src] failed to find an airlock at [AREACOORD(src)]")
/obj/effect/mapping_helpers/airlock/locked
name = "airlock lock helper"
icon_state = "airlock_locked_helper"
/obj/effect/mapping_helpers/airlock/locked/Initialize(mapload)
. = ..()
if(!mapload)
log_world("### MAP WARNING, [src] spawned outside of mapload!")
return
var/obj/machinery/door/airlock/airlock = locate(/obj/machinery/door/airlock) in loc
if(airlock)
if(airlock.locked)
log_world("### MAP WARNING, [src] at [AREACOORD(src)] tried to bolt [airlock] but it's already locked!")
else
airlock.locked = TRUE
else
log_world("### MAP WARNING, [src] failed to find an airlock at [AREACOORD(src)]")
/obj/effect/mapping_helpers/airlock/unres
name = "airlock unresctricted side helper"
icon_state = "airlock_unres_helper"
/obj/effect/mapping_helpers/airlock/unres/Initialize(mapload)
. = ..()
if(!mapload)
log_world("### MAP WARNING, [src] spawned outside of mapload!")
return
var/obj/machinery/door/airlock/airlock = locate(/obj/machinery/door/airlock) in loc
if(airlock)
airlock.unres_sides ^= dir
else
log_world("### MAP WARNING, [src] failed to find an airlock at [AREACOORD(src)]")
//needs to do its thing before spawn_rivers() is called
INITIALIZE_IMMEDIATE(/obj/effect/mapping_helpers/no_lava)
/obj/effect/mapping_helpers/no_lava
icon_state = "no_lava"
/obj/effect/mapping_helpers/no_lava/Initialize()
. = ..()
var/turf/T = get_turf(src)
T.flags_1 |= NO_LAVA_GEN_1
/// Adds the map it is on to the z_is_planet list
/obj/effect/mapping_helpers/planet_z
name = "planet z helper"
layer = POINT_LAYER
/obj/effect/mapping_helpers/planet_z/Initialize()
. = ..()
var/datum/space_level/S = SSmapping.get_level(z)
S.traits[ZTRAIT_PLANET] = TRUE
//This helper applies components to things on the map directly.
/obj/effect/mapping_helpers/component_injector
name = "Component Injector"
late = TRUE
var/target_type
var/target_name
var/component_type
//Late init so everything is likely ready and loaded (no warranty)
/obj/effect/mapping_helpers/component_injector/LateInitialize()
if(!ispath(component_type,/datum/component))
CRASH("Wrong component type in [type] - [component_type] is not a component")
var/turf/T = get_turf(src)
for(var/atom/A in T.GetAllContents())
if(A == src)
continue
if(target_name && A.name != target_name)
continue
if(target_type && !istype(A,target_type))
continue
var/cargs = build_args()
A.AddComponent(arglist(cargs))
qdel(src)
return
/obj/effect/mapping_helpers/component_injector/proc/build_args()
return list(component_type)
/obj/effect/mapping_helpers/component_injector/infective
name = "Infective Injector"
icon_state = "component_infective"
component_type = /datum/component/infective
var/disease_type
/obj/effect/mapping_helpers/component_injector/infective/build_args()
if(!ispath(disease_type,/datum/disease))
CRASH("Wrong disease type passed in.")
var/datum/disease/D = new disease_type()
return list(component_type,D)