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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -33,7 +33,7 @@ namespace Content.Server.AI.Operators.Movement
|
||||
steering.Register(_owner, _request);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public override void Shutdown(Outcome outcome)
|
||||
{
|
||||
base.Shutdown(outcome);
|
||||
@@ -60,4 +60,4 @@ namespace Content.Server.AI.Operators.Movement
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Content.Server.AI.Utility.Actions.Test
|
||||
originalPosOp
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
protected override IReadOnlyCollection<Func<float>> GetConsiderations(Blackboard context)
|
||||
{
|
||||
var considerationsManager = IoCManager.Resolve<ConsiderationsManager>();
|
||||
|
||||
@@ -13,9 +13,9 @@ namespace Content.Server.AI.Utility.Considerations.Movement
|
||||
{
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user