Skip to content

Commit 35740a2

Browse files
Adds support for machinery to be bigger than 1x1 (ParadiseSS13#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 <[email protected]>
1 parent 33b2dc3 commit 35740a2

File tree

11 files changed

+100
-82
lines changed

11 files changed

+100
-82
lines changed

SpacemanDMM.toml

+2
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,5 @@ hide_invisible = [
3434

3535
[map_renderer.render_passes]
3636
smart-cables = false
37+
# With the multitile component and the removal of the gravity gen parts, the gravity generator will fail the render passes
38+
gravity-gen = false

_maps/map_files/stations/boxstation.dmm

+1-1
Original file line numberDiff line numberDiff line change
@@ -68595,7 +68595,6 @@
6859568595
/turf/simulated/floor/plating,
6859668596
/area/station/maintenance/disposal)
6859768597
"lSr" = (
68598-
/obj/machinery/gravity_generator/main/station,
6859968598
/obj/effect/turf_decal/stripes/line{
6860068599
dir = 10
6860168600
},
@@ -91302,6 +91301,7 @@
9130291301
/area/station/command/office/rd)
9130391302
"xjh" = (
9130491303
/obj/effect/turf_decal/stripes/line,
91304+
/obj/machinery/gravity_generator/main/station,
9130591305
/turf/simulated/floor/plasteel{
9130691306
dir = 8;
9130791307
icon_state = "vault"

_maps/map_files/stations/cerestation.dmm

+2-2
Original file line numberDiff line numberDiff line change
@@ -144582,7 +144582,7 @@ aXn
144582144582
gzv
144583144583
tHv
144584144584
tHv
144585-
bII
144585+
tHv
144586144586
xpg
144587144587
kBo
144588144588
vPy
@@ -144839,7 +144839,7 @@ aXn
144839144839
gzv
144840144840
tHv
144841144841
tHv
144842-
tHv
144842+
bII
144843144843
pnV
144844144844
aWx
144845144845
sJs

_maps/map_files/stations/deltastation.dmm

+3-3
Original file line numberDiff line numberDiff line change
@@ -28050,7 +28050,7 @@
2805028050
"bEG" = (
2805128051
/obj/machinery/gravity_generator/main/station,
2805228052
/turf/simulated/floor/plasteel{
28053-
dir = 1;
28053+
dir = 8;
2805428054
icon_state = "vault"
2805528055
},
2805628056
/area/station/engineering/gravitygenerator)
@@ -119468,7 +119468,7 @@ bwN
119468119468
bzE
119469119469
bBi
119470119470
bBj
119471-
bEG
119471+
bBi
119472119472
bGB
119473119473
bwN
119474119474
abj
@@ -119725,7 +119725,7 @@ bwN
119725119725
bzE
119726119726
bBj
119727119727
bDc
119728-
bBj
119728+
bEG
119729119729
bzE
119730119730
bwN
119731119731
abj

_maps/map_files/stations/metastation.dmm

+3-3
Original file line numberDiff line numberDiff line change
@@ -2133,7 +2133,7 @@
21332133
"aqh" = (
21342134
/obj/machinery/gravity_generator/main/station,
21352135
/turf/simulated/floor/plasteel{
2136-
dir = 4;
2136+
dir = 8;
21372137
icon_state = "vault"
21382138
},
21392139
/area/station/engineering/gravitygenerator)
@@ -134896,7 +134896,7 @@ abq
134896134896
amk
134897134897
anl
134898134898
aoJ
134899-
aqh
134899+
ann
134900134900
aGt
134901134901
nHi
134902134902
avR
@@ -135153,7 +135153,7 @@ abq
135153135153
amk
135154135154
apJ
135155135155
ank
135156-
aoJ
135156+
aqh
135157135157
ccM
135158135158
asQ
135159135159
avV

code/__DEFINES/misc_defines.dm

+3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@
104104
#define STAGE_FIVE 9
105105
#define STAGE_SIX 11 //From supermatter shard
106106

107+
/// A define for the center of the coordinate map of big machinery
108+
#define MACH_CENTER 0
109+
107110
#define in_range(source, user) (get_dist(source, user) <= 1)
108111

109112
#define RANGE_TURFS(RADIUS, CENTER) \

code/datums/components/multitile.dm

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
///Lets multitile objects have dense walls around them based on the coordinate map
2+
/datum/component/multitile
3+
///Reference to all fillers
4+
var/list/all_fillers = list()
5+
6+
/*
7+
* These should all be done in this style. It represents a coordinate map of the grid around `src`.
8+
* The src itself should always have no density, as the density should be set on the atom and not with a filler
9+
* list(
10+
list(0, 0, 0, 0, 0),
11+
list(0, 0, 0, 0, 0),
12+
list(0, 0, MACH_CENTER, 0, 0),
13+
list(0, 0, 0, 0, 0),
14+
list(0, 0, 0, 0, 0)
15+
)
16+
*/
17+
18+
//distance_from_center does not include src itself
19+
/datum/component/multitile/Initialize(distance_from_center, new_filler_map)
20+
if(!distance_from_center || !length(new_filler_map))
21+
return COMPONENT_INCOMPATIBLE
22+
23+
if(!isatom(parent))
24+
return COMPONENT_INCOMPATIBLE
25+
26+
var/atom/owner = parent
27+
if(owner.x + distance_from_center > world.maxx || owner.x - distance_from_center < 1)
28+
var/obj/machinery/machine = parent
29+
machine.deconstruct()
30+
return COMPONENT_INCOMPATIBLE
31+
32+
if(owner.y + distance_from_center > world.maxy || owner.y - distance_from_center < 1)
33+
var/obj/machinery/machine = parent
34+
machine.deconstruct()
35+
return COMPONENT_INCOMPATIBLE
36+
37+
var/max_height = length(new_filler_map)
38+
var/max_width = length(new_filler_map[1]) //it should have the same length on every row
39+
for(var/i in 2 to length(new_filler_map))
40+
var/length = length(new_filler_map[i])
41+
if(length != max_width)
42+
stack_trace("A multitile component was passed a list wich did not have the same length every row. Atom parent is: [parent]")
43+
var/obj/machinery/machine = parent
44+
machine.deconstruct()
45+
return COMPONENT_INCOMPATIBLE
46+
47+
var/current_height = 0
48+
var/current_width = 0
49+
50+
for(var/turf/filler_turf as anything in RANGE_TURFS(distance_from_center, owner))
51+
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
52+
var/obj/structure/filler/new_filler = new(filler_turf)
53+
all_fillers += new_filler
54+
current_width += 1
55+
if(current_width == max_width)
56+
current_height += 1
57+
current_width = 0
58+
59+
/datum/component/multitile/Destroy(force, silent)
60+
QDEL_LIST_CONTENTS(all_fillers)
61+
return ..()

code/modules/power/gravitygenerator.dm

+7-27
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ GLOBAL_LIST_EMPTY(gravity_generators)
1818
name = "gravitational generator"
1919
desc = "A device which produces a graviton field when set up."
2020
icon = 'icons/obj/machines/gravity_generator.dmi'
21+
pixel_x = -32
2122
anchored = TRUE
2223
density = TRUE
2324
power_state = NO_POWER_USE
@@ -51,26 +52,23 @@ GLOBAL_LIST_EMPTY(gravity_generators)
5152
/obj/machinery/gravity_generator/proc/set_fix()
5253
stat &= ~BROKEN
5354

54-
//
55-
// Part generator which is mostly there for collision
56-
//
57-
58-
/obj/machinery/gravity_generator/part
59-
invisibility = INVISIBILITY_ABSTRACT
60-
6155
//
6256
// Generator which spawns with the station.
6357
//
6458

6559
/obj/machinery/gravity_generator/main/station/Initialize(mapload)
6660
. = ..()
67-
setup_parts()
61+
AddComponent(/datum/component/multitile, 1, list(
62+
list(1, 1, 1),
63+
list(1, MACH_CENTER, 1),
64+
list(0, 0, 0),
65+
))
6866
update_gen_list()
6967
set_power()
7068

7169
//
7270
// Main Generator with the main code
73-
//
71+
// With the multitile component it's dubious to still have this and not merge it with the `/obj/machinery/gravity_generator` itself
7472

7573
/obj/machinery/gravity_generator/main
7674
icon_state = "generator_body"
@@ -82,8 +80,6 @@ GLOBAL_LIST_EMPTY(gravity_generators)
8280
var/on = TRUE
8381
/// Is the breaker switch turned on
8482
var/breaker_on = TRUE
85-
/// Generator parts on adjacent tiles
86-
var/list/parts = list()
8783
/// Charging state (Idle, Charging, Discharging)
8884
var/charging_state = GRAV_POWER_IDLE
8985
/// Charge percentage
@@ -111,29 +107,13 @@ GLOBAL_LIST_EMPTY(gravity_generators)
111107
investigate_log("was destroyed!", "gravity")
112108
on = FALSE
113109
update_gen_list()
114-
for(var/obj/machinery/gravity_generator/part/O in parts)
115-
qdel(O)
116110
for(var/area/A in world)
117111
if(!is_station_level(A.z))
118112
continue
119113
A.gravitychange(FALSE, A)
120114
shake_everyone()
121115
return ..()
122116

123-
/obj/machinery/gravity_generator/main/proc/setup_parts()
124-
var/turf/our_turf = get_turf(src)
125-
// 9x9 block obtained from the bottom left of the block
126-
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)
127-
var/count = 10
128-
for(var/turf/T in spawn_turfs)
129-
count--
130-
if(T == our_turf) // Main body, skip it
131-
continue
132-
var/obj/machinery/gravity_generator/part/part = new(T)
133-
if(count <= 3) // That section is the top part of the generator
134-
part.density = FALSE
135-
parts += part
136-
137117
/obj/machinery/gravity_generator/main/set_broken()
138118
..()
139119
charging_state = GRAV_POWER_IDLE

code/modules/station_goals/bluespace_tap.dm

+10-22
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,6 @@
194194
max_integrity = 300
195195
pixel_x = -32 //shamelessly stolen from dna vault
196196
pixel_y = -32
197-
/// For faking having a big machine, dummy 'machines' that are hidden inside the large sprite and make certain tiles dense. See new and destroy.
198-
var/list/obj/structure/fillers = list()
199197
power_state = NO_POWER_USE // power usage is handelled manually
200198
density = TRUE
201199
interact_offline = TRUE
@@ -227,7 +225,6 @@
227225
/// How much power the machine needs per processing tick at the current level.
228226
var/actual_power_usage = 0
229227

230-
231228
// Tweak these and active_power_consumption to balance power generation
232229

233230
/// Max power input level, I don't expect this to be ever reached. It has been reached.
@@ -251,24 +248,20 @@
251248

252249
/obj/machinery/power/bluespace_tap/Initialize(mapload)
253250
. = ..()
254-
//more code stolen from dna vault, inculding comment below. Taking bets on that datum being made ever.
255-
//TODO: Replace this,bsa and gravgen with some big machinery datum
256-
var/list/occupied = list()
257-
for(var/direct in list(NORTH, NORTHEAST, NORTHWEST, EAST, WEST, SOUTHEAST, SOUTHWEST))
258-
occupied += get_step(src, direct)
259-
260-
for(var/T in occupied)
261-
var/obj/structure/filler/F = new(T)
262-
F.parent = src
263-
fillers += F
264251
component_parts = list()
265-
component_parts += new /obj/item/circuitboard/machine/bluespace_tap(null)
266-
for(var/i = 1 to 5) //five of each
267-
component_parts += new /obj/item/stock_parts/capacitor/quadratic(null)
268-
component_parts += new /obj/item/stack/ore/bluespace_crystal(null)
252+
component_parts += new /obj/item/circuitboard/machine/bluespace_tap()
253+
for(var/i in 1 to 5) //five of each
254+
component_parts += new /obj/item/stock_parts/capacitor/quadratic()
255+
component_parts += new /obj/item/stack/ore/bluespace_crystal()
269256
if(!powernet)
270257
connect_to_network()
271258

259+
AddComponent(/datum/component/multitile, 1, list(
260+
list(1, 1, 1),
261+
list(1, MACH_CENTER, 1),
262+
list(1, 0, 1),
263+
))
264+
272265
/obj/machinery/power/bluespace_tap/update_icon_state()
273266
. = ..()
274267

@@ -302,7 +295,6 @@
302295
if(light)
303296
underlays += emissive_appearance(icon, "light_mask")
304297

305-
306298
/obj/machinery/power/bluespace_tap/proc/get_icon_state_number()
307299
switch(input_level)
308300
if(0)
@@ -338,10 +330,6 @@
338330
if(.)
339331
update_icon()
340332

341-
/obj/machinery/power/bluespace_tap/Destroy()
342-
QDEL_LIST_CONTENTS(fillers)
343-
return ..()
344-
345333
/**
346334
* Increases the desired mining level
347335
*

code/modules/station_goals/dna_vault.dm

+7-24
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,6 @@ GLOBAL_LIST_INIT(non_simple_animals, typecacheof(list(/mob/living/carbon/human/m
134134
density = TRUE
135135
anchored = TRUE
136136
invisibility = 101
137-
var/obj/machinery/parent
138-
139-
/obj/structure/filler/Destroy()
140-
parent = null
141-
return ..()
142137

143138
/obj/structure/filler/ex_act()
144139
return
@@ -166,29 +161,22 @@ GLOBAL_LIST_INIT(non_simple_animals, typecacheof(list(/mob/living/carbon/human/m
166161
var/completed = FALSE
167162
var/static/list/power_lottery = list()
168163

169-
var/list/obj/structure/fillers = list()
170-
171164
/obj/machinery/dna_vault/Initialize(mapload)
172165
. = ..()
173-
//TODO: Replace this,bsa and gravgen with some big machinery datum
174-
var/list/occupied = list()
175-
for(var/direct in list(EAST,WEST,SOUTHEAST,SOUTHWEST))
176-
occupied += get_step(src,direct)
177-
occupied += locate(x+1,y-2,z)
178-
occupied += locate(x-1,y-2,z)
179-
180-
for(var/T in occupied)
181-
var/obj/structure/filler/F = new(T)
182-
F.parent = src
183-
fillers += F
184-
185166
if(SSticker.mode)
186167
for(var/datum/station_goal/dna_vault/G in SSticker.mode.station_goals)
187168
animals_max = G.animal_count
188169
plants_max = G.plant_count
189170
dna_max = G.human_count
190171
break
191172

173+
AddComponent(/datum/component/multitile, 2, list(
174+
list(0, 0, 0, 0, 0),
175+
list(0, 0, 0, 0, 0),
176+
list(0, 1, MACH_CENTER, 1, 0),
177+
list(0, 1, 0, 1, 0),
178+
list(0, 1, 0, 1, 0)
179+
))
192180
/obj/machinery/dna_vault/update_icon_state()
193181
if(stat & NOPOWER)
194182
icon_state = "vaultoff"
@@ -200,11 +188,6 @@ GLOBAL_LIST_INIT(non_simple_animals, typecacheof(list(/mob/living/carbon/human/m
200188
return
201189
update_icon(UPDATE_ICON_STATE)
202190

203-
204-
/obj/machinery/dna_vault/Destroy()
205-
QDEL_LIST_CONTENTS(fillers)
206-
return ..()
207-
208191
/obj/machinery/dna_vault/attack_ghost(mob/user)
209192
if(stat & (BROKEN|MAINT))
210193
return

paradise.dme

+1
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@
438438
#include "code\datums\components\label.dm"
439439
#include "code\datums\components\largeobjecttransparency.dm"
440440
#include "code\datums\components\material_container.dm"
441+
#include "code\datums\components\multitile.dm"
441442
#include "code\datums\components\orbiter.dm"
442443
#include "code\datums\components\paintable.dm"
443444
#include "code\datums\components\parry.dm"

0 commit comments

Comments
 (0)