diff --git a/Content.Client/IconSmoothing/IconSmoothSystem.Edge.cs b/Content.Client/IconSmoothing/IconSmoothSystem.Edge.cs new file mode 100644 index 0000000000..6de31e8f0a --- /dev/null +++ b/Content.Client/IconSmoothing/IconSmoothSystem.Edge.cs @@ -0,0 +1,87 @@ +using Content.Shared.IconSmoothing; +using Robust.Client.GameObjects; + +namespace Content.Client.IconSmoothing; + +public sealed partial class IconSmoothSystem +{ + // Handles drawing edge sprites on the non-smoothed edges. + + private void InitializeEdge() + { + SubscribeLocalEvent(OnEdgeStartup); + SubscribeLocalEvent(OnEdgeShutdown); + } + + private void OnEdgeStartup(EntityUid uid, SmoothEdgeComponent component, ComponentStartup args) + { + if (!TryComp(uid, out var sprite)) + return; + + sprite.LayerSetOffset(EdgeLayer.South, new Vector2(0, -1f)); + sprite.LayerSetOffset(EdgeLayer.East, new Vector2(1f, 0f)); + sprite.LayerSetOffset(EdgeLayer.North, new Vector2(0, 1f)); + sprite.LayerSetOffset(EdgeLayer.West, new Vector2(-1f, 0f)); + + sprite.LayerSetVisible(EdgeLayer.South, false); + sprite.LayerSetVisible(EdgeLayer.East, false); + sprite.LayerSetVisible(EdgeLayer.North, false); + sprite.LayerSetVisible(EdgeLayer.West, false); + } + + private void OnEdgeShutdown(EntityUid uid, SmoothEdgeComponent component, ComponentShutdown args) + { + if (!TryComp(uid, out var sprite)) + return; + + sprite.LayerMapRemove(EdgeLayer.South); + sprite.LayerMapRemove(EdgeLayer.East); + sprite.LayerMapRemove(EdgeLayer.North); + sprite.LayerMapRemove(EdgeLayer.West); + } + + private void CalculateEdge(EntityUid uid, DirectionFlag directions, SpriteComponent? sprite = null, SmoothEdgeComponent? component = null) + { + if (!Resolve(uid, ref sprite, ref component, false)) + return; + + for (var i = 0; i < 4; i++) + { + var dir = (DirectionFlag) Math.Pow(2, i); + var edge = GetEdge(dir); + + if ((dir & directions) != 0x0) + { + sprite.LayerSetVisible(edge, false); + continue; + } + + sprite.LayerSetVisible(edge, true); + } + } + + private EdgeLayer GetEdge(DirectionFlag direction) + { + switch (direction) + { + case DirectionFlag.South: + return EdgeLayer.South; + case DirectionFlag.East: + return EdgeLayer.East; + case DirectionFlag.North: + return EdgeLayer.North; + case DirectionFlag.West: + return EdgeLayer.West; + default: + throw new ArgumentOutOfRangeException(); + } + } + + private enum EdgeLayer : byte + { + South, + East, + North, + West + } +} diff --git a/Content.Client/IconSmoothing/IconSmoothSystem.cs b/Content.Client/IconSmoothing/IconSmoothSystem.cs index 2206821303..af04d6d67d 100644 --- a/Content.Client/IconSmoothing/IconSmoothSystem.cs +++ b/Content.Client/IconSmoothing/IconSmoothSystem.cs @@ -1,3 +1,4 @@ +using Content.Shared.IconSmoothing; using JetBrains.Annotations; using Robust.Client.GameObjects; using Robust.Shared.Map; @@ -11,7 +12,7 @@ namespace Content.Client.IconSmoothing /// Entity system implementing the logic for /// [UsedImplicitly] - internal sealed class IconSmoothSystem : EntitySystem + public sealed partial class IconSmoothSystem : EntitySystem { [Dependency] private readonly IMapManager _mapManager = default!; @@ -24,6 +25,7 @@ namespace Content.Client.IconSmoothing { base.Initialize(); + InitializeEdge(); SubscribeLocalEvent(OnAnchorChanged); SubscribeLocalEvent(OnShutdown); SubscribeLocalEvent(OnStartup); @@ -166,6 +168,9 @@ namespace Content.Client.IconSmoothing EntityQuery xformQuery, IconSmoothComponent? smooth = null) { + TransformComponent? xform; + MapGridComponent? grid = null; + // The generation check prevents updating an entity multiple times per tick. // As it stands now, it's totally possible for something to get queued twice. // Generation on the component is set after an update so we can cull updates that happened this generation. @@ -173,8 +178,33 @@ namespace Content.Client.IconSmoothing || smooth.Mode == IconSmoothingMode.NoSprite || smooth.UpdateGeneration == _generation) { + if (smooth != null && + TryComp(uid, out var edge) && + xformQuery.TryGetComponent(uid, out xform)) + { + var directions = DirectionFlag.None; + + if (_mapManager.TryGetGrid(xform.GridUid, out grid)) + { + var pos = grid.TileIndicesFor(xform.Coordinates); + + if (MatchingEntity(smooth, grid.GetAnchoredEntities(pos.Offset(Direction.North)), smoothQuery)) + directions |= DirectionFlag.North; + if (MatchingEntity(smooth, grid.GetAnchoredEntities(pos.Offset(Direction.South)), smoothQuery)) + directions |= DirectionFlag.South; + if (MatchingEntity(smooth, grid.GetAnchoredEntities(pos.Offset(Direction.East)), smoothQuery)) + directions |= DirectionFlag.East; + if (MatchingEntity(smooth, grid.GetAnchoredEntities(pos.Offset(Direction.West)), smoothQuery)) + directions |= DirectionFlag.West; + } + + CalculateEdge(uid, directions, component: edge); + } + return; } + + xform = xformQuery.GetComponent(uid); smooth.UpdateGeneration = _generation; if (!spriteQuery.TryGetComponent(uid, out var sprite)) @@ -184,10 +214,6 @@ namespace Content.Client.IconSmoothing return; } - var xform = xformQuery.GetComponent(uid); - - MapGridComponent? grid = null; - if (xform.Anchored) { if (!_mapManager.TryGetGrid(xform.GridUid, out grid)) @@ -242,10 +268,11 @@ namespace Content.Client.IconSmoothing if (matching) { sprite.LayerSetState(0, $"{smooth.StateBase}1"); - return; } - - sprite.LayerSetState(0, $"{smooth.StateBase}0"); + else + { + sprite.LayerSetState(0, $"{smooth.StateBase}0"); + } } private void CalculateNewSpriteCardinal(MapGridComponent? grid, IconSmoothComponent smooth, SpriteComponent sprite, TransformComponent xform, EntityQuery smoothQuery) @@ -269,6 +296,19 @@ namespace Content.Client.IconSmoothing dirs |= CardinalConnectDirs.West; sprite.LayerSetState(0, $"{smooth.StateBase}{(int) dirs}"); + + var directions = DirectionFlag.None; + + if ((dirs & CardinalConnectDirs.South) != 0x0) + directions |= DirectionFlag.South; + if ((dirs & CardinalConnectDirs.East) != 0x0) + directions |= DirectionFlag.East; + if ((dirs & CardinalConnectDirs.North) != 0x0) + directions |= DirectionFlag.North; + if ((dirs & CardinalConnectDirs.West) != 0x0) + directions |= DirectionFlag.West; + + CalculateEdge(sprite.Owner, directions, sprite); } private bool MatchingEntity(IconSmoothComponent smooth, IEnumerable candidates, EntityQuery smoothQuery) @@ -297,6 +337,22 @@ namespace Content.Client.IconSmoothing sprite.LayerSetState(CornerLayers.SE, $"{smooth.StateBase}{(int) cornerSE}"); sprite.LayerSetState(CornerLayers.SW, $"{smooth.StateBase}{(int) cornerSW}"); sprite.LayerSetState(CornerLayers.NW, $"{smooth.StateBase}{(int) cornerNW}"); + + var directions = DirectionFlag.None; + + if ((cornerSE & cornerSW) != CornerFill.None) + directions |= DirectionFlag.South; + + if ((cornerSE & cornerNE) != CornerFill.None) + directions |= DirectionFlag.East; + + if ((cornerNE & cornerNW) != CornerFill.None) + directions |= DirectionFlag.North; + + if ((cornerNW & cornerSW) != CornerFill.None) + directions |= DirectionFlag.West; + + CalculateEdge(sprite.Owner, directions, sprite); } private (CornerFill ne, CornerFill nw, CornerFill sw, CornerFill se) CalculateCornerFill(MapGridComponent grid, IconSmoothComponent smooth, TransformComponent xform, EntityQuery smoothQuery) diff --git a/Content.Client/Mining/OreVeinVisualsComponent.cs b/Content.Client/Mining/OreVeinVisualsComponent.cs new file mode 100644 index 0000000000..c662111c3e --- /dev/null +++ b/Content.Client/Mining/OreVeinVisualsComponent.cs @@ -0,0 +1,6 @@ +namespace Content.Client.Mining; + +public sealed class OreVeinVisualsComponent +{ + +} diff --git a/Content.Shared/IconSmoothing/SmoothEdgeComponent.cs b/Content.Shared/IconSmoothing/SmoothEdgeComponent.cs new file mode 100644 index 0000000000..ccde4c9c98 --- /dev/null +++ b/Content.Shared/IconSmoothing/SmoothEdgeComponent.cs @@ -0,0 +1,12 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.IconSmoothing; + +/// +/// Applies an edge sprite to for non-smoothed directions. +/// +[RegisterComponent, NetworkedComponent] +public sealed class SmoothEdgeComponent : Component +{ + +} diff --git a/Content.Server/Mining/Components/OreVeinComponent.cs b/Content.Shared/Mining/Components/OreVeinComponent.cs similarity index 100% rename from Content.Server/Mining/Components/OreVeinComponent.cs rename to Content.Shared/Mining/Components/OreVeinComponent.cs diff --git a/Content.Shared/Mining/OrePrototype.cs b/Content.Shared/Mining/OrePrototype.cs index f2dbe2cc68..3d0cab5a02 100644 --- a/Content.Shared/Mining/OrePrototype.cs +++ b/Content.Shared/Mining/OrePrototype.cs @@ -7,7 +7,6 @@ namespace Content.Shared.Mining; /// This is a prototype for defining ores that generate in rock /// [Prototype("ore")] -[DataDefinition] public sealed class OrePrototype : IPrototype { /// diff --git a/Resources/Prototypes/Entities/Structures/Walls/asteroid.yml b/Resources/Prototypes/Entities/Structures/Walls/asteroid.yml index 62e2bf9bb7..89d9d732ea 100644 --- a/Resources/Prototypes/Entities/Structures/Walls/asteroid.yml +++ b/Resources/Prototypes/Entities/Structures/Walls/asteroid.yml @@ -56,3 +56,188 @@ - type: OreVein oreChance: 0.33 oreRarityPrototypeId: RandomOreDistributionStandard + +# Rocks and ore veins +- type: entity + id: WallRock + parent: BaseStructure + name: rock + components: + - type: Gatherable + whitelist: + tags: + - Pickaxe + - type: Damageable + damageContainer: Inorganic + damageModifierSet: Metallic + - type: Destructible + thresholds: + - trigger: + !type:DamageTrigger + damage: 150 + behaviors: + - !type:DoActsBehavior + acts: ["Destruction"] + - type: Occluder + - type: Airtight + - type: Fixtures + fixtures: + - shape: + !type:PhysShapeAabb + bounds: "-0.5,-0.5,0.5,0.5" + density: 100 + mask: + - FullTileMask + layer: + - WallLayer + - type: IconSmooth + key: walls + mode: NoSprite + - type: SmoothEdge + - type: Sprite + sprite: Structures/Walls/rock.rsi + netsync: false + layers: + - state: rock + - map: [ "enum.EdgeLayer.South" ] + state: rock_south + - map: [ "enum.EdgeLayer.East" ] + state: rock_east + - map: [ "enum.EdgeLayer.North" ] + state: rock_north + - map: [ "enum.EdgeLayer.West" ] + state: rock_west + +# Ore veins +- type: entity + id: WallRockGold + parent: WallRock + description: An ore vein rich with gold + suffix: Gold + components: + - type: OreVein + oreChance: 1.0 + currentOre: OreGold + - type: Sprite + layers: + - state: rock + - map: [ "enum.EdgeLayer.South" ] + state: rock_south + - map: [ "enum.EdgeLayer.East" ] + state: rock_east + - map: [ "enum.EdgeLayer.North" ] + state: rock_north + - map: [ "enum.EdgeLayer.West" ] + state: rock_west + - state: rock_gold + +- type: entity + id: WallRockPlasma + parent: WallRock + description: An ore vein rich with plasma + suffix: Plasma + components: + - type: OreVein + oreChance: 1.0 + currentOre: OrePlasma + - type: Sprite + layers: + - state: rock + - map: [ "enum.EdgeLayer.South" ] + state: rock_south + - map: [ "enum.EdgeLayer.East" ] + state: rock_east + - map: [ "enum.EdgeLayer.North" ] + state: rock_north + - map: [ "enum.EdgeLayer.West" ] + state: rock_west + - state: rock_phoron + +- type: entity + id: WallRockQuartz + parent: WallRock + description: An ore vein rich with quartz + suffix: Quartz + components: + - type: OreVein + oreChance: 1.0 + currentOre: OreSpaceQuartz + - type: Sprite + layers: + - state: rock + - map: [ "enum.EdgeLayer.South" ] + state: rock_south + - map: [ "enum.EdgeLayer.East" ] + state: rock_east + - map: [ "enum.EdgeLayer.North" ] + state: rock_north + - map: [ "enum.EdgeLayer.West" ] + state: rock_west + - state: rock_quartz + +- type: entity + id: WallRockSilver + parent: WallRock + description: An ore vein rich with silver + suffix: Silver + components: + - type: OreVein + oreChance: 1.0 + currentOre: OreSilver + - type: Sprite + layers: + - state: rock + - map: [ "enum.EdgeLayer.South" ] + state: rock_south + - map: [ "enum.EdgeLayer.East" ] + state: rock_east + - map: [ "enum.EdgeLayer.North" ] + state: rock_north + - map: [ "enum.EdgeLayer.West" ] + state: rock_west + - state: rock_silver + +# Yes I know it drops steel but we may get smelting at some point +- type: entity + id: WallRockTin + parent: WallRock + description: An ore vein rich with steel + suffix: Steel + components: + - type: OreVein + oreChance: 1.0 + currentOre: OreSteel + - type: Sprite + layers: + - state: rock + - map: [ "enum.EdgeLayer.South" ] + state: rock_south + - map: [ "enum.EdgeLayer.East" ] + state: rock_east + - map: [ "enum.EdgeLayer.North" ] + state: rock_north + - map: [ "enum.EdgeLayer.West" ] + state: rock_west + - state: rock_tin + +- type: entity + id: WallRockUranium + parent: WallRock + description: An ore vein rich with uranium + suffix: Uranium + components: + - type: OreVein + oreChance: 1.0 + currentOre: OreUranium + - type: Sprite + layers: + - state: rock + - map: [ "enum.EdgeLayer.South" ] + state: rock_south + - map: [ "enum.EdgeLayer.East" ] + state: rock_east + - map: [ "enum.EdgeLayer.North" ] + state: rock_north + - map: [ "enum.EdgeLayer.West" ] + state: rock_west + - state: rock_uranium diff --git a/Resources/Textures/Structures/Walls/rock.rsi/meta.json b/Resources/Textures/Structures/Walls/rock.rsi/meta.json new file mode 100644 index 0000000000..ce053d2a8f --- /dev/null +++ b/Resources/Textures/Structures/Walls/rock.rsi/meta.json @@ -0,0 +1,80 @@ +{ + "version": 1, + "license": "CC-BY-SA-3.0", + "copyright": "https://github.com/Citadel-Station-13/Citadel-Station-13-RP/blob/817e7c1f225876b45891e3f06908e6d032f0a8bc/icons/turf/walls.dmi", + "size": { + "x": 32, + "y": 32 + }, + "states": [ + { + "name": "rock" + }, + { + "name": "rock_south" + }, + { + "name": "rock_east" + }, + { + "name": "rock_north" + }, + { + "name": "rock_west" + }, + { + "name": "rock_bauxite" + }, + { + "name": "rock_carbon" + }, + { + "name": "rock_copper" + }, + { + "name": "rock_diamond" + }, + { + "name": "rock_gold" + }, + { + "name": "rock_hematite" + }, + { + "name": "rock_lead" + }, + { + "name": "rock_marble" + }, + { + "name": "rock_painite" + }, + { + "name": "rock_phoron" + }, + { + "name": "rock_platinum" + }, + { + "name": "rock_quartz" + }, + { + "name": "rock_rutile" + }, + { + "name": "rock_silver" + }, + { + "name": "rock_tin" + }, + { + "name": "rock_uranium" + }, + { + "name": "rock_verdantium" + }, + { + "name": "rock_void_opal" + } + ] +} \ No newline at end of file diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock.png b/Resources/Textures/Structures/Walls/rock.rsi/rock.png new file mode 100644 index 0000000000..e52978b0c5 Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_bauxite.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_bauxite.png new file mode 100644 index 0000000000..f47f6386b4 Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_bauxite.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_carbon.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_carbon.png new file mode 100644 index 0000000000..a58cd1c264 Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_carbon.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_copper.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_copper.png new file mode 100644 index 0000000000..e22a15f31f Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_copper.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_diamond.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_diamond.png new file mode 100644 index 0000000000..eb05ebd3d1 Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_diamond.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_east.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_east.png new file mode 100644 index 0000000000..cb5cb42319 Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_east.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_gold.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_gold.png new file mode 100644 index 0000000000..5a5f005768 Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_gold.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_hematite.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_hematite.png new file mode 100644 index 0000000000..decd28a6a1 Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_hematite.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_lead.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_lead.png new file mode 100644 index 0000000000..ce186c4b5a Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_lead.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_marble.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_marble.png new file mode 100644 index 0000000000..df72eb9e25 Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_marble.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_north.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_north.png new file mode 100644 index 0000000000..06f0f0469c Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_north.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_painite.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_painite.png new file mode 100644 index 0000000000..44a1f9e811 Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_painite.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_phoron.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_phoron.png new file mode 100644 index 0000000000..b78b02323a Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_phoron.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_platinum.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_platinum.png new file mode 100644 index 0000000000..4c2fa783fb Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_platinum.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_quartz.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_quartz.png new file mode 100644 index 0000000000..7f4a091605 Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_quartz.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_rutile.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_rutile.png new file mode 100644 index 0000000000..ff63e930fd Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_rutile.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_silver.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_silver.png new file mode 100644 index 0000000000..3a06596ccf Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_silver.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_south.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_south.png new file mode 100644 index 0000000000..e3c77fcc6e Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_south.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_tin.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_tin.png new file mode 100644 index 0000000000..8f92a51636 Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_tin.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_uranium.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_uranium.png new file mode 100644 index 0000000000..1815c44d6c Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_uranium.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_verdantium.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_verdantium.png new file mode 100644 index 0000000000..69ba57867d Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_verdantium.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_void_opal.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_void_opal.png new file mode 100644 index 0000000000..7624dcee44 Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_void_opal.png differ diff --git a/Resources/Textures/Structures/Walls/rock.rsi/rock_west.png b/Resources/Textures/Structures/Walls/rock.rsi/rock_west.png new file mode 100644 index 0000000000..3859a8c07e Binary files /dev/null and b/Resources/Textures/Structures/Walls/rock.rsi/rock_west.png differ