From c1a7a56078962b01ca76b5560bb8c5aba4573d6e Mon Sep 17 00:00:00 2001 From: vincibrv Date: Wed, 10 Jul 2024 12:06:27 +0200 Subject: [PATCH 01/24] roofs --- code/game/objects/structures/roof.dm | 151 +++++++++++++++++++++++++++ colonialmarines.dme | 1 + 2 files changed, 152 insertions(+) create mode 100644 code/game/objects/structures/roof.dm diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm new file mode 100644 index 000000000000..40f54ca8844e --- /dev/null +++ b/code/game/objects/structures/roof.dm @@ -0,0 +1,151 @@ +/obj/structure/roof + name = "roof" + desc = "A roof" + icon = 'icons/turf/almayer.dmi' + icon_state = "plating_catwalk" + density = FALSE + layer = ABOVE_XENO_LAYER + health = 6000 + var/image/under_image + var/image/normal_image + var/datum/roof_master_node/linked_master + var/lazy_nodes = TRUE + + +/obj/structure/roof/Initialize() + . = ..() + under_image = image(icon, src, icon_state, layer = layer) + under_image.alpha = 127 + + normal_image = image(icon, src, icon_state, layer = layer) + + icon_state = null + + RegisterSignal(SSdcs, COMSIG_GLOB_MOB_LOGGED_IN, PROC_REF(add_default_image)) + + for(var/icon in GLOB.player_list) + add_default_image(SSdcs, icon) + if(lazy_nodes) + var/obj/effect/roof_node/neighbor = locate() in src.loc + if(!neighbor) + neighbor = new(src.loc) + for(var/direction in CARDINAL_ALL_DIRS) + var/adjacent_loc = get_step(src, direction) + neighbor = locate() in adjacent_loc + if(!neighbor) + neighbor = new(adjacent_loc) + return INITIALIZE_HINT_LATELOAD + +/obj/structure/roof/LateInitialize() + . = ..() + if(!linked_master) + for(var/direction in CARDINAL_ALL_DIRS) + for(var/obj/structure/roof/roof in get_step(src,direction)) + if(roof.linked_master) + roof.linked_master.connect(loc) + return + var/datum/roof_master_node/roof_master_node = new(loc) + roof_master_node.connect(loc) + +/obj/structure/roof/proc/add_default_image(subsystem, mob/mob) + SIGNAL_HANDLER + mob.client.images += normal_image + +/obj/structure/roof/Destroy() + linked_master.remove_roof(src) + for(var/icon in GLOB.player_list) + var/mob/mob = icon + mob.client.images -= normal_image + return ..() + +/obj/structure/roof/proc/link_master(datum/roof_master_node/master) + if(linked_master != null) + return + master.connected_roof += src + linked_master = master + for(var/direction in CARDINAL_ALL_DIRS) + for(var/obj/structure/roof/roof in get_step(src,direction)) + roof.link_master(master) + +/obj/effect/roof_node + name = "roof_node" + anchored = TRUE + mouse_opacity = MOUSE_OPACITY_TRANSPARENT + invisibility = 101 + unacidable = TRUE + var/datum/roof_master_node/linked_master = null + +/obj/effect/roof_node/Crossed(atom/movable/mover, target_dir) + if(!linked_master) + return + if(isliving(mover)) + var/mob/living/mob = mover + linked_master.add_under_roof(mob) + +/obj/effect/roof_node/proc/link_master(datum/roof_master_node/master) + if(linked_master != null) + return + master.connected_nodes += src + linked_master = master + for(var/direction in CARDINAL_ALL_DIRS) + for(var/obj/effect/roof_node/node in get_step(src,direction)) + node.link_master(master) + + + +/datum/roof_master_node + var/list/connected_nodes = list() + var/list/connected_roof = list() + var/list/mobs_under = list() + var/location + +/datum/roof_master_node/proc/add_under_roof(mob/living/living) + if(living in mobs_under) + return + mobs_under += living + RegisterSignal(living, COMSIG_PARENT_QDELETING, PROC_REF(remove_under_roof)) + RegisterSignal(living, COMSIG_MOB_LOGGED_IN, PROC_REF(add_client)) + RegisterSignal(living, COMSIG_MOVABLE_MOVED, PROC_REF(check_under_roof)) + + if(living.client) + add_client(living) + +/datum/roof_master_node/proc/add_client(mob/living/mob) + SIGNAL_HANDLER + for(var/obj/structure/roof/roof in connected_roof) + mob.client.images -= roof.normal_image + mob.client.images += roof.under_image + +/datum/roof_master_node/proc/remove_under_roof(mob/living/living) + SIGNAL_HANDLER + if(living.client) + for(var/obj/structure/roof/roof in connected_roof) + living.client.images -= roof.under_image + roof.add_default_image(SSdcs, living) + mobs_under -= living + UnregisterSignal(living, list( + COMSIG_PARENT_QDELETING, + COMSIG_MOB_LOGGED_IN, + COMSIG_MOVABLE_MOVED, + )) + + + +/datum/roof_master_node/proc/check_under_roof(mob/living/living) + SIGNAL_HANDLER + for(var/obj/effect/roof_node/roof in connected_nodes) + if(living.loc == roof.loc) + return + + remove_under_roof(living) + +/datum/roof_master_node/proc/connect(location) + for(var/obj/effect/roof_node/node in location) + node.link_master(src) + for(var/obj/structure/roof/roof in location) + roof.link_master(src) + +/datum/roof_master_node/proc/remove_roof(obj/structure/roof/roof) + connected_roof -= roof + if(!length(connected_roof)) + qdel(src) diff --git a/colonialmarines.dme b/colonialmarines.dme index 5193cd3571cb..985c41a6ef44 100644 --- a/colonialmarines.dme +++ b/colonialmarines.dme @@ -1313,6 +1313,7 @@ #include "code\game\objects\structures\prop_mech.dm" #include "code\game\objects\structures\props.dm" #include "code\game\objects\structures\reagent_dispensers.dm" +#include "code\game\objects\structures\roof.dm" #include "code\game\objects\structures\safe.dm" #include "code\game\objects\structures\shower.dm" #include "code\game\objects\structures\signs.dm" From 3e4c40c03f989212aee184fbe85da1f2d4f9b066 Mon Sep 17 00:00:00 2001 From: vincibrv Date: Wed, 10 Jul 2024 23:04:41 +0200 Subject: [PATCH 02/24] dereferences master --- code/game/objects/structures/roof.dm | 32 +++++++++++++++------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index 40f54ca8844e..0c12dd6aa214 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -6,10 +6,10 @@ density = FALSE layer = ABOVE_XENO_LAYER health = 6000 - var/image/under_image + var/image/under_image //immage that is used when there is mob on connected node, displayed only to mobs under it not others var/image/normal_image var/datum/roof_master_node/linked_master - var/lazy_nodes = TRUE + var/lazy_nodes = TRUE //if roof should create nodes that watch around it on spawn /obj/structure/roof/Initialize() @@ -25,7 +25,7 @@ for(var/icon in GLOB.player_list) add_default_image(SSdcs, icon) - if(lazy_nodes) + if(lazy_nodes) //creates new node on each surounding tile if there is not one already var/obj/effect/roof_node/neighbor = locate() in src.loc if(!neighbor) neighbor = new(src.loc) @@ -36,15 +36,15 @@ neighbor = new(adjacent_loc) return INITIALIZE_HINT_LATELOAD -/obj/structure/roof/LateInitialize() +/obj/structure/roof/LateInitialize() //we use late init to allow for lazy nodes to spawn first on mapload . = ..() if(!linked_master) - for(var/direction in CARDINAL_ALL_DIRS) + for(var/direction in CARDINAL_ALL_DIRS) //this searches if there is lattice with master already, to work with runtime creation for(var/obj/structure/roof/roof in get_step(src,direction)) if(roof.linked_master) roof.linked_master.connect(loc) return - var/datum/roof_master_node/roof_master_node = new(loc) + var/datum/roof_master_node/roof_master_node = new(loc) //no master and no lattice to connect to, create new master roof_master_node.connect(loc) /obj/structure/roof/proc/add_default_image(subsystem, mob/mob) @@ -53,12 +53,13 @@ /obj/structure/roof/Destroy() linked_master.remove_roof(src) + linked_master = null for(var/icon in GLOB.player_list) var/mob/mob = icon mob.client.images -= normal_image return ..() -/obj/structure/roof/proc/link_master(datum/roof_master_node/master) +/obj/structure/roof/proc/link_master(datum/roof_master_node/master) //performs bfs and connects to master if(linked_master != null) return master.connected_roof += src @@ -67,7 +68,7 @@ for(var/obj/structure/roof/roof in get_step(src,direction)) roof.link_master(master) -/obj/effect/roof_node +/obj/effect/roof_node //used for observing if mob is near the roof name = "roof_node" anchored = TRUE mouse_opacity = MOUSE_OPACITY_TRANSPARENT @@ -82,7 +83,7 @@ var/mob/living/mob = mover linked_master.add_under_roof(mob) -/obj/effect/roof_node/proc/link_master(datum/roof_master_node/master) +/obj/effect/roof_node/proc/link_master(datum/roof_master_node/master) //performs bfs and connects to master if(linked_master != null) return master.connected_nodes += src @@ -93,13 +94,13 @@ -/datum/roof_master_node +/datum/roof_master_node //maintains one block of roof var/list/connected_nodes = list() var/list/connected_roof = list() var/list/mobs_under = list() var/location -/datum/roof_master_node/proc/add_under_roof(mob/living/living) +/datum/roof_master_node/proc/add_under_roof(mob/living/living) //mob crossed connected node if(living in mobs_under) return mobs_under += living @@ -116,7 +117,7 @@ mob.client.images -= roof.normal_image mob.client.images += roof.under_image -/datum/roof_master_node/proc/remove_under_roof(mob/living/living) +/datum/roof_master_node/proc/remove_under_roof(mob/living/living) //mob is no longer under roof SIGNAL_HANDLER if(living.client) for(var/obj/structure/roof/roof in connected_roof) @@ -131,12 +132,11 @@ -/datum/roof_master_node/proc/check_under_roof(mob/living/living) +/datum/roof_master_node/proc/check_under_roof(mob/living/living) //check if the mob is under connected roof SIGNAL_HANDLER for(var/obj/effect/roof_node/roof in connected_nodes) if(living.loc == roof.loc) return - remove_under_roof(living) /datum/roof_master_node/proc/connect(location) @@ -145,7 +145,9 @@ for(var/obj/structure/roof/roof in location) roof.link_master(src) -/datum/roof_master_node/proc/remove_roof(obj/structure/roof/roof) +/datum/roof_master_node/proc/remove_roof(obj/structure/roof/roof) //roof tile got removed connected_roof -= roof if(!length(connected_roof)) + for(var/obj/effect/roof_node/roof_node in connected_nodes) + roof_node.linked_master = null qdel(src) From 637d4d5552ecada60d2c4342143bb598a4e96a35 Mon Sep 17 00:00:00 2001 From: vincibrv Date: Wed, 10 Jul 2024 23:11:37 +0200 Subject: [PATCH 03/24] eh --- code/game/objects/structures/roof.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index 0c12dd6aa214..8439d15bdb77 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -149,5 +149,5 @@ connected_roof -= roof if(!length(connected_roof)) for(var/obj/effect/roof_node/roof_node in connected_nodes) - roof_node.linked_master = null + roof_node.Destroy() qdel(src) From edcd64716f9c7f8b2630ef1c1c39a8c6d76c77d0 Mon Sep 17 00:00:00 2001 From: vincibrv Date: Wed, 10 Jul 2024 23:17:38 +0200 Subject: [PATCH 04/24] I should sleep not code --- code/game/objects/structures/roof.dm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index 8439d15bdb77..17ad6a67a7d2 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -148,6 +148,14 @@ /datum/roof_master_node/proc/remove_roof(obj/structure/roof/roof) //roof tile got removed connected_roof -= roof if(!length(connected_roof)) - for(var/obj/effect/roof_node/roof_node in connected_nodes) - roof_node.Destroy() - qdel(src) + Destroy() + + + +/datum/roof_master_node/Destroy(force, ...) + . = ..() + for(var/obj/effect/roof_node/roof_node in connected_nodes) + roof_node.Destroy() + for(var/obj/structure/roof/roof in location) + roof.Destroy() + qdel(src) From 362416880062506d8f3ef8e96d1f9a6478901a7a Mon Sep 17 00:00:00 2001 From: vincibrv Date: Wed, 10 Jul 2024 23:25:48 +0200 Subject: [PATCH 05/24] pff --- code/game/objects/structures/roof.dm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index 17ad6a67a7d2..306c4d17c71c 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -92,6 +92,10 @@ for(var/obj/effect/roof_node/node in get_step(src,direction)) node.link_master(master) +/obj/effect/roof_node/Destroy(force) + . = ..() + link_master = null + /datum/roof_master_node //maintains one block of roof From 64046b1b6b7f9ef1f220dd6b2470added742de57 Mon Sep 17 00:00:00 2001 From: vincibrv Date: Thu, 11 Jul 2024 09:25:37 +0200 Subject: [PATCH 06/24] eh --- code/game/objects/structures/roof.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index 306c4d17c71c..2def79ad7992 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -94,7 +94,7 @@ /obj/effect/roof_node/Destroy(force) . = ..() - link_master = null + linked_master = null From fe3484bfd0e4a82ee2e94ed656e674294f9ca5d0 Mon Sep 17 00:00:00 2001 From: vincibrv Date: Thu, 11 Jul 2024 09:37:55 +0200 Subject: [PATCH 07/24] I am lost --- code/game/objects/structures/roof.dm | 1 + 1 file changed, 1 insertion(+) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index 2def79ad7992..814f6ec4df7c 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -94,6 +94,7 @@ /obj/effect/roof_node/Destroy(force) . = ..() + linked_master.connected_nodes -= src linked_master = null From a203f43e665fea3fbe9497dcd16a56681df3f233 Mon Sep 17 00:00:00 2001 From: vincibrv Date: Thu, 11 Jul 2024 09:46:52 +0200 Subject: [PATCH 08/24] eh --- code/game/objects/structures/roof.dm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index 814f6ec4df7c..ded7b74f55d9 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -53,7 +53,6 @@ /obj/structure/roof/Destroy() linked_master.remove_roof(src) - linked_master = null for(var/icon in GLOB.player_list) var/mob/mob = icon mob.client.images -= normal_image @@ -74,7 +73,7 @@ mouse_opacity = MOUSE_OPACITY_TRANSPARENT invisibility = 101 unacidable = TRUE - var/datum/roof_master_node/linked_master = null + var/datum/roof_master_node/linked_master /obj/effect/roof_node/Crossed(atom/movable/mover, target_dir) if(!linked_master) @@ -95,7 +94,6 @@ /obj/effect/roof_node/Destroy(force) . = ..() linked_master.connected_nodes -= src - linked_master = null From bceb32643420fbc5821bee57a521a9142bdeefeb Mon Sep 17 00:00:00 2001 From: vincibrv Date: Thu, 11 Jul 2024 09:55:44 +0200 Subject: [PATCH 09/24] I am so lost --- code/game/objects/structures/roof.dm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index ded7b74f55d9..4ab8d080e660 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -92,8 +92,9 @@ node.link_master(master) /obj/effect/roof_node/Destroy(force) - . = ..() linked_master.connected_nodes -= src + . = ..() + @@ -155,10 +156,10 @@ -/datum/roof_master_node/Destroy(force, ...) - . = ..() +/datum/roof_master_node/Destroy() for(var/obj/effect/roof_node/roof_node in connected_nodes) roof_node.Destroy() for(var/obj/structure/roof/roof in location) roof.Destroy() - qdel(src) + . = ..() + From 077db82d773a66e3d1c7ed363bac758b539e3cc0 Mon Sep 17 00:00:00 2001 From: vincibrv Date: Thu, 11 Jul 2024 10:07:00 +0200 Subject: [PATCH 10/24] so lost --- code/game/objects/structures/roof.dm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index 4ab8d080e660..792500a4f093 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -51,7 +51,7 @@ SIGNAL_HANDLER mob.client.images += normal_image -/obj/structure/roof/Destroy() +/obj/structure/roof/Destroy(force, ...) linked_master.remove_roof(src) for(var/icon in GLOB.player_list) var/mob/mob = icon @@ -91,7 +91,7 @@ for(var/obj/effect/roof_node/node in get_step(src,direction)) node.link_master(master) -/obj/effect/roof_node/Destroy(force) +/obj/effect/roof_node/Destroy(force, ...) linked_master.connected_nodes -= src . = ..() @@ -156,10 +156,11 @@ -/datum/roof_master_node/Destroy() +/datum/roof_master_node/Destroy(force, ...) for(var/obj/effect/roof_node/roof_node in connected_nodes) roof_node.Destroy() for(var/obj/structure/roof/roof in location) roof.Destroy() . = ..() + From 1ee9bf8fb3651c1f6933e1efcadfded178fb792c Mon Sep 17 00:00:00 2001 From: vincibrv Date: Thu, 11 Jul 2024 10:17:46 +0200 Subject: [PATCH 11/24] still so lost --- code/game/objects/structures/roof.dm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index 792500a4f093..2aee78c9ad6d 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -52,7 +52,8 @@ mob.client.images += normal_image /obj/structure/roof/Destroy(force, ...) - linked_master.remove_roof(src) + if(linked_master) + linked_master.remove_roof(src) for(var/icon in GLOB.player_list) var/mob/mob = icon mob.client.images -= normal_image From 493233a1aa493d9e2279521011609952f92b1495 Mon Sep 17 00:00:00 2001 From: vincibrv Date: Thu, 11 Jul 2024 10:35:27 +0200 Subject: [PATCH 12/24] I have no clue --- code/game/objects/structures/roof.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index 2aee78c9ad6d..25da436bd4a7 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -153,15 +153,15 @@ /datum/roof_master_node/proc/remove_roof(obj/structure/roof/roof) //roof tile got removed connected_roof -= roof if(!length(connected_roof)) - Destroy() + Destroy(1) /datum/roof_master_node/Destroy(force, ...) for(var/obj/effect/roof_node/roof_node in connected_nodes) - roof_node.Destroy() + roof_node.Destroy(1) for(var/obj/structure/roof/roof in location) - roof.Destroy() + roof.Destroy(1) . = ..() From 9b5db9e2a0fb84b04b77c04a88f0fb834510fc88 Mon Sep 17 00:00:00 2001 From: vincibrv Date: Thu, 11 Jul 2024 10:54:59 +0200 Subject: [PATCH 13/24] no idea --- code/game/objects/structures/roof.dm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index 25da436bd4a7..6a009abe53c3 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -93,8 +93,9 @@ node.link_master(master) /obj/effect/roof_node/Destroy(force, ...) + .=..() linked_master.connected_nodes -= src - . = ..() + From 7f71b7ebbeed384ba7da038b47bad9499039def2 Mon Sep 17 00:00:00 2001 From: vincibrv Date: Thu, 11 Jul 2024 11:03:33 +0200 Subject: [PATCH 14/24] mby? --- code/game/objects/structures/roof.dm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index 6a009abe53c3..c3adbf6ac0e6 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -159,10 +159,12 @@ /datum/roof_master_node/Destroy(force, ...) - for(var/obj/effect/roof_node/roof_node in connected_nodes) - roof_node.Destroy(1) - for(var/obj/structure/roof/roof in location) - roof.Destroy(1) + if(connected_nodes) + for(var/obj/effect/roof_node/roof_node in connected_nodes) + roof_node.Destroy(1) + if(connected_nodes) + for(var/obj/structure/roof/roof in connected_roof) + roof.Destroy(1) . = ..() From ab975a764bbe68285f643b4ac3d2738eb0494b05 Mon Sep 17 00:00:00 2001 From: vincibrv Date: Thu, 11 Jul 2024 11:09:55 +0200 Subject: [PATCH 15/24] eh --- code/game/objects/structures/roof.dm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index c3adbf6ac0e6..0b7973558f6b 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -93,8 +93,9 @@ node.link_master(master) /obj/effect/roof_node/Destroy(force, ...) - .=..() linked_master.connected_nodes -= src + .=..() + From 2457bfb291dc8e287a9ba03b4a9ac60cbeec99a9 Mon Sep 17 00:00:00 2001 From: vincibrv Date: Thu, 11 Jul 2024 11:17:34 +0200 Subject: [PATCH 16/24] aaaa --- code/game/objects/structures/roof.dm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index 0b7973558f6b..b7312e2ada72 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -93,7 +93,8 @@ node.link_master(master) /obj/effect/roof_node/Destroy(force, ...) - linked_master.connected_nodes -= src + if(linked_master.connected_nodes) + linked_master.connected_nodes -= src .=..() From c0f2440e0c5bf73c9b5fb2bf00d3424ce5946b40 Mon Sep 17 00:00:00 2001 From: vincibrv Date: Thu, 11 Jul 2024 11:28:13 +0200 Subject: [PATCH 17/24] aaaaaa --- code/game/objects/structures/roof.dm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index b7312e2ada72..6b179e6ecb9f 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -93,8 +93,9 @@ node.link_master(master) /obj/effect/roof_node/Destroy(force, ...) - if(linked_master.connected_nodes) - linked_master.connected_nodes -= src + if(linked_master) + if(linked_master.connected_nodes) + linked_master.connected_nodes -= src .=..() From ed0287818d388247d12c26b9c80282b7c30e5896 Mon Sep 17 00:00:00 2001 From: vincibrv Date: Thu, 11 Jul 2024 11:41:14 +0200 Subject: [PATCH 18/24] okey works now --- code/game/objects/structures/roof.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index 6b179e6ecb9f..ca9982bd5f79 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -26,7 +26,7 @@ for(var/icon in GLOB.player_list) add_default_image(SSdcs, icon) if(lazy_nodes) //creates new node on each surounding tile if there is not one already - var/obj/effect/roof_node/neighbor = locate() in src.loc + var/obj/effect/roof_node/neighbor = locate() in loc if(!neighbor) neighbor = new(src.loc) for(var/direction in CARDINAL_ALL_DIRS) From 10c7fb949f3c5ae2e3917ddbd0126d71428cf80b Mon Sep 17 00:00:00 2001 From: vincibrv Date: Thu, 11 Jul 2024 11:45:56 +0200 Subject: [PATCH 19/24] polishing --- code/game/objects/structures/roof.dm | 51 ++++++++++++---------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index ca9982bd5f79..47412887f4ee 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -47,10 +47,6 @@ var/datum/roof_master_node/roof_master_node = new(loc) //no master and no lattice to connect to, create new master roof_master_node.connect(loc) -/obj/structure/roof/proc/add_default_image(subsystem, mob/mob) - SIGNAL_HANDLER - mob.client.images += normal_image - /obj/structure/roof/Destroy(force, ...) if(linked_master) linked_master.remove_roof(src) @@ -59,6 +55,10 @@ mob.client.images -= normal_image return ..() +/obj/structure/roof/proc/add_default_image(subsystem, mob/mob) + SIGNAL_HANDLER + mob.client.images += normal_image + /obj/structure/roof/proc/link_master(datum/roof_master_node/master) //performs bfs and connects to master if(linked_master != null) return @@ -68,6 +68,7 @@ for(var/obj/structure/roof/roof in get_step(src,direction)) roof.link_master(master) + /obj/effect/roof_node //used for observing if mob is near the roof name = "roof_node" anchored = TRUE @@ -83,8 +84,14 @@ var/mob/living/mob = mover linked_master.add_under_roof(mob) +/obj/effect/roof_node/Destroy(force, ...) + if(linked_master) + if(linked_master.connected_nodes) + linked_master.connected_nodes -= src + .=..() + /obj/effect/roof_node/proc/link_master(datum/roof_master_node/master) //performs bfs and connects to master - if(linked_master != null) + if(linked_master) return master.connected_nodes += src linked_master = master @@ -92,16 +99,6 @@ for(var/obj/effect/roof_node/node in get_step(src,direction)) node.link_master(master) -/obj/effect/roof_node/Destroy(force, ...) - if(linked_master) - if(linked_master.connected_nodes) - linked_master.connected_nodes -= src - .=..() - - - - - /datum/roof_master_node //maintains one block of roof var/list/connected_nodes = list() @@ -109,6 +106,15 @@ var/list/mobs_under = list() var/location +/datum/roof_master_node/Destroy(force, ...) + if(connected_nodes) + for(var/obj/effect/roof_node/roof_node in connected_nodes) + roof_node.Destroy(1) + if(connected_nodes) + for(var/obj/structure/roof/roof in connected_roof) + roof.Destroy(1) + . = ..() + /datum/roof_master_node/proc/add_under_roof(mob/living/living) //mob crossed connected node if(living in mobs_under) return @@ -139,8 +145,6 @@ COMSIG_MOVABLE_MOVED, )) - - /datum/roof_master_node/proc/check_under_roof(mob/living/living) //check if the mob is under connected roof SIGNAL_HANDLER for(var/obj/effect/roof_node/roof in connected_nodes) @@ -158,16 +162,3 @@ connected_roof -= roof if(!length(connected_roof)) Destroy(1) - - - -/datum/roof_master_node/Destroy(force, ...) - if(connected_nodes) - for(var/obj/effect/roof_node/roof_node in connected_nodes) - roof_node.Destroy(1) - if(connected_nodes) - for(var/obj/structure/roof/roof in connected_roof) - roof.Destroy(1) - . = ..() - - From 75e351bb6d597a503da6b2f55644ec6c126252b4 Mon Sep 17 00:00:00 2001 From: vincibrv Date: Sun, 14 Jul 2024 12:53:34 +0200 Subject: [PATCH 20/24] qdel instead of destroy --- code/game/objects/structures/roof.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index 47412887f4ee..1d4b2340c0b5 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -109,10 +109,10 @@ /datum/roof_master_node/Destroy(force, ...) if(connected_nodes) for(var/obj/effect/roof_node/roof_node in connected_nodes) - roof_node.Destroy(1) + qdel(roof_node) if(connected_nodes) for(var/obj/structure/roof/roof in connected_roof) - roof.Destroy(1) + qdel(roof) . = ..() /datum/roof_master_node/proc/add_under_roof(mob/living/living) //mob crossed connected node @@ -161,4 +161,4 @@ /datum/roof_master_node/proc/remove_roof(obj/structure/roof/roof) //roof tile got removed connected_roof -= roof if(!length(connected_roof)) - Destroy(1) + qdel(src) From 5421f201b2bbcf59f2efae3056aa98c8d3fac789 Mon Sep 17 00:00:00 2001 From: cuberound <122645057+cuberound@users.noreply.github.com> Date: Sun, 14 Jul 2024 15:01:10 +0200 Subject: [PATCH 21/24] Update code/game/objects/structures/roof.dm Co-authored-by: Drathek <76988376+Drulikar@users.noreply.github.com> --- code/game/objects/structures/roof.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index 1d4b2340c0b5..acf02c3ab822 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -28,7 +28,7 @@ if(lazy_nodes) //creates new node on each surounding tile if there is not one already var/obj/effect/roof_node/neighbor = locate() in loc if(!neighbor) - neighbor = new(src.loc) + neighbor = new(loc) for(var/direction in CARDINAL_ALL_DIRS) var/adjacent_loc = get_step(src, direction) neighbor = locate() in adjacent_loc From 322b67f9b932cd11219ed52388b8f7d6f290a224 Mon Sep 17 00:00:00 2001 From: cuberound <122645057+cuberound@users.noreply.github.com> Date: Sun, 14 Jul 2024 15:02:12 +0200 Subject: [PATCH 22/24] Update code/game/objects/structures/roof.dm Co-authored-by: Drathek <76988376+Drulikar@users.noreply.github.com> --- code/game/objects/structures/roof.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index acf02c3ab822..16b8c9c0eb1e 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -113,7 +113,7 @@ if(connected_nodes) for(var/obj/structure/roof/roof in connected_roof) qdel(roof) - . = ..() + return ..() /datum/roof_master_node/proc/add_under_roof(mob/living/living) //mob crossed connected node if(living in mobs_under) From 3a6d89b2bec5d276dd34c57406426c1763047a20 Mon Sep 17 00:00:00 2001 From: cuberound <122645057+cuberound@users.noreply.github.com> Date: Sun, 14 Jul 2024 15:02:23 +0200 Subject: [PATCH 23/24] Update code/game/objects/structures/roof.dm Co-authored-by: Drathek <76988376+Drulikar@users.noreply.github.com> --- code/game/objects/structures/roof.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index 16b8c9c0eb1e..ee43167a3899 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -88,7 +88,7 @@ if(linked_master) if(linked_master.connected_nodes) linked_master.connected_nodes -= src - .=..() + return ..() /obj/effect/roof_node/proc/link_master(datum/roof_master_node/master) //performs bfs and connects to master if(linked_master) From e41b77c5884e193754e42e973650ce5c33cf4079 Mon Sep 17 00:00:00 2001 From: vincibrv Date: Sun, 14 Jul 2024 13:04:10 +0200 Subject: [PATCH 24/24] finishing touch --- code/game/objects/structures/roof.dm | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/code/game/objects/structures/roof.dm b/code/game/objects/structures/roof.dm index ee43167a3899..e302133f0c9a 100644 --- a/code/game/objects/structures/roof.dm +++ b/code/game/objects/structures/roof.dm @@ -38,14 +38,15 @@ /obj/structure/roof/LateInitialize() //we use late init to allow for lazy nodes to spawn first on mapload . = ..() - if(!linked_master) - for(var/direction in CARDINAL_ALL_DIRS) //this searches if there is lattice with master already, to work with runtime creation - for(var/obj/structure/roof/roof in get_step(src,direction)) - if(roof.linked_master) - roof.linked_master.connect(loc) - return - var/datum/roof_master_node/roof_master_node = new(loc) //no master and no lattice to connect to, create new master - roof_master_node.connect(loc) + if(linked_master) + return + for(var/direction in CARDINAL_ALL_DIRS) //this searches if there is lattice with master already, to work with runtime creation + for(var/obj/structure/roof/roof in get_step(src,direction)) + if(roof.linked_master) + roof.linked_master.connect(loc) + return + var/datum/roof_master_node/roof_master_node = new(loc) //no master and no lattice to connect to, create new master + roof_master_node.connect(loc) /obj/structure/roof/Destroy(force, ...) if(linked_master)