mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Fix some grid-related warnings
This commit is contained in:
@@ -36,10 +36,10 @@ namespace Robust.Shared.Scripting
|
||||
|
||||
public EntityCoordinates gpos(double x, double y, int gridId)
|
||||
{
|
||||
return gpos(x, y, new GridId(gridId));
|
||||
return gpos(x, y, new EntityUid(gridId));
|
||||
}
|
||||
|
||||
public EntityCoordinates gpos(double x, double y, GridId gridId)
|
||||
public EntityCoordinates gpos(double x, double y, EntityUid gridId)
|
||||
{
|
||||
if (!map.TryGetGrid(gridId, out var grid))
|
||||
{
|
||||
@@ -61,10 +61,10 @@ namespace Robust.Shared.Scripting
|
||||
|
||||
public IMapGrid getgrid(int i)
|
||||
{
|
||||
return map.GetGrid(new GridId(i));
|
||||
return map.GetGrid(new EntityUid(i));
|
||||
}
|
||||
|
||||
public IMapGrid getgrid(GridId mapId)
|
||||
public IMapGrid getgrid(EntityUid mapId)
|
||||
{
|
||||
return map.GetGrid(mapId);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// </summary>
|
||||
public interface IMapGridComponent : IComponent
|
||||
{
|
||||
[Obsolete("Use EntityUids instead")]
|
||||
GridId GridIndex { get; }
|
||||
IMapGrid Grid { get; }
|
||||
}
|
||||
@@ -33,11 +34,14 @@ namespace Robust.Shared.GameObjects
|
||||
// If you want to remove this, you would have to restructure the map save file.
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
[DataField("index")]
|
||||
#pragma warning disable CS0618
|
||||
private GridId _gridIndex = GridId.Invalid;
|
||||
#pragma warning restore CS0618
|
||||
|
||||
private IMapGrid? _mapGrid;
|
||||
|
||||
/// <inheritdoc />
|
||||
[Obsolete("Use EntityUid instead")]
|
||||
public GridId GridIndex
|
||||
{
|
||||
get => _gridIndex;
|
||||
@@ -96,7 +100,9 @@ namespace Robust.Shared.GameObjects
|
||||
{
|
||||
DebugTools.Assert(LifeStage == ComponentLifeStage.Added);
|
||||
|
||||
#pragma warning disable CS0618
|
||||
var grid = new MapGrid(_mapManager, _entMan, GridIndex, chunkSize);
|
||||
#pragma warning restore CS0618
|
||||
grid.TileSize = tileSize;
|
||||
|
||||
Grid = grid;
|
||||
@@ -160,6 +166,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// <summary>
|
||||
/// Serialized state of a <see cref="MapGridComponentState"/>.
|
||||
/// </summary>
|
||||
#pragma warning disable CS0618
|
||||
[Serializable, NetSerializable]
|
||||
internal sealed class MapGridComponentState : ComponentState
|
||||
{
|
||||
@@ -184,4 +191,5 @@ namespace Robust.Shared.GameObjects
|
||||
ChunkSize = chunkSize;
|
||||
}
|
||||
}
|
||||
#pragma warning restore CS0618
|
||||
}
|
||||
|
||||
@@ -713,7 +713,7 @@ public sealed partial class EntityLookupSystem
|
||||
|
||||
public Box2Rotated GetWorldBounds(TileRef tileRef, Matrix3? worldMatrix = null, Angle? angle = null)
|
||||
{
|
||||
var grid = _mapManager.GetGrid(tileRef.GridIndex);
|
||||
var grid = _mapManager.GetGrid(tileRef.GridUid);
|
||||
|
||||
if (worldMatrix == null || angle == null)
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -45,19 +46,25 @@ namespace Robust.Shared.GameObjects
|
||||
|
||||
private void OnGridInit(EntityUid uid, MapGridComponent component, ComponentInit args)
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
var msg = new GridInitializeEvent(uid, component.GridIndex);
|
||||
#pragma warning restore CS0618
|
||||
EntityManager.EventBus.RaiseLocalEvent(uid, msg, true);
|
||||
}
|
||||
|
||||
private void OnGridStartup(EntityUid uid, MapGridComponent component, ComponentStartup args)
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
var msg = new GridStartupEvent(uid, component.GridIndex);
|
||||
#pragma warning restore CS0618
|
||||
EntityManager.EventBus.RaiseLocalEvent(uid, msg, true);
|
||||
}
|
||||
|
||||
private void OnGridRemove(EntityUid uid, MapGridComponent component, ComponentShutdown args)
|
||||
{
|
||||
#pragma warning disable CS0618
|
||||
EntityManager.EventBus.RaiseLocalEvent(uid, new GridRemovalEvent(uid, component.GridIndex), true);
|
||||
#pragma warning restore CS0618
|
||||
MapManager.OnComponentRemoved(component);
|
||||
}
|
||||
}
|
||||
@@ -92,9 +99,11 @@ namespace Robust.Shared.GameObjects
|
||||
public bool Destroyed => !Created;
|
||||
}
|
||||
|
||||
#pragma warning disable CS0618
|
||||
public sealed class GridStartupEvent : EntityEventArgs
|
||||
{
|
||||
public EntityUid EntityUid { get; }
|
||||
[Obsolete("Use EntityUids")]
|
||||
public GridId GridId { get; }
|
||||
|
||||
public GridStartupEvent(EntityUid uid, GridId gridId)
|
||||
@@ -107,6 +116,7 @@ namespace Robust.Shared.GameObjects
|
||||
public sealed class GridRemovalEvent : EntityEventArgs
|
||||
{
|
||||
public EntityUid EntityUid { get; }
|
||||
[Obsolete("Use EntityUids")]
|
||||
public GridId GridId { get; }
|
||||
|
||||
public GridRemovalEvent(EntityUid uid, GridId gridId)
|
||||
@@ -122,6 +132,7 @@ namespace Robust.Shared.GameObjects
|
||||
public sealed class GridInitializeEvent : EntityEventArgs
|
||||
{
|
||||
public EntityUid EntityUid { get; }
|
||||
[Obsolete("Use EntityUids")]
|
||||
public GridId GridId { get; }
|
||||
|
||||
public GridInitializeEvent(EntityUid uid, GridId gridId)
|
||||
@@ -130,6 +141,7 @@ namespace Robust.Shared.GameObjects
|
||||
GridId = gridId;
|
||||
}
|
||||
}
|
||||
#pragma warning restore CS0618
|
||||
|
||||
/// <summary>
|
||||
/// Raised whenever a grid is Added
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Robust.Shared.GameObjects
|
||||
if(e.NewTile.Tile != Tile.Empty)
|
||||
return;
|
||||
|
||||
DeparentAllEntsOnTile(e.NewTile.GridIndex, e.NewTile.GridIndices);
|
||||
DeparentAllEntsOnTile(e.NewTile.GridUid, e.NewTile.GridIndices);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -52,7 +52,7 @@ namespace Robust.Shared.GameObjects
|
||||
/// Used when a tile on a grid is removed (becomes space). Only de-parents entities if they are actually
|
||||
/// parented to that grid. No more disemboweling mobs.
|
||||
/// </remarks>
|
||||
private void DeparentAllEntsOnTile(GridId gridId, Vector2i tileIndices)
|
||||
private void DeparentAllEntsOnTile(EntityUid gridId, Vector2i tileIndices)
|
||||
{
|
||||
var grid = _mapManager.GetGrid(gridId);
|
||||
var gridUid = grid.GridEntityId;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
@@ -6,6 +7,7 @@ namespace Robust.Shared.Map
|
||||
{
|
||||
public static class CoordinatesExtensions
|
||||
{
|
||||
[Obsolete("Use EntityUid overload instead.")]
|
||||
public static EntityCoordinates ToEntityCoordinates(this Vector2i vector, GridId gridId, IMapManager? mapManager = null)
|
||||
{
|
||||
IoCManager.Resolve(ref mapManager);
|
||||
@@ -19,7 +21,7 @@ namespace Robust.Shared.Map
|
||||
public static EntityCoordinates ToEntityCoordinates(this Vector2i vector, EntityUid gridId, IMapManager? mapManager = null)
|
||||
{
|
||||
IoCManager.Resolve(ref mapManager);
|
||||
|
||||
|
||||
var grid = mapManager.GetGrid(gridId);
|
||||
var tile = grid.TileSize;
|
||||
|
||||
@@ -31,9 +33,9 @@ namespace Robust.Shared.Map
|
||||
var coords = coordinates;
|
||||
IoCManager.Resolve(ref entityManager, ref mapManager);
|
||||
|
||||
var gridId = coords.GetGridId(entityManager);
|
||||
var gridId = coords.GetGridUid(entityManager);
|
||||
|
||||
if (!gridId.IsValid() || !mapManager.GridExists(gridId))
|
||||
if (gridId != null || !mapManager.GridExists(gridId))
|
||||
{
|
||||
var mapCoords = coords.ToMap(entityManager);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -150,11 +150,11 @@ namespace Robust.Shared.Map
|
||||
if(!IsValid(entityManager))
|
||||
return new Vector2i();
|
||||
|
||||
var gridId = GetGridId(entityManager);
|
||||
var gridId = GetGridUid(entityManager);
|
||||
|
||||
if (gridId != GridId.Invalid)
|
||||
if (gridId != null)
|
||||
{
|
||||
return mapManager.GetGrid(gridId).GetTileRef(this).GridIndices;
|
||||
return mapManager.GetGrid(gridId.Value).GetTileRef(this).GridIndices;
|
||||
}
|
||||
|
||||
var (x, y) = ToMapPos(entityManager);
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Robust.Shared.Map;
|
||||
|
||||
[Obsolete("EntityQuery for MapGridComponent instead")]
|
||||
public struct GridEnumerator
|
||||
{
|
||||
private Dictionary<GridId, EntityUid>.Enumerator _enumerator;
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Robust.Shared.Map
|
||||
/// <summary>
|
||||
/// The identifier of this grid.
|
||||
/// </summary>
|
||||
[Obsolete("Use EntityUids instead")]
|
||||
GridId Index { get; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -16,6 +16,7 @@ namespace Robust.Shared.Map
|
||||
/// <summary>
|
||||
/// A faster version of <see cref="GetAllGrids"/>
|
||||
/// </summary>
|
||||
[Obsolete("EntityQuery for MapGridComponent instead")]
|
||||
GridEnumerator GetAllGridsEnumerator();
|
||||
|
||||
IEnumerable<IMapGrid> GetAllGrids();
|
||||
@@ -91,11 +92,20 @@ namespace Robust.Shared.Map
|
||||
|
||||
void DeleteMap(MapId mapId);
|
||||
|
||||
[Obsolete("Use overload without GridId parameter instead")]
|
||||
// ReSharper disable once MethodOverloadWithOptionalParameter
|
||||
IMapGrid CreateGrid(MapId currentMapId, GridId? gridId = null, ushort chunkSize = 16);
|
||||
IMapGrid CreateGrid(MapId currentMapId, in GridCreateOptions options);
|
||||
IMapGrid CreateGrid(MapId currentMapId);
|
||||
[Obsolete("Use EntityUids instead")]
|
||||
IMapGrid GetGrid(GridId gridId);
|
||||
IMapGrid GetGrid(EntityUid gridId);
|
||||
[Obsolete("Use EntityUids instead")]
|
||||
bool TryGetGrid(GridId gridId, [NotNullWhen(true)] out IMapGrid? grid);
|
||||
bool TryGetGrid([NotNullWhen(true)] EntityUid? euid, [NotNullWhen(true)] out IMapGrid? grid);
|
||||
[Obsolete("Use EntityUids instead")]
|
||||
bool GridExists(GridId gridId);
|
||||
bool GridExists([NotNullWhen(true)] EntityUid? euid);
|
||||
IEnumerable<IMapGrid> GetAllMapGrids(MapId mapId);
|
||||
|
||||
/// <summary>
|
||||
@@ -140,6 +150,7 @@ namespace Robust.Shared.Map
|
||||
/// <param name="approx">Set to false if you wish to accurately get the grid bounds per-tile.</param>
|
||||
IEnumerable<IMapGrid> FindGridsIntersecting(MapId mapId, Box2Rotated worldArea, bool approx = false);
|
||||
|
||||
[Obsolete("Delete the grid's entity instead")]
|
||||
void DeleteGrid(GridId gridId);
|
||||
|
||||
/// <summary>
|
||||
@@ -179,11 +190,11 @@ namespace Robust.Shared.Map
|
||||
|
||||
[Obsolete("Whatever this is used for, it is a terrible idea. Create a new map and get it's MapId.")]
|
||||
MapId NextMapId();
|
||||
[Obsolete("Use EntityUids instead")]
|
||||
EntityUid GetGridEuid(GridId id);
|
||||
[Obsolete("Use EntityUids instead")]
|
||||
IMapGridComponent GetGridComp(GridId id);
|
||||
IMapGridComponent GetGridComp(EntityUid euid);
|
||||
bool TryGetGrid([NotNullWhen(true)] EntityUid? euid, [NotNullWhen(true)] out IMapGrid? grid);
|
||||
bool GridExists([NotNullWhen(true)] EntityUid? euid);
|
||||
|
||||
//
|
||||
// Pausing functions
|
||||
@@ -202,6 +213,7 @@ namespace Robust.Shared.Map
|
||||
bool IsGridPaused(IMapGrid grid);
|
||||
|
||||
[Pure]
|
||||
[Obsolete("Use EntityUids instead")]
|
||||
bool IsGridPaused(GridId gridId);
|
||||
|
||||
[Pure]
|
||||
@@ -210,4 +222,14 @@ namespace Robust.Shared.Map
|
||||
[Pure]
|
||||
bool IsMapInitialized(MapId mapId);
|
||||
}
|
||||
|
||||
public struct GridCreateOptions
|
||||
{
|
||||
public static readonly GridCreateOptions Default = new()
|
||||
{
|
||||
ChunkSize = 16
|
||||
};
|
||||
|
||||
public ushort ChunkSize;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
// GridId obsolete
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace Robust.Shared.Map
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@@ -109,6 +112,7 @@ namespace Robust.Shared.Map
|
||||
|
||||
/// <inheritdoc />
|
||||
[ViewVariables]
|
||||
[Obsolete("Use EntityUids instead")]
|
||||
public GridId Index { get; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -7,6 +7,9 @@ using Robust.Shared.Log;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
// All the obsolete warnings about GridId are probably useless here.
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace Robust.Shared.Map;
|
||||
|
||||
/// <summary>
|
||||
@@ -135,11 +138,22 @@ internal partial class MapManager
|
||||
}
|
||||
}
|
||||
|
||||
// ReSharper disable once MethodOverloadWithOptionalParameter
|
||||
public IMapGrid CreateGrid(MapId currentMapId, GridId? forcedGridId = null, ushort chunkSize = 16)
|
||||
{
|
||||
return CreateGrid(currentMapId, forcedGridId, chunkSize, default);
|
||||
}
|
||||
|
||||
public IMapGrid CreateGrid(MapId currentMapId, in GridCreateOptions options)
|
||||
{
|
||||
return CreateGrid(currentMapId, null, options.ChunkSize, default);
|
||||
}
|
||||
|
||||
public IMapGrid CreateGrid(MapId currentMapId)
|
||||
{
|
||||
return CreateGrid(currentMapId, GridCreateOptions.Default);
|
||||
}
|
||||
|
||||
public IMapGrid GetGrid(GridId gridId)
|
||||
{
|
||||
DebugTools.Assert(gridId != GridId.Invalid);
|
||||
@@ -172,6 +186,7 @@ internal partial class MapManager
|
||||
return false;
|
||||
}
|
||||
|
||||
[Obsolete("Use EntityUids")]
|
||||
public bool TryGetGrid(GridId gridId, [MaybeNullWhen(false)] out IMapGrid grid)
|
||||
{
|
||||
// grid 0 compatibility
|
||||
@@ -190,6 +205,7 @@ internal partial class MapManager
|
||||
return TryGetGrid(euid, out grid);
|
||||
}
|
||||
|
||||
[Obsolete("Use EntityUids")]
|
||||
public bool GridExists(GridId gridId)
|
||||
{
|
||||
// grid 0 compatibility
|
||||
@@ -213,6 +229,7 @@ internal partial class MapManager
|
||||
enumerator = new FindGridsEnumerator(EntityManager, GetAllGrids().Cast<MapGrid>().GetEnumerator(), mapId, worldAabb, approx);
|
||||
}
|
||||
|
||||
[Obsolete("Delete the grid's entity instead")]
|
||||
public virtual void DeleteGrid(GridId gridId)
|
||||
{
|
||||
#if DEBUG
|
||||
|
||||
@@ -74,7 +74,7 @@ internal partial class MapManager
|
||||
|
||||
private void OnGridInit(GridInitializeEvent args)
|
||||
{
|
||||
var grid = (MapGrid) GetGrid(args.GridId);
|
||||
var grid = (MapGrid) GetGrid(args.EntityUid);
|
||||
var xform = EntityManager.GetComponent<TransformComponent>(args.EntityUid);
|
||||
var mapId = xform.MapID;
|
||||
|
||||
@@ -95,7 +95,7 @@ internal partial class MapManager
|
||||
|
||||
private void OnGridRemove(GridRemovalEvent args)
|
||||
{
|
||||
var grid = (MapGrid) GetGrid(args.GridId);
|
||||
var grid = (MapGrid) GetGrid(args.EntityUid);
|
||||
var xform = EntityManager.GetComponent<TransformComponent>(args.EntityUid);
|
||||
|
||||
// Can't check for free proxy because DetachParentToNull gets called first woo!
|
||||
|
||||
@@ -88,18 +88,6 @@ namespace Robust.Shared.Map
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void DoGridMapInitialize(IMapGrid grid)
|
||||
{
|
||||
// NOP
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void DoGridMapInitialize(GridId gridId)
|
||||
{
|
||||
// NOP
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void AddUninitializedMap(MapId mapId)
|
||||
{
|
||||
@@ -177,6 +165,7 @@ namespace Robust.Shared.Map
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
[Obsolete("Use EntityUids instead")]
|
||||
public bool IsGridPaused(GridId gridId)
|
||||
{
|
||||
if (TryGetGrid(gridId, out var grid))
|
||||
|
||||
@@ -41,7 +41,10 @@ internal partial class MapManager : IMapManagerInternal, IEntityEventSubscriber
|
||||
EnsureNullspaceExistsAndClear();
|
||||
|
||||
DebugTools.Assert(_grids.Count == 0);
|
||||
#pragma warning disable CS0618
|
||||
// Not really sure what to do with this. Can't hurt to leave it in.
|
||||
DebugTools.Assert(!GridExists(GridId.Invalid));
|
||||
#pragma warning restore CS0618
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -60,7 +63,9 @@ internal partial class MapManager : IMapManagerInternal, IEntityEventSubscriber
|
||||
|
||||
#if DEBUG
|
||||
DebugTools.Assert(_grids.Count == 0);
|
||||
#pragma warning disable CS0618
|
||||
DebugTools.Assert(!GridExists(GridId.Invalid));
|
||||
#pragma warning restore CS0618
|
||||
_dbgGuardRunning = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Utility;
|
||||
#pragma warning disable CS0618
|
||||
|
||||
namespace Robust.Shared.Map
|
||||
{
|
||||
@@ -17,6 +18,7 @@ namespace Robust.Shared.Map
|
||||
/// <summary>
|
||||
/// Identifier of the <see cref="MapGrid"/> this Tile belongs to.
|
||||
/// </summary>
|
||||
[Obsolete("Use EntityUids instead")]
|
||||
public readonly GridId GridIndex;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -929,7 +929,7 @@ namespace Robust.Shared.Physics
|
||||
continue;
|
||||
}
|
||||
|
||||
var grid = (IMapGridInternal) _mapManager.GetGrid(mapGrid.GridIndex);
|
||||
var grid = (IMapGridInternal) mapGrid.Grid;
|
||||
|
||||
// Won't worry about accurate bounds checks as it's probably slower in most use cases.
|
||||
var chunkEnumerator = grid.GetMapChunks(aabb);
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.UnitTesting.Server;
|
||||
|
||||
namespace Robust.UnitTesting.Client.GameObjects.Components
|
||||
@@ -15,10 +12,8 @@ namespace Robust.UnitTesting.Client.GameObjects.Components
|
||||
public sealed class TransformComponentTests
|
||||
{
|
||||
private static readonly MapId TestMapId = new(1);
|
||||
private static readonly GridId TestGridAId = new(1);
|
||||
private static readonly GridId TestGridBId = new(2);
|
||||
|
||||
private static ISimulation SimulationFactory()
|
||||
private static (ISimulation, EntityUid gridA, EntityUid gridB) SimulationFactory()
|
||||
{
|
||||
var sim = RobustServerSimulation
|
||||
.NewSimulation()
|
||||
@@ -30,10 +25,10 @@ namespace Robust.UnitTesting.Client.GameObjects.Components
|
||||
mapManager.CreateMap(TestMapId);
|
||||
|
||||
// Adds two grids to use in tests.
|
||||
mapManager.CreateGrid(TestMapId, TestGridAId);
|
||||
mapManager.CreateGrid(TestMapId, TestGridBId);
|
||||
var gridA = mapManager.CreateGrid(TestMapId);
|
||||
var gridB = mapManager.CreateGrid(TestMapId);
|
||||
|
||||
return sim;
|
||||
return (sim, gridA.GridEntityId, gridB.GridEntityId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -42,12 +37,12 @@ namespace Robust.UnitTesting.Client.GameObjects.Components
|
||||
[Test]
|
||||
public void ComponentStatePositionTest()
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
var (sim, gridIdA, gridIdB) = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
|
||||
var gridA = mapMan.GetGrid(TestGridAId);
|
||||
var gridB = mapMan.GetGrid(TestGridBId);
|
||||
var gridA = mapMan.GetGrid(gridIdA);
|
||||
var gridB = mapMan.GetGrid(gridIdB);
|
||||
|
||||
// Arrange
|
||||
var initialPos = new EntityCoordinates(gridA.GridEntityId, (0, 0));
|
||||
@@ -79,13 +74,13 @@ namespace Robust.UnitTesting.Client.GameObjects.Components
|
||||
[Test]
|
||||
public void WorldRotationTest()
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
var (sim, gridIdA, gridIdB) = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
var xformSystem = sim.Resolve<IEntitySystemManager>().GetEntitySystem<SharedTransformSystem>();
|
||||
|
||||
var gridA = mapMan.GetGrid(TestGridAId);
|
||||
var gridB = mapMan.GetGrid(TestGridBId);
|
||||
var gridA = mapMan.GetGrid(gridIdA);
|
||||
var gridB = mapMan.GetGrid(gridIdB);
|
||||
|
||||
// Arrange
|
||||
var initalPos = new EntityCoordinates(gridA.GridEntityId, (0, 0));
|
||||
|
||||
@@ -16,7 +16,6 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
public sealed class AnchoredSystemTests
|
||||
{
|
||||
private static readonly MapId TestMapId = new(1);
|
||||
private static readonly GridId TestGridId = new(1);
|
||||
|
||||
private sealed class Subscriber : IEntityEventSubscriber { }
|
||||
|
||||
@@ -28,7 +27,7 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
- type: Transform
|
||||
anchored: true";
|
||||
|
||||
private static ISimulation SimulationFactory()
|
||||
private static (ISimulation, EntityUid gridId) SimulationFactory()
|
||||
{
|
||||
var sim = RobustServerSimulation
|
||||
.NewSimulation()
|
||||
@@ -44,9 +43,9 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
mapManager.CreateMap(TestMapId);
|
||||
|
||||
// Add grid 1, as the default grid to anchor things to.
|
||||
mapManager.CreateGrid(TestMapId, TestGridId);
|
||||
var grid = mapManager.CreateGrid(TestMapId);
|
||||
|
||||
return sim;
|
||||
return (sim, grid.GridEntityId);
|
||||
}
|
||||
|
||||
// An entity is anchored to the tile it is over on the target grid.
|
||||
@@ -65,14 +64,14 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
[Test]
|
||||
public void OnAnchored_WorldPosition_TileCenter()
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
var (sim, gridId) = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
|
||||
var coordinates = new MapCoordinates(new Vector2(7, 7), TestMapId);
|
||||
|
||||
// can only be anchored to a tile
|
||||
var grid = mapMan.GetGrid(TestGridId);
|
||||
var grid = mapMan.GetGrid(gridId);
|
||||
grid.SetTile(grid.TileIndicesFor(coordinates), new Tile(1));
|
||||
|
||||
var subscriber = new Subscriber();
|
||||
@@ -97,14 +96,14 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
[Test]
|
||||
public void OnAnchored_Parent_SetToGrid()
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
var (sim, gridId) = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
|
||||
var coordinates = new MapCoordinates(new Vector2(7, 7), TestMapId);
|
||||
|
||||
// can only be anchored to a tile
|
||||
var grid = mapMan.GetGrid(TestGridId);
|
||||
var grid = mapMan.GetGrid(gridId);
|
||||
grid.SetTile(grid.TileIndicesFor(coordinates), new Tile(1));
|
||||
|
||||
var subscriber = new Subscriber();
|
||||
@@ -130,11 +129,11 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
[Test]
|
||||
public void OnAnchored_EmptyTile_Nop()
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
var (sim, gridId) = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
|
||||
var grid = mapMan.GetGrid(TestGridId);
|
||||
var grid = mapMan.GetGrid(gridId);
|
||||
var ent1 = entMan.SpawnEntity(null, new MapCoordinates(new Vector2(7, 7), TestMapId));
|
||||
var tileIndices = grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent1).Coordinates);
|
||||
grid.SetTile(tileIndices, Tile.Empty);
|
||||
@@ -153,11 +152,11 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
[Test]
|
||||
public void OnAnchored_NonEmptyTile_Anchors()
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
var (sim, gridId) = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
|
||||
var grid = mapMan.GetGrid(TestGridId);
|
||||
var grid = mapMan.GetGrid(gridId);
|
||||
var ent1 = entMan.SpawnEntity(null, new MapCoordinates(new Vector2(7, 7), TestMapId));
|
||||
var tileIndices = grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent1).Coordinates);
|
||||
grid.SetTile(tileIndices, new Tile(1));
|
||||
@@ -180,7 +179,7 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
[Test]
|
||||
public void Anchored_SetPosition_Nop()
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
var (sim, gridId) = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
|
||||
@@ -188,7 +187,7 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
var coordinates = new MapCoordinates(new Vector2(7.5f, 7.5f), TestMapId);
|
||||
|
||||
// can only be anchored to a tile
|
||||
var grid = mapMan.GetGrid(TestGridId);
|
||||
var grid = mapMan.GetGrid(gridId);
|
||||
grid.SetTile(grid.TileIndicesFor(coordinates), new Tile(1));
|
||||
|
||||
var subscriber = new Subscriber();
|
||||
@@ -217,13 +216,13 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
[Test]
|
||||
public void Anchored_ChangeParent_Unanchors()
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
var (sim, gridId) = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
|
||||
var coordinates = new MapCoordinates(new Vector2(7, 7), TestMapId);
|
||||
|
||||
var grid = mapMan.GetGrid(TestGridId);
|
||||
var grid = mapMan.GetGrid(gridId);
|
||||
|
||||
var ent1 = entMan.SpawnEntity(null, coordinates);
|
||||
var tileIndices = grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent1).Coordinates);
|
||||
@@ -246,11 +245,11 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
[Test]
|
||||
public void Anchored_SetParentSame_Nop()
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
var (sim, gridId) = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
|
||||
var grid = mapMan.GetGrid(TestGridId);
|
||||
var grid = mapMan.GetGrid(gridId);
|
||||
var ent1 = entMan.SpawnEntity(null, new MapCoordinates(new Vector2(7, 7), TestMapId));
|
||||
var tileIndices = grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent1).Coordinates);
|
||||
grid.SetTile(tileIndices, new Tile(1));
|
||||
@@ -269,11 +268,11 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
[Test]
|
||||
public void Anchored_TileToSpace_Unanchors()
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
var (sim, gridId) = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
|
||||
var grid = mapMan.GetGrid(TestGridId);
|
||||
var grid = mapMan.GetGrid(gridId);
|
||||
var ent1 = entMan.SpawnEntity(null, new MapCoordinates(new Vector2(7, 7), TestMapId));
|
||||
var tileIndices = grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent1).Coordinates);
|
||||
grid.SetTile(tileIndices, new Tile(1));
|
||||
@@ -298,11 +297,11 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
[Test]
|
||||
public void Anchored_AddToContainer_Unanchors()
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
var (sim, gridId) = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
|
||||
var grid = mapMan.GetGrid(TestGridId);
|
||||
var grid = mapMan.GetGrid(gridId);
|
||||
var ent1 = entMan.SpawnEntity(null, new MapCoordinates(new Vector2(7, 7), TestMapId));
|
||||
var tileIndices = grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent1).Coordinates);
|
||||
grid.SetTile(tileIndices, new Tile(1));
|
||||
@@ -326,11 +325,11 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
[Test]
|
||||
public void Anchored_AddPhysComp_IsStaticBody()
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
var (sim, gridId) = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
|
||||
var grid = mapMan.GetGrid(TestGridId);
|
||||
var grid = mapMan.GetGrid(gridId);
|
||||
var ent1 = entMan.SpawnEntity(null, new MapCoordinates(new Vector2(7, 7), TestMapId));
|
||||
var tileIndices = grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent1).Coordinates);
|
||||
grid.SetTile(tileIndices, new Tile(1));
|
||||
@@ -349,14 +348,14 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
[Test]
|
||||
public void OnAnchored_HasPhysicsComp_IsStaticBody()
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
var (sim, gridId) = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
|
||||
var coordinates = new MapCoordinates(new Vector2(7, 7), TestMapId);
|
||||
|
||||
// can only be anchored to a tile
|
||||
var grid = mapMan.GetGrid(TestGridId);
|
||||
var grid = mapMan.GetGrid(gridId);
|
||||
grid.SetTile(grid.TileIndicesFor(coordinates), new Tile(1));
|
||||
|
||||
var ent1 = entMan.SpawnEntity(null, coordinates);
|
||||
@@ -375,11 +374,11 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
[Test]
|
||||
public void OnUnanchored_HasPhysicsComp_IsDynamicBody()
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
var (sim, gridId) = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
|
||||
var grid = mapMan.GetGrid(TestGridId);
|
||||
var grid = mapMan.GetGrid(gridId);
|
||||
var ent1 = entMan.SpawnEntity(null, new MapCoordinates(new Vector2(7, 7), TestMapId));
|
||||
var tileIndices = grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent1).Coordinates);
|
||||
grid.SetTile(tileIndices, new Tile(1));
|
||||
@@ -398,11 +397,11 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
[Test]
|
||||
public void SpawnAnchored_EmptyTile_Unanchors()
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
var (sim, gridId) = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
|
||||
var grid = mapMan.GetGrid(TestGridId);
|
||||
var grid = mapMan.GetGrid(gridId);
|
||||
|
||||
// Act
|
||||
var ent1 = entMan.SpawnEntity("anchoredEnt", new MapCoordinates(new Vector2(7, 7), TestMapId));
|
||||
@@ -419,11 +418,11 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
[Test]
|
||||
public void OnAnchored_InContainer_Nop()
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
var (sim, gridId) = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
|
||||
var grid = mapMan.GetGrid(TestGridId);
|
||||
var grid = mapMan.GetGrid(gridId);
|
||||
var ent1 = entMan.SpawnEntity(null, new MapCoordinates(new Vector2(7, 7), TestMapId));
|
||||
var tileIndices = grid.TileIndicesFor(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(ent1).Coordinates);
|
||||
grid.SetTile(tileIndices, new Tile(1));
|
||||
@@ -447,14 +446,14 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
[Test]
|
||||
public void Unanchored_Unanchor_Nop()
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
var (sim, gridId) = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
|
||||
var coordinates = new MapCoordinates(new Vector2(7, 7), TestMapId);
|
||||
|
||||
// can only be anchored to a tile
|
||||
var grid = mapMan.GetGrid(TestGridId);
|
||||
var grid = mapMan.GetGrid(gridId);
|
||||
grid.SetTile(grid.TileIndicesFor(coordinates), new Tile(1));
|
||||
|
||||
var subscriber = new Subscriber();
|
||||
@@ -480,14 +479,14 @@ namespace Robust.UnitTesting.Shared.GameObjects.Systems
|
||||
[Test]
|
||||
public void Anchored_Unanchored_ParentUnchanged()
|
||||
{
|
||||
var sim = SimulationFactory();
|
||||
var (sim, gridId) = SimulationFactory();
|
||||
var entMan = sim.Resolve<IEntityManager>();
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
|
||||
var coordinates = new MapCoordinates(new Vector2(7, 7), TestMapId);
|
||||
|
||||
// can only be anchored to a tile
|
||||
var grid = mapMan.GetGrid(TestGridId);
|
||||
var grid = mapMan.GetGrid(gridId);
|
||||
grid.SetTile(grid.TileIndicesFor(coordinates), new Tile(1));
|
||||
var ent1 = entMan.SpawnEntity("anchoredEnt", grid.MapToGrid(coordinates));
|
||||
|
||||
|
||||
@@ -45,9 +45,8 @@ namespace Robust.UnitTesting.Shared.Map
|
||||
var mapMan = sim.Resolve<IMapManager>();
|
||||
|
||||
var mapID = new MapId(11);
|
||||
var gridId = new GridId(7);
|
||||
mapMan.CreateMap(mapID);
|
||||
mapMan.CreateGrid(mapID, gridId);
|
||||
var gridId = mapMan.CreateGrid(mapID).GridEntityId;
|
||||
|
||||
mapMan.Restart();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user