Replace every usage of GridCoordinates with EntityCoordinates (#2021)

* Update RobustToolbox

* Transition direct type usages

* More updates

* Fix invalid use of to map

* Update RobustToolbox

* Fix dropping items

* Rename name usages of "GridCoordinates" to "EntityCoordinates"

* Revert "Update RobustToolbox"

This reverts commit 9f334a17c5908ded0043a63158bb671e4aa3f346.

* Revert "Update RobustToolbox"

This reverts commit 3a9c8cfa3606fa501aa84407796d2ad920853a09.

# Conflicts:
#	RobustToolbox

* Fix cursed IMapGrid method usage.

* GridTileLookupTest now uses EntityCoordinates

Co-authored-by: Víctor Aguilera Puerto <6766154+Zumorica@users.noreply.github.com>
Co-authored-by: Víctor Aguilera Puerto <zddm@outlook.es>
This commit is contained in:
DrSmugleaf
2020-09-06 16:11:53 +02:00
committed by GitHub
parent 72d2318ea7
commit 48b61f6bcc
196 changed files with 780 additions and 676 deletions

View File

@@ -49,7 +49,7 @@ namespace Content.Client
private void DoNotifyCoordinates(MsgDoNotifyCoordinates message)
{
PopupMessage(_eyeManager.WorldToScreen(message.Coordinates), message.Message);
PopupMessage(_eyeManager.CoordinatesToScreen(message.Coordinates), message.Message);
}
private void DoNotifyEntity(MsgDoNotifyEntity message)
@@ -59,27 +59,27 @@ namespace Content.Client
return;
}
PopupMessage(_eyeManager.WorldToScreen(entity.Transform.GridPosition), message.Message);
PopupMessage(_eyeManager.CoordinatesToScreen(entity.Transform.Coordinates), message.Message);
}
public override void PopupMessage(IEntity source, IEntity viewer, string message)
{
if (viewer != _playerManager.LocalPlayer.ControlledEntity)
if (viewer != _playerManager.LocalPlayer?.ControlledEntity)
{
return;
}
PopupMessage(_eyeManager.WorldToScreen(source.Transform.GridPosition), message);
PopupMessage(_eyeManager.CoordinatesToScreen(source.Transform.Coordinates), message);
}
public override void PopupMessage(GridCoordinates coordinates, IEntity viewer, string message)
public override void PopupMessage(EntityCoordinates coordinates, IEntity viewer, string message)
{
if (viewer != _playerManager.LocalPlayer.ControlledEntity)
{
return;
}
PopupMessage(_eyeManager.WorldToScreen(coordinates), message);
PopupMessage(_eyeManager.CoordinatesToScreen(coordinates), message);
}
public override void PopupMessageCursor(IEntity viewer, string message)

View File

