diff --git a/Content.Client/IconSmoothing/IconSmoothComponent.cs b/Content.Client/IconSmoothing/IconSmoothComponent.cs index c4b6e25ec6..bc7667d222 100644 --- a/Content.Client/IconSmoothing/IconSmoothComponent.cs +++ b/Content.Client/IconSmoothing/IconSmoothComponent.cs @@ -18,19 +18,19 @@ namespace Content.Client.IconSmoothing /// /// We will smooth with other objects with the same key. /// - [DataField("key")] + [ViewVariables(VVAccess.ReadWrite), DataField("key")] public string? SmoothKey { get; } /// /// Prepended to the RSI state. /// - [DataField("base")] + [ViewVariables(VVAccess.ReadWrite), DataField("base")] public string StateBase { get; } = string.Empty; /// /// Mode that controls how the icon should be selected. /// - [DataField("mode")] + [ViewVariables(VVAccess.ReadWrite), DataField("mode")] public IconSmoothingMode Mode = IconSmoothingMode.Corners; /// @@ -57,6 +57,11 @@ namespace Content.Client.IconSmoothing /// CardinalFlags, + /// + /// The icon represents a triangular sprite with only 2 states, representing South / East being occupied or not. + /// + Diagonal, + /// /// Where this component contributes to our neighbors being calculated but we do not update our own sprite. /// diff --git a/Content.Client/IconSmoothing/IconSmoothSystem.cs b/Content.Client/IconSmoothing/IconSmoothSystem.cs index d1cc36becd..2206821303 100644 --- a/Content.Client/IconSmoothing/IconSmoothSystem.cs +++ b/Content.Client/IconSmoothing/IconSmoothSystem.cs @@ -129,12 +129,12 @@ namespace Content.Client.IconSmoothing } // Yes, we updates ALL smoothing entities surrounding us even if they would never smooth with us. - DirtyEntities(grid.GetAnchoredEntities(pos + new Vector2i(1, 0))); DirtyEntities(grid.GetAnchoredEntities(pos + new Vector2i(-1, 0))); DirtyEntities(grid.GetAnchoredEntities(pos + new Vector2i(0, 1))); DirtyEntities(grid.GetAnchoredEntities(pos + new Vector2i(0, -1))); - if (comp.Mode == IconSmoothingMode.Corners) + + if (comp.Mode is IconSmoothingMode.Corners or IconSmoothingMode.NoSprite or IconSmoothingMode.Diagonal) { DirtyEntities(grid.GetAnchoredEntities(pos + new Vector2i(1, 1))); DirtyEntities(grid.GetAnchoredEntities(pos + new Vector2i(-1, -1))); @@ -205,11 +205,49 @@ namespace Content.Client.IconSmoothing case IconSmoothingMode.CardinalFlags: CalculateNewSpriteCardinal(grid, smooth, sprite, xform, smoothQuery); break; + case IconSmoothingMode.Diagonal: + CalculateNewSpriteDiagonal(grid, smooth, sprite, xform, smoothQuery); + break; default: throw new ArgumentOutOfRangeException(); } } + private void CalculateNewSpriteDiagonal(MapGridComponent? grid, IconSmoothComponent smooth, + SpriteComponent sprite, TransformComponent xform, EntityQuery smoothQuery) + { + if (grid == null) + { + sprite.LayerSetState(0, $"{smooth.StateBase}0"); + return; + } + + var neighbors = new Vector2[] + { + new(1, 0), + new(1, -1), + new(0, -1), + }; + + var pos = grid.TileIndicesFor(xform.Coordinates); + var rotation = xform.LocalRotation; + var matching = true; + + for (var i = 0; i < neighbors.Length; i++) + { + var neighbor = (Vector2i) rotation.RotateVec(neighbors[i]); + matching = matching && MatchingEntity(smooth, grid.GetAnchoredEntities(pos + neighbor), smoothQuery); + } + + if (matching) + { + sprite.LayerSetState(0, $"{smooth.StateBase}1"); + return; + } + + sprite.LayerSetState(0, $"{smooth.StateBase}0"); + } + private void CalculateNewSpriteCardinal(MapGridComponent? grid, IconSmoothComponent smooth, SpriteComponent sprite, TransformComponent xform, EntityQuery smoothQuery) { var dirs = CardinalConnectDirs.None; diff --git a/Resources/Prototypes/Entities/Structures/Walls/walls.yml b/Resources/Prototypes/Entities/Structures/Walls/walls.yml index fdb30ab809..3c7c63dd88 100644 --- a/Resources/Prototypes/Entities/Structures/Walls/walls.yml +++ b/Resources/Prototypes/Entities/Structures/Walls/walls.yml @@ -588,9 +588,12 @@ - type: Sprite netsync: false drawdepth: Walls - # TODO: Icon smoothing support sprite: Structures/Walls/shuttle_diagonal.rsi state: state0 + - type: IconSmooth + mode: Diagonal + key: walls + base: state - type: Icon sprite: Structures/Walls/shuttle_diagonal.rsi state: state0 diff --git a/Resources/Textures/Structures/Walls/shuttle_diagonal.rsi/meta.json b/Resources/Textures/Structures/Walls/shuttle_diagonal.rsi/meta.json index d031322d2d..bfe6cd74ef 100644 --- a/Resources/Textures/Structures/Walls/shuttle_diagonal.rsi/meta.json +++ b/Resources/Textures/Structures/Walls/shuttle_diagonal.rsi/meta.json @@ -9,6 +9,9 @@ "states": [ { "name": "state0" + }, + { + "name": "state1" } ] } \ No newline at end of file diff --git a/Resources/Textures/Structures/Walls/shuttle_diagonal.rsi/state1.png b/Resources/Textures/Structures/Walls/shuttle_diagonal.rsi/state1.png new file mode 100644 index 0000000000..127a0ce55f Binary files /dev/null and b/Resources/Textures/Structures/Walls/shuttle_diagonal.rsi/state1.png differ