From 06ce830b21d05596a404790b8f3e63bef1119893 Mon Sep 17 00:00:00 2001 From: Erika Fox <94164348+Bjarl@users.noreply.github.com> Date: Mon, 23 Sep 2024 01:05:19 -0400 Subject: [PATCH] Turrets Now Actually Connect To Their Console Consistently (#3412) ## About The Pull Request makes turrets link to their console once everything has been linked to the shuttle. Adds a proc just in case anyone else needs 2 do this. ## Why It's Good For The Game functional code ## Changelog :cl: fix: turrets will now _actually_ connect to their console. i swear im a real coder. /:cl: --- code/__DEFINES/dcs/signals/signals_ship.dm | 2 ++ code/game/machinery/porta_turret/portable_turret.dm | 8 ++++++++ code/modules/shuttle/shuttle.dm | 1 + shiptest.dme | 1 + 4 files changed, 12 insertions(+) create mode 100644 code/__DEFINES/dcs/signals/signals_ship.dm diff --git a/code/__DEFINES/dcs/signals/signals_ship.dm b/code/__DEFINES/dcs/signals/signals_ship.dm new file mode 100644 index 000000000000..c18a26c5089d --- /dev/null +++ b/code/__DEFINES/dcs/signals/signals_ship.dm @@ -0,0 +1,2 @@ +///Sent when a shuttle finishes loading to allow for any machinery that requires a late connection to fire that connection +#define COMSIG_SHIP_DONE_CONNECTING "late_connect" diff --git a/code/game/machinery/porta_turret/portable_turret.dm b/code/game/machinery/porta_turret/portable_turret.dm index 33e493b3819e..3e50954df0c7 100644 --- a/code/game/machinery/porta_turret/portable_turret.dm +++ b/code/game/machinery/porta_turret/portable_turret.dm @@ -949,6 +949,14 @@ DEFINE_BITFIELD(turret_flags, list( /obj/machinery/turretid/connect_to_shuttle(obj/docking_port/mobile/port, obj/docking_port/stationary/dock) id = "[REF(port)][id]" + RegisterSignal(port, COMSIG_SHIP_DONE_CONNECTING, PROC_REF(late_connect_to_shuttle)) + +/obj/machinery/turretid/disconnect_from_shuttle(obj/docking_port/mobile/port) + UnregisterSignal(port, COMSIG_SHIP_DONE_CONNECTING) + +/obj/machinery/turretid/proc/late_connect_to_shuttle(obj/docking_port/mobile/port, obj/docking_port/stationary/dock) + SIGNAL_HANDLER + for(var/datum/weakref/ship_guns in port.turret_list) var/obj/machinery/porta_turret/turret_gun = ship_guns.resolve() if(turret_gun.id == id) diff --git a/code/modules/shuttle/shuttle.dm b/code/modules/shuttle/shuttle.dm index 084d4a49f3e7..5af554a60557 100644 --- a/code/modules/shuttle/shuttle.dm +++ b/code/modules/shuttle/shuttle.dm @@ -431,6 +431,7 @@ for(var/each in place) var/atom/atom = each atom.connect_to_shuttle(src, dock) + SEND_SIGNAL(src, COMSIG_SHIP_DONE_CONNECTING, dock) //this is a hook for custom behaviour. Maybe at some point we could add checks to see if engines are intact /obj/docking_port/mobile/proc/can_move() diff --git a/shiptest.dme b/shiptest.dme index 4861e9ab8f44..c1a3a2111b2a 100644 --- a/shiptest.dme +++ b/shiptest.dme @@ -163,6 +163,7 @@ #include "code\__DEFINES\dcs\helpers.dm" #include "code\__DEFINES\dcs\signals\signals.dm" #include "code\__DEFINES\dcs\signals\signals_mod.dm" +#include "code\__DEFINES\dcs\signals\signals_ship.dm" #include "code\__DEFINES\dcs\signals\signals_storage.dm" #include "code\__DEFINES\dcs\signals\signals_mob\signals_mob_carbon.dm" #include "code\__DEFINES\dcs\signals\signals_obj\signals_object.dm"