@@ -20,7 +20,7 @@ namespace Content.Client.Construction
}
/// <inheritdoc />
public override bool HijackPlacementRequest(GridCoordinates coordinates)
public override bool HijackPlacementRequest(EntityCoordinates coordinates)
{
if (_prototype != null)
{

View File

@@ -37,7 +37,7 @@ namespace Content.Client.GameObjects.Components
{
base.Startup();
_overlayEntity = Owner.EntityManager.SpawnEntity("LowWallOverlay", Owner.Transform.GridPosition);
_overlayEntity = Owner.EntityManager.SpawnEntity("LowWallOverlay", Owner.Transform.Coordinates);
_overlayEntity.Transform.AttachParent(Owner);
_overlaySprite = _overlayEntity.GetComponent<ISpriteComponent>();

View File

@@ -9,7 +9,7 @@ namespace Content.Client.GameObjects.Components.Movement
[ComponentReference(typeof(IMoverComponent))]
public class PlayerInputMoverComponent : SharedPlayerInputMoverComponent
{
public override GridCoordinates LastPosition { get; set; }
public override EntityCoordinates LastPosition { get; set; }
public override float StepSoundDistance { get; set; }
}
}

View File

@@ -52,7 +52,7 @@ namespace Content.Client.GameObjects.EntitySystems.AI
continue;
}
var (x, y) = _eyeManager.WorldToScreen(entity.Transform.GridPosition).Position;
var (x, y) = _eyeManager.CoordinatesToScreen(entity.Transform.Coordinates).Position;
var offsetPosition = new Vector2(x - panel.Width / 2, y - panel.Height - 50f);
panel.Visible = true;

View File

@@ -150,7 +150,7 @@ namespace Content.Client.GameObjects.EntitySystems
/// <summary>
/// Creates a construction ghost at the given location.
/// </summary>
public void SpawnGhost(ConstructionPrototype prototype, GridCoordinates loc, Direction dir)
public void SpawnGhost(ConstructionPrototype prototype, EntityCoordinates loc, Direction dir)
{
if (GhostPresent(loc))
{
@@ -174,11 +174,11 @@ namespace Content.Client.GameObjects.EntitySystems
/// <summary>
/// Checks if any construction ghosts are present at the given position
/// </summary>
private bool GhostPresent(GridCoordinates loc)
private bool GhostPresent(EntityCoordinates loc)
{
foreach (KeyValuePair<int, ConstructionGhostComponent> ghost in _ghosts)
foreach (var ghost in _ghosts)
{
if (ghost.Value.Owner.Transform.GridPosition.Equals(loc))
if (ghost.Value.Owner.Transform.Coordinates.Equals(loc))
{
return true;
}
@@ -191,7 +191,7 @@ namespace Content.Client.GameObjects.EntitySystems
{
var ghost = _ghosts[ghostId];
var transform = ghost.Owner.Transform;
var msg = new TryStartStructureConstructionMessage(transform.GridPosition, ghost.Prototype.ID, transform.LocalRotation, ghostId);
var msg = new TryStartStructureConstructionMessage(transform.Coordinates, ghost.Prototype.ID, transform.LocalRotation, ghostId);
RaiseNetworkEvent(msg);
}

View File

@@ -159,7 +159,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
}
// Set position ready for 2nd+ frames.
_playerPosition = _eyeManager.WorldToScreen(AttachedEntity.Transform.GridPosition);
_playerPosition = _eyeManager.CoordinatesToScreen(AttachedEntity.Transform.Coordinates);
LayoutContainer.SetPosition(this, new Vector2(_playerPosition.X - Width / 2, _playerPosition.Y - Height - 30.0f));
if (_firstDraw)

View File

@@ -98,7 +98,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
return;
}
var userGrid = _player.Transform.GridPosition;
var userGrid = _player.Transform.Coordinates;
// Check cancellations / finishes
foreach (var (id, doAfter) in doAfters)
@@ -133,7 +133,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
{
var targetEntity = _entityManager.GetEntity(doAfter.TargetUid);
if (targetEntity.Transform.GridPosition != doAfter.TargetGrid)
if (targetEntity.Transform.Coordinates != doAfter.TargetGrid)
{
doAfterComponent.Cancel(id, currentTime);
continue;

View File

@@ -50,7 +50,7 @@ namespace Content.Client.GameObjects.EntitySystems
base.Shutdown();
}
private bool HandleExamine(ICommonSession session, GridCoordinates coords, EntityUid uid)
private bool HandleExamine(ICommonSession session, EntityCoordinates coords, EntityUid uid)
{
if (!uid.IsValid() || !_entityManager.TryGetEntity(uid, out var examined))
{

View File

@@ -52,7 +52,7 @@ namespace Content.Client.GameObjects.EntitySystems
var lunge = attacker.EnsureComponent<MeleeLungeComponent>();
lunge.SetData(msg.Angle);
var entity = EntityManager.SpawnEntity(weaponArc.Prototype, attacker.Transform.GridPosition);
var entity = EntityManager.SpawnEntity(weaponArc.Prototype, attacker.Transform.Coordinates);
entity.Transform.LocalRotation = msg.Angle;
var weaponArcAnimation = entity.GetComponent<MeleeWeaponArcAnimationComponent>();
@@ -68,7 +68,7 @@ namespace Content.Client.GameObjects.EntitySystems
{
EffectSprite = sourceSprite.BaseRSI.Path.ToString(),
RsiState = sourceSprite.LayerGetState(0).Name,
Coordinates = attacker.Transform.GridPosition,
Coordinates = attacker.Transform.Coordinates,
Color = Vector4.Multiply(new Vector4(255, 255, 255, 125), 1.0f),
ColorDelta = Vector4.Multiply(new Vector4(0, 0, 0, -10), 1.0f),
Velocity = msg.Angle.ToVec(),

View File

@@ -1,22 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading;
using Content.Client.State;
using Content.Client.UserInterface;
using Content.Client.Utility;
using Content.Shared.GameObjects.EntitySystemMessages;
using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Verbs;
using Content.Shared.Input;
using Content.Shared.Physics;
using JetBrains.Annotations;
using Robust.Client.GameObjects.EntitySystems;
using Robust.Client.Graphics;
using Robust.Client.Graphics.Drawing;
using Robust.Client.Interfaces.GameObjects.Components;
using Robust.Client.Interfaces.Graphics.ClientEye;
using Robust.Client.Interfaces.Input;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.Interfaces.State;
@@ -27,12 +23,9 @@ using Robust.Client.UserInterface.Controls;
using Robust.Client.Utility;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Input;
using Robust.Shared.Input.Binding;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.Interfaces.Physics;
using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC;
using Robust.Shared.Log;
@@ -53,7 +46,6 @@ namespace Content.Client.GameObjects.EntitySystems
[Dependency] private readonly IItemSlotManager _itemSlotManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
private EntityList _currentEntityList;
private VerbPopup _currentVerbListRoot;
@@ -119,7 +111,7 @@ namespace Content.Client.GameObjects.EntitySystems
return false;
}
var mapCoordinates = args.Coordinates.ToMap(_mapManager);
var mapCoordinates = args.Coordinates.ToMap(_entityManager);
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
if (playerEntity == null || !TryGetContextEntities(playerEntity, mapCoordinates, out var entities))
@@ -469,7 +461,7 @@ namespace Content.Client.GameObjects.EntitySystems
var funcId = _master._inputManager.NetworkBindMap.KeyFunctionID(args.Function);
var message = new FullInputCmdMessage(_master._gameTiming.CurTick, _master._gameTiming.TickFraction, funcId, BoundKeyState.Down,
_entity.Transform.GridPosition,
_entity.Transform.Coordinates,
args.PointerLocation, _entity.Uid);
// client side command handlers will always be sent the local player session.

View File

@@ -3,7 +3,6 @@ using System.Collections.Immutable;
using System.Linq;
using Content.Client.GameObjects.Components;
using Content.Client.Utility;
using Content.Shared.Utility;
using Robust.Client.GameObjects.EntitySystems;
using Robust.Client.Interfaces.GameObjects;
using Robust.Client.Interfaces.Graphics.ClientEye;
@@ -111,9 +110,9 @@ namespace Content.Client.State
return entitiesUnderPosition.Count > 0 ? entitiesUnderPosition[0] : null;
}
public IList<IEntity> GetEntitiesUnderPosition(GridCoordinates coordinates)
public IList<IEntity> GetEntitiesUnderPosition(EntityCoordinates coordinates)
{
return GetEntitiesUnderPosition(coordinates.ToMap(MapManager));
return GetEntitiesUnderPosition(coordinates.ToMap(EntityManager));
}
public IList<IEntity> GetEntitiesUnderPosition(MapCoordinates coordinates)
@@ -152,7 +151,7 @@ namespace Content.Client.State
/// <param name="stateManager">state manager to use to get the current game screen</param>
/// <param name="coordinates">coordinates to check</param>
/// <returns>the entities under the position, empty list if none found</returns>
public static IList<IEntity> GetEntitiesUnderPosition(IStateManager stateManager, GridCoordinates coordinates)
public static IList<IEntity> GetEntitiesUnderPosition(IStateManager stateManager, EntityCoordinates coordinates)
{
if (stateManager.CurrentState is GameScreenBase gameScreenBase)
{
@@ -184,7 +183,7 @@ namespace Content.Client.State
var transx = x.clicked.Transform;
var transy = y.clicked.Transform;
val = transx.GridPosition.Y.CompareTo(transy.GridPosition.Y);
val = transx.Coordinates.Y.CompareTo(transy.Coordinates.Y);
if (val != 0)
{
return val;

View File

@@ -56,15 +56,15 @@ namespace Content.Client.Utility
public static bool InRangeUnobstructed(
this LocalPlayer origin,
GridCoordinates other,
EntityCoordinates other,
float range = InteractionRange,
CollisionGroup collisionMask = CollisionGroup.Impassable,
Ignored predicate = null,
bool ignoreInsideBlocker = false,
bool popup = false)
{
var mapManager = IoCManager.Resolve<IMapManager>();
var otherPosition = other.ToMap(mapManager);
var entityManager = IoCManager.Resolve<IEntityManager>();
var otherPosition = other.ToMap(entityManager);
return origin.InRangeUnobstructed(otherPosition, range, collisionMask, predicate, ignoreInsideBlocker,
popup);

View File

@@ -58,9 +58,9 @@ namespace Content.IntegrationTests
{
}
public GridCoordinates GetLateJoinSpawnPoint() => GridCoordinates.InvalidGrid;
public GridCoordinates GetJobSpawnPoint(string jobId) => GridCoordinates.InvalidGrid;
public GridCoordinates GetObserverSpawnPoint() => GridCoordinates.InvalidGrid;
public EntityCoordinates GetLateJoinSpawnPoint() => EntityCoordinates.Invalid;
public EntityCoordinates GetJobSpawnPoint(string jobId) => EntityCoordinates.Invalid;
public EntityCoordinates GetObserverSpawnPoint() => EntityCoordinates.Invalid;
public void EquipStartingGear(IEntity entity, StartingGearPrototype startingGear)
{

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Content.Server.GameObjects.Components.Movement;
using Content.Shared.Utility;
using NUnit.Framework;
using Robust.Server.AI;
using Robust.Shared.GameObjects;
@@ -50,7 +51,7 @@ namespace Content.IntegrationTests.Tests.AI
if (!comps.ContainsKey("AiController")) continue;
var aiEntity = entityManager.SpawnEntity(entity.ID, new GridCoordinates(new Vector2(0, 0), grid.Index));
var aiEntity = entityManager.SpawnEntity(entity.ID, grid.ToCoordinates());
var aiController = aiEntity.GetComponent<AiControllerComponent>();
Assert.That(processorNames.Contains(aiController.LogicName), $"Could not find valid processor named {aiController.LogicName} on entity {entity.ID}");
}
@@ -58,6 +59,5 @@ namespace Content.IntegrationTests.Tests.AI
await server.WaitIdleAsync();
}
}
}

View File

@@ -1,6 +1,7 @@
using System.Threading.Tasks;
using Content.Server.Atmos;
using NUnit.Framework;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Map;
namespace Content.IntegrationTests.Tests.Atmos
@@ -10,17 +11,23 @@ namespace Content.IntegrationTests.Tests.Atmos
public class AtmosHelpersTest : ContentIntegrationTest
{
[Test]
public async Task GetTileAtmosphereGridCoordinatesNullTest()
public async Task GetTileAtmosphereEntityCoordinatesNullTest()
{
var server = StartServerDummyTicker();
await server.WaitIdleAsync();
var entityManager = server.ResolveDependency<IEntityManager>();
server.Assert(() =>
{
Assert.DoesNotThrow(() =>
{
var atmosphere = default(GridCoordinates).GetTileAtmosphere();
var atmosphere1 = default(EntityCoordinates).GetTileAtmosphere();
var atmosphere2 = default(EntityCoordinates).GetTileAtmosphere(entityManager);
Assert.Null(atmosphere);
Assert.Null(atmosphere1);
Assert.Null(atmosphere2);
});
});
@@ -28,7 +35,7 @@ namespace Content.IntegrationTests.Tests.Atmos
}
[Test]
public async Task GetTileAirGridCoordinatesNullTest()
public async Task GetTileAirEntityCoordinatesNullTest()
{
var server = StartServerDummyTicker();
@@ -36,7 +43,7 @@ namespace Content.IntegrationTests.Tests.Atmos
{
Assert.DoesNotThrow(() =>
{
var air = default(GridCoordinates).GetTileAir();
var air = default(EntityCoordinates).GetTileAir();
Assert.Null(air);
});
@@ -46,7 +53,7 @@ namespace Content.IntegrationTests.Tests.Atmos
}
[Test]
public async Task TryGetTileAtmosphereGridCoordinatesNullTest()
public async Task TryGetTileAtmosphereEntityCoordinatesNullTest()
{
var server = StartServerDummyTicker();
@@ -54,7 +61,7 @@ namespace Content.IntegrationTests.Tests.Atmos
{
Assert.DoesNotThrow(() =>
{
var hasAtmosphere = default(GridCoordinates).TryGetTileAtmosphere(out var atmosphere);
var hasAtmosphere = default(EntityCoordinates).TryGetTileAtmosphere(out var atmosphere);
Assert.False(hasAtmosphere);
Assert.Null(atmosphere);
@@ -65,7 +72,7 @@ namespace Content.IntegrationTests.Tests.Atmos
}
[Test]
public async Task TryGetTileTileAirGridCoordinatesNullTest()
public async Task TryGetTileTileAirEntityCoordinatesNullTest()
{
var server = StartServerDummyTicker();
@@ -73,7 +80,7 @@ namespace Content.IntegrationTests.Tests.Atmos
{
Assert.DoesNotThrow(() =>
{
var hasAir = default(GridCoordinates).TryGetTileAir(out var air);
var hasAir = default(EntityCoordinates).TryGetTileAir(out var air);
Assert.False(hasAir);
Assert.Null(air);

View File

@@ -7,6 +7,7 @@ using Content.Shared.Damage;
using Content.Shared.GameObjects.Components.Buckle;
using Content.Shared.GameObjects.Components.Damage;
using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.Utility;
using NUnit.Framework;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
@@ -193,7 +194,7 @@ namespace Content.IntegrationTests.Tests
var entityManager = IoCManager.Resolve<IEntityManager>();
var gridId = new GridId(1);
var grid = mapManager.CreateGrid(mapId, gridId);
var coordinates = new GridCoordinates((0, 0), gridId);
var coordinates = grid.GridEntityId.ToCoordinates();
var tileManager = IoCManager.Resolve<ITileDefinitionManager>();
var tileId = tileManager["underplating"].TileId;
var tile = new Tile(tileId);

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Content.Shared.Utility;
using NUnit.Framework;
using Robust.Server.Interfaces.Timing;
using Robust.Shared.GameObjects;
@@ -52,7 +53,7 @@ namespace Content.IntegrationTests.Tests
var tileDefinition = tileDefinitionManager["underplating"];
var tile = new Tile(tileDefinition.TileId);
var coordinates = new GridCoordinates(0, 0, gridId);
var coordinates = grid.ToCoordinates();
grid.SetTile(coordinates, tile);
@@ -61,7 +62,7 @@ namespace Content.IntegrationTests.Tests
server.Assert(() =>
{
var testLocation = new GridCoordinates(new Vector2(0, 0), grid);
var testLocation = grid.ToCoordinates();
//Generate list of non-abstract prototypes to test
foreach (var prototype in prototypeMan.EnumeratePrototypes<EntityPrototype>())
@@ -160,7 +161,7 @@ namespace Content.IntegrationTests.Tests
var tileDefinition = tileDefinitionManager["underplating"];
var tile = new Tile(tileDefinition.TileId);
var coordinates = new GridCoordinates(0, 0, gridId);
var coordinates = grid.ToCoordinates();
grid.SetTile(coordinates, tile);
@@ -169,7 +170,7 @@ namespace Content.IntegrationTests.Tests
server.Assert(() =>
{
var testLocation = new GridCoordinates(new Vector2(0, 0), grid);
var testLocation = grid.ToCoordinates();
foreach (var type in componentFactory.AllRegisteredTypes)
{
@@ -255,7 +256,7 @@ namespace Content.IntegrationTests.Tests
var tileDefinition = tileDefinitionManager["underplating"];
var tile = new Tile(tileDefinition.TileId);
var coordinates = new GridCoordinates(0, 0, gridId);
var coordinates = grid.ToCoordinates();
grid.SetTile(coordinates, tile);
@@ -300,7 +301,7 @@ namespace Content.IntegrationTests.Tests
{
foreach (var distinct in distinctComponents)
{
var testLocation = new GridCoordinates(new Vector2(0, 0), grid);
var testLocation = grid.ToCoordinates();
var entity = entityManager.SpawnEntity("AllComponentsOneEntityDeleteTestEntity", testLocation);
Assert.That(entity.Initialized);

View File

@@ -1,6 +1,7 @@
using System.Threading.Tasks;
using Content.Server.GameObjects.Components.Fluids;
using Content.Shared.Chemistry;
using Content.Shared.Utility;
using NUnit.Framework;
using Robust.Server.Interfaces.Timing;
using Robust.Shared.Interfaces.Map;
@@ -23,7 +24,7 @@ namespace Content.IntegrationTests.Tests.Fluids
var pauseManager = server.ResolveDependency<IPauseManager>();
var tileDefinitionManager = server.ResolveDependency<ITileDefinitionManager>();
GridCoordinates coordinates = default;
EntityCoordinates coordinates = default;
// Build up test environment
server.Post(() =>
@@ -42,7 +43,7 @@ namespace Content.IntegrationTests.Tests.Fluids
var tileDefinition = tileDefinitionManager["underplating"];
var tile = new Tile(tileDefinition.TileId);
coordinates = new GridCoordinates(0, 0, gridId);
coordinates = grid.ToCoordinates();
grid.SetTile(coordinates, tile);
@@ -69,6 +70,7 @@ namespace Content.IntegrationTests.Tests.Fluids
await server.WaitIdleAsync();
var mapManager = server.ResolveDependency<IMapManager>();
var pauseManager = server.ResolveDependency<IPauseManager>();
IMapGrid grid = null;
// Build up test environment
server.Post(() =>
@@ -79,9 +81,9 @@ namespace Content.IntegrationTests.Tests.Fluids
var gridId = new GridId(1);
if (!mapManager.GridExists(gridId))
if (!mapManager.TryGetGrid(gridId, out grid))
{
mapManager.CreateGrid(mapId, gridId);
grid = mapManager.CreateGrid(mapId, gridId);
}
});
@@ -90,7 +92,7 @@ namespace Content.IntegrationTests.Tests.Fluids
server.Assert(() =>
{
var gridId = new GridId(1);
var coordinates = new GridCoordinates(0, 0, gridId);
var coordinates = grid.ToCoordinates();
var solution = new Solution("water", ReagentUnit.New(20));
var puddle = solution.SpillAt(coordinates, "PuddleSmear");
Assert.Null(puddle);

View File

@@ -1,6 +1,7 @@
using System.Threading.Tasks;
using Content.Server.GameObjects.Components.Gravity;
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
using Content.Shared.Utility;
using NUnit.Framework;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
@@ -37,7 +38,7 @@ namespace Content.IntegrationTests.Tests
var entityMan = IoCManager.Resolve<IEntityManager>();
generator = entityMan.SpawnEntity("GravityGenerator", new GridCoordinates(new Vector2(0, 0), grid2.Index));
generator = entityMan.SpawnEntity("GravityGenerator", grid2.ToCoordinates());
Assert.That(generator.HasComponent<GravityGeneratorComponent>());
Assert.That(generator.HasComponent<PowerReceiverComponent>());
var generatorComponent = generator.GetComponent<GravityGeneratorComponent>();

View File

@@ -45,8 +45,8 @@ namespace Content.IntegrationTests.Tests
entities = tileLookup.GetEntitiesIntersecting(gridOne.Index, new MapIndices(1000, 1000)).ToList();
Assert.That(entities.Count, Is.EqualTo(0));
var entityOne = entityManager.SpawnEntity("HumanMob_Content", new GridCoordinates(Vector2.Zero, gridOne));
entityManager.SpawnEntity("HumanMob_Content", new GridCoordinates(Vector2.One, gridOne));
var entityOne = entityManager.SpawnEntity("HumanMob_Content", new EntityCoordinates(gridOne.GridEntityId, Vector2.Zero));
entityManager.SpawnEntity("HumanMob_Content", new EntityCoordinates(gridOne.GridEntityId, Vector2.One));
var entityTiles = tileLookup.GetIndices(entityOne);
Assert.That(entityTiles.Count, Is.EqualTo(2));

View File

@@ -41,7 +41,7 @@ namespace Content.IntegrationTests.Tests.Interaction
IEntity other = null;
IContainer container = null;
IComponent component = null;
GridCoordinates gridCoordinates = default;
EntityCoordinates entityCoordinates = default;
MapCoordinates mapCoordinates = default;
server.Assert(() =>
@@ -53,7 +53,7 @@ namespace Content.IntegrationTests.Tests.Interaction
other = entityManager.SpawnEntity(HumanId, coordinates);
container = ContainerManagerComponent.Ensure<Container>("InRangeUnobstructedTestOtherContainer", other);
component = other.Transform;
gridCoordinates = other.Transform.GridPosition;
entityCoordinates = other.Transform.Coordinates;
mapCoordinates = other.Transform.MapPosition;
});
@@ -73,9 +73,9 @@ namespace Content.IntegrationTests.Tests.Interaction
Assert.True(origin.InRangeUnobstructed(container));
Assert.True(container.InRangeUnobstructed(origin));
// Entity <-> GridCoordinates
Assert.True(origin.InRangeUnobstructed(gridCoordinates));
Assert.True(gridCoordinates.InRangeUnobstructed(origin));
// Entity <-> EntityCoordinates
Assert.True(origin.InRangeUnobstructed(entityCoordinates));
Assert.True(entityCoordinates.InRangeUnobstructed(origin));
// Entity <-> MapCoordinates
Assert.True(origin.InRangeUnobstructed(mapCoordinates));
@@ -97,9 +97,9 @@ namespace Content.IntegrationTests.Tests.Interaction
Assert.True(origin.InRangeUnobstructed(container));
Assert.True(container.InRangeUnobstructed(origin));
// Entity <-> GridCoordinates
Assert.True(origin.InRangeUnobstructed(gridCoordinates));
Assert.True(gridCoordinates.InRangeUnobstructed(origin));
// Entity <-> EntityCoordinates
Assert.True(origin.InRangeUnobstructed(entityCoordinates));
Assert.True(entityCoordinates.InRangeUnobstructed(origin));
// Entity <-> MapCoordinates
Assert.True(origin.InRangeUnobstructed(mapCoordinates));
@@ -121,9 +121,9 @@ namespace Content.IntegrationTests.Tests.Interaction
Assert.False(origin.InRangeUnobstructed(container));
Assert.False(container.InRangeUnobstructed(origin));
// Entity <-> GridCoordinates
Assert.False(origin.InRangeUnobstructed(gridCoordinates));
Assert.False(gridCoordinates.InRangeUnobstructed(origin));
// Entity <-> EntityCoordinates
Assert.False(origin.InRangeUnobstructed(entityCoordinates));
Assert.False(entityCoordinates.InRangeUnobstructed(origin));
// Entity <-> MapCoordinates
Assert.False(origin.InRangeUnobstructed(mapCoordinates));
@@ -144,9 +144,9 @@ namespace Content.IntegrationTests.Tests.Interaction
Assert.True(origin.InRangeUnobstructed(container, InteractionRangeDivided15Times3));
Assert.True(container.InRangeUnobstructed(origin, InteractionRangeDivided15Times3));
// Entity <-> GridCoordinates
Assert.True(origin.InRangeUnobstructed(gridCoordinates, InteractionRangeDivided15Times3));
Assert.True(gridCoordinates.InRangeUnobstructed(origin, InteractionRangeDivided15Times3));
// Entity <-> EntityCoordinates
Assert.True(origin.InRangeUnobstructed(entityCoordinates, InteractionRangeDivided15Times3));
Assert.True(entityCoordinates.InRangeUnobstructed(origin, InteractionRangeDivided15Times3));
// Entity <-> MapCoordinates
Assert.True(origin.InRangeUnobstructed(mapCoordinates, InteractionRangeDivided15Times3));

View File

@@ -2,6 +2,7 @@
using System.Threading.Tasks;
using Content.Server.Mobs;
using Content.Server.Players;
using Content.Shared.Utility;
using NUnit.Framework;
using Robust.Server.Interfaces.GameObjects;
using Robust.Server.Interfaces.Player;
@@ -128,7 +129,7 @@ namespace Content.IntegrationTests.Tests
mapMan.CreateNewMapEntity(MapId.Nullspace);
playerEnt = entMgr.SpawnEntity(null, new GridCoordinates(Vector2.Zero, grid.Index));
playerEnt = entMgr.SpawnEntity(null, grid.ToCoordinates());
mind = new Mind(player.SessionId);
player.ContentData().Mind = mind;

View File

@@ -50,7 +50,7 @@ namespace Content.IntegrationTests.Tests.Networking
var lastSvEntity = svEntityManager.GetEntities().Last();
var lastClEntity = clEntityManager.GetEntity(lastSvEntity.Uid);
Assert.That(lastClEntity.Transform.GridPosition, Is.EqualTo(lastSvEntity.Transform.GridPosition));
Assert.That(lastClEntity.Transform.Coordinates, Is.EqualTo(lastSvEntity.Transform.Coordinates));
}
}
}

View File

@@ -8,6 +8,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using System.Threading.Tasks;
using Content.Shared.Utility;
namespace Content.IntegrationTests.Tests
{
@@ -30,9 +31,9 @@ namespace Content.IntegrationTests.Tests
mapMan.CreateMap(new MapId(1));
var grid = mapMan.CreateGrid(new MapId(1));
var generatorEnt = entityMan.SpawnEntity("DebugGenerator", new GridCoordinates(new Vector2(0, 0), grid.Index));
var consumerEnt1 = entityMan.SpawnEntity("DebugConsumer", new GridCoordinates(new Vector2(0, 1), grid.Index));
var consumerEnt2 = entityMan.SpawnEntity("DebugConsumer", new GridCoordinates(new Vector2(0, 2), grid.Index));
var generatorEnt = entityMan.SpawnEntity("DebugGenerator", grid.ToCoordinates());
var consumerEnt1 = entityMan.SpawnEntity("DebugConsumer", grid.ToCoordinates(0, 1));
var consumerEnt2 = entityMan.SpawnEntity("DebugConsumer", grid.ToCoordinates(0, 2));
Assert.That(generatorEnt.TryGetComponent(out supplier));
Assert.That(consumerEnt1.TryGetComponent(out consumer1));
@@ -74,9 +75,9 @@ namespace Content.IntegrationTests.Tests
mapMan.CreateMap(new MapId(1));
var grid = mapMan.CreateGrid(new MapId(1));
var generatorEnt = entityMan.SpawnEntity("DebugGenerator", new GridCoordinates(new Vector2(0, 0), grid.Index));
var substationEnt = entityMan.SpawnEntity("DebugSubstation", new GridCoordinates(new Vector2(0, 1), grid.Index));
var apcEnt = entityMan.SpawnEntity("DebugApc", new GridCoordinates(new Vector2(0, 2), grid.Index));
var generatorEnt = entityMan.SpawnEntity("DebugGenerator", grid.ToCoordinates());
var substationEnt = entityMan.SpawnEntity("DebugSubstation", grid.ToCoordinates(0, 1));
var apcEnt = entityMan.SpawnEntity("DebugApc", grid.ToCoordinates(0, 2));
Assert.That(generatorEnt.TryGetComponent<PowerSupplierComponent>(out var generatorSupplier));
@@ -120,9 +121,9 @@ namespace Content.IntegrationTests.Tests
mapMan.CreateMap(new MapId(1));
var grid = mapMan.CreateGrid(new MapId(1));
var apcEnt = entityMan.SpawnEntity("DebugApc", new GridCoordinates(new Vector2(0, 0), grid.Index));
var apcExtensionEnt = entityMan.SpawnEntity("ApcExtensionCable", new GridCoordinates(new Vector2(0, 1), grid.Index));
var powerReceiverEnt = entityMan.SpawnEntity("DebugPowerReceiver", new GridCoordinates(new Vector2(0, 2), grid.Index));
var apcEnt = entityMan.SpawnEntity("DebugApc", grid.ToCoordinates(0, 0));
var apcExtensionEnt = entityMan.SpawnEntity("ApcExtensionCable", grid.ToCoordinates(0, 1));
var powerReceiverEnt = entityMan.SpawnEntity("DebugPowerReceiver", grid.ToCoordinates(0, 2));
Assert.That(apcEnt.TryGetComponent<ApcComponent>(out var apc));
Assert.That(apcExtensionEnt.TryGetComponent<PowerProviderComponent>(out var provider));

View File

@@ -66,7 +66,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
var meleeWeapon = hands.GetActiveHand.Owner;
meleeWeapon.TryGetComponent(out MeleeWeaponComponent meleeWeaponComponent);
if ((_target.Transform.GridPosition.Position - _owner.Transform.GridPosition.Position).Length >
if ((_target.Transform.Coordinates.Position - _owner.Transform.Coordinates.Position).Length >
meleeWeaponComponent.Range)
{
return Outcome.Failed;
@@ -74,7 +74,7 @@ namespace Content.Server.AI.Operators.Combat.Melee
var interactionSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<InteractionSystem>();
interactionSystem.UseItemInHand(_owner, _target.Transform.GridPosition, _target.Uid);
interactionSystem.UseItemInHand(_owner, _target.Transform.Coordinates, _target.Uid);
_elapsedTime += frameTime;
return Outcome.Continuing;
}

View File

@@ -72,14 +72,14 @@ namespace Content.Server.AI.Operators.Combat.Melee
return Outcome.Failed;
}
if ((_target.Transform.GridPosition.Position - _owner.Transform.GridPosition.Position).Length >
if ((_target.Transform.Coordinates.Position - _owner.Transform.Coordinates.Position).Length >
_unarmedCombat.Range)
{
return Outcome.Failed;
}
var interactionSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<InteractionSystem>();
interactionSystem.UseItemInHand(_owner, _target.Transform.GridPosition, _target.Uid);
interactionSystem.UseItemInHand(_owner, _target.Transform.Coordinates, _target.Uid);
_elapsedTime += frameTime;
return Outcome.Continuing;
}

View File

@@ -41,7 +41,7 @@ namespace Content.Server.AI.Operators.Inventory
// Click on da thing
var interactionSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<InteractionSystem>();
interactionSystem.UseItemInHand(_owner, _useTarget.Transform.GridPosition, _useTarget.Uid);
interactionSystem.UseItemInHand(_owner, _useTarget.Transform.Coordinates, _useTarget.Uid);
return Outcome.Success;
}

View File

@@ -11,10 +11,10 @@ namespace Content.Server.AI.Operators.Movement
{
private readonly IEntity _owner;
private GridTargetSteeringRequest _request;
private readonly GridCoordinates _target;
private readonly EntityCoordinates _target;
public float DesiredRange { get; set; }
public MoveToGridOperator(IEntity owner, GridCoordinates target, float desiredRange = 1.5f)
public MoveToGridOperator(IEntity owner, EntityCoordinates target, float desiredRange = 1.5f)
{
_owner = owner;
_target = target;

View File

@@ -33,7 +33,7 @@ namespace Content.Server.AI.Utility.Actions.Idle
var robustRandom = IoCManager.Resolve<IRobustRandom>();
var randomGrid = FindRandomGrid(robustRandom);
float waitTime;
if (randomGrid != GridCoordinates.InvalidGrid)
if (randomGrid != EntityCoordinates.Invalid)
{
waitTime = robustRandom.Next(3, 8);
}
@@ -60,7 +60,7 @@ namespace Content.Server.AI.Utility.Actions.Idle
};
}
private GridCoordinates FindRandomGrid(IRobustRandom robustRandom)
private EntityCoordinates FindRandomGrid(IRobustRandom robustRandom)
{
// Very inefficient (should weight each region by its node count) but better than the old system
var reachableSystem = EntitySystem.Get<AiReachableSystem>();

View File

@@ -21,8 +21,8 @@ namespace Content.Server.AI.Utility.Actions.Test
public override void SetupOperators(Blackboard context)
{
var currentPosition = Owner.Transform.GridPosition;
var nextPosition = Owner.Transform.GridPosition.Offset(new Vector2(10.0f, 0.0f));
var currentPosition = Owner.Transform.Coordinates;
var nextPosition = Owner.Transform.Coordinates.Offset(new Vector2(10.0f, 0.0f));
var originalPosOp = new MoveToGridOperator(Owner, currentPosition, 0.25f);
var newPosOp = new MoveToGridOperator(Owner, nextPosition, 0.25f);

View File

@@ -15,7 +15,7 @@ namespace Content.Server.AI.Utility.Considerations.Movement
}
// Anything further than 100 tiles gets clamped
return (target.Transform.GridPosition.Position - self.Transform.GridPosition.Position).Length / 100;
return (target.Transform.Coordinates.Position - self.Transform.Coordinates.Position).Length / 100;
}
}
}

View File

@@ -26,7 +26,7 @@ namespace Content.Server.AI.Utils
if (owner.TryGetComponent(out AiControllerComponent controller))
{
var targetRange = (target.Transform.GridPosition.Position - owner.Transform.GridPosition.Position).Length;
var targetRange = (target.Transform.Coordinates.Position - owner.Transform.Coordinates.Position).Length;
if (targetRange > controller.VisionRadius)
{
return false;
@@ -35,9 +35,9 @@ namespace Content.Server.AI.Utils
range = controller.VisionRadius;
}
var angle = new Angle(target.Transform.GridPosition.Position - owner.Transform.GridPosition.Position);
var angle = new Angle(target.Transform.Coordinates.Position - owner.Transform.Coordinates.Position);
var ray = new CollisionRay(
owner.Transform.GridPosition.Position,
owner.Transform.Coordinates.Position,
angle.ToVec(),
(int)(CollisionGroup.Opaque | CollisionGroup.Impassable | CollisionGroup.MobImpassable));
@@ -47,25 +47,25 @@ namespace Content.Server.AI.Utils
}
// Should this be in robust or something? Fark it
public static IEnumerable<IEntity> GetNearestEntities(GridCoordinates grid, Type component, float range)
public static IEnumerable<IEntity> GetNearestEntities(EntityCoordinates grid, Type component, float range)
{
var inRange = GetEntitiesInRange(grid, component, range).ToList();
var sortedInRange = inRange.OrderBy(o => (o.Transform.GridPosition.Position - grid.Position).Length);
var sortedInRange = inRange.OrderBy(o => (o.Transform.Coordinates.Position - grid.Position).Length);
return sortedInRange;
}
public static IEnumerable<IEntity> GetEntitiesInRange(GridCoordinates grid, Type component, float range)
public static IEnumerable<IEntity> GetEntitiesInRange(EntityCoordinates grid, Type component, float range)
{
var entityManager = IoCManager.Resolve<IEntityManager>();
foreach (var entity in entityManager.GetEntities(new TypeEntityQuery(component)))
{
if (entity.Transform.GridPosition.GridID != grid.GridID)
if (entity.Transform.Coordinates.GetGridId(entityManager) != grid.GetGridId(entityManager))
{
continue;
}
if ((entity.Transform.GridPosition.Position - grid.Position).Length <= range)
if ((entity.Transform.Coordinates.Position - grid.Position).Length <= range)
{
yield return entity;
}

View File

@@ -24,7 +24,7 @@ namespace Content.Server.AI.WorldState.States.Clothing
}
foreach (var entity in Visibility
.GetNearestEntities(Owner.Transform.GridPosition, typeof(ClothingComponent), controller.VisionRadius))
.GetNearestEntities(Owner.Transform.Coordinates, typeof(ClothingComponent), controller.VisionRadius))
{
if (ContainerHelpers.TryGetContainer(entity, out var container))
{

View File

@@ -22,7 +22,7 @@ namespace Content.Server.AI.WorldState.States.Combat.Nearby
}
foreach (var entity in Visibility
.GetNearestEntities(Owner.Transform.GridPosition, typeof(MeleeWeaponComponent), controller.VisionRadius))
.GetNearestEntities(Owner.Transform.Coordinates, typeof(MeleeWeaponComponent), controller.VisionRadius))
{
result.Add(entity);
}

View File

@@ -21,7 +21,7 @@ namespace Content.Server.AI.WorldState.States.Mobs
return result;
}
foreach (var entity in Visibility.GetEntitiesInRange(Owner.Transform.GridPosition, typeof(ISharedBodyManagerComponent), controller.VisionRadius))
foreach (var entity in Visibility.GetEntitiesInRange(Owner.Transform.Coordinates, typeof(ISharedBodyManagerComponent), controller.VisionRadius))
{
if (entity == Owner) continue;
result.Add(entity);

View File

@@ -23,7 +23,7 @@ namespace Content.Server.AI.WorldState.States.Mobs
}
var playerManager = IoCManager.Resolve<IPlayerManager>();
var nearbyPlayers = playerManager.GetPlayersInRange(Owner.Transform.GridPosition, (int) controller.VisionRadius);
var nearbyPlayers = playerManager.GetPlayersInRange(Owner.Transform.Coordinates, (int) controller.VisionRadius);
foreach (var player in nearbyPlayers)
{

View File

@@ -24,7 +24,7 @@ namespace Content.Server.AI.WorldState.States.Nutrition
}
foreach (var entity in Visibility
.GetNearestEntities(Owner.Transform.GridPosition, typeof(DrinkComponent), controller.VisionRadius))
.GetNearestEntities(Owner.Transform.Coordinates, typeof(DrinkComponent), controller.VisionRadius))
{
if (ContainerHelpers.TryGetContainer(entity, out var container))
{

View File

@@ -24,7 +24,7 @@ namespace Content.Server.AI.WorldState.States.Nutrition
}
foreach (var entity in Visibility
.GetNearestEntities(Owner.Transform.GridPosition, typeof(FoodComponent), controller.VisionRadius))
.GetNearestEntities(Owner.Transform.Coordinates, typeof(FoodComponent), controller.VisionRadius))
{
if (ContainerHelpers.TryGetContainer(entity, out var container))
{

View File

@@ -60,32 +60,36 @@ namespace Content.Server.Administration
var mapManager = IoCManager.Resolve<IMapManager>();
var currentMap = player.AttachedEntity.Transform.MapID;
var currentGrid = player.AttachedEntity.Transform.GridID;
var entityManager = IoCManager.Resolve<IEntityManager>();
var found = comp.EntityQuery<WarpPointComponent>()
.Where(p => p.Location == location)
.Select(p => p.Owner.Transform.GridPosition)
.OrderBy(p => p, Comparer<GridCoordinates>.Create((a, b) =>
.Select(p => p.Owner.Transform.Coordinates)
.OrderBy(p => p, Comparer<EntityCoordinates>.Create((a, b) =>
{
// Sort so that warp points on the same grid/map are first.
// So if you have two maps loaded with the same warp points,
// it will prefer the warp points on the map you're currently on.
if (a.GridID == b.GridID)
var aGrid = a.GetGridId(entityManager);
var bGrid = b.GetGridId(entityManager);
if (aGrid == bGrid)
{
return 0;
}
if (a.GridID == currentGrid)
if (aGrid == currentGrid)
{
return -1;
}
if (b.GridID == currentGrid)
if (bGrid == currentGrid)
{
return 1;
}
var mapA = mapManager.GetGrid(a.GridID).ParentMapId;
var mapB = mapManager.GetGrid(b.GridID).ParentMapId;
var mapA = mapManager.GetGrid(aGrid).ParentMapId;
var mapB = mapManager.GetGrid(bGrid).ParentMapId;
if (mapA == mapB)
{
@@ -106,9 +110,9 @@ namespace Content.Server.Administration
}))
.FirstOrDefault();
if (found.GridID != GridId.Invalid)
if (found.GetGridId(entityManager) != GridId.Invalid)
{
player.AttachedEntity.Transform.GridPosition = found;
player.AttachedEntity.Transform.Coordinates = found;
if (player.AttachedEntity.TryGetComponent(out ICollidableComponent collidable))
{
collidable.Stop();

View File

@@ -2,31 +2,35 @@
using System.Diagnostics.CodeAnalysis;
using Content.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
namespace Content.Server.Atmos
{
public static class AtmosHelpers
{
public static TileAtmosphere? GetTileAtmosphere(this GridCoordinates coordinates)
public static TileAtmosphere? GetTileAtmosphere(this EntityCoordinates coordinates, IEntityManager? entityManager = null)
{
var gridAtmos = EntitySystem.Get<AtmosphereSystem>().GetGridAtmosphere(coordinates.GridID);
entityManager ??= IoCManager.Resolve<IEntityManager>();
var gridAtmos = EntitySystem.Get<AtmosphereSystem>().GetGridAtmosphere(coordinates.GetGridId(entityManager));
return gridAtmos?.GetTile(coordinates);
}
public static GasMixture? GetTileAir(this GridCoordinates coordinates)
public static GasMixture? GetTileAir(this EntityCoordinates coordinates)
{
return coordinates.GetTileAtmosphere()?.Air;
}
public static bool TryGetTileAtmosphere(this GridCoordinates coordinates, [MaybeNullWhen(false)] out TileAtmosphere atmosphere)
public static bool TryGetTileAtmosphere(this EntityCoordinates coordinates, [MaybeNullWhen(false)] out TileAtmosphere atmosphere)
{
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
return !Equals(atmosphere = coordinates.GetTileAtmosphere()!, default);
}
public static bool TryGetTileAir(this GridCoordinates coordinates, [MaybeNullWhen(false)] out GasMixture air)
public static bool TryGetTileAir(this EntityCoordinates coordinates, [MaybeNullWhen(false)] out GasMixture air)
{
// ReSharper disable once ConditionIsAlwaysTrueOrFalse
return !Equals(air = coordinates.GetTileAir()!, default);

View File

@@ -53,7 +53,7 @@ namespace Content.Server.Atmos
{
tank.TryRemoveReagent(_fuelType, ReagentUnit.New(_fuelCost));
var playerPos = eventArgs.User.Transform.GridPosition;
var playerPos = eventArgs.User.Transform.Coordinates;
var direction = (eventArgs.ClickLocation.Position - playerPos.Position).Normalized;
playerPos.Offset(direction/2);

View File

@@ -8,9 +8,9 @@ using Robust.Shared.IoC;
using Robust.Shared.Maths;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
using Content.Server.GameObjects.Components.Atmos;
using Content.Server.Interfaces;
using Content.Shared.Atmos;
using Robust.Shared.Map;
namespace Content.Server.Atmos
{
@@ -18,6 +18,8 @@ namespace Content.Server.Atmos
class GasVaporComponent : Component, ICollideBehavior, IGasMixtureHolder
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
public override string Name => "GasVapor";
[ViewVariables] public GasMixture Air { get; set; }
@@ -76,10 +78,10 @@ namespace Content.Server.Atmos
foreach (var tile in tiles)
{
var pos = tile.GridIndices.ToGridCoordinates(_mapManager, tile.GridIndex);
var atmos = AtmosHelpers.GetTileAtmosphere(pos);
var pos = tile.GridIndices.ToEntityCoordinates(_mapManager, tile.GridIndex);
var atmos = pos.GetTileAtmosphere(_entityManager);
if (atmos.Air == null)
if (atmos?.Air == null)
{
return;
}

View File

@@ -26,7 +26,7 @@ namespace Content.Server.Atmos
private const float ThrowForce = 100f;
public void ExperiencePressureDifference(int cycle, float pressureDifference, AtmosDirection direction,
float pressureResistanceProbDelta, GridCoordinates throwTarget)
float pressureResistanceProbDelta, EntityCoordinates throwTarget)
{
if (ControlledComponent == null)
return;
@@ -52,10 +52,10 @@ namespace Content.Server.Atmos
if (maxForce > ThrowForce)
{
if (throwTarget != GridCoordinates.InvalidGrid)
if (throwTarget != EntityCoordinates.Invalid)
{
var moveForce = maxForce * MathHelper.Clamp(moveProb, 0, 100) / 150f;
var pos = ((throwTarget.Position - transform.GridPosition.Position).Normalized + direction.ToDirection().ToVec()).Normalized;
var pos = ((throwTarget.Position - transform.Coordinates.Position).Normalized + direction.ToDirection().ToVec()).Normalized;
LinearVelocity = pos * moveForce;
}
@@ -74,7 +74,7 @@ namespace Content.Server.Atmos
{
base.UpdateAfterProcessing();
if (ControlledComponent != null && !_physicsManager.IsWeightless(ControlledComponent.Owner.Transform.GridPosition))
if (ControlledComponent != null && !_physicsManager.IsWeightless(ControlledComponent.Owner.Transform.Coordinates))
{
LinearVelocity *= 0.85f;
if (MathF.Abs(LinearVelocity.Length) < 1f)

View File

@@ -117,7 +117,7 @@ namespace Content.Server.Atmos
/// </summary>
/// <param name="coordinates"></param>
/// <returns></returns>
TileAtmosphere GetTile(GridCoordinates coordinates, bool createSpace = true);
TileAtmosphere GetTile(EntityCoordinates coordinates, bool createSpace = true);
/// <summary>
/// Returns if the tile in question is air-blocked.

View File

@@ -9,6 +9,7 @@ using Content.Server.Interfaces;
using Content.Shared.Atmos;
using Content.Shared.Audio;
using Content.Shared.Maps;
using Content.Shared.Utility;
using JetBrains.Annotations;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Server.GameObjects.EntitySystems.TileLookup;
@@ -188,7 +189,7 @@ namespace Content.Server.Atmos
{
if(_soundCooldown == 0)
EntitySystem.Get<AudioSystem>().PlayAtCoords("/Audio/Effects/space_wind.ogg",
GridIndices.ToGridCoordinates(_mapManager, GridIndex), AudioHelpers.WithVariation(0.125f).WithVolume(MathHelper.Clamp(PressureDifference / 10, 10, 100)));
GridIndices.ToEntityCoordinates(_mapManager, GridIndex), AudioHelpers.WithVariation(0.125f).WithVolume(MathHelper.Clamp(PressureDifference / 10, 10, 100)));
}
foreach (var entity in _gridTileLookupSystem.GetEntitiesIntersecting(GridIndex, GridIndices))
@@ -203,7 +204,7 @@ namespace Content.Server.Atmos
var pressureMovements = physics.EnsureController<HighPressureMovementController>();
if (pressure.LastHighPressureMovementAirCycle < _gridAtmosphereComponent.UpdateCounter)
{
pressureMovements.ExperiencePressureDifference(_gridAtmosphereComponent.UpdateCounter, PressureDifference, _pressureDirection, 0, PressureSpecificTarget?.GridIndices.ToGridCoordinates(_mapManager, GridIndex) ?? GridCoordinates.InvalidGrid);
pressureMovements.ExperiencePressureDifference(_gridAtmosphereComponent.UpdateCounter, PressureDifference, _pressureDirection, 0, PressureSpecificTarget?.GridIndices.ToEntityCoordinates(_mapManager, GridIndex) ?? EntityCoordinates.Invalid);
}
}

View File

@@ -328,7 +328,7 @@ namespace Content.Server.Body
SizeUsed -= mechanismTarget.Size;
var entityManager = IoCManager.Resolve<IEntityManager>();
var position = dropLocation.Transform.GridPosition;
var position = dropLocation.Transform.Coordinates;
var mechanismEntity = entityManager.SpawnEntity("BaseDroppedMechanism", position);
dropped = mechanismEntity.GetComponent<DroppedMechanismComponent>();
@@ -524,7 +524,7 @@ namespace Content.Server.Body
return false;
}
dropped = IoCManager.Resolve<IEntityManager>().SpawnEntity("BaseDroppedBodyPart", Body.Owner.Transform.GridPosition);
dropped = IoCManager.Resolve<IEntityManager>().SpawnEntity("BaseDroppedBodyPart", Body.Owner.Transform.Coordinates);
dropped.GetComponent<DroppedBodyPartComponent>().TransferBodyPartData(this);

View File

@@ -112,7 +112,7 @@ namespace Content.Server.Chat
// Ensure the first letter inside the message string is always a capital letter
message = message[0].ToString().ToUpper() + message.Remove(0,1);
var pos = source.Transform.GridPosition;
var pos = source.Transform.Coordinates;
var clients = _playerManager.GetPlayersInRange(pos, VoiceRange).Select(p => p.ConnectedClient);
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
@@ -144,7 +144,7 @@ namespace Content.Server.Chat
return;
}
var pos = source.Transform.GridPosition;
var pos = source.Transform.Coordinates;
var clients = _playerManager.GetPlayersInRange(pos, VoiceRange).Select(p => p.ConnectedClient);
var msg = _netManager.CreateNetMessage<MsgChatMessage>();

View File

@@ -58,7 +58,7 @@ namespace Content.Server.Chemistry.ReactionEffects
int finalHeavyImpactRange = (int)MathF.Round(_heavyImpactRange * floatIntensity);
int finalLightImpactRange = (int)MathF.Round(_lightImpactRange * floatIntensity);
int finalFlashRange = (int)MathF.Round(_flashRange * floatIntensity);
ExplosionHelper.SpawnExplosion(solutionEntity.Transform.GridPosition, finalDevastationRange,
ExplosionHelper.SpawnExplosion(solutionEntity.Transform.Coordinates, finalDevastationRange,
finalHeavyImpactRange, finalLightImpactRange, finalFlashRange);
}
}

View File

@@ -26,13 +26,14 @@ namespace Content.Server.Explosions
/// </summary>
private static Vector2 _epicenterDistance = (0.1f, 0.1f);
public static void SpawnExplosion(GridCoordinates coords, int devastationRange, int heavyImpactRange, int lightImpactRange, int flashRange)
public static void SpawnExplosion(EntityCoordinates coords, int devastationRange, int heavyImpactRange, int lightImpactRange, int flashRange)
{
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
var serverEntityManager = IoCManager.Resolve<IServerEntityManager>();
var entitySystemManager = IoCManager.Resolve<IEntitySystemManager>();
var mapManager = IoCManager.Resolve<IMapManager>();
var robustRandom = IoCManager.Resolve<IRobustRandom>();
var entityManager = IoCManager.Resolve<IEntityManager>();
var maxRange = MathHelper.Max(devastationRange, heavyImpactRange, lightImpactRange, 0f);
//Entity damage calculation
@@ -45,17 +46,21 @@ namespace Content.Server.Explosions
if (!entity.Transform.IsMapTransform)
continue;
var distanceFromEntity = (int)entity.Transform.GridPosition.Distance(mapManager, coords);
if (!entity.Transform.Coordinates.TryDistance(entityManager, coords, out var distance))
{
continue;
}
ExplosionSeverity severity;
if (distanceFromEntity < devastationRange)
if (distance < devastationRange)
{
severity = ExplosionSeverity.Destruction;
}
else if (distanceFromEntity < heavyImpactRange)
else if (distance < heavyImpactRange)
{
severity = ExplosionSeverity.Heavy;
}
else if (distanceFromEntity < lightImpactRange)
else if (distance < lightImpactRange)
{
severity = ExplosionSeverity.Light;
}
@@ -70,7 +75,7 @@ namespace Content.Server.Explosions
//Tile damage calculation mockup
//TODO: make it into some sort of actual damage component or whatever the boys think is appropriate
var mapGrid = mapManager.GetGrid(coords.GridID);
var mapGrid = mapManager.GetGrid(coords.GetGridId(entityManager));
var circle = new Circle(coords.Position, maxRange);
var tiles = mapGrid.GetTilesIntersecting(circle);
foreach (var tile in tiles)
@@ -82,12 +87,16 @@ namespace Content.Server.Explosions
{
continue;
}
var distanceFromTile = (int) tileLoc.Distance(mapManager, coords);
if (!tileLoc.TryDistance(entityManager, coords, out var distance))
{
continue;
}
var zeroTile = new Tile(tileDefinitionManager[baseTurfs[0]].TileId);
var previousTile = new Tile(tileDefinitionManager[baseTurfs[^1]].TileId);
switch (distanceFromTile)
switch (distance)
{
case var d when d < devastationRange:
mapGrid.SetTile(tileLoc, zeroTile);
@@ -137,7 +146,7 @@ namespace Content.Server.Explosions
}
var playerPos = player.AttachedEntity.Transform.WorldPosition;
var delta = coords.ToMapPos(mapManager) - playerPos;
var delta = coords.ToMapPos(entityManager) - playerPos;
//Change if zero. Will result in a NaN later breaking camera shake if not changed
if (delta.EqualsApprox((0.0f, 0.0f)))
delta = _epicenterDistance;

View File

@@ -134,7 +134,7 @@ namespace Content.Server.GameObjects.Components.ActionBlocking
var entity = _container.ContainedEntities[_container.ContainedEntities.Count - 1];
_container.Remove(entity);
entity.Transform.WorldPosition = Owner.Transform.GridPosition.Position;
entity.Transform.WorldPosition = Owner.Transform.Coordinates.Position;
}
if (dirty)

View File

@@ -4,6 +4,7 @@ using Robust.Server.Interfaces.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components.Transform;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC;
using Robust.Shared.Log;
@@ -17,6 +18,7 @@ namespace Content.Server.GameObjects.Components.Atmos
public class AirtightComponent : Component, IMapInit
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
private (GridId, MapIndices) _lastPosition;
@@ -89,7 +91,7 @@ namespace Content.Server.GameObjects.Components.Atmos
if (_fixVacuum)
{
var mapIndices = Owner.Transform.GridPosition.ToMapIndices(_mapManager);
var mapIndices = Owner.Transform.Coordinates.ToMapIndices(_entityManager, _mapManager);
EntitySystem.Get<AtmosphereSystem>().GetGridAtmosphere(Owner.Transform.GridID)?.FixVacuum(mapIndices);
}
@@ -109,7 +111,7 @@ namespace Content.Server.GameObjects.Components.Atmos
private void UpdatePosition()
{
var mapIndices = Owner.Transform.GridPosition.ToMapIndices(_mapManager);
var mapIndices = Owner.Transform.Coordinates.ToMapIndices(_entityManager, _mapManager);
UpdatePosition(Owner.Transform.GridID, mapIndices);
}

View File

@@ -9,6 +9,7 @@ using Content.Shared.Damage;
using Content.Shared.GameObjects.Components.Mobs;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
namespace Content.Server.GameObjects.Components.Atmos
{
@@ -18,6 +19,8 @@ namespace Content.Server.GameObjects.Components.Atmos
[RegisterComponent]
public class BarotraumaComponent : Component
{
[Robust.Shared.IoC.Dependency] private readonly IEntityManager _entityManager = default!;
public override string Name => "Barotrauma";
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -26,8 +29,8 @@ namespace Content.Server.GameObjects.Components.Atmos
if (!Owner.TryGetComponent(out IDamageableComponent damageable)) return;
Owner.TryGetComponent(out ServerStatusEffectsComponent status);
var coordinates = Owner.Transform.GridPosition;
var gridAtmos = EntitySystem.Get<AtmosphereSystem>().GetGridAtmosphere(coordinates.GridID);
var coordinates = Owner.Transform.Coordinates;
var gridAtmos = EntitySystem.Get<AtmosphereSystem>().GetGridAtmosphere(coordinates.GetGridId(_entityManager));
var tile = gridAtmos?.GetTile(coordinates);
var pressure = 1f;

View File

@@ -13,6 +13,7 @@ using Robust.Server.Interfaces.GameObjects;
using Robust.Server.Interfaces.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
@@ -25,12 +26,13 @@ namespace Content.Server.GameObjects.Components.Atmos
public class GasAnalyzerComponent : SharedGasAnalyzerComponent, IAfterInteract, IDropped, IUse
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
private GasAnalyzerDanger _pressureDanger;
private float _timeSinceSync;
private const float TimeBetweenSyncs = 2f;
private bool _checkPlayer = false; // Check at the player pos or at some other tile?
private GridCoordinates? _position; // The tile that we scanned
private EntityCoordinates? _position; // The tile that we scanned
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(GasAnalyzerUiKey.Key);
@@ -69,7 +71,7 @@ namespace Content.Server.GameObjects.Components.Atmos
/// </summary>
/// <param name="session">The session to open the ui for</param>
/// <param name="pos">The position to analyze the gas</param>
public void OpenInterface(IPlayerSession session, GridCoordinates pos)
public void OpenInterface(IPlayerSession session, EntityCoordinates pos)
{
_checkPlayer = false;
_position = pos;
@@ -100,7 +102,7 @@ namespace Content.Server.GameObjects.Components.Atmos
// Already get the pressure before Dirty(), because we can't get the EntitySystem in that thread or smth
var pressure = 0f;
var gam = EntitySystem.Get<AtmosphereSystem>().GetGridAtmosphere(Owner.Transform.GridID);
var tile = gam?.GetTile(Owner.Transform.GridPosition).Air;
var tile = gam?.GetTile(Owner.Transform.Coordinates).Air;
if (tile != null)
{
pressure = tile.Pressure;
@@ -148,18 +150,18 @@ namespace Content.Server.GameObjects.Components.Atmos
}
}
var pos = Owner.Transform.GridPosition;
var pos = Owner.Transform.Coordinates;
if (!_checkPlayer && _position.HasValue)
{
// Check if position is out of range => don't update
if (!_position.Value.InRange(_mapManager, pos, SharedInteractionSystem.InteractionRange))
if (!_position.Value.InRange(_entityManager, pos, SharedInteractionSystem.InteractionRange))
return;
pos = _position.Value;
}
var atmosSystem = EntitySystem.Get<AtmosphereSystem>();
var gam = atmosSystem.GetGridAtmosphere(pos.GridID);
var gam = atmosSystem.GetGridAtmosphere(pos.GetGridId(_entityManager));
var tile = gam?.GetTile(pos).Air;
if (tile == null)
{

View File

@@ -374,9 +374,9 @@ namespace Content.Server.GameObjects.Components.Atmos
}
/// <inheritdoc />
public TileAtmosphere? GetTile(GridCoordinates coordinates, bool createSpace = true)
public TileAtmosphere? GetTile(EntityCoordinates coordinates, bool createSpace = true)
{
return GetTile(coordinates.ToMapIndices(_mapManager), createSpace);
return GetTile(coordinates.ToMapIndices(_serverEntityManager, _mapManager), createSpace);
}
/// <inheritdoc />

View File

@@ -6,6 +6,8 @@ using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Log;
using Robust.Shared.ViewVariables;
using System.Linq;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.GameObjects.Components.Atmos.Piping
{
@@ -14,6 +16,8 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
/// </summary>
public abstract class BaseSiphonComponent : PipeNetDeviceComponent
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[ViewVariables]
private PipeNode _scrubberOutlet;
@@ -40,11 +44,11 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
public override void Update()
{
var tileAtmos = AtmosHelpers.GetTileAtmosphere(Owner.Transform.GridPosition);
var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere(_entityManager);
if (tileAtmos == null)
return;
ScrubGas(tileAtmos.Air, _scrubberOutlet.Air);
_atmosSystem.GetGridAtmosphere(Owner.Transform.GridID).Invalidate(tileAtmos.GridIndices);
_atmosSystem.GetGridAtmosphere(Owner.Transform.GridID)?.Invalidate(tileAtmos.GridIndices);
}
protected abstract void ScrubGas(GasMixture inletGas, GasMixture outletGas);

View File

@@ -6,6 +6,8 @@ using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Log;
using Robust.Shared.ViewVariables;
using System.Linq;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.GameObjects.Components.Atmos.Piping
{
@@ -14,13 +16,13 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
/// </summary>
public abstract class BaseVentComponent : PipeNetDeviceComponent
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[ViewVariables]
private PipeNode _ventInlet;
private AtmosphereSystem _atmosSystem;
public override void Initialize()
{
base.Initialize();
@@ -42,7 +44,7 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
public override void Update()
{
var tileAtmos = AtmosHelpers.GetTileAtmosphere(Owner.Transform.GridPosition);
var tileAtmos = Owner.Transform.Coordinates.GetTileAtmosphere(_entityManager);
if (tileAtmos == null)
return;
VentGas(_ventInlet.Air, tileAtmos.Air);

View File

@@ -83,7 +83,7 @@ namespace Content.Server.GameObjects.Components.Body.Respiratory
return;
}
if (!Owner.Transform.GridPosition.TryGetTileAir(out var tileAir))
if (!Owner.Transform.Coordinates.TryGetTileAir(out var tileAir))
{
return;
}
@@ -104,7 +104,7 @@ namespace Content.Server.GameObjects.Components.Body.Respiratory
return;
}
if (!Owner.Transform.GridPosition.TryGetTileAir(out var tileAir))
if (!Owner.Transform.Coordinates.TryGetTileAir(out var tileAir))
{
return;
}

View File

@@ -426,9 +426,9 @@ namespace Content.Server.GameObjects.Components.Buckle
return;
}
var bucklePosition = BuckledTo.Owner.Transform.GridPosition.Offset(BuckleOffset.Value);
var bucklePosition = BuckledTo.Owner.Transform.Coordinates.Offset(BuckleOffset.Value);
if (moveEvent.NewPosition.InRange(_mapManager, bucklePosition, 0.2f))
if (moveEvent.NewPosition.InRange(_entityManager, bucklePosition, 0.2f))
{
return;
}

View File

@@ -168,7 +168,7 @@ namespace Content.Server.GameObjects.Components.Cargo
continue;
for (var i = 0; i < order.Amount; i++)
{
Owner.EntityManager.SpawnEntity(product.Product, Owner.Transform.GridPosition);
Owner.EntityManager.SpawnEntity(product.Product, Owner.Transform.Coordinates);
}
}
break;

View File

@@ -279,7 +279,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
var actualVolume = ReagentUnit.Min(individualVolume, ReagentUnit.New(30));
for (int i = 0; i < bottleAmount; i++)
{
var bottle = Owner.EntityManager.SpawnEntity("bottle", Owner.Transform.GridPosition);
var bottle = Owner.EntityManager.SpawnEntity("bottle", Owner.Transform.Coordinates);
var bufferSolution = BufferSolution.Solution.SplitSolution(actualVolume);
@@ -298,7 +298,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
}
//Put it on the floor
bottle.Transform.GridPosition = user.Transform.GridPosition;
bottle.Transform.Coordinates = user.Transform.Coordinates;
//Give it an offset
bottle.RandomOffset(0.2f);
}
@@ -313,7 +313,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
var actualVolume = ReagentUnit.Min(individualVolume, ReagentUnit.New(50));
for (int i = 0; i < pillAmount; i++)
{
var pill = Owner.EntityManager.SpawnEntity("pill", Owner.Transform.GridPosition);
var pill = Owner.EntityManager.SpawnEntity("pill", Owner.Transform.Coordinates);
var bufferSolution = BufferSolution.Solution.SplitSolution(actualVolume);
@@ -333,7 +333,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
}
//Put it on the floor
pill.Transform.GridPosition = user.Transform.GridPosition;
pill.Transform.Coordinates = user.Transform.Coordinates;
//Give it an offset
pill.RandomOffset(0.2f);
}

View File

@@ -499,7 +499,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
}
//Play reaction sound client-side
_audioSystem.PlayAtCoords("/Audio/Effects/Chemistry/bubbles.ogg", Owner.Transform.GridPosition);
_audioSystem.PlayAtCoords("/Audio/Effects/Chemistry/bubbles.ogg", Owner.Transform.Coordinates);
}
/// <summary>

View File

@@ -75,7 +75,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
var amount = _transferAmount / ReagentUnit.New(tiles.Count());
foreach (var tile in tiles)
{
var pos = tile.GridIndices.ToGridCoordinates(_mapManager, tile.GridIndex);
var pos = tile.GridIndices.ToEntityCoordinates(_mapManager, tile.GridIndex);
contents.SplitSolution(amount).SpillAt(pos, "PuddleSmear", false); // TODO: Make non PuddleSmear?
}
}

View File

@@ -70,7 +70,7 @@ namespace Content.Server.GameObjects.Components.Damage
_actSystem.HandleBreakage(Owner);
if (!Owner.Deleted && DestroySound != string.Empty)
{
var pos = Owner.Transform.GridPosition;
var pos = Owner.Transform.Coordinates;
EntitySystem.Get<AudioSystem>().PlayAtCoords(DestroySound, pos);
}
}

View File

@@ -32,7 +32,7 @@ namespace Content.Server.GameObjects.Components.Damage
{
if (!string.IsNullOrWhiteSpace(SpawnOnDestroy) && eventArgs.IsSpawnWreck)
{
Owner.EntityManager.SpawnEntity(SpawnOnDestroy, Owner.Transform.GridPosition);
Owner.EntityManager.SpawnEntity(SpawnOnDestroy, Owner.Transform.Coordinates);
}
}
@@ -53,7 +53,7 @@ namespace Content.Server.GameObjects.Components.Damage
{
if (!Owner.Deleted)
{
var pos = Owner.Transform.GridPosition;
var pos = Owner.Transform.Coordinates;
ActSystem.HandleDestruction(Owner,
true); //This will call IDestroyAct.OnDestroy on this component (and all other components on this entity)
if (DestroySound != string.Empty)

View File

@@ -61,7 +61,7 @@ namespace Content.Server.GameObjects.Components.Damage
if (!Owner.Deleted && DestroySound != string.Empty)
{
var pos = Owner.Transform.GridPosition;
var pos = Owner.Transform.Coordinates;
EntitySystem.Get<AudioSystem>().PlayAtCoords(DestroySound, pos);
}

View File

@@ -88,7 +88,7 @@ namespace Content.Server.GameObjects.Components.Disposal
PreviousTube = CurrentTube;
}
Owner.Transform.GridPosition = tube.Owner.Transform.GridPosition;
Owner.Transform.Coordinates = tube.Owner.Transform.Coordinates;
CurrentTube = tube;
NextTube = tube.NextTube(this);
StartingTime = 0.1f;

View File

@@ -273,7 +273,7 @@ namespace Content.Server.GameObjects.Components.Disposal
}
_lastClang = _gameTiming.CurTime;
EntitySystem.Get<AudioSystem>().PlayAtCoords(_clangSound, Owner.Transform.GridPosition);
EntitySystem.Get<AudioSystem>().PlayAtCoords(_clangSound, Owner.Transform.Coordinates);
break;
}
}

View File

@@ -34,7 +34,7 @@ namespace Content.Server.GameObjects.Components.Explosion
if (_beingExploded) return true;
_beingExploded = true;
ExplosionHelper.SpawnExplosion(Owner.Transform.GridPosition, DevastationRange, HeavyImpactRange, LightImpactRange, FlashRange);
ExplosionHelper.SpawnExplosion(Owner.Transform.Coordinates, DevastationRange, HeavyImpactRange, LightImpactRange, FlashRange);
Owner.Delete();
return true;

View File

@@ -44,7 +44,7 @@ namespace Content.Server.GameObjects.Components.Explosion
if (_sound != null)
{
EntitySystem.Get<AudioSystem>().PlayAtCoords(_sound, Owner.Transform.GridPosition);
EntitySystem.Get<AudioSystem>().PlayAtCoords(_sound, Owner.Transform.Coordinates);
}
if (_deleteOnFlash && !Owner.Deleted)

View File

@@ -89,7 +89,7 @@ namespace Content.Server.GameObjects.Components
}
else if (ItemContainer.Remove(ItemContainer.ContainedEntity))
{
ItemContainer.ContainedEntity.Transform.GridPosition = Owner.Transform.GridPosition;
ItemContainer.ContainedEntity.Transform.Coordinates = Owner.Transform.Coordinates;
}
}
else

View File

@@ -13,7 +13,7 @@ namespace Content.Server.GameObjects.Components
{
base.Initialize();
ItemContainer.Insert(Owner.EntityManager.SpawnEntity("FireExtinguisher", Owner.Transform.GridPosition));
ItemContainer.Insert(Owner.EntityManager.SpawnEntity("FireExtinguisher", Owner.Transform.Coordinates));
}
}
}

View File

@@ -39,7 +39,7 @@ namespace Content.Server.GameObjects.Components.Fluids
{
var solutionComponent = component.Owner.GetComponent<SolutionComponent>();
// Need this as when we split the component's owner may be deleted
var entityLocation = component.Owner.Transform.GridPosition;
var entityLocation = component.Owner.Transform.Coordinates;
var solution = solutionComponent.SplitSolution(solutionComponent.CurrentVolume);
solution.SpillAt(entityLocation, "PuddleSmear");
}

View File

@@ -195,7 +195,7 @@ namespace Content.Server.GameObjects.Components.Fluids
return true;
}
EntitySystem.Get<AudioSystem>().PlayAtCoords(_spillSound, Owner.Transform.GridPosition);
EntitySystem.Get<AudioSystem>().PlayAtCoords(_spillSound, Owner.Transform.Coordinates);
return true;
}
@@ -354,7 +354,7 @@ namespace Content.Server.GameObjects.Components.Fluids
var mapGrid = _mapManager.GetGrid(Owner.Transform.GridID);
if (!Owner.Transform.GridPosition.Offset(direction).TryGetTileRef(out var tile))
if (!Owner.Transform.Coordinates.Offset(direction).TryGetTileRef(out var tile))
{
return false;
}

View File

@@ -23,7 +23,7 @@ namespace Content.Server.GameObjects.Components.Fluids
/// <returns>The puddle if one was created, null otherwise.</returns>
public static PuddleComponent? SpillAt(this Solution solution, IEntity entity, string prototype, bool sound = true)
{
var coordinates = entity.Transform.GridPosition;
var coordinates = entity.Transform.Coordinates;
return solution.SpillAt(coordinates, prototype, sound);
}
@@ -52,7 +52,7 @@ namespace Content.Server.GameObjects.Components.Fluids
/// <param name="prototype">The prototype to use.</param>
/// <param name="sound">Whether or not to play the spill sound.</param>
/// <returns>The puddle if one was created, null otherwise.</returns>
public static PuddleComponent? SpillAt(this Solution solution, GridCoordinates coordinates, string prototype, bool sound = true)
public static PuddleComponent? SpillAt(this Solution solution, EntityCoordinates coordinates, string prototype, bool sound = true)
{
if (solution.TotalVolume == 0)
{
@@ -63,7 +63,8 @@ namespace Content.Server.GameObjects.Components.Fluids
var entityManager = IoCManager.Resolve<IEntityManager>();
var serverEntityManager = IoCManager.Resolve<IServerEntityManager>();
var mapGrid = mapManager.GetGrid(coordinates.GridID);
var gridId = coordinates.GetGridId(entityManager);
var mapGrid = mapManager.GetGrid(gridId);
// If space return early, let that spill go out into the void
var tileRef = mapGrid.GetTileRef(coordinates);
@@ -74,7 +75,7 @@ namespace Content.Server.GameObjects.Components.Fluids
// Get normalized co-ordinate for spill location and spill it in the centre
// TODO: Does SnapGrid or something else already do this?
var spillTileMapGrid = mapManager.GetGrid(coordinates.GridID);
var spillTileMapGrid = mapManager.GetGrid(gridId);
var spillTileRef = spillTileMapGrid.GetTileRef(coordinates).GridIndices;
var spillGridCoords = spillTileMapGrid.GridTileToLocal(spillTileRef);
@@ -119,7 +120,7 @@ namespace Content.Server.GameObjects.Components.Fluids
/// <param name="puddle">The puddle if one was created, null otherwise.</param>
/// <param name="sound">Play the spill sound.</param>
/// <returns>True if a puddle was created, false otherwise.</returns>
public static bool TrySpillAt(this Solution solution, GridCoordinates coordinates, string prototype, [NotNullWhen(true)] out PuddleComponent? puddle, bool sound = true)
public static bool TrySpillAt(this Solution solution, EntityCoordinates coordinates, string prototype, [NotNullWhen(true)] out PuddleComponent? puddle, bool sound = true)
{
puddle = solution.SpillAt(coordinates, prototype, sound);
return puddle != null;

View File

@@ -74,8 +74,8 @@ namespace Content.Server.GameObjects.Components.Fluids
return;
}
var playerPos = eventArgs.User.Transform.GridPosition;
if (eventArgs.ClickLocation.GridID != playerPos.GridID)
var playerPos = eventArgs.User.Transform.Coordinates;
if (eventArgs.ClickLocation.GetGridId(_serverEntityManager) != playerPos.GetGridId(_serverEntityManager))
return;
if (!Owner.TryGetComponent(out SolutionComponent contents))

View File

@@ -181,7 +181,7 @@ namespace Content.Server.GameObjects.Components.GUI
{
if (!PutInHand(item, mobCheck))
{
item.Owner.Transform.GridPosition = Owner.Transform.GridPosition;
item.Owner.Transform.Coordinates = Owner.Transform.Coordinates;
}
}
@@ -245,7 +245,7 @@ namespace Content.Server.GameObjects.Components.GUI
return false;
}
public bool Drop(string slot, GridCoordinates coords, bool doMobChecks = true)
public bool Drop(string slot, EntityCoordinates coords, bool doMobChecks = true)
{
var hand = GetHand(slot);
if (!CanDrop(slot) || hand?.Entity == null)
@@ -264,7 +264,7 @@ namespace Content.Server.GameObjects.Components.GUI
return false;
item.RemovedFromSlot();
item.Owner.Transform.GridPosition = coords;
item.Owner.Transform.Coordinates = coords;
if (ContainerHelpers.TryGetContainer(Owner, out var container))
{
@@ -277,7 +277,7 @@ namespace Content.Server.GameObjects.Components.GUI
return true;
}
public bool Drop(IEntity entity, GridCoordinates coords, bool doMobChecks = true)
public bool Drop(IEntity entity, EntityCoordinates coords, bool doMobChecks = true)
{
if (entity == null)
{
@@ -311,7 +311,7 @@ namespace Content.Server.GameObjects.Components.GUI
}
item.RemovedFromSlot();
item.Owner.Transform.GridPosition = Owner.Transform.GridPosition;
item.Owner.Transform.Coordinates = Owner.Transform.Coordinates;
if (item.Owner.TryGetComponent<SpriteComponent>(out var spriteComponent))
{
@@ -564,7 +564,7 @@ namespace Content.Server.GameObjects.Components.GUI
controller.StartPull(Owner.GetComponent<ICollidableComponent>());
}
public void MovePulledObject(GridCoordinates puller, GridCoordinates to)
public void MovePulledObject(EntityCoordinates puller, EntityCoordinates to)
{
if (PulledObject != null &&
PulledObject.TryGetController(out PullController controller))
@@ -655,7 +655,7 @@ namespace Content.Server.GameObjects.Components.GUI
if (used != null)
{
interactionSystem.Interaction(Owner, used, hand.Entity,
GridCoordinates.InvalidGrid);
EntityCoordinates.Invalid);
}
else
{

View File

@@ -446,7 +446,7 @@ namespace Content.Server.GameObjects.Components.GUI
if (activeHand != null)
{
interactionSystem.Interaction(Owner, activeHand.Owner, itemContainedInSlot.Owner,
new GridCoordinates());
new EntityCoordinates());
}
else if (Unequip(msg.Inventoryslot))
{

View File

@@ -234,7 +234,7 @@ namespace Content.Server.GameObjects.Components.Interactable
if (!hands.PutInHand(cell.Owner.GetComponent<ItemComponent>()))
{
cell.Owner.Transform.GridPosition = user.Transform.GridPosition;
cell.Owner.Transform.Coordinates = user.Transform.Coordinates;
}
EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Items/pistol_magout.ogg", Owner);
@@ -292,7 +292,7 @@ namespace Content.Server.GameObjects.Components.Interactable
return;
}
var cell = Owner.EntityManager.SpawnEntity("PowerCellSmallStandard", Owner.Transform.GridPosition);
var cell = Owner.EntityManager.SpawnEntity("PowerCellSmallStandard", Owner.Transform.Coordinates);
_cellContainer.Insert(cell);
}
}

View File

@@ -1,5 +1,4 @@
using Content.Server.GameObjects.EntitySystems.Click;
using Content.Shared.GameObjects.Components.Interactable;
using Content.Shared.GameObjects.Components.Interactable;
using Content.Shared.Interfaces.GameObjects.Components;
using Content.Shared.Maps;
using Content.Shared.Utility;
@@ -15,7 +14,6 @@ namespace Content.Server.GameObjects.Components.Interactable
[RegisterComponent]
public class TilePryingComponent : Component, IAfterInteract
{
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefinitionManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
@@ -33,12 +31,12 @@ namespace Content.Server.GameObjects.Components.Interactable
serializer.DataField(ref _toolComponentNeeded, "toolComponentNeeded", true);
}
public async void TryPryTile(IEntity user, GridCoordinates clickLocation)
public async void TryPryTile(IEntity user, EntityCoordinates clickLocation)
{
if (!Owner.TryGetComponent<ToolComponent>(out var tool) && _toolComponentNeeded)
return;
var mapGrid = _mapManager.GetGrid(clickLocation.GridID);
var mapGrid = _mapManager.GetGrid(clickLocation.GetGridId(Owner.EntityManager));
var tile = mapGrid.GetTileRef(clickLocation);
var coordinates = mapGrid.GridTileToLocal(tile.GridIndices);
@@ -53,7 +51,7 @@ namespace Content.Server.GameObjects.Components.Interactable
if (_toolComponentNeeded && !await tool!.UseTool(user, null, 0f, ToolQuality.Prying))
return;
coordinates.PryTile(_mapManager, _tileDefinitionManager, Owner.EntityManager);
coordinates.PryTile(Owner.EntityManager, _mapManager);
}
}
}

View File

@@ -49,7 +49,7 @@ namespace Content.Server.GameObjects.Components.Interactable
var mapManager = IoCManager.Resolve<IMapManager>();
var playerGrid = player.AttachedEntity.Transform.GridID;
var mapGrid = mapManager.GetGrid(playerGrid);
var playerPosition = player.AttachedEntity.Transform.GridPosition;
var playerPosition = player.AttachedEntity.Transform.Coordinates;
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
for (var i = -radius; i <= radius; i++)

View File

@@ -201,7 +201,7 @@ namespace Content.Server.GameObjects.Components.Interactable
PlaySoundCollection("WelderOn", -5);
_welderSystem.Subscribe(this);
Owner.Transform.GridPosition
Owner.Transform.Coordinates
.GetTileAtmosphere()?.HotspotExpose(700f, 50f, true);
return true;
@@ -243,7 +243,7 @@ namespace Content.Server.GameObjects.Components.Interactable
_solutionComponent?.TryRemoveReagent("chem.WeldingFuel", ReagentUnit.New(FuelLossRate * frameTime));
Owner.Transform.GridPosition
Owner.Transform.Coordinates
.GetTileAtmosphere()?.HotspotExpose(700f, 50f, true);
if (Fuel == 0)

View File

@@ -40,7 +40,7 @@ namespace Content.Server.GameObjects.Components.Items
if (!Owner.TryGetComponent(out StackComponent stack)) return;
var attacked = eventArgs.Target;
var mapGrid = _mapManager.GetGrid(eventArgs.ClickLocation.GridID);
var mapGrid = _mapManager.GetGrid(eventArgs.ClickLocation.GetGridId(Owner.EntityManager));
var tile = mapGrid.GetTileRef(eventArgs.ClickLocation);
var tileDef = (ContentTileDefinition)_tileDefinitionManager[tile.Tile.TypeId];

View File

@@ -97,7 +97,7 @@ namespace Content.Server.GameObjects.Components.Items.RCD
//No changing mode mid-RCD
var startingMode = _mode;
var mapGrid = _mapManager.GetGrid(eventArgs.ClickLocation.GridID);
var mapGrid = _mapManager.GetGrid(eventArgs.ClickLocation.GetGridId(Owner.EntityManager));
var tile = mapGrid.GetTileRef(eventArgs.ClickLocation);
var snapPos = mapGrid.SnapGridCellFor(eventArgs.ClickLocation, SnapGridOffset.Center);
@@ -166,8 +166,8 @@ namespace Content.Server.GameObjects.Components.Items.RCD
return false;
}
var coordinates = mapGrid.GridTileToLocal(tile.GridIndices);
if (coordinates == GridCoordinates.InvalidGrid || !eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true))
var coordinates = mapGrid.ToCoordinates(tile.GridIndices);
if (coordinates == EntityCoordinates.Invalid || !eventArgs.InRangeUnobstructed(ignoreInsideBlocker: true, popup: true))
{
return false;
}

View File

@@ -16,7 +16,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
void Spawn(string prototype)
{
storage.Insert(Owner.EntityManager.SpawnEntity(prototype, Owner.Transform.GridPosition));
storage.Insert(Owner.EntityManager.SpawnEntity(prototype, Owner.Transform.Coordinates));
}
Spawn("MopItem");

View File

@@ -18,7 +18,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
void Spawn(string prototype)
{
storage.Insert(Owner.EntityManager.SpawnEntity(prototype, Owner.Transform.GridPosition));
storage.Insert(Owner.EntityManager.SpawnEntity(prototype, Owner.Transform.Coordinates));
}
if (random.Prob(0.4f))

View File

@@ -18,7 +18,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
void Spawn(string prototype)
{
storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.GridPosition));
storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.Coordinates));
}
Spawn("Brutepack");

View File

@@ -34,7 +34,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
void Spawn(string prototype)
{
storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.GridPosition));
storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.Coordinates));
}
foreach (var prototype in _contents)

View File

@@ -18,7 +18,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
void Spawn(string prototype)
{
storage.Insert(Owner.EntityManager.SpawnEntity(prototype, Owner.Transform.GridPosition));
storage.Insert(Owner.EntityManager.SpawnEntity(prototype, Owner.Transform.Coordinates));
}
if (random.Prob(0.4f))

View File

@@ -21,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
void Spawn(string prototype)
{
storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.GridPosition));
storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.Coordinates));
}
Spawn("Screwdriver");

