diff --git a/code/__DEFINES/misc_defines.dm b/code/__DEFINES/misc_defines.dm index 7d5b8ecdb25..12efdafa7a5 100644 --- a/code/__DEFINES/misc_defines.dm +++ b/code/__DEFINES/misc_defines.dm @@ -105,7 +105,7 @@ #define STAGE_SIX 11 //From supermatter shard /// A define for the center of the coordinate map of big machinery -#define MACH_CENTER 0 +#define MACH_CENTER 2 #define in_range(source, user) (get_dist(source, user) <= 1) diff --git a/code/datums/components/multitile.dm b/code/datums/components/multitile.dm index da09bfc6d57..aa01a5741aa 100644 --- a/code/datums/components/multitile.dm +++ b/code/datums/components/multitile.dm @@ -16,45 +16,64 @@ */ //distance_from_center does not include src itself -/datum/component/multitile/Initialize(distance_from_center, new_filler_map) - if(!distance_from_center || !length(new_filler_map)) +/datum/component/multitile/Initialize(new_filler_map) + if(!length(new_filler_map)) return COMPONENT_INCOMPATIBLE if(!isatom(parent)) return COMPONENT_INCOMPATIBLE - - var/atom/owner = parent - if(owner.x + distance_from_center > world.maxx || owner.x - distance_from_center < 1) - var/obj/machinery/machine = parent - machine.deconstruct() - return COMPONENT_INCOMPATIBLE - - if(owner.y + distance_from_center > world.maxy || owner.y - distance_from_center < 1) - var/obj/machinery/machine = parent - machine.deconstruct() - return COMPONENT_INCOMPATIBLE - var/max_height = length(new_filler_map) var/max_width = length(new_filler_map[1]) //it should have the same length on every row - for(var/i in 2 to length(new_filler_map)) - var/length = length(new_filler_map[i]) - if(length != max_width) + + var/offset_x = 0 + var/offset_y = 0 + + var/atom/owner = parent + + for(var/i in 1 to length(new_filler_map)) + if(length(new_filler_map[i] != max_width)) stack_trace("A multitile component was passed a list wich did not have the same length every row. Atom parent is: [parent]") var/obj/machinery/machine = parent machine.deconstruct() return COMPONENT_INCOMPATIBLE - var/current_height = 0 - var/current_width = 0 + for(var/j in 1 to length(new_filler_map[i])) + if(new_filler_map[i][j] == MACH_CENTER) + offset_x = j - ((length(new_filler_map[i]) + 1) / 2) + offset_y = i - ((length(new_filler_map) + 1) / 2) - for(var/turf/filler_turf as anything in RANGE_TURFS(distance_from_center, owner)) - if(new_filler_map[max_height - current_height][max_width - current_width]) // Because the `block()` proc always works from the bottom left to the top right, we have to loop through our nested lists in reverse + var/distance_from_center_x = (max_width - 1) / 2 + var/distance_from_center_y = (max_height - 1) / 2 + + if(owner.x - offset_x + distance_from_center_x > world.maxx || owner.x + offset_x - distance_from_center_x < 1) + var/obj/machinery/machine = parent + machine.deconstruct() + return COMPONENT_INCOMPATIBLE + + if(owner.y + offset_y + distance_from_center_y > world.maxy || owner.y - offset_y - distance_from_center_y < 1) + var/obj/machinery/machine = parent + machine.deconstruct() + return COMPONENT_INCOMPATIBLE + + var/current_height = 0 + var/current_width = 1 + var/tile_index = 1 + + for(var/turf/filler_turf as anything in block( + owner.x - offset_x - distance_from_center_x, owner.y + offset_y - distance_from_center_y, owner.z, + owner.x - offset_x + distance_from_center_x, owner.y + offset_y + distance_from_center_y, owner.z, + )) + //Last check is for filler row lists of length 1. + if(new_filler_map[max_height - current_height][current_width] == 1) // Because the `block()` proc always works from the bottom left to the top right, we have to loop through our list in reverse var/obj/structure/filler/new_filler = new(filler_turf) all_fillers += new_filler current_width += 1 - if(current_width == max_width) + tile_index++ + if(tile_index % max_width == 1) current_height += 1 - current_width = 0 + current_width = 1 + if(current_height == max_height) + break /datum/component/multitile/Destroy(force, silent) QDEL_LIST_CONTENTS(all_fillers) diff --git a/code/modules/power/gravitygenerator.dm b/code/modules/power/gravitygenerator.dm index 4e7c27fb5e5..899cf969e00 100644 --- a/code/modules/power/gravitygenerator.dm +++ b/code/modules/power/gravitygenerator.dm @@ -58,10 +58,9 @@ GLOBAL_LIST_EMPTY(gravity_generators) /obj/machinery/gravity_generator/main/station/Initialize(mapload) . = ..() - AddComponent(/datum/component/multitile, 1, list( + AddComponent(/datum/component/multitile, list( list(1, 1, 1), list(1, MACH_CENTER, 1), - list(0, 0, 0), )) update_gen_list() set_power() diff --git a/code/modules/station_goals/bluespace_tap.dm b/code/modules/station_goals/bluespace_tap.dm index d4c3a950901..1f027e36fee 100644 --- a/code/modules/station_goals/bluespace_tap.dm +++ b/code/modules/station_goals/bluespace_tap.dm @@ -256,7 +256,7 @@ if(!powernet) connect_to_network() - AddComponent(/datum/component/multitile, 1, list( + AddComponent(/datum/component/multitile, list( list(1, 1, 1), list(1, MACH_CENTER, 1), list(1, 0, 1), diff --git a/code/modules/station_goals/dna_vault.dm b/code/modules/station_goals/dna_vault.dm index 6eca59c5e29..04d85784bd0 100644 --- a/code/modules/station_goals/dna_vault.dm +++ b/code/modules/station_goals/dna_vault.dm @@ -170,9 +170,7 @@ GLOBAL_LIST_INIT(non_simple_animals, typecacheof(list(/mob/living/carbon/human/m dna_max = G.human_count break - AddComponent(/datum/component/multitile, 2, list( - list(0, 0, 0, 0, 0), - list(0, 0, 0, 0, 0), + AddComponent(/datum/component/multitile, list( list(0, 1, MACH_CENTER, 1, 0), list(0, 1, 0, 1, 0), list(0, 1, 0, 1, 0)