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:
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -11,20 +12,20 @@ namespace Content.Shared.GameObjects.EntitySystems.Atmos
|
||||
/// Grid for this chunk
|
||||
/// </summary>
|
||||
public GridId GridIndices { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Origin of this chunk
|
||||
/// </summary>
|
||||
public MapIndices MapIndices { get; }
|
||||
|
||||
public Vector2i Vector2i { get; }
|
||||
|
||||
public SharedGasTileOverlaySystem.GasOverlayData[,] TileData = new SharedGasTileOverlaySystem.GasOverlayData[SharedGasTileOverlaySystem.ChunkSize, SharedGasTileOverlaySystem.ChunkSize];
|
||||
|
||||
public GameTick LastUpdate { get; private set; }
|
||||
|
||||
public GasOverlayChunk(GridId gridIndices, MapIndices mapIndices)
|
||||
public GasOverlayChunk(GridId gridIndices, Vector2i Vector2i)
|
||||
{
|
||||
GridIndices = gridIndices;
|
||||
MapIndices = mapIndices;
|
||||
Vector2i = Vector2i;
|
||||
}
|
||||
|
||||
public void Dirty(GameTick currentTick)
|
||||
@@ -37,12 +38,12 @@ namespace Content.Shared.GameObjects.EntitySystems.Atmos
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="indices"></param>
|
||||
public void Update(SharedGasTileOverlaySystem.GasOverlayData data, MapIndices indices)
|
||||
public void Update(SharedGasTileOverlaySystem.GasOverlayData data, Vector2i indices)
|
||||
{
|
||||
DebugTools.Assert(InBounds(indices));
|
||||
var (offsetX, offsetY) = (indices.X - MapIndices.X,
|
||||
indices.Y - MapIndices.Y);
|
||||
|
||||
var (offsetX, offsetY) = (indices.X - Vector2i.X,
|
||||
indices.Y - Vector2i.Y);
|
||||
|
||||
TileData[offsetX, offsetY] = data;
|
||||
}
|
||||
|
||||
@@ -64,7 +65,7 @@ namespace Content.Shared.GameObjects.EntitySystems.Atmos
|
||||
}
|
||||
}
|
||||
|
||||
public void GetData(List<(MapIndices, SharedGasTileOverlaySystem.GasOverlayData)> existingData, HashSet<MapIndices> indices)
|
||||
public void GetData(List<(Vector2i, SharedGasTileOverlaySystem.GasOverlayData)> existingData, HashSet<Vector2i> indices)
|
||||
{
|
||||
foreach (var index in indices)
|
||||
{
|
||||
@@ -72,28 +73,28 @@ namespace Content.Shared.GameObjects.EntitySystems.Atmos
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<MapIndices> GetAllIndices()
|
||||
public IEnumerable<Vector2i> GetAllIndices()
|
||||
{
|
||||
for (var x = 0; x < SharedGasTileOverlaySystem.ChunkSize; x++)
|
||||
{
|
||||
for (var y = 0; y < SharedGasTileOverlaySystem.ChunkSize; y++)
|
||||
{
|
||||
yield return new MapIndices(MapIndices.X + x, MapIndices.Y + y);
|
||||
yield return new Vector2i(Vector2i.X + x, Vector2i.Y + y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public SharedGasTileOverlaySystem.GasOverlayData GetData(MapIndices indices)
|
||||
public SharedGasTileOverlaySystem.GasOverlayData GetData(Vector2i indices)
|
||||
{
|
||||
DebugTools.Assert(InBounds(indices));
|
||||
return TileData[indices.X - MapIndices.X, indices.Y - MapIndices.Y];
|
||||
return TileData[indices.X - Vector2i.X, indices.Y - Vector2i.Y];
|
||||
}
|
||||
|
||||
private bool InBounds(MapIndices indices)
|
||||
private bool InBounds(Vector2i indices)
|
||||
{
|
||||
if (indices.X < MapIndices.X || indices.Y < MapIndices.Y) return false;
|
||||
if (indices.X >= MapIndices.X + SharedGasTileOverlaySystem.ChunkSize || indices.Y >= MapIndices.Y + SharedGasTileOverlaySystem.ChunkSize) return false;
|
||||
if (indices.X < Vector2i.X || indices.Y < Vector2i.Y) return false;
|
||||
if (indices.X >= Vector2i.X + SharedGasTileOverlaySystem.ChunkSize || indices.Y >= Vector2i.Y + SharedGasTileOverlaySystem.ChunkSize) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ using Robust.Shared.Map;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Utility;
|
||||
using Content.Shared.Atmos;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Shared.GameObjects.EntitySystems.Atmos
|
||||
{
|
||||
@@ -41,11 +42,11 @@ namespace Content.Shared.GameObjects.EntitySystems.Atmos
|
||||
{
|
||||
public GridId GridId { get; }
|
||||
|
||||
public MapIndices BaseIdx { get; }
|
||||
public Vector2i BaseIdx { get; }
|
||||
// LocalViewRange*LocalViewRange
|
||||
public AtmosDebugOverlayData[] OverlayData { get; }
|
||||
|
||||
public AtmosDebugOverlayMessage(GridId gridIndices, MapIndices baseIdx, AtmosDebugOverlayData[] overlayData)
|
||||
public AtmosDebugOverlayMessage(GridId gridIndices, Vector2i baseIdx, AtmosDebugOverlayData[] overlayData)
|
||||
{
|
||||
GridId = gridIndices;
|
||||
BaseIdx = baseIdx;
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
@@ -13,9 +14,9 @@ namespace Content.Shared.GameObjects.EntitySystems.Atmos
|
||||
public const byte ChunkSize = 8;
|
||||
protected float AccumulatedFrameTime;
|
||||
|
||||
public static MapIndices GetGasChunkIndices(MapIndices indices)
|
||||
public static Vector2i GetGasChunkIndices(Vector2i indices)
|
||||
{
|
||||
return new MapIndices((int) Math.Floor((float) indices.X / ChunkSize) * ChunkSize, (int) MathF.Floor((float) indices.Y / ChunkSize) * ChunkSize);
|
||||
return new Vector2i((int) Math.Floor((float) indices.X / ChunkSize) * ChunkSize, (int) MathF.Floor((float) indices.Y / ChunkSize) * ChunkSize);
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
@@ -85,9 +86,9 @@ namespace Content.Shared.GameObjects.EntitySystems.Atmos
|
||||
{
|
||||
public GridId GridId { get; }
|
||||
|
||||
public List<(MapIndices, GasOverlayData)> OverlayData { get; }
|
||||
public List<(Vector2i, GasOverlayData)> OverlayData { get; }
|
||||
|
||||
public GasOverlayMessage(GridId gridIndices, List<(MapIndices,GasOverlayData)> overlayData)
|
||||
public GasOverlayMessage(GridId gridIndices, List<(Vector2i,GasOverlayData)> overlayData)
|
||||
{
|
||||
GridId = gridIndices;
|
||||
OverlayData = overlayData;
|
||||
|
||||
Reference in New Issue
Block a user