Adds border smoothing! (Look ma I'm upstreaming) (#76134)

## About The Pull Request

Ok so we currently have 1 (count em) border object that wants to smooth
with other border objects. That's the tram window.

It currently does this manually, via map edits, but that's kinda crappy
so lets be better.

This pr adds a new smoothing mode to handle border objects. 
Unlike other smoothing modes, it returns a bitfield of directions the
border object connects in.

I do this by memorizing a calculation of which dirs "connect" at init,
and reading out of a global list with border object direction, direction
between objects, and if it's a border object, the other object's dir.

I'm doing this primarily because it's become useful for wallening (a
spriter saw the tram thing and is doing the same thing to pod windows,
and I want to support that)

I do think it's potentially useful in other applications too tho, and I
like dehardcoding tram windows.

Also fun bonus (or maybe downside), it's nearly 0 cost because I pulled
the bitmask smoothing define into 2 subdefines, and am swapping the
handler one out to do what I want.
Oh also I got rid of a for loop in smoothing code, redundant and costs
time in list iteration

[Moves tram windows over to the new border object
smoothing](https://github.com/tgstation/tgstation/commit/114873679c94d680788edee9665fa18dba8108c0)

Also replaces some typepath chicanery with a setDir override, for
redundancy in future
Oh and there's a update paths script too, to be nice

## Why It's Good For The Game

More visual possibility in future, fixes a hack we have currently, and
makes some spriters happy.

## Changelog
🆑
fix: Dehardcodes some stuff with tram windows, they'll be easier to map
with now
refactor: Border objects can now smooth with each other. I'm sure
something cool will come of this
/🆑
This commit is contained in:
LemonInTheDark
2023-06-21 23:05:44 -07:00
committed by GitHub
parent b78ea0997b
commit 5c032cc098
7 changed files with 240 additions and 108 deletions
@@ -3,6 +3,9 @@
desc = "A window made out of a titanium-silicate alloy. It looks tough to break. Is that a challenge?"
icon = 'icons/obj/smooth_structures/tram_window.dmi'
icon_state = "tram_mid"
smoothing_flags = SMOOTH_BITMASK|SMOOTH_BORDER_OBJECT
canSmoothWith = SMOOTH_GROUP_WINDOW_DIRECTIONAL_TRAM
smoothing_groups = SMOOTH_GROUP_WINDOW_DIRECTIONAL_TRAM
reinf = TRUE
heat_resistance = 1600
armor_type = /datum/armor/window_tram
@@ -12,6 +15,38 @@
rad_insulation = RAD_MEDIUM_INSULATION
glass_material_datum = /datum/material/alloy/titaniumglass
/obj/structure/window/reinforced/tram/Initialize(mapload, direct)
. = ..()
setDir(dir)
/obj/structure/window/reinforced/tram/setDir(new_dir)
. = ..()
if(fulltile)
return
if(dir & NORTH)
layer = LOW_ITEM_LAYER
else
layer = BELOW_OBJ_LAYER
if(dir & SOUTH)
SET_PLANE_IMPLICIT(src, WALL_PLANE_UPPER)
else
SET_PLANE_IMPLICIT(src, GAME_PLANE)
/obj/structure/window/reinforced/tram/set_smoothed_icon_state(new_junction)
if(fulltile)
return ..()
smoothing_junction = new_junction
var/smooth_left = (smoothing_junction & turn(dir, 90))
var/smooth_right = (smoothing_junction & turn(dir, -90))
if(smooth_left && smooth_right)
icon_state = "tram_mid"
else if (smooth_left)
icon_state = "tram_left"
else if (smooth_right)
icon_state = "tram_right"
else
icon_state = "tram_mid"
/obj/structure/window/reinforced/tram/front
name = "tram wall"
desc = "A lightweight titanium composite structure with a windscreen installed."
@@ -19,35 +54,14 @@
base_icon_state = "tram_window"
wtype = "shuttle"
fulltile = TRUE
smoothing_flags = NONE
canSmoothWith = null
smoothing_groups = SMOOTH_GROUP_WINDOW_DIRECTIONAL_TRAM
flags_1 = PREVENT_CLICK_UNDER_1
explosion_block = 3
glass_amount = 2
receive_ricochet_chance_mod = 1.2
/obj/structure/window/reinforced/tram/left/directional/north
icon_state = "tram_left"
layer = LOW_ITEM_LAYER
/obj/structure/window/reinforced/tram/left/directional/south
icon_state = "tram_left"
plane = WALL_PLANE_UPPER
/obj/structure/window/reinforced/tram/mid/directional/north
icon_state = "tram_mid"
layer = LOW_ITEM_LAYER
/obj/structure/window/reinforced/tram/mid/directional/south
icon_state = "tram_mid"
plane = WALL_PLANE_UPPER
/obj/structure/window/reinforced/tram/right/directional/north
icon_state = "tram_right"
layer = LOW_ITEM_LAYER
/obj/structure/window/reinforced/tram/right/directional/south
icon_state = "tram_right"
plane = WALL_PLANE_UPPER
/datum/armor/window_tram
melee = 80
bullet = 5
@@ -55,6 +69,4 @@
fire = 99
acid = 100
MAPPING_DIRECTIONAL_HELPERS(/obj/structure/window/reinforced/tram/left, 0)
MAPPING_DIRECTIONAL_HELPERS(/obj/structure/window/reinforced/tram/mid, 0)
MAPPING_DIRECTIONAL_HELPERS(/obj/structure/window/reinforced/tram/right, 0)
MAPPING_DIRECTIONAL_HELPERS(/obj/structure/window/reinforced/tram, 0)