Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCD, Airlock QoL #8195

Merged
merged 12 commits into from
Dec 14, 2023
29 changes: 19 additions & 10 deletions code/__DEFINES/construction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,26 @@
#define CAT_DRINK "Drinks"
#define CAT_STRUCTURE "Structures"


// rcd buildtype defines
#define RCD_FLOORWALL 1
#define RCD_AIRLOCK 2
#define RCD_DECONSTRUCT 3
#define RCD_WINDOWGRILLE 4
#define RCD_LADDER 5
#define RCD_MACHINE 8
#define RCD_COMPUTER 16

#define RCD_UPGRADE_FRAMES (1<<0)
// these aren't even used as bitflags so who even knows why they are treated like them
#define RCD_FLOORWALL (1<<0)
#define RCD_AIRLOCK (1<<1)
#define RCD_DECONSTRUCT (1<<2)
#define RCD_WINDOWGRILLE (1<<3)
#define RCD_MACHINE (1<<4)
#define RCD_COMPUTER (1<<5)
#define RCD_FURNISHING (1<<6)
#define RCD_LADDER (1<<7)

#define RCD_UPGRADE_FRAMES (1<<0)
#define RCD_UPGRADE_SIMPLE_CIRCUITS (1<<1)
#define RCD_UPGRADE_SILO_LINK (1<<2)
#define RCD_UPGRADE_SILO_LINK (1<<2)
#define RCD_UPGRADE_FURNISHING (1<<3)

#define RCD_WINDOW_FULLTILE "full tile"
#define RCD_WINDOW_DIRECTIONAL "directional"
#define RCD_WINDOW_NORMAL "glass"
#define RCD_WINDOW_REINFORCED "reinforced glass"

#define RPD_UPGRADE_UNWRENCH (1<<0)
33 changes: 25 additions & 8 deletions code/game/machinery/doors/airlock.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
var/aiHacking = FALSE
var/closeOtherId //Cyclelinking for airlocks that aren't on the same x or y coord as the target.
var/obj/machinery/door/airlock/closeOther
var/list/obj/machinery/door/airlock/close_others = list()
var/justzap = FALSE
var/obj/item/electronics/airlock/electronics
COOLDOWN_DECLARE(shockCooldown) //Prevents multiple shocks from happening
Expand Down Expand Up @@ -133,8 +134,6 @@
if(frequency)
set_frequency(frequency)

if(closeOtherId != null)
addtimer(CALLBACK(.proc/update_other_id), 5)
if(glass)
airlock_material = "glass"
if(security_level > AIRLOCK_SECURITY_IRON)
Expand Down Expand Up @@ -215,10 +214,12 @@
add_filter("mask_filter", 1, list(type="alpha",icon=mask_file,x=mask_x,y=mask_y))

/obj/machinery/door/airlock/proc/update_other_id()
for(var/obj/machinery/door/airlock/A in GLOB.airlocks)
if(A.closeOtherId == closeOtherId && A != src)
closeOther = A
break
for(var/obj/machinery/door/airlock/Airlock in GLOB.airlocks)
if(Airlock.closeOtherId == closeOtherId && Airlock != src)
if(!(Airlock in close_others))
close_others += Airlock
if(!(src in Airlock.close_others))
Airlock.close_others += src
Tsar-Salat marked this conversation as resolved.
Show resolved Hide resolved

/obj/machinery/door/airlock/proc/cyclelinkairlock()
if (cyclelinkedairlock)
Expand Down Expand Up @@ -382,6 +383,11 @@
if (cyclelinkedairlock.cyclelinkedairlock == src)
cyclelinkedairlock.cyclelinkedairlock = null
cyclelinkedairlock = null
if(close_others) //remove this airlock from the list of every linked airlock
closeOtherId = null
for(var/obj/machinery/door/airlock/otherlock as anything in close_others)
otherlock.close_others -= src
close_others.Cut()
if(id_tag)
for(var/obj/machinery/doorButtons/D in GLOB.machines)
D.removeMe(src)
Expand Down Expand Up @@ -434,8 +440,15 @@
return
if(SEND_SIGNAL(src, COMSIG_AIRLOCK_TOUCHED, user) & COMPONENT_PREVENT_OPEN)
return
if (cyclelinkedairlock)
if (!shuttledocked && !emergency && !cyclelinkedairlock.shuttledocked && !cyclelinkedairlock.emergency && allowed(user))
if(close_others)
for(var/obj/machinery/door/airlock/otherlock as anything in close_others)
if(!shuttledocked && !emergency && !otherlock.shuttledocked && !otherlock.emergency && allowed(user))
if(otherlock.operating)
otherlock.delayed_close_requested = TRUE
else
addtimer(CALLBACK(otherlock, .proc/close), 2)
if(cyclelinkedairlock)
if(!shuttledocked && !emergency && !cyclelinkedairlock.shuttledocked && !cyclelinkedairlock.emergency && allowed(user))
if(cyclelinkedairlock.operating)
cyclelinkedairlock.delayed_close_requested = TRUE
else
Expand Down Expand Up @@ -717,6 +730,10 @@

/obj/machinery/door/airlock/examine(mob/user)
. = ..()
if(closeOtherId)
. += "<span_class='warning'>This airlock cycles on ID: [sanitize(closeOtherId)].</span>"
else if(!closeOtherId)
. += "<span class='warning'>This airlock does not cycle.</span>"
Tsar-Salat marked this conversation as resolved.
Show resolved Hide resolved
if(obj_flags & EMAGGED)
. += "<span class='warning'>Its access panel is smoking slightly.</span>"
if(charge && !panel_open && in_range(user, src))
Expand Down
14 changes: 14 additions & 0 deletions code/game/machinery/doors/airlock_electronics.dm
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
var/one_access = 0
/// Unrestricted sides, or sides of the airlock that will open regardless of access
var/unres_sides = 0
///what name are we passing to the finished airlock
var/passed_name
///what string are we passing to the finished airlock as the cycle ID
var/passed_cycle_id
/// A holder of the electronics, in case of them working as an integrated part
var/holder

