Ore veins (#14011)
* Ore veins I dislike rocks just providing generic drops and this factors into mining more. * fixes * descriptions * comment * every flipping time
This commit is contained in:
87
Content.Client/IconSmoothing/IconSmoothSystem.Edge.cs
Normal file
87
Content.Client/IconSmoothing/IconSmoothSystem.Edge.cs
Normal file
@@ -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<SmoothEdgeComponent, ComponentStartup>(OnEdgeStartup);
|
||||
SubscribeLocalEvent<SmoothEdgeComponent, ComponentShutdown>(OnEdgeShutdown);
|
||||
}
|
||||
|
||||
private void OnEdgeStartup(EntityUid uid, SmoothEdgeComponent component, ComponentStartup args)
|
||||
{
|
||||
if (!TryComp<SpriteComponent>(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<SpriteComponent>(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
|
||||
}
|
||||
}
|
||||
@@ -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 <see cref="IconSmoothComponent"/>
|
||||
/// </summary>
|
||||
[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<IconSmoothComponent, AnchorStateChangedEvent>(OnAnchorChanged);
|
||||
SubscribeLocalEvent<IconSmoothComponent, ComponentShutdown>(OnShutdown);
|
||||
SubscribeLocalEvent<IconSmoothComponent, ComponentStartup>(OnStartup);
|
||||
@@ -166,6 +168,9 @@ namespace Content.Client.IconSmoothing
|
||||
EntityQuery<TransformComponent> 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<SmoothEdgeComponent>(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<IconSmoothComponent> 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<EntityUid> candidates, EntityQuery<IconSmoothComponent> 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<IconSmoothComponent> smoothQuery)
|
||||
|
||||
6
Content.Client/Mining/OreVeinVisualsComponent.cs
Normal file
6
Content.Client/Mining/OreVeinVisualsComponent.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Content.Client.Mining;
|
||||
|
||||
public sealed class OreVeinVisualsComponent
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user