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

@@ -4,7 +4,6 @@ using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.Physics;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC;
@@ -40,12 +39,12 @@ namespace Content.Server.Throw
/// <param name="throwSourceEnt">
/// The entity that did the throwing. An opposite impulse will be applied to this entity if passed in.
/// </param>
public static void Throw(IEntity thrownEnt, float throwForce, GridCoordinates targetLoc, GridCoordinates sourceLoc, bool spread = false, IEntity throwSourceEnt = null)
public static void Throw(IEntity thrownEnt, float throwForce, EntityCoordinates targetLoc, EntityCoordinates sourceLoc, bool spread = false, IEntity throwSourceEnt = null)
{
if (!thrownEnt.TryGetComponent(out ICollidableComponent colComp))
return;
var mapManager = IoCManager.Resolve<IMapManager>();
var entityManager = IoCManager.Resolve<IEntityManager>();
colComp.CanCollide = true;
// I can now collide with player, so that i can do damage.
@@ -60,7 +59,7 @@ namespace Content.Server.Throw
colComp.PhysicsShapes[0].CollisionMask |= (int) CollisionGroup.ThrownItem;
colComp.Status = BodyStatus.InAir;
}
var angle = new Angle(targetLoc.ToMapPos(mapManager) - sourceLoc.ToMapPos(mapManager));
var angle = new Angle(targetLoc.ToMapPos(entityManager) - sourceLoc.ToMapPos(entityManager));
if (spread)
{
@@ -90,7 +89,7 @@ namespace Content.Server.Throw
{
var physicsMgr = IoCManager.Resolve<IPhysicsManager>();
if (physicsMgr.IsWeightless(throwSourceEnt.Transform.GridPosition))
if (physicsMgr.IsWeightless(throwSourceEnt.Transform.Coordinates))
{
// We don't check for surrounding entities,
// so you'll still get knocked around if you're hugging the station wall in zero g.
@@ -126,14 +125,18 @@ namespace Content.Server.Throw
/// <param name="throwSourceEnt">
/// The entity that did the throwing. An opposite impulse will be applied to this entity if passed in.
/// </param>
public static void ThrowTo(IEntity thrownEnt, float throwForceMax, GridCoordinates targetLoc,
GridCoordinates sourceLoc, bool spread = false, IEntity throwSourceEnt = null)
public static void ThrowTo(IEntity thrownEnt, float throwForceMax, EntityCoordinates targetLoc,
EntityCoordinates sourceLoc, bool spread = false, IEntity throwSourceEnt = null)
{
var mapManager = IoCManager.Resolve<IMapManager>();
var entityManager = IoCManager.Resolve<IEntityManager>();
var timing = IoCManager.Resolve<IGameTiming>();
// Calculate the force necessary to land a throw based on throw duration, mass and distance.
var distance = (targetLoc.ToMapPos(mapManager) - sourceLoc.ToMapPos(mapManager)).Length;
if (!targetLoc.TryDistance(entityManager, sourceLoc, out var distance))
{
return;
}
var throwDuration = ThrownItemComponent.DefaultThrowTime;
var mass = 1f;
if (thrownEnt.TryGetComponent(out ICollidableComponent physicsComponent))