From 35740a27cca2e94a504956d1141aecfed225e651 Mon Sep 17 00:00:00 2001 From: DGamerL <108773801+DGamerL@users.noreply.github.com> Date: Tue, 10 Sep 2024 02:50:59 +0200 Subject: [PATCH] Adds support for machinery to be bigger than 1x1 (#26531) * Adds big machinery * Remove debug stuff * Even less debug stuff * Contra review * Complete refactor + BSH * Reverts `/big` * Adds missing * * initial * Removes unneeded shit * Adds edge of world edgecases * Whoops * Fix * Lewc review * Make the grav gen better * Render passes fix * Extra comment in the toml * Extra deconstruct just in case * One less loop --------- Co-authored-by: BeagleGaming1 <56142455+BeagleGaming1@users.noreply.github.com> --- SpacemanDMM.toml | 2 + _maps/map_files/stations/boxstation.dmm | 2 +- _maps/map_files/stations/cerestation.dmm | 4 +- _maps/map_files/stations/deltastation.dmm | 6 +- _maps/map_files/stations/metastation.dmm | 6 +- code/__DEFINES/misc_defines.dm | 3 + code/datums/components/multitile.dm | 61 +++++++++++++++++++++ code/modules/power/gravitygenerator.dm | 34 +++--------- code/modules/station_goals/bluespace_tap.dm | 32 ++++------- code/modules/station_goals/dna_vault.dm | 31 +++-------- paradise.dme | 1 + 11 files changed, 100 insertions(+), 82 deletions(-) create mode 100644 code/datums/components/multitile.dm diff --git a/SpacemanDMM.toml b/SpacemanDMM.toml index b996b87313d9..ec6f5ef068fc 100644 --- a/SpacemanDMM.toml +++ b/SpacemanDMM.toml @@ -34,3 +34,5 @@ hide_invisible = [ [map_renderer.render_passes] smart-cables = false +# With the multitile component and the removal of the gravity gen parts, the gravity generator will fail the render passes +gravity-gen = false diff --git a/_maps/map_files/stations/boxstation.dmm b/_maps/map_files/stations/boxstation.dmm index 41acd29526aa..849a4379553a 100644 --- a/_maps/map_files/stations/boxstation.dmm +++ b/_maps/map_files/stations/boxstation.dmm @@ -68595,7 +68595,6 @@ /turf/simulated/floor/plating, /area/station/maintenance/disposal) "lSr" = ( -/obj/machinery/gravity_generator/main/station, /obj/effect/turf_decal/stripes/line{ dir = 10 }, @@ -91302,6 +91301,7 @@ /area/station/command/office/rd) "xjh" = ( /obj/effect/turf_decal/stripes/line, +/obj/machinery/gravity_generator/main/station, /turf/simulated/floor/plasteel{ dir = 8; icon_state = "vault" diff --git a/_maps/map_files/stations/cerestation.dmm b/_maps/map_files/stations/cerestation.dmm index 9a130e77549d..682ee1f84cc3 100644 --- a/_maps/map_files/stations/cerestation.dmm +++ b/_maps/map_files/stations/cerestation.dmm @@ -144582,7 +144582,7 @@ aXn gzv tHv tHv -bII +tHv xpg kBo vPy @@ -144839,7 +144839,7 @@ aXn gzv tHv tHv -tHv +bII pnV aWx sJs diff --git a/_maps/map_files/stations/deltastation.dmm b/_maps/map_files/stations/deltastation.dmm index abcc88356918..62249a03f95e 100644 --- a/_maps/map_files/stations/deltastation.dmm +++ b/_maps/map_files/stations/deltastation.dmm @@ -28050,7 +28050,7 @@ "bEG" = ( /obj/machinery/gravity_generator/main/station, /turf/simulated/floor/plasteel{ - dir = 1; + dir = 8; icon_state = "vault" }, /area/station/engineering/gravitygenerator) @@ -119468,7 +119468,7 @@ bwN bzE bBi bBj -bEG +bBi bGB bwN abj @@ -119725,7 +119725,7 @@ bwN bzE bBj bDc -bBj +bEG bzE bwN abj diff --git a/_maps/map_files/stations/metastation.dmm b/_maps/map_files/stations/metastation.dmm index cd6c7a7a701f..c6b54b9eec7b 100644 --- a/_maps/map_files/stations/metastation.dmm +++ b/_maps/map_files/stations/metastation.dmm @@ -2133,7 +2133,7 @@ "aqh" = ( /obj/machinery/gravity_generator/main/station, /turf/simulated/floor/plasteel{ - dir = 4; + dir = 8; icon_state = "vault" }, /area/station/engineering/gravitygenerator) @@ -134896,7 +134896,7 @@ abq amk anl aoJ -aqh +ann aGt nHi avR @@ -135153,7 +135153,7 @@ abq amk apJ ank -aoJ +aqh ccM asQ avV diff --git a/code/__DEFINES/misc_defines.dm b/code/__DEFINES/misc_defines.dm index ad1a5a1aa8b5..acbbb10dccf4 100644 --- a/code/__DEFINES/misc_defines.dm +++ b/code/__DEFINES/misc_defines.dm @@ -104,6 +104,9 @@ #define STAGE_FIVE 9 #define STAGE_SIX 11 //From supermatter shard +/// A define for the center of the coordinate map of big machinery +#define MACH_CENTER 0 + #define in_range(source, user) (get_dist(source, user) <= 1) #define RANGE_TURFS(RADIUS, CENTER) \ diff --git a/code/datums/components/multitile.dm b/code/datums/components/multitile.dm new file mode 100644 index 000000000000..da09bfc6d575 --- /dev/null +++ b/code/datums/components/multitile.dm @@ -0,0 +1,61 @@ +///Lets multitile objects have dense walls around them based on the coordinate map +/datum/component/multitile + ///Reference to all fillers + var/list/all_fillers = list() + +/* + * These should all be done in this style. It represents a coordinate map of the grid around `src`. + * The src itself should always have no density, as the density should be set on the atom and not with a filler + * list( + list(0, 0, 0, 0, 0), + list(0, 0, 0, 0, 0), + list(0, 0, MACH_CENTER, 0, 0), + list(0, 0, 0, 0, 0), + list(0, 0, 0, 0, 0) + ) + */ + +//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)) + 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) + 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/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/obj/structure/filler/new_filler = new(filler_turf) + all_fillers += new_filler + current_width += 1 + if(current_width == max_width) + current_height += 1 + current_width = 0 + +/datum/component/multitile/Destroy(force, silent) + QDEL_LIST_CONTENTS(all_fillers) + return ..() diff --git a/code/modules/power/gravitygenerator.dm b/code/modules/power/gravitygenerator.dm index f91169d26b17..4e7c27fb5e55 100644 --- a/code/modules/power/gravitygenerator.dm +++ b/code/modules/power/gravitygenerator.dm @@ -18,6 +18,7 @@ GLOBAL_LIST_EMPTY(gravity_generators) name = "gravitational generator" desc = "A device which produces a graviton field when set up." icon = 'icons/obj/machines/gravity_generator.dmi' + pixel_x = -32 anchored = TRUE density = TRUE power_state = NO_POWER_USE @@ -51,26 +52,23 @@ GLOBAL_LIST_EMPTY(gravity_generators) /obj/machinery/gravity_generator/proc/set_fix() stat &= ~BROKEN -// -// Part generator which is mostly there for collision -// - -/obj/machinery/gravity_generator/part - invisibility = INVISIBILITY_ABSTRACT - // // Generator which spawns with the station. // /obj/machinery/gravity_generator/main/station/Initialize(mapload) . = ..() - setup_parts() + AddComponent(/datum/component/multitile, 1, list( + list(1, 1, 1), + list(1, MACH_CENTER, 1), + list(0, 0, 0), + )) update_gen_list() set_power() // // Main Generator with the main code -// +// With the multitile component it's dubious to still have this and not merge it with the `/obj/machinery/gravity_generator` itself /obj/machinery/gravity_generator/main icon_state = "generator_body" @@ -82,8 +80,6 @@ GLOBAL_LIST_EMPTY(gravity_generators) var/on = TRUE /// Is the breaker switch turned on var/breaker_on = TRUE - /// Generator parts on adjacent tiles - var/list/parts = list() /// Charging state (Idle, Charging, Discharging) var/charging_state = GRAV_POWER_IDLE /// Charge percentage @@ -111,8 +107,6 @@ GLOBAL_LIST_EMPTY(gravity_generators) investigate_log("was destroyed!", "gravity") on = FALSE update_gen_list() - for(var/obj/machinery/gravity_generator/part/O in parts) - qdel(O) for(var/area/A in world) if(!is_station_level(A.z)) continue @@ -120,20 +114,6 @@ GLOBAL_LIST_EMPTY(gravity_generators) shake_everyone() return ..() -/obj/machinery/gravity_generator/main/proc/setup_parts() - var/turf/our_turf = get_turf(src) - // 9x9 block obtained from the bottom left of the block - var/list/spawn_turfs = block(our_turf.x + 2, our_turf.y + 2, our_turf.z, our_turf.x, our_turf.y, our_turf.z) - var/count = 10 - for(var/turf/T in spawn_turfs) - count-- - if(T == our_turf) // Main body, skip it - continue - var/obj/machinery/gravity_generator/part/part = new(T) - if(count <= 3) // That section is the top part of the generator - part.density = FALSE - parts += part - /obj/machinery/gravity_generator/main/set_broken() ..() charging_state = GRAV_POWER_IDLE diff --git a/code/modules/station_goals/bluespace_tap.dm b/code/modules/station_goals/bluespace_tap.dm index aae9f1755e69..d4c3a9509013 100644 --- a/code/modules/station_goals/bluespace_tap.dm +++ b/code/modules/station_goals/bluespace_tap.dm @@ -194,8 +194,6 @@ max_integrity = 300 pixel_x = -32 //shamelessly stolen from dna vault pixel_y = -32 - /// For faking having a big machine, dummy 'machines' that are hidden inside the large sprite and make certain tiles dense. See new and destroy. - var/list/obj/structure/fillers = list() power_state = NO_POWER_USE // power usage is handelled manually density = TRUE interact_offline = TRUE @@ -227,7 +225,6 @@ /// How much power the machine needs per processing tick at the current level. var/actual_power_usage = 0 - // Tweak these and active_power_consumption to balance power generation /// Max power input level, I don't expect this to be ever reached. It has been reached. @@ -251,24 +248,20 @@ /obj/machinery/power/bluespace_tap/Initialize(mapload) . = ..() - //more code stolen from dna vault, inculding comment below. Taking bets on that datum being made ever. - //TODO: Replace this,bsa and gravgen with some big machinery datum - var/list/occupied = list() - for(var/direct in list(NORTH, NORTHEAST, NORTHWEST, EAST, WEST, SOUTHEAST, SOUTHWEST)) - occupied += get_step(src, direct) - - for(var/T in occupied) - var/obj/structure/filler/F = new(T) - F.parent = src - fillers += F component_parts = list() - component_parts += new /obj/item/circuitboard/machine/bluespace_tap(null) - for(var/i = 1 to 5) //five of each - component_parts += new /obj/item/stock_parts/capacitor/quadratic(null) - component_parts += new /obj/item/stack/ore/bluespace_crystal(null) + component_parts += new /obj/item/circuitboard/machine/bluespace_tap() + for(var/i in 1 to 5) //five of each + component_parts += new /obj/item/stock_parts/capacitor/quadratic() + component_parts += new /obj/item/stack/ore/bluespace_crystal() if(!powernet) connect_to_network() + AddComponent(/datum/component/multitile, 1, list( + list(1, 1, 1), + list(1, MACH_CENTER, 1), + list(1, 0, 1), + )) + /obj/machinery/power/bluespace_tap/update_icon_state() . = ..() @@ -302,7 +295,6 @@ if(light) underlays += emissive_appearance(icon, "light_mask") - /obj/machinery/power/bluespace_tap/proc/get_icon_state_number() switch(input_level) if(0) @@ -338,10 +330,6 @@ if(.) update_icon() -/obj/machinery/power/bluespace_tap/Destroy() - QDEL_LIST_CONTENTS(fillers) - return ..() - /** * Increases the desired mining level * diff --git a/code/modules/station_goals/dna_vault.dm b/code/modules/station_goals/dna_vault.dm index f2c6c00fc3b3..6eca59c5e29b 100644 --- a/code/modules/station_goals/dna_vault.dm +++ b/code/modules/station_goals/dna_vault.dm @@ -134,11 +134,6 @@ GLOBAL_LIST_INIT(non_simple_animals, typecacheof(list(/mob/living/carbon/human/m density = TRUE anchored = TRUE invisibility = 101 - var/obj/machinery/parent - -/obj/structure/filler/Destroy() - parent = null - return ..() /obj/structure/filler/ex_act() return @@ -166,22 +161,8 @@ GLOBAL_LIST_INIT(non_simple_animals, typecacheof(list(/mob/living/carbon/human/m var/completed = FALSE var/static/list/power_lottery = list() - var/list/obj/structure/fillers = list() - /obj/machinery/dna_vault/Initialize(mapload) . = ..() - //TODO: Replace this,bsa and gravgen with some big machinery datum - var/list/occupied = list() - for(var/direct in list(EAST,WEST,SOUTHEAST,SOUTHWEST)) - occupied += get_step(src,direct) - occupied += locate(x+1,y-2,z) - occupied += locate(x-1,y-2,z) - - for(var/T in occupied) - var/obj/structure/filler/F = new(T) - F.parent = src - fillers += F - if(SSticker.mode) for(var/datum/station_goal/dna_vault/G in SSticker.mode.station_goals) animals_max = G.animal_count @@ -189,6 +170,13 @@ 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), + list(0, 1, MACH_CENTER, 1, 0), + list(0, 1, 0, 1, 0), + list(0, 1, 0, 1, 0) + )) /obj/machinery/dna_vault/update_icon_state() if(stat & NOPOWER) icon_state = "vaultoff" @@ -200,11 +188,6 @@ GLOBAL_LIST_INIT(non_simple_animals, typecacheof(list(/mob/living/carbon/human/m return update_icon(UPDATE_ICON_STATE) - -/obj/machinery/dna_vault/Destroy() - QDEL_LIST_CONTENTS(fillers) - return ..() - /obj/machinery/dna_vault/attack_ghost(mob/user) if(stat & (BROKEN|MAINT)) return diff --git a/paradise.dme b/paradise.dme index 92fc9cfb83b8..8aa6a39ae1dc 100644 --- a/paradise.dme +++ b/paradise.dme @@ -438,6 +438,7 @@ #include "code\datums\components\label.dm" #include "code\datums\components\largeobjecttransparency.dm" #include "code\datums\components\material_container.dm" +#include "code\datums\components\multitile.dm" #include "code\datums\components\orbiter.dm" #include "code\datums\components\paintable.dm" #include "code\datums\components\parry.dm"