Refactors sheet crafting to better support directional construction (#74572)

## About The Pull Request


https://github.com/tgstation/tgstation/blob/0426f7ddbaa91439c7278189101f5db9c7f2ed95/code/game/objects/items/stacks/stack.dm#L449

Ok, but can we not?

This PR refactors sheet crafting to generalize all the cases that were
previously locked behind grille/window type checks and such. In their
stead there are bitflags that can be set to achieve certain behaviors.

All the behavior from before should be preserved, but now it can be
extended to other items. E.g. if you want a railing that can be crafted
underneath directional windows, or an item that behaves like a grille
does--it's just a matter of setting the right obj_flags for it now.

This makes it very simple and painless to add new recipes that use
directional crafting! It's all modular now.

<details><summary>Details</summary>

---

### What I've done:

-Eliminated all the type checks, instead it will now be handled by
object flags and recipe vars, making for a much more configurable
system.

-Added two new obj_flags: `BLOCKS_CONSTRUCTION_DIR` and
`IGNORE_DENSITY`.
-Additionally, I renamed the existing flag `NO_BUILD` to
`BLOCKS_CONSTRUCTION`.

-Changes the proc `valid_window_location` to `valid_build_direction`,
and makes it work for things other than windows.

-Removed a deprecated `window_checks` var from the stack_recipe datum.
-Added three more vars to the stack_recipe datum: `check_direction` and
`check_density`, `is_fulltile`

-Decoupled `on_solid_ground` from the object density check. Now you can
set those separately, allowing you to make recipes that forbid/allow
building things over other things while in space.

---

### What the new flags do:

`BLOCKS_CONSTRUCTION` works as before---prevents objects from being
built on the object. I felt that the previous name was not descriptive
enough, you should know exactly what it does just from looking at the
name.
_example: dna scanner_

`BLOCKS_CONSTRUCTION_DIR` -- setting this on an object will prevent
objects from being built on it when their directions are the same.
_example: directional windows, windoors, railings_

`IGNORE_DENSITY` -- setting this on an object will cause its density to
be ignored when performing the construction density check. This could
have other potential uses as well in the future.
_example: grilles, directional windows, tables_

These three flags cover all the bases for the types of items that are
currently craftable, so there is no more need for any type checking or
weird snowflake window checks. Simply set the appropriate flag and it'll
work as you would expect.

---


### What the recipe vars do:
`check_direction` tells the recipe to check if there's something in that
direction with the `BLOCKS_CONSTRUCTION_DIR` flag set.

`check_density` tells the recipe to run the density check when set. This
is true by default. There are very few items in the game that currently
have this set to false--namely grilles. Setting this to false will make
it so that the object can be constructed regardless of what is in that
tile (unless `one_per_turf` is also set, which will make it so that you
can't craft the same thing twice in the same turf).

`is_fulltile` is used for fulltile windows, but it doesn't necessarily
have to be--you can give this to any recipe and it will adopt the same
properties as that of the fulltile window. Basically they have a special
case where they shouldn't be able to be built over directional
constructions, where normally things would be able to be. Setting this
makes check_direction true as well.

---

### In summary: 

Sheet crafting still works just as it did before. But the backend of it
has gotten a glow up and will be able to more easily support new
behaviors.

</details>

## Why It's Good For The Game

This makes the crafting system much more flexible to add recipes to, and
will prevent bad code practices of stacking more conditionals down the
line whenever someone wants to add an item that behaves like grilles or
directional windows in how they are constructed.

It had to be done. Those window checks were a mess.

## Changelog

🆑
qol: added fifty stack versions of remaining glass sheet stacks for ease
of debugging
refactor: refactored sheet crafting to better support directional
constructions that aren't windows
/🆑

---------

Co-authored-by: san7890 <the@san7890.com>
This commit is contained in:
Bloop
2023-04-15 23:48:34 -04:00
committed by GitHub
parent 70064d50db
commit ac5236a251
29 changed files with 280 additions and 257 deletions
+2 -1
View File
@@ -11,6 +11,7 @@
anchored = TRUE
pass_flags_self = PASSGRILLE
flags_1 = CONDUCT_1
obj_flags = CAN_BE_HIT | IGNORE_DENSITY
pressure_resistance = 5*ONE_ATMOSPHERE
armor_type = /datum/armor/structure_grille
max_integrity = 50
@@ -104,7 +105,7 @@
var/obj/structure/window/window_path = the_rcd.window_type
if(!ispath(window_path))
CRASH("Invalid window path type in RCD: [window_path]")
if(!valid_window_location(T, user.dir, is_fulltile = initial(window_path.fulltile)))
if(!valid_build_direction(T, user.dir, is_fulltile = initial(window_path.fulltile)))
balloon_alert(user, "window already here!")
return FALSE
var/obj/structure/window/WD = new the_rcd.window_type(T, user.dir)
+1
View File
@@ -4,6 +4,7 @@
icon = 'icons/obj/railings.dmi'
icon_state = "railing"
flags_1 = ON_BORDER_1
obj_flags = CAN_BE_HIT | BLOCKS_CONSTRUCTION_DIR
density = TRUE
anchored = TRUE
pass_flags_self = LETPASSTHROW|PASSSTRUCTURE
@@ -22,6 +22,7 @@
anchored = TRUE
pass_flags_self = PASSTABLE | LETPASSTHROW
layer = TABLE_LAYER
obj_flags = CAN_BE_HIT | IGNORE_DENSITY
var/frame = /obj/structure/table_frame
var/framestack = /obj/item/stack/rods
var/glass_shard_type = /obj/item/shard
@@ -18,6 +18,7 @@
anchored = FALSE
density = FALSE
dir = NORTH
obj_flags = CAN_BE_HIT | BLOCKS_CONSTRUCTION_DIR
set_dir_on_move = FALSE
var/obj/item/electronics/airlock/electronics = null
@@ -64,10 +65,10 @@
if(istype(mover, /obj/structure/window))
var/obj/structure/window/moved_window = mover
return valid_window_location(loc, moved_window.dir, is_fulltile = moved_window.fulltile)
return valid_build_direction(loc, moved_window.dir, is_fulltile = moved_window.fulltile)
if(istype(mover, /obj/structure/windoor_assembly) || istype(mover, /obj/machinery/door/window))
return valid_window_location(loc, mover.dir, is_fulltile = FALSE)
return valid_build_direction(loc, mover.dir, is_fulltile = FALSE)
/obj/structure/windoor_assembly/can_atmos_pass(turf/T, vertical = FALSE)
if(get_dir(loc, T) == dir)
+14 -2
View File
@@ -7,6 +7,7 @@
pressure_resistance = 4*ONE_ATMOSPHERE
anchored = TRUE //initially is 0 for tile smoothing
flags_1 = ON_BORDER_1
obj_flags = CAN_BE_HIT | BLOCKS_CONSTRUCTION_DIR | IGNORE_DENSITY
max_integrity = 50
can_be_unanchored = TRUE
resistance_flags = ACID_PROOF
@@ -56,6 +57,8 @@
if(fulltile)
setDir()
obj_flags &= ~BLOCKS_CONSTRUCTION_DIR
obj_flags &= ~IGNORE_DENSITY
AddElement(/datum/element/can_barricade)
//windows only block while reinforced and fulltile
@@ -123,10 +126,10 @@
if(istype(mover, /obj/structure/window))
var/obj/structure/window/moved_window = mover
return valid_window_location(loc, moved_window.dir, is_fulltile = moved_window.fulltile)
return valid_build_direction(loc, moved_window.dir, is_fulltile = moved_window.fulltile)
if(istype(mover, /obj/structure/windoor_assembly) || istype(mover, /obj/machinery/door/window))
return valid_window_location(loc, mover.dir, is_fulltile = FALSE)
return valid_build_direction(loc, mover.dir, is_fulltile = FALSE)
return TRUE
@@ -647,6 +650,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/window/reinforced/plasma/spawner, 0)
max_integrity = 100
fulltile = TRUE
flags_1 = PREVENT_CLICK_UNDER_1
obj_flags = CAN_BE_HIT
smoothing_flags = SMOOTH_BITMASK
smoothing_groups = SMOOTH_GROUP_WINDOW_FULLTILE
canSmoothWith = SMOOTH_GROUP_WINDOW_FULLTILE
@@ -668,6 +672,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/window/reinforced/plasma/spawner, 0)
max_integrity = 400
fulltile = TRUE
flags_1 = PREVENT_CLICK_UNDER_1
obj_flags = CAN_BE_HIT
smoothing_flags = SMOOTH_BITMASK
smoothing_groups = SMOOTH_GROUP_WINDOW_FULLTILE
canSmoothWith = SMOOTH_GROUP_WINDOW_FULLTILE
@@ -684,6 +689,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/window/reinforced/plasma/spawner, 0)
max_integrity = 1000
fulltile = TRUE
flags_1 = PREVENT_CLICK_UNDER_1
obj_flags = CAN_BE_HIT
smoothing_flags = SMOOTH_BITMASK
smoothing_groups = SMOOTH_GROUP_WINDOW_FULLTILE
canSmoothWith = SMOOTH_GROUP_WINDOW_FULLTILE
@@ -700,6 +706,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/window/reinforced/plasma/spawner, 0)
max_integrity = 150
fulltile = TRUE
flags_1 = PREVENT_CLICK_UNDER_1
obj_flags = CAN_BE_HIT
state = RWINDOW_SECURE
smoothing_flags = SMOOTH_BITMASK
smoothing_groups = SMOOTH_GROUP_WINDOW_FULLTILE
@@ -722,6 +729,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/window/reinforced/plasma/spawner, 0)
base_icon_state = "tinted_window"
fulltile = TRUE
flags_1 = PREVENT_CLICK_UNDER_1
obj_flags = CAN_BE_HIT
smoothing_flags = SMOOTH_BITMASK
smoothing_groups = SMOOTH_GROUP_WINDOW_FULLTILE
canSmoothWith = SMOOTH_GROUP_WINDOW_FULLTILE
@@ -748,6 +756,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/window/reinforced/plasma/spawner, 0)
reinf = TRUE
fulltile = TRUE
flags_1 = PREVENT_CLICK_UNDER_1
obj_flags = CAN_BE_HIT
reinf = TRUE
heat_resistance = 1600
armor_type = /datum/armor/reinforced_shuttle
@@ -795,6 +804,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/window/reinforced/plasma/spawner, 0)
wtype = "shuttle"
fulltile = TRUE
flags_1 = PREVENT_CLICK_UNDER_1
obj_flags = CAN_BE_HIT
heat_resistance = 1600
armor_type = /datum/armor/plasma_plastitanium
smoothing_flags = SMOOTH_BITMASK
@@ -827,6 +837,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/window/reinforced/plasma/spawner, 0)
max_integrity = 15
fulltile = TRUE
flags_1 = PREVENT_CLICK_UNDER_1
obj_flags = CAN_BE_HIT
smoothing_flags = SMOOTH_BITMASK
smoothing_groups = SMOOTH_GROUP_PAPERFRAME
canSmoothWith = SMOOTH_GROUP_PAPERFRAME
@@ -916,6 +927,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/window/reinforced/plasma/spawner, 0)
canSmoothWith = SMOOTH_GROUP_WINDOW_FULLTILE_BRONZE
fulltile = TRUE
flags_1 = PREVENT_CLICK_UNDER_1
obj_flags = CAN_BE_HIT
max_integrity = 50
glass_amount = 2