Eris low walls & windows.
Still needs work blocked by better entity parenting, but oh well.
@@ -109,6 +109,8 @@ namespace Content.Client
|
||||
factory.Register<ConstructorComponent>();
|
||||
factory.Register<ConstructionGhostComponent>();
|
||||
factory.Register<IconSmoothComponent>();
|
||||
factory.Register<LowWallComponent>();
|
||||
factory.RegisterReference<LowWallComponent, IconSmoothComponent>();
|
||||
factory.Register<DamageableComponent>();
|
||||
factory.Register<ClothingComponent>();
|
||||
factory.Register<ItemComponent>();
|
||||
@@ -159,6 +161,8 @@ namespace Content.Client
|
||||
factory.Register<ExaminerComponent>();
|
||||
factory.Register<CharacterInfoComponent>();
|
||||
|
||||
factory.Register<WindowComponent>();
|
||||
|
||||
IoCManager.Register<IGameHud, GameHud>();
|
||||
IoCManager.Register<IClientNotifyManager, ClientNotifyManager>();
|
||||
IoCManager.Register<ISharedNotifyManager, ClientNotifyManager>();
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Client.GameObjects.EntitySystems;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization;
|
||||
using static Robust.Client.GameObjects.SpriteComponent;
|
||||
|
||||
@@ -21,7 +25,7 @@ namespace Content.Client.GameObjects.Components.IconSmoothing
|
||||
/// To use, set <c>base</c> equal to the prefix of the corner states in the sprite base RSI.
|
||||
/// Any objects with the same <c>key</c> will connect.
|
||||
/// </remarks>
|
||||
public sealed class IconSmoothComponent : Component
|
||||
public class IconSmoothComponent : Component
|
||||
{
|
||||
private string _smoothKey;
|
||||
private string _stateBase;
|
||||
@@ -76,9 +80,9 @@ namespace Content.Client.GameObjects.Components.IconSmoothing
|
||||
|
||||
SnapGrid.OnPositionChanged += SnapGridOnPositionChanged;
|
||||
Owner.EntityManager.RaiseEvent(Owner, new IconSmoothDirtyEvent(null, SnapGrid.Offset, Mode));
|
||||
var state0 = $"{StateBase}0";
|
||||
if (Mode == IconSmoothingMode.Corners)
|
||||
{
|
||||
var state0 = $"{StateBase}0";
|
||||
Sprite.LayerMapSet(CornerLayers.SE, Sprite.AddLayerState(state0));
|
||||
Sprite.LayerSetDirOffset(CornerLayers.SE, DirectionOffset.None);
|
||||
Sprite.LayerMapSet(CornerLayers.NE, Sprite.AddLayerState(state0));
|
||||
@@ -90,6 +94,107 @@ namespace Content.Client.GameObjects.Components.IconSmoothing
|
||||
}
|
||||
}
|
||||
|
||||
internal virtual void CalculateNewSprite()
|
||||
{
|
||||
switch (Mode)
|
||||
{
|
||||
case IconSmoothingMode.Corners:
|
||||
CalculateNewSpriteCorers();
|
||||
break;
|
||||
|
||||
case IconSmoothingMode.CardinalFlags:
|
||||
CalculateNewSpriteCardinal();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
private void CalculateNewSpriteCardinal()
|
||||
{
|
||||
var dirs = CardinalConnectDirs.None;
|
||||
|
||||
if (MatchingEntity(SnapGrid.GetInDir(Direction.North)))
|
||||
dirs |= CardinalConnectDirs.North;
|
||||
if (MatchingEntity(SnapGrid.GetInDir(Direction.South)))
|
||||
dirs |= CardinalConnectDirs.South;
|
||||
if (MatchingEntity(SnapGrid.GetInDir(Direction.East)))
|
||||
dirs |= CardinalConnectDirs.East;
|
||||
if (MatchingEntity(SnapGrid.GetInDir(Direction.West)))
|
||||
dirs |= CardinalConnectDirs.West;
|
||||
|
||||
Sprite.LayerSetState(0, $"{StateBase}{(int) dirs}");
|
||||
}
|
||||
|
||||
private void CalculateNewSpriteCorers()
|
||||
{
|
||||
var n = MatchingEntity(SnapGrid.GetInDir(Direction.North));
|
||||
var ne = MatchingEntity(SnapGrid.GetInDir(Direction.NorthEast));
|
||||
var e = MatchingEntity(SnapGrid.GetInDir(Direction.East));
|
||||
var se = MatchingEntity(SnapGrid.GetInDir(Direction.SouthEast));
|
||||
var s = MatchingEntity(SnapGrid.GetInDir(Direction.South));
|
||||
var sw = MatchingEntity(SnapGrid.GetInDir(Direction.SouthWest));
|
||||
var w = MatchingEntity(SnapGrid.GetInDir(Direction.West));
|
||||
var nw = MatchingEntity(SnapGrid.GetInDir(Direction.NorthWest));
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
var cornerNE = CornerFill.None;
|
||||
var cornerSE = CornerFill.None;
|
||||
var cornerSW = CornerFill.None;
|
||||
var cornerNW = CornerFill.None;
|
||||
// ReSharper restore InconsistentNaming
|
||||
|
||||
if (n)
|
||||
{
|
||||
cornerNE |= CornerFill.CounterClockwise;
|
||||
cornerNW |= CornerFill.Clockwise;
|
||||
}
|
||||
|
||||
if (ne)
|
||||
{
|
||||
cornerNE |= CornerFill.Diagonal;
|
||||
}
|
||||
|
||||
if (e)
|
||||
{
|
||||
cornerNE |= CornerFill.Clockwise;
|
||||
cornerSE |= CornerFill.CounterClockwise;
|
||||
}
|
||||
|
||||
if (se)
|
||||
{
|
||||
cornerSE |= CornerFill.Diagonal;
|
||||
}
|
||||
|
||||
if (s)
|
||||
{
|
||||
cornerSE |= CornerFill.Clockwise;
|
||||
cornerSW |= CornerFill.CounterClockwise;
|
||||
}
|
||||
|
||||
if (sw)
|
||||
{
|
||||
cornerSW |= CornerFill.Diagonal;
|
||||
}
|
||||
|
||||
if (w)
|
||||
{
|
||||
cornerSW |= CornerFill.Clockwise;
|
||||
cornerNW |= CornerFill.CounterClockwise;
|
||||
}
|
||||
|
||||
if (nw)
|
||||
{
|
||||
cornerNW |= CornerFill.Diagonal;
|
||||
}
|
||||
|
||||
Sprite.LayerSetState(CornerLayers.NE, $"{StateBase}{(int) cornerNE}");
|
||||
Sprite.LayerSetState(CornerLayers.SE, $"{StateBase}{(int) cornerSE}");
|
||||
Sprite.LayerSetState(CornerLayers.SW, $"{StateBase}{(int) cornerSW}");
|
||||
Sprite.LayerSetState(CornerLayers.NW, $"{StateBase}{(int) cornerNW}");
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
SnapGrid.OnPositionChanged -= SnapGridOnPositionChanged;
|
||||
@@ -104,6 +209,52 @@ namespace Content.Client.GameObjects.Components.IconSmoothing
|
||||
_lastPosition = (Owner.Transform.GridID, SnapGrid.Position);
|
||||
}
|
||||
|
||||
[System.Diagnostics.Contracts.Pure]
|
||||
protected bool MatchingEntity(IEnumerable<IEntity> candidates)
|
||||
{
|
||||
foreach (var entity in candidates)
|
||||
{
|
||||
if (!entity.TryGetComponent(out IconSmoothComponent other))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (other.SmoothKey == SmoothKey)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[Flags]
|
||||
private enum CardinalConnectDirs : byte
|
||||
{
|
||||
None = 0,
|
||||
North = 1,
|
||||
South = 2,
|
||||
East = 4,
|
||||
West = 8
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum CornerFill : byte
|
||||
{
|
||||
// These values are pulled from Baystation12.
|
||||
// I'm too lazy to convert the state names.
|
||||
None = 0,
|
||||
|
||||
// The cardinal tile counter-clockwise of this corner is filled.
|
||||
CounterClockwise = 1,
|
||||
|
||||
// The diagonal tile in the direction of this corner.
|
||||
Diagonal = 2,
|
||||
|
||||
// The cardinal tile clockwise of this corner is filled.
|
||||
Clockwise = 4,
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
public enum CornerLayers
|
||||
{
|
||||
|
||||
206
Content.Client/GameObjects/Components/LowWallComponent.cs
Normal file
@@ -0,0 +1,206 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Client.GameObjects.Components.IconSmoothing;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
using static Robust.Client.GameObjects.SpriteComponent;
|
||||
|
||||
namespace Content.Client.GameObjects.Components
|
||||
{
|
||||
// TODO: Over layers should be placed ABOVE the window itself too.
|
||||
// This is gonna require a client entity & parenting,
|
||||
// so IsMapTransform being naive is gonna be a problem.
|
||||
|
||||
/// <summary>
|
||||
/// Override of icon smoothing to handle the specific complexities of low walls.
|
||||
/// </summary>
|
||||
public class LowWallComponent : IconSmoothComponent
|
||||
{
|
||||
public override string Name => "LowWall";
|
||||
|
||||
public CornerFill LastCornerNE { get; private set; }
|
||||
public CornerFill LastCornerSE { get; private set; }
|
||||
public CornerFill LastCornerSW { get; private set; }
|
||||
public CornerFill LastCornerNW { get; private set; }
|
||||
|
||||
public override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
|
||||
var overState0 = $"{StateBase}over_0";
|
||||
Sprite.LayerMapSet(OverCornerLayers.SE, Sprite.AddLayerState(overState0));
|
||||
Sprite.LayerSetDirOffset(OverCornerLayers.SE, DirectionOffset.None);
|
||||
Sprite.LayerMapSet(OverCornerLayers.NE, Sprite.AddLayerState(overState0));
|
||||
Sprite.LayerSetDirOffset(OverCornerLayers.NE, DirectionOffset.CounterClockwise);
|
||||
Sprite.LayerMapSet(OverCornerLayers.NW, Sprite.AddLayerState(overState0));
|
||||
Sprite.LayerSetDirOffset(OverCornerLayers.NW, DirectionOffset.Flip);
|
||||
Sprite.LayerMapSet(OverCornerLayers.SW, Sprite.AddLayerState(overState0));
|
||||
Sprite.LayerSetDirOffset(OverCornerLayers.SW, DirectionOffset.Clockwise);
|
||||
}
|
||||
|
||||
internal override void CalculateNewSprite()
|
||||
{
|
||||
base.CalculateNewSprite();
|
||||
|
||||
var (n, nl) = MatchingWall(SnapGrid.GetInDir(Direction.North));
|
||||
var (ne, nel) = MatchingWall(SnapGrid.GetInDir(Direction.NorthEast));
|
||||
var (e, el) = MatchingWall(SnapGrid.GetInDir(Direction.East));
|
||||
var (se, sel) = MatchingWall(SnapGrid.GetInDir(Direction.SouthEast));
|
||||
var (s, sl) = MatchingWall(SnapGrid.GetInDir(Direction.South));
|
||||
var (sw, swl) = MatchingWall(SnapGrid.GetInDir(Direction.SouthWest));
|
||||
var (w, wl) = MatchingWall(SnapGrid.GetInDir(Direction.West));
|
||||
var (nw, nwl) = MatchingWall(SnapGrid.GetInDir(Direction.NorthWest));
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
var cornerNE = CornerFill.None;
|
||||
var cornerSE = CornerFill.None;
|
||||
var cornerSW = CornerFill.None;
|
||||
var cornerNW = CornerFill.None;
|
||||
|
||||
var lowCornerNE = CornerFill.None;
|
||||
var lowCornerSE = CornerFill.None;
|
||||
var lowCornerSW = CornerFill.None;
|
||||
var lowCornerNW = CornerFill.None;
|
||||
// ReSharper restore InconsistentNaming
|
||||
|
||||
if (n)
|
||||
{
|
||||
cornerNE |= CornerFill.CounterClockwise;
|
||||
cornerNW |= CornerFill.Clockwise;
|
||||
|
||||
if (!nl)
|
||||
{
|
||||
lowCornerNE |= CornerFill.CounterClockwise;
|
||||
lowCornerNW |= CornerFill.Clockwise;
|
||||
}
|
||||
}
|
||||
|
||||
if (ne)
|
||||
{
|
||||
cornerNE |= CornerFill.Diagonal;
|
||||
|
||||
if (!nel && (nl || el || n && e))
|
||||
{
|
||||
lowCornerNE |= CornerFill.Diagonal;
|
||||
}
|
||||
}
|
||||
|
||||
if (e)
|
||||
{
|
||||
cornerNE |= CornerFill.Clockwise;
|
||||
cornerSE |= CornerFill.CounterClockwise;
|
||||
|
||||
if (!el)
|
||||
{
|
||||
lowCornerNE |= CornerFill.Clockwise;
|
||||
lowCornerSE |= CornerFill.CounterClockwise;
|
||||
}
|
||||
}
|
||||
|
||||
if (se)
|
||||
{
|
||||
cornerSE |= CornerFill.Diagonal;
|
||||
|
||||
if (!sel && (sl || el || s && e))
|
||||
{
|
||||
lowCornerSE |= CornerFill.Diagonal;
|
||||
}
|
||||
}
|
||||
|
||||
if (s)
|
||||
{
|
||||
cornerSE |= CornerFill.Clockwise;
|
||||
cornerSW |= CornerFill.CounterClockwise;
|
||||
|
||||
if (!sl)
|
||||
{
|
||||
lowCornerSE |= CornerFill.Clockwise;
|
||||
lowCornerSW |= CornerFill.CounterClockwise;
|
||||
}
|
||||
}
|
||||
|
||||
if (sw)
|
||||
{
|
||||
cornerSW |= CornerFill.Diagonal;
|
||||
|
||||
if (!swl && (sl || wl || s && w))
|
||||
{
|
||||
lowCornerSW |= CornerFill.Diagonal;
|
||||
}
|
||||
}
|
||||
|
||||
if (w)
|
||||
{
|
||||
cornerSW |= CornerFill.Clockwise;
|
||||
cornerNW |= CornerFill.CounterClockwise;
|
||||
|
||||
if (!wl)
|
||||
{
|
||||
lowCornerSW |= CornerFill.Clockwise;
|
||||
lowCornerNW |= CornerFill.CounterClockwise;
|
||||
}
|
||||
}
|
||||
|
||||
if (nw)
|
||||
{
|
||||
cornerNW |= CornerFill.Diagonal;
|
||||
|
||||
if (!nwl && (nl || wl || n && w))
|
||||
{
|
||||
lowCornerNW |= CornerFill.Diagonal;
|
||||
}
|
||||
}
|
||||
|
||||
Sprite.LayerSetState(CornerLayers.NE, $"{StateBase}{(int) cornerNE}");
|
||||
Sprite.LayerSetState(CornerLayers.SE, $"{StateBase}{(int) cornerSE}");
|
||||
Sprite.LayerSetState(CornerLayers.SW, $"{StateBase}{(int) cornerSW}");
|
||||
Sprite.LayerSetState(CornerLayers.NW, $"{StateBase}{(int) cornerNW}");
|
||||
|
||||
Sprite.LayerSetState(OverCornerLayers.NE, $"{StateBase}over_{(int) lowCornerNE}");
|
||||
Sprite.LayerSetState(OverCornerLayers.SE, $"{StateBase}over_{(int) lowCornerSE}");
|
||||
Sprite.LayerSetState(OverCornerLayers.SW, $"{StateBase}over_{(int) lowCornerSW}");
|
||||
Sprite.LayerSetState(OverCornerLayers.NW, $"{StateBase}over_{(int) lowCornerNW}");
|
||||
|
||||
LastCornerNE = cornerNE;
|
||||
LastCornerSE = cornerSE;
|
||||
LastCornerSW = cornerSW;
|
||||
LastCornerNW = cornerNW;
|
||||
|
||||
foreach (var entity in SnapGrid.GetLocal())
|
||||
{
|
||||
if (entity.TryGetComponent(out WindowComponent window))
|
||||
{
|
||||
window.UpdateSprite();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[System.Diagnostics.Contracts.Pure]
|
||||
private (bool connected, bool lowWall) MatchingWall(IEnumerable<IEntity> candidates)
|
||||
{
|
||||
foreach (var entity in candidates)
|
||||
{
|
||||
if (!entity.TryGetComponent(out IconSmoothComponent other))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (other.SmoothKey == SmoothKey)
|
||||
{
|
||||
return (true, other is LowWallComponent);
|
||||
}
|
||||
}
|
||||
|
||||
return (false, false);
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
private enum OverCornerLayers
|
||||
{
|
||||
SE,
|
||||
NE,
|
||||
NW,
|
||||
SW,
|
||||
}
|
||||
}
|
||||
}
|
||||
91
Content.Client/GameObjects/Components/WindowComponent.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using Content.Client.GameObjects.EntitySystems;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
using Robust.Shared.Serialization;
|
||||
using static Content.Client.GameObjects.Components.IconSmoothing.IconSmoothComponent;
|
||||
|
||||
namespace Content.Client.GameObjects.Components
|
||||
{
|
||||
public sealed class WindowComponent : Component
|
||||
{
|
||||
public override string Name => "Window";
|
||||
|
||||
private string _stateBase;
|
||||
private ISpriteComponent _sprite;
|
||||
private SnapGridComponent _snapGrid;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_sprite = Owner.GetComponent<ISpriteComponent>();
|
||||
_snapGrid = Owner.GetComponent<SnapGridComponent>();
|
||||
}
|
||||
|
||||
public override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
|
||||
_snapGrid.OnPositionChanged += SnapGridOnPositionChanged;
|
||||
Owner.EntityManager.RaiseEvent(Owner, new WindowSmoothDirtyEvent());
|
||||
|
||||
var state0 = $"{_stateBase}0";
|
||||
_sprite.LayerMapSet(CornerLayers.SE, _sprite.AddLayerState(state0));
|
||||
_sprite.LayerSetDirOffset(CornerLayers.SE, SpriteComponent.DirectionOffset.None);
|
||||
_sprite.LayerMapSet(CornerLayers.NE, _sprite.AddLayerState(state0));
|
||||
_sprite.LayerSetDirOffset(CornerLayers.NE, SpriteComponent.DirectionOffset.CounterClockwise);
|
||||
_sprite.LayerMapSet(CornerLayers.NW, _sprite.AddLayerState(state0));
|
||||
_sprite.LayerSetDirOffset(CornerLayers.NW, SpriteComponent.DirectionOffset.Flip);
|
||||
_sprite.LayerMapSet(CornerLayers.SW, _sprite.AddLayerState(state0));
|
||||
_sprite.LayerSetDirOffset(CornerLayers.SW, SpriteComponent.DirectionOffset.Clockwise);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
_snapGrid.OnPositionChanged -= SnapGridOnPositionChanged;
|
||||
|
||||
base.Shutdown();
|
||||
}
|
||||
|
||||
private void SnapGridOnPositionChanged()
|
||||
{
|
||||
Owner.EntityManager.RaiseEvent(Owner, new WindowSmoothDirtyEvent());
|
||||
}
|
||||
|
||||
public void UpdateSprite()
|
||||
{
|
||||
var lowWall = FindLowWall();
|
||||
if (lowWall == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_sprite.LayerSetState(CornerLayers.NE, $"{_stateBase}{(int) lowWall.LastCornerNE}");
|
||||
_sprite.LayerSetState(CornerLayers.SE, $"{_stateBase}{(int) lowWall.LastCornerSE}");
|
||||
_sprite.LayerSetState(CornerLayers.SW, $"{_stateBase}{(int) lowWall.LastCornerSW}");
|
||||
_sprite.LayerSetState(CornerLayers.NW, $"{_stateBase}{(int) lowWall.LastCornerNW}");
|
||||
}
|
||||
|
||||
private LowWallComponent FindLowWall()
|
||||
{
|
||||
foreach (var entity in _snapGrid.GetLocal())
|
||||
{
|
||||
if (entity.TryGetComponent(out LowWallComponent lowWall))
|
||||
{
|
||||
return lowWall;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(ref _stateBase, "base", null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Client.GameObjects.Components.IconSmoothing;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.Interfaces.GameObjects.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
@@ -132,157 +130,10 @@ namespace Content.Client.GameObjects.EntitySystems
|
||||
return;
|
||||
}
|
||||
|
||||
var sprite = smoothing.Sprite;
|
||||
var snapGrid = smoothing.SnapGrid;
|
||||
|
||||
switch (smoothing.Mode)
|
||||
{
|
||||
case IconSmoothingMode.Corners:
|
||||
_calculateNewSpriteCorers(smoothing, snapGrid, sprite);
|
||||
break;
|
||||
|
||||
case IconSmoothingMode.CardinalFlags:
|
||||
_calculateNewSpriteCardinal(smoothing, snapGrid, sprite);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
smoothing.CalculateNewSprite();
|
||||
|
||||
smoothing.UpdateGeneration = _generation;
|
||||
}
|
||||
|
||||
private static void _calculateNewSpriteCardinal(IconSmoothComponent smoothing, SnapGridComponent snapGrid,
|
||||
ISpriteComponent sprite)
|
||||
{
|
||||
var dirs = CardinalConnectDirs.None;
|
||||
|
||||
if (MatchingEntity(smoothing, snapGrid.GetInDir(Direction.North)))
|
||||
dirs |= CardinalConnectDirs.North;
|
||||
if (MatchingEntity(smoothing, snapGrid.GetInDir(Direction.South)))
|
||||
dirs |= CardinalConnectDirs.South;
|
||||
if (MatchingEntity(smoothing, snapGrid.GetInDir(Direction.East)))
|
||||
dirs |= CardinalConnectDirs.East;
|
||||
if (MatchingEntity(smoothing, snapGrid.GetInDir(Direction.West)))
|
||||
dirs |= CardinalConnectDirs.West;
|
||||
|
||||
sprite.LayerSetState(0, $"{smoothing.StateBase}{(int) dirs}");
|
||||
}
|
||||
|
||||
private static void _calculateNewSpriteCorers(IconSmoothComponent smoothing, SnapGridComponent snapGrid,
|
||||
ISpriteComponent sprite)
|
||||
{
|
||||
var n = MatchingEntity(smoothing, snapGrid.GetInDir(Direction.North));
|
||||
var ne = MatchingEntity(smoothing, snapGrid.GetInDir(Direction.NorthEast));
|
||||
var e = MatchingEntity(smoothing, snapGrid.GetInDir(Direction.East));
|
||||
var se = MatchingEntity(smoothing, snapGrid.GetInDir(Direction.SouthEast));
|
||||
var s = MatchingEntity(smoothing, snapGrid.GetInDir(Direction.South));
|
||||
var sw = MatchingEntity(smoothing, snapGrid.GetInDir(Direction.SouthWest));
|
||||
var w = MatchingEntity(smoothing, snapGrid.GetInDir(Direction.West));
|
||||
var nw = MatchingEntity(smoothing, snapGrid.GetInDir(Direction.NorthWest));
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
var cornerNE = CornerFill.None;
|
||||
var cornerSE = CornerFill.None;
|
||||
var cornerSW = CornerFill.None;
|
||||
var cornerNW = CornerFill.None;
|
||||
// ReSharper restore InconsistentNaming
|
||||
|
||||
if (n)
|
||||
{
|
||||
cornerNE |= CornerFill.CounterClockwise;
|
||||
cornerNW |= CornerFill.Clockwise;
|
||||
}
|
||||
|
||||
if (ne)
|
||||
{
|
||||
cornerNE |= CornerFill.Diagonal;
|
||||
}
|
||||
|
||||
if (e)
|
||||
{
|
||||
cornerNE |= CornerFill.Clockwise;
|
||||
cornerSE |= CornerFill.CounterClockwise;
|
||||
}
|
||||
|
||||
if (se)
|
||||
{
|
||||
cornerSE |= CornerFill.Diagonal;
|
||||
}
|
||||
|
||||
if (s)
|
||||
{
|
||||
cornerSE |= CornerFill.Clockwise;
|
||||
cornerSW |= CornerFill.CounterClockwise;
|
||||
}
|
||||
|
||||
if (sw)
|
||||
{
|
||||
cornerSW |= CornerFill.Diagonal;
|
||||
}
|
||||
|
||||
if (w)
|
||||
{
|
||||
cornerSW |= CornerFill.Clockwise;
|
||||
cornerNW |= CornerFill.CounterClockwise;
|
||||
}
|
||||
|
||||
if (nw)
|
||||
{
|
||||
cornerNW |= CornerFill.Diagonal;
|
||||
}
|
||||
|
||||
sprite.LayerSetState(IconSmoothComponent.CornerLayers.NE, $"{smoothing.StateBase}{(int) cornerNE}");
|
||||
sprite.LayerSetState(IconSmoothComponent.CornerLayers.SE, $"{smoothing.StateBase}{(int) cornerSE}");
|
||||
sprite.LayerSetState(IconSmoothComponent.CornerLayers.SW, $"{smoothing.StateBase}{(int) cornerSW}");
|
||||
sprite.LayerSetState(IconSmoothComponent.CornerLayers.NW, $"{smoothing.StateBase}{(int) cornerNW}");
|
||||
}
|
||||
|
||||
[System.Diagnostics.Contracts.Pure]
|
||||
private static bool MatchingEntity(IconSmoothComponent source, IEnumerable<IEntity> candidates)
|
||||
{
|
||||
foreach (var entity in candidates)
|
||||
{
|
||||
if (!entity.TryGetComponent(out IconSmoothComponent other))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (other.SmoothKey == source.SmoothKey)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
[Flags]
|
||||
private enum CardinalConnectDirs : byte
|
||||
{
|
||||
None = 0,
|
||||
North = 1,
|
||||
South = 2,
|
||||
East = 4,
|
||||
West = 8
|
||||
}
|
||||
|
||||
[Flags]
|
||||
private enum CornerFill : byte
|
||||
{
|
||||
// These values are pulled from Baystation12.
|
||||
// I'm too lazy to convert the state names.
|
||||
None = 0,
|
||||
|
||||
// The cardinal tile counter-clockwise of this corner is filled.
|
||||
CounterClockwise = 1,
|
||||
|
||||
// The diagonal tile in the direction of this corner.
|
||||
Diagonal = 2,
|
||||
|
||||
// The cardinal tile clockwise of this corner is filled.
|
||||
Clockwise = 4,
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
51
Content.Client/GameObjects/EntitySystems/WindowSystem.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.GameObjects.Components;
|
||||
using Content.Client.GameObjects.Components.IconSmoothing;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components.Transform;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Client.GameObjects.EntitySystems
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class WindowSystem : EntitySystem
|
||||
{
|
||||
private readonly Queue<IEntity> _dirtyEntities = new Queue<IEntity>();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeEvent<WindowSmoothDirtyEvent>(HandleDirtyEvent);
|
||||
}
|
||||
|
||||
private void HandleDirtyEvent(object sender, WindowSmoothDirtyEvent ev)
|
||||
{
|
||||
if (sender is IEntity senderEnt && senderEnt.HasComponent<WindowComponent>())
|
||||
{
|
||||
_dirtyEntities.Enqueue(senderEnt);
|
||||
}
|
||||
}
|
||||
|
||||
public override void FrameUpdate(float frameTime)
|
||||
{
|
||||
base.FrameUpdate(frameTime);
|
||||
|
||||
// Performance: This could be spread over multiple updates, or made parallel.
|
||||
while (_dirtyEntities.Count > 0)
|
||||
{
|
||||
_dirtyEntities.Dequeue().GetComponent<WindowComponent>().UpdateSprite();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event raised by a <see cref="WindowComponent"/> when it needs to be recalculated.
|
||||
/// </summary>
|
||||
public sealed class WindowSmoothDirtyEvent : EntitySystemMessage
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
- type: Clickable
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
color: "#636769"
|
||||
color: "#71797a"
|
||||
drawdepth: Walls
|
||||
sprite: Buildings/wall.rsi
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
sizeX: 32
|
||||
sizeY: 32
|
||||
- type: SnapGrid
|
||||
offset: Edge
|
||||
offset: Center
|
||||
|
||||
- type: IconSmooth
|
||||
key: walls. Seriously, just a wall. Nothing extraordinary here.
|
||||
key: walls
|
||||
base: solid
|
||||
|
||||
placement:
|
||||
|
||||
32
Resources/Prototypes/Entities/walls/structures/low_wall.yml
Normal file
@@ -0,0 +1,32 @@
|
||||
- type: entity
|
||||
id: low_wall
|
||||
name: Low Wall
|
||||
description: Goes up to about your waist.
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
color: "#71797a"
|
||||
drawdepth: Walls
|
||||
sprite: Buildings/low_wall.rsi
|
||||
|
||||
- type: Icon
|
||||
sprite: Buildings/low_wall.rsi
|
||||
state: metal
|
||||
|
||||
- type: BoundingBox
|
||||
- type: Collidable
|
||||
- type: Damageable
|
||||
- type: Destructible
|
||||
thresholdvalue: 100
|
||||
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
|
||||
- type: LowWall
|
||||
key: walls
|
||||
base: metal_
|
||||
|
||||
placement:
|
||||
snap:
|
||||
- Wall
|
||||
30
Resources/Prototypes/Entities/walls/structures/windows.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
- type: entity
|
||||
id: window
|
||||
name: Window
|
||||
description: Don't smudge up the glass down there.
|
||||
components:
|
||||
- type: Clickable
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
drawdepth: WallTops
|
||||
sprite: Buildings/window.rsi
|
||||
|
||||
- type: Icon
|
||||
sprite: Buildings/window.rsi
|
||||
state: window0
|
||||
|
||||
- type: BoundingBox
|
||||
- type: Collidable
|
||||
- type: Damageable
|
||||
- type: Destructible
|
||||
thresholdvalue: 100
|
||||
|
||||
- type: SnapGrid
|
||||
offset: Center
|
||||
|
||||
- type: Window
|
||||
base: window
|
||||
|
||||
placement:
|
||||
snap:
|
||||
- Wall
|
||||
1
Resources/Textures/Buildings/low_wall.rsi/meta.json
Normal file
@@ -0,0 +1 @@
|
||||
{"version": 1, "size": {"x": 32, "y": 32}, "license": "CC-BY-SA-3.0", "copyright": "Taken from https://github.com/discordia-space/CEV-Eris/blob/b503939d31b23c025ddb936b75e0a265d85154c5/icons/obj/structures/low_wall.dmi", "states": [{"name": "metal", "directions": 1, "delays": [[1.0]]}, {"name": "metal_0", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "metal_1", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "metal_2", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "metal_3", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "metal_4", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "metal_5", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "metal_6", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "metal_7", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "metal_over_0", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "metal_over_1", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "metal_over_2", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "metal_over_3", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "metal_over_4", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "metal_over_5", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "metal_over_6", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "metal_over_7", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}]}
|
||||
BIN
Resources/Textures/Buildings/low_wall.rsi/metal.png
Normal file
|
After Width: | Height: | Size: 326 B |
BIN
Resources/Textures/Buildings/low_wall.rsi/metal_0.png
Normal file
|
After Width: | Height: | Size: 561 B |
BIN
Resources/Textures/Buildings/low_wall.rsi/metal_1.png
Normal file
|
After Width: | Height: | Size: 432 B |
BIN
Resources/Textures/Buildings/low_wall.rsi/metal_2.png
Normal file
|
After Width: | Height: | Size: 561 B |
BIN
Resources/Textures/Buildings/low_wall.rsi/metal_3.png
Normal file
|
After Width: | Height: | Size: 432 B |
BIN
Resources/Textures/Buildings/low_wall.rsi/metal_4.png
Normal file
|
After Width: | Height: | Size: 435 B |
BIN
Resources/Textures/Buildings/low_wall.rsi/metal_5.png
Normal file
|
After Width: | Height: | Size: 440 B |
BIN
Resources/Textures/Buildings/low_wall.rsi/metal_6.png
Normal file
|
After Width: | Height: | Size: 435 B |
BIN
Resources/Textures/Buildings/low_wall.rsi/metal_7.png
Normal file
|
After Width: | Height: | Size: 243 B |
BIN
Resources/Textures/Buildings/low_wall.rsi/metal_over_0.png
Normal file
|
After Width: | Height: | Size: 96 B |
BIN
Resources/Textures/Buildings/low_wall.rsi/metal_over_1.png
Normal file
|
After Width: | Height: | Size: 400 B |
BIN
Resources/Textures/Buildings/low_wall.rsi/metal_over_2.png
Normal file
|
After Width: | Height: | Size: 96 B |
BIN
Resources/Textures/Buildings/low_wall.rsi/metal_over_3.png
Normal file
|
After Width: | Height: | Size: 235 B |
BIN
Resources/Textures/Buildings/low_wall.rsi/metal_over_4.png
Normal file
|
After Width: | Height: | Size: 396 B |
BIN
Resources/Textures/Buildings/low_wall.rsi/metal_over_5.png
Normal file
|
After Width: | Height: | Size: 521 B |
BIN
Resources/Textures/Buildings/low_wall.rsi/metal_over_6.png
Normal file
|
After Width: | Height: | Size: 232 B |
BIN
Resources/Textures/Buildings/low_wall.rsi/metal_over_7.png
Normal file
|
After Width: | Height: | Size: 288 B |
1
Resources/Textures/Buildings/rwindow.rsi/meta.json
Normal file
@@ -0,0 +1 @@
|
||||
{"version": 1, "size": {"x": 32, "y": 32}, "license": "CC-BY-SA-3.0", "copyright": "Taken from https://github.com/discordia-space/CEV-Eris/blob/c0293684320e7b70cbcac932b8dddeee35f3a51f/icons/obj/structures/windows.dmi", "states": [{"name": "rwindow0", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "rwindow1", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "rwindow2", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "rwindow3", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "rwindow4", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "rwindow5", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "rwindow6", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "rwindow7", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}]}
|
||||
BIN
Resources/Textures/Buildings/rwindow.rsi/rwindow0.png
Normal file
|
After Width: | Height: | Size: 814 B |
BIN
Resources/Textures/Buildings/rwindow.rsi/rwindow1.png
Normal file
|
After Width: | Height: | Size: 460 B |
BIN
Resources/Textures/Buildings/rwindow.rsi/rwindow2.png
Normal file
|
After Width: | Height: | Size: 814 B |
BIN
Resources/Textures/Buildings/rwindow.rsi/rwindow3.png
Normal file
|
After Width: | Height: | Size: 460 B |
BIN
Resources/Textures/Buildings/rwindow.rsi/rwindow4.png
Normal file
|
After Width: | Height: | Size: 489 B |
BIN
Resources/Textures/Buildings/rwindow.rsi/rwindow5.png
Normal file
|
After Width: | Height: | Size: 916 B |
BIN
Resources/Textures/Buildings/rwindow.rsi/rwindow6.png
Normal file
|
After Width: | Height: | Size: 489 B |
BIN
Resources/Textures/Buildings/rwindow.rsi/rwindow7.png
Normal file
|
After Width: | Height: | Size: 324 B |
|
Before Width: | Height: | Size: 321 B After Width: | Height: | Size: 269 B |
|
Before Width: | Height: | Size: 264 B After Width: | Height: | Size: 324 B |
|
Before Width: | Height: | Size: 256 B After Width: | Height: | Size: 231 B |
|
Before Width: | Height: | Size: 264 B After Width: | Height: | Size: 324 B |
|
Before Width: | Height: | Size: 256 B After Width: | Height: | Size: 231 B |
|
Before Width: | Height: | Size: 258 B After Width: | Height: | Size: 237 B |
|
Before Width: | Height: | Size: 254 B After Width: | Height: | Size: 283 B |
|
Before Width: | Height: | Size: 258 B After Width: | Height: | Size: 237 B |
|
Before Width: | Height: | Size: 191 B After Width: | Height: | Size: 144 B |
1
Resources/Textures/Buildings/window.rsi/meta.json
Normal file
@@ -0,0 +1 @@
|
||||
{"version": 1, "size": {"x": 32, "y": 32}, "license": "CC-BY-SA-3.0", "copyright": "Taken from https://github.com/discordia-space/CEV-Eris/blob/c0293684320e7b70cbcac932b8dddeee35f3a51f/icons/obj/structures/windows.dmi", "states": [{"name": "window0", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "window1", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "window2", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "window3", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "window4", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "window5", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "window6", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}, {"name": "window7", "directions": 4, "delays": [[1.0], [1.0], [1.0], [1.0]]}]}
|
||||
BIN
Resources/Textures/Buildings/window.rsi/window0.png
Normal file
|
After Width: | Height: | Size: 524 B |
BIN
Resources/Textures/Buildings/window.rsi/window1.png
Normal file
|
After Width: | Height: | Size: 348 B |
BIN
Resources/Textures/Buildings/window.rsi/window2.png
Normal file
|
After Width: | Height: | Size: 524 B |
BIN
Resources/Textures/Buildings/window.rsi/window3.png
Normal file
|
After Width: | Height: | Size: 348 B |
BIN
Resources/Textures/Buildings/window.rsi/window4.png
Normal file
|
After Width: | Height: | Size: 352 B |
BIN
Resources/Textures/Buildings/window.rsi/window5.png
Normal file
|
After Width: | Height: | Size: 516 B |
BIN
Resources/Textures/Buildings/window.rsi/window6.png
Normal file
|
After Width: | Height: | Size: 352 B |
BIN
Resources/Textures/Buildings/window.rsi/window7.png
Normal file
|
After Width: | Height: | Size: 246 B |