Replace MapIndices with Vector2i (#2228)

* Replace MapIndices with Vector2i

* Update da submodule

* AA EE II OO U U

Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
DrSmugleaf
2020-10-11 15:21:21 +02:00
committed by GitHub
parent 5127824716
commit 753ca81865
35 changed files with 224 additions and 211 deletions

View File

@@ -35,7 +35,7 @@ namespace Content.Client.GameObjects.Components.IconSmoothing
internal ISpriteComponent Sprite { get; private set; }
internal SnapGridComponent SnapGrid { get; private set; }
private (GridId, MapIndices) _lastPosition;
private (GridId, Vector2i) _lastPosition;
/// <summary>
/// We will smooth with other objects with the same key.

View File

@@ -69,7 +69,7 @@ namespace Content.Client.GameObjects.EntitySystems
return _tileData.ContainsKey(gridId);
}
public AtmosDebugOverlayData? GetData(GridId gridIndex, MapIndices indices)
public AtmosDebugOverlayData? GetData(GridId gridIndex, Vector2i indices)
{
if (!_tileData.TryGetValue(gridIndex, out var srcMsg))
return null;

View File

@@ -41,8 +41,8 @@ namespace Content.Client.GameObjects.EntitySystems
private readonly int[] _fireFrameCounter = new int[FireStates];
private readonly Texture[][] _fireFrames = new Texture[FireStates][];
private Dictionary<GridId, Dictionary<MapIndices, GasOverlayChunk>> _tileData =
new Dictionary<GridId, Dictionary<MapIndices, GasOverlayChunk>>();
private Dictionary<GridId, Dictionary<Vector2i, GasOverlayChunk>> _tileData =
new Dictionary<GridId, Dictionary<Vector2i, GasOverlayChunk>>();
private AtmosphereSystem _atmosphereSystem = default!;
@@ -107,11 +107,11 @@ namespace Content.Client.GameObjects.EntitySystems
}
// Slightly different to the server-side system version
private GasOverlayChunk GetOrCreateChunk(GridId gridId, MapIndices indices)
private GasOverlayChunk GetOrCreateChunk(GridId gridId, Vector2i indices)
{
if (!_tileData.TryGetValue(gridId, out var chunks))
{
chunks = new Dictionary<MapIndices, GasOverlayChunk>();
chunks = new Dictionary<Vector2i, GasOverlayChunk>();
_tileData[gridId] = chunks;
}
@@ -148,7 +148,7 @@ namespace Content.Client.GameObjects.EntitySystems
return _tileData.ContainsKey(gridId);
}
public (Texture, Color color)[] GetOverlays(GridId gridIndex, MapIndices indices)
public (Texture, Color color)[] GetOverlays(GridId gridIndex, Vector2i indices)
{
if (!_tileData.TryGetValue(gridIndex, out var chunks))
return Array.Empty<(Texture, Color)>();

View File

@@ -82,16 +82,16 @@ namespace Content.Client.GameObjects.EntitySystems
{
var pos = ev.LastPosition.Value.pos;
AddValidEntities(grid.GetSnapGridCell(pos + new MapIndices(1, 0), ev.Offset));
AddValidEntities(grid.GetSnapGridCell(pos + new MapIndices(-1, 0), ev.Offset));
AddValidEntities(grid.GetSnapGridCell(pos + new MapIndices(0, 1), ev.Offset));
AddValidEntities(grid.GetSnapGridCell(pos + new MapIndices(0, -1), ev.Offset));
AddValidEntities(grid.GetSnapGridCell(pos + new Vector2i(1, 0), ev.Offset));
AddValidEntities(grid.GetSnapGridCell(pos + new Vector2i(-1, 0), ev.Offset));
AddValidEntities(grid.GetSnapGridCell(pos + new Vector2i(0, 1), ev.Offset));
AddValidEntities(grid.GetSnapGridCell(pos + new Vector2i(0, -1), ev.Offset));
if (ev.Mode == IconSmoothingMode.Corners)
{
AddValidEntities(grid.GetSnapGridCell(pos + new MapIndices(1, 1), ev.Offset));
AddValidEntities(grid.GetSnapGridCell(pos + new MapIndices(-1, -1), ev.Offset));
AddValidEntities(grid.GetSnapGridCell(pos + new MapIndices(-1, 1), ev.Offset));
AddValidEntities(grid.GetSnapGridCell(pos + new MapIndices(1, -1), ev.Offset));
AddValidEntities(grid.GetSnapGridCell(pos + new Vector2i(1, 1), ev.Offset));
AddValidEntities(grid.GetSnapGridCell(pos + new Vector2i(-1, -1), ev.Offset));
AddValidEntities(grid.GetSnapGridCell(pos + new Vector2i(-1, 1), ev.Offset));
AddValidEntities(grid.GetSnapGridCell(pos + new Vector2i(1, -1), ev.Offset));
}
}
}
@@ -135,7 +135,7 @@ namespace Content.Client.GameObjects.EntitySystems
/// </summary>
public sealed class IconSmoothDirtyEvent : EntitySystemMessage
{
public IconSmoothDirtyEvent(IEntity sender, (GridId grid, MapIndices pos)? lastPosition, SnapGridOffset offset, IconSmoothingMode mode)
public IconSmoothDirtyEvent(IEntity sender, (GridId grid, Vector2i pos)? lastPosition, SnapGridOffset offset, IconSmoothingMode mode)
{
LastPosition = lastPosition;
Offset = offset;
@@ -143,7 +143,7 @@ namespace Content.Client.GameObjects.EntitySystems
Sender = sender;
}
public (GridId grid, MapIndices pos)? LastPosition { get; }
public (GridId grid, Vector2i pos)? LastPosition { get; }
public SnapGridOffset Offset { get; }
public IconSmoothingMode Mode { get; }
public IEntity Sender { get; }

View File

@@ -6,6 +6,7 @@ using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.ViewVariables;
namespace Content.Client.GameObjects.EntitySystems
@@ -80,7 +81,7 @@ namespace Content.Client.GameObjects.EntitySystems
}
}
private void UpdateTile(IMapGrid grid, MapIndices position)
private void UpdateTile(IMapGrid grid, Vector2i position)
{
var tile = grid.GetTileRef(position);
var tileDef = (ContentTileDefinition) _tileDefinitionManager[tile.Tile.TypeId];