mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Rename GridId.Nullspace to GridId.Invalid, because it has nothing to do with Nullspace anymore.
This commit is contained in:
@@ -194,7 +194,7 @@ namespace Robust.Client.GameObjects
|
||||
public override IEntity CreateEntityUninitialized(string prototypeName, GridCoordinates coordinates)
|
||||
{
|
||||
var newEntity = CreateEntity(prototypeName, NewClientEntityUid());
|
||||
if (coordinates.GridID != GridId.Nullspace)
|
||||
if (coordinates.GridID != GridId.Invalid)
|
||||
{
|
||||
var gridEntityId = _mapManager.GetGrid(coordinates.GridID).GridEntity;
|
||||
newEntity.Transform.AttachParent(GetEntity(gridEntityId));
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace Robust.Client.Graphics.ClientEye
|
||||
}
|
||||
else
|
||||
{
|
||||
grid = _mapManager.GetGrid(GridId.Nullspace);
|
||||
grid = _mapManager.GetGrid(GridId.Invalid);
|
||||
}
|
||||
return new GridCoordinates(grid.WorldToLocal(mapPos), grid);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Robust.Server.GameObjects
|
||||
public override IEntity CreateEntityUninitialized(string prototypeName, GridCoordinates coordinates)
|
||||
{
|
||||
var newEntity = CreateEntity(prototypeName);
|
||||
if(coordinates.GridID != GridId.Nullspace)
|
||||
if(coordinates.GridID != GridId.Invalid)
|
||||
{
|
||||
var gridEntityId = _mapManager.GetGrid(coordinates.GridID).GridEntity;
|
||||
newEntity.Transform.AttachParent(GetEntity(gridEntityId));
|
||||
|
||||
@@ -561,7 +561,7 @@ namespace Robust.Server.Maps
|
||||
{
|
||||
if (node.AsString() == "null")
|
||||
{
|
||||
obj = GridId.Nullspace;
|
||||
obj = GridId.Invalid;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,12 +50,12 @@ namespace Robust.Shared.GameObjects.Components.Map
|
||||
|
||||
public void ClearGridId()
|
||||
{
|
||||
_gridIndex = GridId.Nullspace;
|
||||
_gridIndex = GridId.Invalid;
|
||||
}
|
||||
|
||||
public override void OnRemove()
|
||||
{
|
||||
if(GridIndex != GridId.Nullspace) // MapManager won't let us delete nullspace, no point trying
|
||||
if(GridIndex != GridId.Invalid)
|
||||
{
|
||||
if(_mapManager.GridExists(_gridIndex))
|
||||
{
|
||||
@@ -89,7 +89,7 @@ namespace Robust.Shared.GameObjects.Components.Map
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(ref _gridIndex, "index", GridId.Nullspace);
|
||||
serializer.DataField(ref _gridIndex, "index", GridId.Invalid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Robust.Shared.GameObjects.Components.Transform
|
||||
{
|
||||
// root node, grid id is undefined
|
||||
if (Owner.HasComponent<IMapComponent>())
|
||||
return GridId.Nullspace;
|
||||
return GridId.Invalid;
|
||||
|
||||
// second level node, terminates recursion up the branch of the tree
|
||||
if (Owner.TryGetComponent(out IMapGridComponent gridComp))
|
||||
@@ -89,7 +89,7 @@ namespace Robust.Shared.GameObjects.Components.Transform
|
||||
return Parent.GridID;
|
||||
|
||||
// Not on a grid
|
||||
return GridId.Nullspace;
|
||||
return GridId.Invalid;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +34,10 @@ namespace Robust.Shared.Map
|
||||
public float Y => Position.Y;
|
||||
|
||||
/// <summary>
|
||||
/// A set of coordinates that is at the origin of Nullspace.
|
||||
/// A set of coordinates that is at the origin of an invalid grid.
|
||||
/// This is also the values of an uninitialized struct.
|
||||
/// </summary>
|
||||
public static readonly GridCoordinates Nullspace = new GridCoordinates(0, 0, GridId.Nullspace);
|
||||
public static readonly GridCoordinates Nullspace = new GridCoordinates(0, 0, GridId.Invalid);
|
||||
|
||||
/// <summary>
|
||||
/// Constructs new grid local coordinates.
|
||||
|
||||
@@ -6,7 +6,10 @@ namespace Robust.Shared.Map
|
||||
[Serializable, NetSerializable]
|
||||
public struct GridId : IEquatable<GridId>
|
||||
{
|
||||
public static readonly GridId Nullspace = new GridId(0);
|
||||
/// <summary>
|
||||
/// An invalid grid ID.
|
||||
/// </summary>
|
||||
public static readonly GridId Invalid = new GridId(0);
|
||||
|
||||
internal readonly int Value;
|
||||
|
||||
@@ -15,6 +18,11 @@ namespace Robust.Shared.Map
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public bool IsValid()
|
||||
{
|
||||
return Value > 0;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool Equals(GridId other)
|
||||
{
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Robust.Shared.Map
|
||||
public bool SuppressOnTileChanged { get; set; }
|
||||
|
||||
private MapId HighestMapID = MapId.Nullspace;
|
||||
private GridId HighestGridID = GridId.Nullspace;
|
||||
private GridId HighestGridID = GridId.Invalid;
|
||||
|
||||
private readonly HashSet<MapId> _maps = new HashSet<MapId>();
|
||||
private readonly Dictionary<MapId, GameTick> _mapCreationTick = new Dictionary<MapId, GameTick>();
|
||||
@@ -66,7 +66,7 @@ namespace Robust.Shared.Map
|
||||
/// <inheritdoc />
|
||||
public void Initialize()
|
||||
{
|
||||
CreateMap(MapId.Nullspace, GridId.Nullspace);
|
||||
CreateMap(MapId.Nullspace, GridId.Invalid);
|
||||
// So uh I removed the contents from this but I'm too lazy to remove the Initialize method.
|
||||
// Deal with it.
|
||||
}
|
||||
@@ -102,7 +102,7 @@ namespace Robust.Shared.Map
|
||||
|
||||
if (!_maps.Contains(MapId.Nullspace))
|
||||
{
|
||||
CreateMap(MapId.Nullspace, GridId.Nullspace);
|
||||
CreateMap(MapId.Nullspace, GridId.Invalid);
|
||||
}
|
||||
else if(_mapEntities.TryGetValue(MapId.Nullspace, out var mapEntId))
|
||||
{
|
||||
@@ -119,7 +119,7 @@ namespace Robust.Shared.Map
|
||||
}
|
||||
|
||||
DebugTools.Assert(_grids.Count == 1);
|
||||
DebugTools.Assert(GridExists(GridId.Nullspace));
|
||||
DebugTools.Assert(GridExists(GridId.Invalid));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -330,7 +330,7 @@ namespace Robust.Shared.Map
|
||||
{
|
||||
if (_defaultGrids.TryGetValue(mapID, out var gridID))
|
||||
return gridID;
|
||||
return GridId.Nullspace; //TODO: Hack to make shutdown work
|
||||
return GridId.Invalid; //TODO: Hack to make shutdown work
|
||||
}
|
||||
|
||||
public IEnumerable<IMapGrid> GetAllGrids()
|
||||
@@ -369,7 +369,7 @@ namespace Robust.Shared.Map
|
||||
_grids.Add(actualID, grid);
|
||||
Logger.DebugS("map", $"Creating new grid {actualID}");
|
||||
|
||||
if (actualID != GridId.Nullspace && createEntity) // nullspace default grid is not bound to an entity
|
||||
if (actualID != GridId.Invalid && createEntity) // nullspace default grid is not bound to an entity
|
||||
{
|
||||
// the entity may already exist from map deserialization
|
||||
IMapGridComponent result = null;
|
||||
@@ -468,7 +468,7 @@ namespace Robust.Shared.Map
|
||||
public void DeleteGrid(GridId gridID)
|
||||
{
|
||||
// nullspace grid cannot be deleted
|
||||
if (gridID == GridId.Nullspace)
|
||||
if (gridID == GridId.Invalid)
|
||||
return;
|
||||
|
||||
var grid = _grids[gridID];
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
mapMan.Restart();
|
||||
|
||||
Assert.That(mapMan.MapExists(MapId.Nullspace), Is.True);
|
||||
Assert.That(mapMan.GridExists(GridId.Nullspace), Is.True);
|
||||
Assert.That(mapMan.GridExists(GridId.Invalid), Is.True);
|
||||
Assert.That(oldEntity.Deleted, Is.True);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user