Skip to content

Commit

Permalink
Airlock mapping helpers & Some updates (#513)
Browse files Browse the repository at this point in the history
* Airlock mapping helpers & Some updates

* Multi-tile door unres overlay
  • Loading branch information
EgorDinamit authored Jan 28, 2024
1 parent ace46c9 commit df62612
Show file tree
Hide file tree
Showing 10 changed files with 191 additions and 42 deletions.
3 changes: 2 additions & 1 deletion baystation12.dme
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@
#include "code\datums\vote\restart.dm"
#include "code\datums\vote\transfer.dm"
#include "code\datums\vote\vote.dm"
#include "code\datums\wires\_wires.dm"
#include "code\datums\wires\airlock.dm"
#include "code\datums\wires\alarm.dm"
#include "code\datums\wires\apc.dm"
Expand All @@ -565,7 +566,6 @@
#include "code\datums\wires\taperecorder.dm"
#include "code\datums\wires\vending.dm"
#include "code\datums\wires\wire_description.dm"
#include "code\datums\wires\wires.dm"
#include "code\game\atoms.dm"
#include "code\game\atoms_fluids.dm"
#include "code\game\atoms_health.dm"
Expand Down Expand Up @@ -909,6 +909,7 @@
#include "code\game\objects\effects\item_pickup_ghost.dm"
#include "code\game\objects\effects\landmarks.dm"
#include "code\game\objects\effects\manifest.dm"
#include "code\game\objects\effects\mapping_helpers.dm"
#include "code\game\objects\effects\mines.dm"
#include "code\game\objects\effects\misc.dm"
#include "code\game\objects\effects\overlays.dm"
Expand Down
11 changes: 6 additions & 5 deletions code/__defines/__renderer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,12 @@
//OBJ
#define BELOW_DOOR_LAYER 2.18
#define OPEN_DOOR_LAYER 2.19
#define BELOW_TABLE_LAYER 2.20
#define TABLE_LAYER 2.21
#define BELOW_OBJ_LAYER 2.22
#define STRUCTURE_LAYER 2.23
#define ABOVE_STRUCTURE_LAYER 2.24
#define DOOR_HELPER_LAYER 2.20 //keep this above OPEN_DOOR_LAYER
#define BELOW_TABLE_LAYER 2.21
#define TABLE_LAYER 2.22
#define BELOW_OBJ_LAYER 2.23
#define STRUCTURE_LAYER 2.24
#define ABOVE_STRUCTURE_LAYER 2.25
// OBJ_LAYER 3
#define ABOVE_OBJ_LAYER 3.01
#define CLOSED_DOOR_LAYER 3.02
Expand Down
File renamed without changes.
120 changes: 91 additions & 29 deletions code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ var/list/airlock_overlays = list()
var/door_crush_damage = DOOR_CRUSH_DAMAGE
var/obj/item/airlock_brace/brace = null

/// Direction to the nearest airlock that will be linked for cycling
var/cycle_link_dir = 0
var/obj/machinery/door/airlock/cycle_link_airlock

//Airlock 2.0 Aesthetics Properties
//The variables below determine what color the airlock and decorative stripes will be -Cakey
var/airlock_type = "Standard"
Expand All @@ -91,6 +95,7 @@ var/list/airlock_overlays = list()
var/sparks_broken_file = 'icons/obj/doors/station/sparks_broken.dmi'
var/welded_file = 'icons/obj/doors/station/welded.dmi'
var/emag_file = 'icons/obj/doors/station/emag.dmi'
var/unres_file = 'icons/obj/doors/station/unres.dmi'

uncreated_component_parts = list(
/obj/item/stock_parts/radio/receiver,
Expand Down Expand Up @@ -440,7 +445,7 @@ About the new airlock wires panel:
* one wire for controlling door speed. When active, dor closes at normal rate. When cut, door does not close manually. When pulsed, door attempts to close every tick.
*/

/obj/machinery/door/airlock/bumpopen(mob/living/user as mob) //Airlocks now zap you when you 'bump' them open when they're electrified. --NeoFite
/obj/machinery/door/airlock/bumpopen(mob/living/user) //Airlocks now zap you when you 'bump' them open when they're electrified. --NeoFite
if(!issilicon(usr))
if(src.isElectrified())
if(!src.justzap)
Expand All @@ -457,14 +462,17 @@ About the new airlock wires panel:
user.adjustHalLoss(20)
user.Weaken(5)
return
..(user)
if(cycle_link_airlock)
if(allowed(user))
if(cycle_link_airlock.operating)
cycle_link_airlock.delayed_close_requested = TRUE
else
addtimer(CALLBACK(cycle_link_airlock, .proc/close), 2)
return ..()

/obj/machinery/door/airlock/proc/set_justzap(val)
justzap = val

/obj/machinery/door/airlock/bumpopen(mob/living/simple_animal/user as mob)
..(user)

/obj/machinery/door/airlock/proc/isElectrified()
if(src.electrified_until != 0)
return 1
Expand Down Expand Up @@ -750,6 +758,7 @@ About the new airlock wires panel:
overlays += lights_overlay
overlays += sparks_overlay
overlays += damage_overlay
CheckUnres()

/obj/machinery/door/airlock/do_animate(animation)
if(overlays)
Expand Down Expand Up @@ -1225,9 +1234,9 @@ About the new airlock wires panel:
s.set_up(5, 1, src)
s.start()

/obj/machinery/door/airlock/open(var/forced=0)
/obj/machinery/door/airlock/open(forced = FALSE)
if(!can_open(forced))
return 0
return FALSE
use_power_oneoff(360) //360 W seems much more appropriate for an actuator moving an industrial door capable of crushing people

//if the door is unpowered then it doesn't make sense to hear the woosh of a pneumatic actuator
Expand All @@ -1240,32 +1249,32 @@ About the new airlock wires panel:
src.closeOther.close()
return ..()

/obj/machinery/door/airlock/can_open(var/forced=0)
/obj/machinery/door/airlock/can_open(forced = FALSE)
if(brace)
return 0
return FALSE

if(!forced)
if(!arePowerSystemsOn() || isWireCut(AIRLOCK_WIRE_OPEN_DOOR))
return 0
return FALSE

if(locked || welded)
return 0
return FALSE
return ..()

/obj/machinery/door/airlock/can_close(var/forced=0)
if(locked || welded)
return 0
return FALSE

if(!forced)
//despite the name, this wire is for general door control.
if(!arePowerSystemsOn() || isWireCut(AIRLOCK_WIRE_OPEN_DOOR))
return 0
return FALSE

return ..()

/obj/machinery/door/airlock/close(var/forced=0)
/obj/machinery/door/airlock/close(forced = FALSE)
if(!can_close(forced))
return 0
return FALSE

if(safe)
for(var/turf/turf in locs)
Expand Down Expand Up @@ -1293,43 +1302,45 @@ About the new airlock wires panel:
else
playsound(src.loc, close_sound_unpowered, 100, 1)

..()
return ..()

/obj/machinery/door/airlock/proc/lock(var/forced=0)
/obj/machinery/door/airlock/proc/lock(forced = FALSE)
if(locked)
return 0
return FALSE

if (operating && !forced) return 0
if(operating && !forced)
return FALSE

if (lock_cut_state == BOLTS_CUT) return 0 //what bolts?
if(lock_cut_state == BOLTS_CUT)
return FALSE //what bolts?

src.locked = 1
locked = TRUE
playsound(src, bolts_dropping, 30, 0, -6)
audible_message("You hear a click from the bottom of the door.", hearing_distance = 1)
update_icon()
return 1
return TRUE

/obj/machinery/door/airlock/proc/unlock(var/forced=0)
if(!src.locked)
/obj/machinery/door/airlock/proc/unlock(forced = FALSE)
if(!locked)
return

if (!forced)
if(operating || !src.arePowerSystemsOn() || isWireCut(AIRLOCK_WIRE_DOOR_BOLTS))
return

src.locked = 0
src.locked = FALSE
playsound(src, bolts_rising, 30, 0, -6)
audible_message("You hear a click from the bottom of the door.", hearing_distance = 1)
update_icon()
return 1
return TRUE

/obj/machinery/door/airlock/proc/toggle_lock(var/forced = 0)
/obj/machinery/door/airlock/proc/toggle_lock(forced = FALSE)
return locked ? unlock() : lock()

/obj/machinery/door/airlock/allowed(mob/M)
if(locked)
return 0
return ..(M)
return FALSE
return ..()

/obj/machinery/door/airlock/New(var/newloc, var/obj/structure/door_assembly/assembly=null)
..()
Expand Down Expand Up @@ -1399,9 +1410,18 @@ About the new airlock wires panel:
window_color = window_material.icon_colour
. = ..()

/obj/machinery/door/airlock/LateInitialize()
. = ..()
if(cycle_link_dir)
CycleLinkAirlock()

/obj/machinery/door/airlock/Destroy()
if(brace)
qdel(brace)
if(cycle_link_airlock)
if(cycle_link_airlock.cycle_link_airlock == src)
cycle_link_airlock.cycle_link_airlock = null
cycle_link_airlock = null
return ..()

/obj/machinery/door/airlock/create_electronics(var/electronics_type = /obj/item/airlock_electronics)
Expand Down Expand Up @@ -1475,6 +1495,48 @@ About the new airlock wires panel:
window_color = GLASS_COLOR
update_icon()

/obj/machinery/door/airlock/proc/CycleLinkAirlock()
if(cycle_link_airlock)
cycle_link_airlock.cycle_link_airlock = null
cycle_link_airlock = null
if(!cycle_link_dir)
return
var/limit = world.view
var/turf/T = get_turf(src)
var/obj/machinery/door/airlock/found_door
do
T = get_step(T, cycle_link_dir)
found_door = locate() in T
if(found_door && found_door.cycle_link_dir != get_dir(found_door, src))
found_door = null
limit--
while(!found_door && limit)
if(!found_door)
log_warning("[src] at [get_log_info_line(src)] failed to find a valid airlock to cyclelink with!")
return
found_door.cycle_link_airlock = src
cycle_link_airlock = found_door

// Unrestricted sides. This overlay indicates which directions the player can access even without an ID
/obj/machinery/door/airlock/proc/CheckUnres()
if(arePowerSystemsOn() && unres_sides)
if(unres_sides & NORTH)
var/image/I = image(icon = unres_file, icon_state="unres_n")
I.pixel_y = 32
overlays += I
if(unres_sides & SOUTH)
var/image/I = image(icon = unres_file, icon_state="unres_s")
I.pixel_y = -32
overlays += I
if(unres_sides & EAST)
var/image/I = image(icon = unres_file, icon_state="unres_e")
I.pixel_x = 32
overlays += I
if(unres_sides & WEST)
var/image/I = image(icon = unres_file, icon_state="unres_w")
I.pixel_x = -32
overlays += I

// Public access

/decl/public_access/public_method/airlock_toggle_bolts
Expand Down
31 changes: 24 additions & 7 deletions code/game/machinery/doors/door.dm
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@

var/autoset_access = TRUE // Determines whether the door will automatically set its access from the areas surrounding it. Can be used for mapping.

/// TRUE means the door will automatically close the next time it's opened.
var/delayed_close_requested = FALSE

/// Unrestricted sides. A bitflag for which direction (if any) can open the door with no access
var/unres_sides = 0

// Multi-tile doors
dir = SOUTH
/// Width of the door in tiles.
Expand Down Expand Up @@ -416,7 +422,7 @@
return


/obj/machinery/door/proc/open(var/forced = 0)
/obj/machinery/door/proc/open(forced = FALSE)
set waitfor = FALSE
if(!can_open(forced))
return
Expand All @@ -440,19 +446,22 @@
set_fillers_opacity(0)
operating = 0

if(autoclose)
if(delayed_close_requested)
delayed_close_requested = FALSE
addtimer(CALLBACK(src, .proc/close), 1)
else if(autoclose)
close_door_at = next_close_time()

return 1
return TRUE

/obj/machinery/door/proc/next_close_time()
return world.time + (normalspeed ? 150 : 5)

/obj/machinery/door/proc/close(var/forced = 0)
/obj/machinery/door/proc/close(forced = FALSE)
set waitfor = FALSE
if(!can_close(forced))
return
operating = 1
operating = TRUE

close_door_at = 0
do_animate("closing")
Expand All @@ -470,7 +479,9 @@
set_fillers_opacity(1)
operating = 0

//I shall not add a check every x ticks if a door has closed over some fire.
delayed_close_requested = FALSE

// I shall not add a check every x ticks if a door has closed over some fire.
var/obj/hotspot/fire = locate() in loc
if(fire)
qdel(fire)
Expand All @@ -486,9 +497,15 @@
return 1

/obj/machinery/door/allowed(mob/M)
if(unrestricted_side(M))
return TRUE
if(!requiresID())
return ..(null) //don't care who they are or what they have, act as if they're NOTHING
return ..(M)
return ..()

/// Allows for specific side of airlocks to be unrestrected (IE, can exit maint freely, but need access to enter)
/obj/machinery/door/proc/unrestricted_side(mob/M)
return get_dir(src, M) & unres_sides

/obj/machinery/door/update_nearby_tiles(need_rebuild)
. = ..()
Expand Down
1 change: 1 addition & 0 deletions code/game/machinery/doors/multi_tile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
panel_file = 'icons/obj/doors/double/panel.dmi'
welded_file = 'icons/obj/doors/double/welded.dmi'
emag_file = 'icons/obj/doors/double/emag.dmi'
unres_file = 'icons/obj/doors/double/unres.dmi'
width = 2
appearance_flags = 0
opacity = 1
Expand Down
Loading

0 comments on commit df62612

Please sign in to comment.