View File

@@ -21,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
void Spawn(string prototype)
{
storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.GridPosition));
storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.Coordinates));
}
Spawn("BreathMaskClothing");

View File

@@ -21,7 +21,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
void Spawn(string prototype)
{
storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.GridPosition));
storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.Coordinates));
}
Spawn("GoldStack");

View File

@@ -18,7 +18,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage.Fill
void Spawn(string prototype)
{
storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.GridPosition));
storage.Insert(_entityManager.SpawnEntity(prototype, Owner.Transform.Coordinates));
}
Spawn("Crowbar");

View File

@@ -1,8 +1,6 @@
using Content.Server.GameObjects.Components.GUI;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces.GameObjects.Components.Items;
using Content.Server.Throw;
using Content.Server.Utility;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Items;
using Content.Shared.GameObjects.EntitySystems;
@@ -14,8 +12,6 @@ using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Serialization;
@@ -26,8 +22,6 @@ namespace Content.Server.GameObjects.Components.Items.Storage
[ComponentReference(typeof(IItemComponent))]
public class ItemComponent : StorableComponent, IInteractHand, IExAct, IEquipped, IUnequipped, IItemComponent
{
[Dependency] private readonly IMapManager _mapManager = default!;
public override string Name => "Item";
public override uint? NetID => ContentNetIDs.ITEM;
@@ -142,8 +136,8 @@ namespace Content.Server.GameObjects.Components.Items.Storage
public void OnExplosion(ExplosionEventArgs eventArgs)
{
var sourceLocation = eventArgs.Source;
var targetLocation = eventArgs.Target.Transform.GridPosition;
var dirVec = (targetLocation.ToMapPos(_mapManager) - sourceLocation.ToMapPos(_mapManager)).Normalized;
var targetLocation = eventArgs.Target.Transform.Coordinates;
var dirVec = (targetLocation.ToMapPos(Owner.EntityManager) - sourceLocation.ToMapPos(Owner.EntityManager)).Normalized;
var throwForce = 1.0f;

View File

@@ -365,7 +365,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
var ownerTransform = Owner.Transform;
var playerTransform = player.Transform;
if (!playerTransform.GridPosition.InRange(_mapManager, ownerTransform.GridPosition, 2) ||
if (!playerTransform.Coordinates.InRange(_entityManager, ownerTransform.Coordinates, 2) ||
!ownerTransform.IsMapTransform &&
!playerTransform.ContainsEntity(ownerTransform))
{

View File

@@ -339,7 +339,7 @@ namespace Content.Server.GameObjects.Components.Kitchen
if (recipeToCook != null)
{
var entityToSpawn = goodMeal ? recipeToCook.Result : _badRecipeName;
_entityManager.SpawnEntity(entityToSpawn, Owner.Transform.GridPosition);
_entityManager.SpawnEntity(entityToSpawn, Owner.Transform.Coordinates);
}
}
_audioSystem.PlayFromEntity(_cookingCompleteSound, Owner, AudioParams.Default.WithVolume(-1f));

View File

@@ -74,7 +74,7 @@ namespace Content.Server.GameObjects.Components.MachineLinking
return true;
}
if (transmitter.Range > 0 && !Owner.Transform.GridPosition.InRange(_mapManager, transmitter.Owner.Transform.GridPosition, transmitter.Range))
if (transmitter.Range > 0 && !Owner.Transform.Coordinates.InRange(Owner.EntityManager, transmitter.Owner.Transform.Coordinates, transmitter.Range))
{
Owner.PopupMessage(user, Loc.GetString("Out of range."));
return false;

View File

@@ -98,7 +98,7 @@ namespace Content.Server.GameObjects.Components.MachineLinking
foreach (var receiver in _receivers)
{
if (Range > 0 && !Owner.Transform.GridPosition.InRange(_mapManager, receiver.Owner.Transform.GridPosition, Range))
if (Range > 0 && !Owner.Transform.Coordinates.InRange(Owner.EntityManager, receiver.Owner.Transform.Coordinates, Range))
{
continue;
}

View File

@@ -87,7 +87,7 @@ namespace Content.Server.GameObjects.Components.Markers
}
if(!Owner.Deleted)
_entityManager.SpawnEntity(_robustRandom.Pick(Prototypes), Owner.Transform.GridPosition);
_entityManager.SpawnEntity(_robustRandom.Pick(Prototypes), Owner.Transform.Coordinates);
}
public virtual void MapInit()

View File

@@ -80,7 +80,7 @@ namespace Content.Server.GameObjects.Components.Markers
for (int i = 0; i < number; i++)
{
var entity = _robustRandom.Pick(Prototypes);
_entityManager.SpawnEntity(entity, Owner.Transform.GridPosition);
_entityManager.SpawnEntity(entity, Owner.Transform.Coordinates);
}
}
}

Some files were not shown because too many files have changed in this diff Show More