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

@@ -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);
}
}