Expand Down Expand Up @@ -51,6 +55,8 @@
data["accesses"] = accesses
data["oneAccess"] = one_access
data["unres_direction"] = unres_sides
data["passedName"] = passed_name
data["passedCycleId"] = passed_cycle_id
return data

/obj/item/electronics/airlock/ui_act(action, params)
Expand Down Expand Up @@ -90,6 +96,14 @@
return
accesses -= get_region_accesses(region)
. = TRUE
if("passedName")
var/new_name = trim("[params["passedName"]]", 30)
passed_name = new_name
. = TRUE
if("passedCycleId")
var/new_cycle_id = trim(params["passedCycleId"], 30)
passed_cycle_id = new_cycle_id
. = TRUE
Tsar-Salat marked this conversation as resolved.
Show resolved Hide resolved

/obj/item/electronics/airlock/ui_host()
if(holder)
Expand Down
4 changes: 2 additions & 2 deletions code/game/machinery/doors/door.dm
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@
return TRUE
return ..()

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

/obj/machinery/door/proc/try_to_weld(obj/item/weldingtool/W, mob/user)
return
Expand Down
49 changes: 43 additions & 6 deletions code/game/machinery/doors/windowdoor.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
pass_flags_self = PASSGLASS
CanAtmosPass = ATMOS_PASS_PROC
interaction_flags_machine = INTERACT_MACHINE_WIRES_IF_OPEN | INTERACT_MACHINE_ALLOW_SILICON | INTERACT_MACHINE_OPEN_SILICON | INTERACT_MACHINE_REQUIRES_SILICON | INTERACT_MACHINE_OPEN
network_id = NETWORK_DOOR_AIRLOCKS
var/obj/item/electronics/airlock/electronics = null
var/reinf = 0
var/shards = 2
var/rods = 2
var/cable = 1
var/list/debris = list()

/obj/machinery/door/window/Initialize(mapload, set_dir)
/obj/machinery/door/window/Initialize(mapload, set_dir, unres_sides)
. = ..()
if(set_dir)
setDir(set_dir)
Expand All @@ -38,12 +37,28 @@
if(cable)
debris += new /obj/item/stack/cable_coil(src, cable)

if(unres_sides)
//remove unres_sides from directions it can't be bumped from
switch(dir)
if(NORTH,SOUTH)
unres_sides &= ~EAST
unres_sides &= ~WEST
if(EAST,WEST)
unres_sides &= ~NORTH
unres_sides &= ~SOUTH

src.unres_sides = unres_sides
update_icon()

var/static/list/loc_connections = list(
COMSIG_ATOM_EXIT = .proc/on_exit,
)

AddElement(/datum/element/connect_loc, loc_connections)
RegisterSignal(src, COMSIG_COMPONENT_NTNET_RECEIVE, .proc/ntnet_receive)

/obj/machinery/door/window/ComponentInitialize()
. = ..()
AddComponent(/datum/component/ntnet_interface)

/obj/machinery/door/window/Destroy()
density = FALSE
Expand Down Expand Up @@ -304,6 +319,11 @@
if (..())
autoclose = FALSE

/obj/machinery/door/window/unrestricted_side(mob/opener)
if(get_turf(opener) == loc)
return turn(dir,180) & unres_sides
return ..()
Tsar-Salat marked this conversation as resolved.
Show resolved Hide resolved

/obj/machinery/door/window/try_to_crowbar(obj/item/I, mob/user)
if(!hasPower())
if(density)
Expand All @@ -326,7 +346,7 @@
// Cutting WIRE_IDSCAN grants remote access... or it would, if we could hack windowdoors.
return id_scan_hacked() || ..()

/obj/machinery/door/window/proc/ntnet_receive(datum/source, datum/netdata/data)
/obj/machinery/door/window/proc/ntnet_receive(datum/netdata/data)
// Check if the airlock is powered.
if(!hasPower())
return
Expand All @@ -335,10 +355,13 @@
if(is_jammed())
return

// Check packet access level.
if(!check_access_ntnet(data))
return

// Handle received packet.
var/command = data.data["data"]
var/command_value = data.data["data_secondary"]
var/command = lowertext(data.data["data"])
var/command_value = lowertext(data.data["data_secondary"])
switch(command)
if("open")
if(command_value == "on" && !density)
Expand All @@ -354,6 +377,20 @@
if("touch")
INVOKE_ASYNC(src, .proc/open_and_close)

/obj/machinery/door/window/rcd_vals(mob/user, obj/item/construction/rcd/the_rcd)
switch(the_rcd.mode)
if(RCD_DECONSTRUCT)
return list("mode" = RCD_DECONSTRUCT, "delay" = 50, "cost" = 32)
return FALSE

/obj/machinery/door/window/rcd_act(mob/user, obj/item/construction/rcd/the_rcd, passed_mode)
switch(passed_mode)
if(RCD_DECONSTRUCT)
to_chat(user, "<span class='notice'>You deconstruct the windoor.</span>")
qdel(src)
return TRUE
return FALSE

/obj/machinery/door/window/brigdoor
name = "secure door"
icon_state = "leftsecure"
Expand Down
Loading