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:
@@ -11,6 +11,7 @@ using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Server.Atmos
|
||||
{
|
||||
@@ -176,7 +177,7 @@ namespace Content.Server.Atmos
|
||||
}
|
||||
|
||||
var gam = grid.GetComponent<GridAtmosphereComponent>();
|
||||
var indices = new MapIndices(x, y);
|
||||
var indices = new Vector2i(x, y);
|
||||
var tile = gam.GetTile(indices);
|
||||
|
||||
if (tile == null)
|
||||
@@ -300,7 +301,7 @@ namespace Content.Server.Atmos
|
||||
}
|
||||
|
||||
var gam = grid.GetComponent<GridAtmosphereComponent>();
|
||||
var indices = new MapIndices(x, y);
|
||||
var indices = new Vector2i(x, y);
|
||||
var tile = gam.GetTile(indices);
|
||||
|
||||
if (tile == null)
|
||||
@@ -368,7 +369,7 @@ namespace Content.Server.Atmos
|
||||
}
|
||||
|
||||
var gam = grid.GetComponent<GridAtmosphereComponent>();
|
||||
var indices = new MapIndices(x, y);
|
||||
var indices = new Vector2i(x, y);
|
||||
var tile = gam.GetTile(indices);
|
||||
|
||||
if (tile == null)
|
||||
|
||||
@@ -5,6 +5,7 @@ using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Server.Atmos
|
||||
{
|
||||
@@ -36,26 +37,26 @@ namespace Content.Server.Atmos
|
||||
return !Equals(air = coordinates.GetTileAir(entityManager)!, default);
|
||||
}
|
||||
|
||||
public static TileAtmosphere? GetTileAtmosphere(this MapIndices indices, GridId gridId)
|
||||
public static TileAtmosphere? GetTileAtmosphere(this Vector2i indices, GridId gridId)
|
||||
{
|
||||
var gridAtmos = EntitySystem.Get<AtmosphereSystem>().GetGridAtmosphere(gridId);
|
||||
|
||||
return gridAtmos?.GetTile(indices);
|
||||
}
|
||||
|
||||
public static GasMixture? GetTileAir(this MapIndices indices, GridId gridId)
|
||||
public static GasMixture? GetTileAir(this Vector2i indices, GridId gridId)
|
||||
{
|
||||
return indices.GetTileAtmosphere(gridId)?.Air;
|
||||
}
|
||||
|
||||
public static bool TryGetTileAtmosphere(this MapIndices indices, GridId gridId,
|
||||
public static bool TryGetTileAtmosphere(this Vector2i indices, GridId gridId,
|
||||
[MaybeNullWhen(false)] out TileAtmosphere atmosphere)
|
||||
{
|
||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
||||
return !Equals(atmosphere = indices.GetTileAtmosphere(gridId)!, default);
|
||||
}
|
||||
|
||||
public static bool TryGetTileAir(this MapIndices indices, GridId gridId, [MaybeNullWhen(false)] out GasMixture air)
|
||||
public static bool TryGetTileAir(this Vector2i indices, GridId gridId, [MaybeNullWhen(false)] out GasMixture air)
|
||||
{
|
||||
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
|
||||
return !Equals(air = indices.GetTileAir(gridId)!, default);
|
||||
|
||||
@@ -23,9 +23,9 @@ namespace Content.Server.Atmos
|
||||
}
|
||||
}
|
||||
|
||||
public static MapIndices Offset(this MapIndices pos, Direction dir)
|
||||
public static Vector2i Offset(this Vector2i pos, Direction dir)
|
||||
{
|
||||
return pos + (MapIndices) dir.CardinalToIntVec();
|
||||
return pos + (Vector2i) dir.CardinalToIntVec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,31 +25,31 @@ namespace Content.Server.Atmos
|
||||
/// Attemps to pry a tile.
|
||||
/// </summary>
|
||||
/// <param name="indices"></param>
|
||||
void PryTile(MapIndices indices);
|
||||
void PryTile(Vector2i indices);
|
||||
|
||||
/// <summary>
|
||||
/// Burns a tile.
|
||||
/// </summary>
|
||||
/// <param name="gridIndices"></param>
|
||||
void BurnTile(MapIndices gridIndices);
|
||||
void BurnTile(Vector2i gridIndices);
|
||||
|
||||
/// <summary>
|
||||
/// Invalidates a coordinate to be revalidated again.
|
||||
/// Use this after changing a tile's gas contents, or when the tile becomes space, etc.
|
||||
/// </summary>
|
||||
/// <param name="indices"></param>
|
||||
void Invalidate(MapIndices indices);
|
||||
void Invalidate(Vector2i indices);
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to fix a sudden vacuum by creating gas.
|
||||
/// </summary>
|
||||
void FixVacuum(MapIndices indices);
|
||||
void FixVacuum(Vector2i indices);
|
||||
|
||||
/// <summary>
|
||||
/// Revalidates indices immediately.
|
||||
/// </summary>
|
||||
/// <param name="indices"></param>
|
||||
void UpdateAdjacentBits(MapIndices indices);
|
||||
void UpdateAdjacentBits(Vector2i indices);
|
||||
|
||||
/// <summary>
|
||||
/// Adds an active tile so it becomes processed every update until it becomes inactive.
|
||||
@@ -120,7 +120,7 @@ namespace Content.Server.Atmos
|
||||
/// <param name="indices"></param>
|
||||
/// <param name="createSpace"></param>
|
||||
/// <returns></returns>
|
||||
TileAtmosphere GetTile(MapIndices indices, bool createSpace = true);
|
||||
TileAtmosphere GetTile(Vector2i indices, bool createSpace = true);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a tile.
|
||||
@@ -138,14 +138,14 @@ namespace Content.Server.Atmos
|
||||
/// <param name="indices"></param>
|
||||
/// <param name="direction"></param>
|
||||
/// <returns></returns>
|
||||
bool IsAirBlocked(MapIndices indices, AtmosDirection direction);
|
||||
bool IsAirBlocked(Vector2i indices, AtmosDirection direction);
|
||||
|
||||
/// <summary>
|
||||
/// Returns if the tile in question is space.
|
||||
/// </summary>
|
||||
/// <param name="indices"></param>
|
||||
/// <returns></returns>
|
||||
bool IsSpace(MapIndices indices);
|
||||
bool IsSpace(Vector2i indices);
|
||||
|
||||
/// <summary>
|
||||
/// Returns the volume in liters for a number of cells/tiles.
|
||||
@@ -157,7 +157,7 @@ namespace Content.Server.Atmos
|
||||
/// <summary>
|
||||
/// Returns a dictionary of adjacent TileAtmospheres.
|
||||
/// </summary>
|
||||
Dictionary<AtmosDirection, TileAtmosphere> GetAdjacentTiles(MapIndices indices, bool includeAirBlocked = false);
|
||||
Dictionary<AtmosDirection, TileAtmosphere> GetAdjacentTiles(Vector2i indices, bool includeAirBlocked = false);
|
||||
|
||||
void Update(float frameTime);
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Content.Server.Atmos
|
||||
public TileRef? Tile => GridIndices.GetTileRef(GridIndex);
|
||||
|
||||
[ViewVariables]
|
||||
public MapIndices GridIndices { get; }
|
||||
public Vector2i GridIndices { get; }
|
||||
|
||||
[ViewVariables]
|
||||
public ExcitedGroup ExcitedGroup { get; set; }
|
||||
@@ -122,7 +122,7 @@ namespace Content.Server.Atmos
|
||||
[ViewVariables]
|
||||
public bool BlocksAllAir => BlockedAirflow == AtmosDirection.All;
|
||||
|
||||
public TileAtmosphere(GridAtmosphereComponent atmosphereComponent, GridId gridIndex, MapIndices gridIndices, GasMixture mixture = null, bool immutable = false)
|
||||
public TileAtmosphere(GridAtmosphereComponent atmosphereComponent, GridId gridIndex, Vector2i gridIndices, GasMixture mixture = null, bool immutable = false)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
_gridAtmosphereComponent = atmosphereComponent;
|
||||
@@ -197,7 +197,7 @@ namespace Content.Server.Atmos
|
||||
{
|
||||
if(_soundCooldown == 0)
|
||||
EntitySystem.Get<AudioSystem>().PlayAtCoords("/Audio/Effects/space_wind.ogg",
|
||||
GridIndices.ToEntityCoordinates(_mapManager, GridIndex), AudioHelpers.WithVariation(0.125f).WithVolume(MathHelper.Clamp(PressureDifference / 10, 10, 100)));
|
||||
GridIndices.ToEntityCoordinates(GridIndex, _mapManager), AudioHelpers.WithVariation(0.125f).WithVolume(MathHelper.Clamp(PressureDifference / 10, 10, 100)));
|
||||
}
|
||||
|
||||
foreach (var entity in _gridTileLookupSystem.GetEntitiesIntersecting(GridIndex, GridIndices))
|
||||
@@ -212,7 +212,7 @@ namespace Content.Server.Atmos
|
||||
var pressureMovements = physics.EnsureController<HighPressureMovementController>();
|
||||
if (pressure.LastHighPressureMovementAirCycle < _gridAtmosphereComponent.UpdateCounter)
|
||||
{
|
||||
pressureMovements.ExperiencePressureDifference(_gridAtmosphereComponent.UpdateCounter, PressureDifference, _pressureDirection, 0, PressureSpecificTarget?.GridIndices.ToEntityCoordinates(_mapManager, GridIndex) ?? EntityCoordinates.Invalid);
|
||||
pressureMovements.ExperiencePressureDifference(_gridAtmosphereComponent.UpdateCounter, PressureDifference, _pressureDirection, 0, PressureSpecificTarget?.GridIndices.ToEntityCoordinates(GridIndex, _mapManager) ?? EntityCoordinates.Invalid);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user