* Give .props files 2-space indents.
* Move to Central Package Management.
Allows us to store NuGet package versions all in one place. Yay!
* Update NuGet packages and fix code for changes.
Notable:
Changes to ILVerify.
Npgsql doesn't need hacks for inet anymore, now we need hacks to make the old code work with this new reality.
NUnit's analyzers are already complaining and I didn't even update it to 4.x yet.
TerraFX changed to GetLastSystemError so error handling had to be changed.
Buncha APIs have more NRT annotations.
* Remove dotnet-eng NuGet package source.
I genuinely don't know what this was for, and Central Package Management starts throwing warnings about it, so YEET.
* Remove Robust.Physics project.
Never used.
* Remove erroneous NVorbis reference.
Should be VorbisPizza and otherwise wasn't used.
* Sandbox fixes
* Remove unused unit test package references.
Castle.Core and NUnit.ConsoleRunner.
* Update NUnit to 4.0.1
This requires replacing all the old assertion methods because they removed them 🥲
* Oh so that's what dotnet-eng was used for. Yeah ok that makes sense.
* Add Robust.Analyzers.Test
* Update submodule
* commit to re-run CI
93 lines
2.6 KiB
C#
93 lines
2.6 KiB
C#
using Content.Shared.Atmos.EntitySystems;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.Timing;
|
|
using Robust.Shared.Utility;
|
|
using static Content.Shared.Atmos.EntitySystems.SharedGasTileOverlaySystem;
|
|
|
|
namespace Content.Shared.Atmos
|
|
{
|
|
[Serializable, NetSerializable]
|
|
[Access(typeof(SharedGasTileOverlaySystem))]
|
|
public sealed class GasOverlayChunk
|
|
{
|
|
/// <summary>
|
|
/// The index of this chunk
|
|
/// </summary>
|
|
public readonly Vector2i Index;
|
|
public readonly Vector2i Origin;
|
|
|
|
public GasOverlayData[] TileData = new GasOverlayData[ChunkSize * ChunkSize];
|
|
|
|
[NonSerialized]
|
|
public GameTick LastUpdate;
|
|
|
|
public GasOverlayChunk(Vector2i index)
|
|
{
|
|
Index = index;
|
|
Origin = Index * ChunkSize;
|
|
}
|
|
|
|
public GasOverlayChunk(GasOverlayChunk data)
|
|
{
|
|
Index = data.Index;
|
|
Origin = data.Origin;
|
|
|
|
// This does not clone the opacity array. However, this chunk cloning is only used by the client,
|
|
// which never modifies that directly. So this should be fine.
|
|
Array.Copy(data.TileData, TileData, data.TileData.Length);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Resolve a data index into <see cref="TileData"/> for the given grid index.
|
|
/// </summary>
|
|
public int GetDataIndex(Vector2i gridIndices)
|
|
{
|
|
DebugTools.Assert(InBounds(gridIndices));
|
|
return (gridIndices.X - Origin.X) + (gridIndices.Y - Origin.Y) * ChunkSize;
|
|
}
|
|
|
|
private bool InBounds(Vector2i gridIndices)
|
|
{
|
|
return gridIndices.X >= Origin.X &&
|
|
gridIndices.Y >= Origin.Y &&
|
|
gridIndices.X < Origin.X + ChunkSize &&
|
|
gridIndices.Y < Origin.Y + ChunkSize;
|
|
}
|
|
}
|
|
|
|
public struct GasChunkEnumerator
|
|
{
|
|
private readonly GasOverlayData[] _tileData;
|
|
private int _index = -1;
|
|
|
|
public int X = ChunkSize - 1;
|
|
public int Y = -1;
|
|
|
|
public GasChunkEnumerator(GasOverlayChunk chunk)
|
|
{
|
|
_tileData = chunk.TileData;
|
|
}
|
|
|
|
public bool MoveNext(out GasOverlayData gas)
|
|
{
|
|
while (_index < _tileData.Length)
|
|
{
|
|
X += 1;
|
|
if (X >= ChunkSize)
|
|
{
|
|
X = 0;
|
|
Y += 1;
|
|
}
|
|
|
|
_index += 1;
|
|
gas = _tileData[_index];
|
|
if (!gas.Equals(default))
|
|
return true;
|
|
}
|
|
|
|
gas = default;
|
|
return false;
|
|
}
|
|
}
|
|
}
|