Skip to content

Commit

Permalink
[MIRROR] Gives broken/burnt grass a smoothed texture, fixes issues wi…
Browse files Browse the repository at this point in the history
…th smoothed textures including a non-smoothed broken overlay displaying some black void (#2400) (#3250)

* Gives broken/burnt grass a smoothed texture, fixes issues with smoothed textures including a non-smoothed broken overlay displaying some black void (#83128)

## About The Pull Request
What it says on the tin. The second part of the title is technically not
currently used, but it's going to help a lot with any downstreams that
might be experiencing those issues, or for anyone in the future that
might not want to go through the troubles of adding a broken state for
their smoothed turf.

## Why It's Good For The Game
It looks nicer.

![image](https://github.com/tgstation/tgstation/assets/58045821/3dad6fb3-2fa8-402c-901e-ed816f857c63)

Credits to @Thlumyn for the pretty sprites!

I did consider using the original broken jungle grass sprites (which
were currently not used because of a typepath typo), but I elected not
to, because I think that it looks better when smoothed out, than when it
isn't smoothed out.
Here's what it looked like before my last commit:

![image](https://github.com/tgstation/tgstation/assets/58045821/8b65f8c7-99c0-4e4a-99da-62d2ec69a1e3)


## Changelog

:cl: GoldenAlpharex for the code, Thlumyn for the sprites
fix: Fixed smoothing turfs displaying some incorrect damaged overlays
because of a non-smoothing damage overlay of different dimensions than
the smoothing sprite used as the base. Less black void, let's go!
image: Added smooth broken/burnt overlays for grass, meaning that it's
going to look a lot less broken when the grass tile is at the edge of a
smoothing group.
/:cl:

* Gives broken/burnt grass a smoothed texture, fixes issues with smoothed textures including a non-smoothed broken overlay displaying some black void

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: GoldenAlpharex <[email protected]>
  • Loading branch information
3 people authored May 9, 2024
1 parent ff668e0 commit 6d00e14
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 15 deletions.
6 changes: 6 additions & 0 deletions code/__DEFINES/icon_smoothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
/// it represents the sides of our directional border object that have a neighbor
/// Is incompatible with SMOOTH_CORNERS because border objects don't have corners
#define SMOOTH_BORDER_OBJECT (1<<6)
/// Has a smooth broken sprite, used to decide whether to apply an offset to the broken overlay or not. For /turf/open only.
#define SMOOTH_BROKEN_TURF (1<<7)
/// Has a smooth burnt sprite, used to decide whether to apply an offset to the burnt overlay or not. For /turf/open only.
#define SMOOTH_BURNT_TURF (1<<8)

DEFINE_BITFIELD(smoothing_flags, list(
"SMOOTH_CORNERS" = SMOOTH_CORNERS,
Expand All @@ -25,6 +29,8 @@ DEFINE_BITFIELD(smoothing_flags, list(
"SMOOTH_QUEUED" = SMOOTH_QUEUED,
"SMOOTH_OBJ" = SMOOTH_OBJ,
"SMOOTH_BORDER_OBJECT" = SMOOTH_BORDER_OBJECT,
"SMOOTH_BROKEN_TURF" = SMOOTH_BROKEN_TURF,
"SMOOTH_BURNT_TURF" = SMOOTH_BURNT_TURF,
))

/// Components of a smoothing junction
Expand Down
5 changes: 5 additions & 0 deletions code/__DEFINES/turfs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,8 @@
* Finds the midpoint of two given turfs.
*/
#define TURF_MIDPOINT(a, b) (locate(((a.x + b.x) * 0.5), (a.y + b.y) * 0.5, (a.z + b.z) * 0.5))

/// Defines the x offset to apply to larger smoothing turfs (such as grass).
#define LARGE_TURF_SMOOTHING_X_OFFSET -9
/// Defines the y offset to apply to larger smoothing turfs (such as grass).
#define LARGE_TURF_SMOOTHING_Y_OFFSET -9
24 changes: 21 additions & 3 deletions code/game/turfs/open/_open.dm
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,33 @@
/turf/open/update_overlays()
if(isnull(damaged_dmi))
return ..()

. = ..()

if(broken)
. += mutable_appearance(damaged_dmi, pick(broken_states()))
var/mutable_appearance/broken_appearance = mutable_appearance(damaged_dmi, pick(broken_states()))

if(smoothing_flags && !(smoothing_flags & SMOOTH_BROKEN_TURF))
var/matrix/translation = new
translation.Translate(-LARGE_TURF_SMOOTHING_X_OFFSET, -LARGE_TURF_SMOOTHING_Y_OFFSET)
broken_appearance.transform = translation

. += broken_appearance

else if(burnt)
var/list/burnt_states = burnt_states()
var/mutable_appearance/burnt_appearance
if(burnt_states.len)
. += mutable_appearance(damaged_dmi, pick(burnt_states))
burnt_appearance = mutable_appearance(damaged_dmi, pick(burnt_states))
else
. += mutable_appearance(damaged_dmi, pick(broken_states()))
burnt_appearance = mutable_appearance(damaged_dmi, pick(broken_states()))

if(smoothing_flags && !(smoothing_flags & SMOOTH_BURNT_TURF))
var/matrix/translation = new
translation.Translate(-LARGE_TURF_SMOOTHING_X_OFFSET, -LARGE_TURF_SMOOTHING_Y_OFFSET)
burnt_appearance.transform = translation

. += burnt_appearance

//direction is direction of travel of A
/turf/open/zPassIn(direction)
Expand Down
33 changes: 28 additions & 5 deletions code/game/turfs/open/grass.dm
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,52 @@
barefootstep = FOOTSTEP_GRASS
clawfootstep = FOOTSTEP_GRASS
heavyfootstep = FOOTSTEP_GENERIC_HEAVY
smoothing_flags = SMOOTH_BITMASK
smoothing_flags = SMOOTH_BITMASK | SMOOTH_BROKEN_TURF | SMOOTH_BURNT_TURF
smoothing_groups = SMOOTH_GROUP_TURF_OPEN + SMOOTH_GROUP_FLOOR_GRASS
canSmoothWith = SMOOTH_GROUP_FLOOR_GRASS + SMOOTH_GROUP_CLOSED_TURFS
layer = HIGH_TURF_LAYER
damaged_dmi = 'icons/turf/damaged.dmi'
damaged_dmi = 'icons/turf/floors/grass_damaged.dmi'
/// The icon used for smoothing.
var/smooth_icon = 'icons/turf/floors/grass.dmi'
/// The base icon_state for the broken state.
var/base_broken_icon_state = "grass_damaged"
/// The base icon_state for the burnt state.
var/base_burnt_icon_state = "grass_damaged"

/turf/open/misc/grass/broken_states()
return list("grass_damaged")
if (!smoothing_junction || !(smoothing_flags & SMOOTH_BROKEN_TURF))
return list("[base_broken_icon_state]-255")

return list("[base_broken_icon_state]-[smoothing_junction]")

/turf/open/misc/grass/burnt_states()
return list("grass_damaged")
if (!smoothing_junction || !(smoothing_flags & SMOOTH_BURNT_TURF))
return list("[base_burnt_icon_state]-255")

return list("[base_burnt_icon_state]-[smoothing_junction]")

/turf/open/misc/grass/Initialize(mapload)
. = ..()
if(smoothing_flags)
var/matrix/translation = new
translation.Translate(-9, -9)
translation.Translate(LARGE_TURF_SMOOTHING_X_OFFSET, LARGE_TURF_SMOOTHING_Y_OFFSET)
transform = translation
icon = smooth_icon

if(is_station_level(z))
GLOB.station_turfs += src


/turf/open/misc/grass/get_smooth_underlay_icon(mutable_appearance/underlay_appearance, turf/asking_turf, adjacency_dir)
. = ..()
if (!.)
return

if(!smoothing_flags)
return

underlay_appearance.transform = transform


/turf/open/misc/grass/lavaland
initial_gas_mix = LAVALAND_DEFAULT_ATMOS
8 changes: 1 addition & 7 deletions code/game/turfs/open/planet.dm
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,14 @@

/turf/open/misc/grass/jungle
name = "jungle grass"
desc = "Greener on the other side."
initial_gas_mix = OPENTURF_DEFAULT_ATMOS
planetary_atmos = TRUE
baseturfs = /turf/open/misc/dirt
desc = "Greener on the other side."
icon_state = "junglegrass"
base_icon_state = "junglegrass"
smooth_icon = 'icons/turf/floors/junglegrass.dmi'

/turf/open/misc/grass/broken_states()
return list("jungle_damaged")

/turf/open/misc/grass/burnt_states()
return list("jungle_damaged")

/turf/open/misc/grass/jungle/lavaland
initial_gas_mix = LAVALAND_DEFAULT_ATMOS

Expand Down
Binary file added icons/turf/floors/grass_damaged.dmi
Binary file not shown.
Binary file added icons/turf/floors/grass_damaged.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions icons/turf/floors/grass_damaged.png.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
output_name = "grass_damaged"
template = "bitmask/diagonal_32x32.toml"

[icon_size]
x = 50
y = 50

[output_icon_size]
x = 50
y = 50

[cut_pos]
x = 25
y = 25

0 comments on commit 6d00e14

Please sign in to comment.