Converted everything to use collision and physics component interfaces.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.Components.Access;
|
||||
using Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders;
|
||||
@@ -148,7 +148,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
var targetNode = _pathfindingSystem.GetNode(targetTile);
|
||||
|
||||
var collisionMask = 0;
|
||||
if (entity.TryGetComponent(out CollidableComponent collidableComponent))
|
||||
if (entity.TryGetComponent(out ICollidableComponent collidableComponent))
|
||||
{
|
||||
collisionMask = collidableComponent.CollisionMask;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.Components.Access;
|
||||
using Content.Server.GameObjects.Components.Movement;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
@@ -27,7 +27,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
public static ReachableArgs GetArgs(IEntity entity)
|
||||
{
|
||||
var collisionMask = 0;
|
||||
if (entity.TryGetComponent(out CollidableComponent collidableComponent))
|
||||
if (entity.TryGetComponent(out ICollidableComponent collidableComponent))
|
||||
{
|
||||
collisionMask = collidableComponent.CollisionMask;
|
||||
}
|
||||
@@ -38,4 +38,4 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
||||
return new ReachableArgs(visionRadius, access, collisionMask);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects.Components.Access;
|
||||
@@ -266,10 +266,10 @@ namespace Content.Server.GameObjects.EntitySystems.Pathfinding
|
||||
return;
|
||||
}
|
||||
|
||||
if (entity.TryGetComponent(out CollidableComponent collidableComponent) &&
|
||||
if (entity.TryGetComponent(out ICollidableComponent collidableComponent) &&
|
||||
(PathfindingSystem.TrackedCollisionLayers & collidableComponent.CollisionLayer) != 0)
|
||||
{
|
||||
if (entity.TryGetComponent(out PhysicsComponent physicsComponent) && !physicsComponent.Anchored)
|
||||
if (entity.TryGetComponent(out IPhysicsComponent physicsComponent) && !physicsComponent.Anchored)
|
||||
{
|
||||
_physicsLayers.Add(entity.Uid, collidableComponent.CollisionLayer);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Content.Server.GameObjects.Components.Access;
|
||||
@@ -358,7 +358,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
||||
|
||||
public bool CanTraverse(IEntity entity, PathfindingNode node)
|
||||
{
|
||||
if (entity.TryGetComponent(out CollidableComponent collidableComponent) &&
|
||||
if (entity.TryGetComponent(out ICollidableComponent collidableComponent) &&
|
||||
(collidableComponent.CollisionMask & node.BlockedCollisionMask) != 0)
|
||||
{
|
||||
return false;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -397,7 +397,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
||||
var startTile = gridManager.GetTileRef(entity.Transform.GridPosition);
|
||||
var endTile = gridManager.GetTileRef(steeringRequest.TargetGrid);
|
||||
var collisionMask = 0;
|
||||
if (entity.TryGetComponent(out CollidableComponent collidableComponent))
|
||||
if (entity.TryGetComponent(out ICollidableComponent collidableComponent))
|
||||
{
|
||||
collisionMask = collidableComponent.CollisionMask;
|
||||
}
|
||||
@@ -581,7 +581,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
||||
return Vector2.Zero;
|
||||
}
|
||||
|
||||
if (target.TryGetComponent(out PhysicsComponent physicsComponent))
|
||||
if (target.TryGetComponent(out IPhysicsComponent physicsComponent))
|
||||
{
|
||||
var targetDistance = (targetPos.Position - entityPos.Position);
|
||||
targetPos = targetPos.Offset(physicsComponent.LinearVelocity * targetDistance);
|
||||
@@ -599,7 +599,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
||||
/// <returns></returns>
|
||||
private Vector2 CollisionAvoidance(IEntity entity, Vector2 direction, ICollection<EntityUid> ignoredTargets)
|
||||
{
|
||||
if (direction == Vector2.Zero || !entity.TryGetComponent(out CollidableComponent collidableComponent))
|
||||
if (direction == Vector2.Zero || !entity.TryGetComponent(out ICollidableComponent collidableComponent))
|
||||
{
|
||||
return Vector2.Zero;
|
||||
}
|
||||
@@ -637,7 +637,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
||||
// if we're moving in the same direction then ignore
|
||||
// So if 2 entities are moving towards each other and both detect a collision they'll both move in the same direction
|
||||
// i.e. towards the right
|
||||
if (collisionEntity.TryGetComponent(out PhysicsComponent physicsComponent) &&
|
||||
if (collisionEntity.TryGetComponent(out IPhysicsComponent physicsComponent) &&
|
||||
Vector2.Dot(physicsComponent.LinearVelocity, direction) > 0)
|
||||
{
|
||||
continue;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#nullable enable
|
||||
#nullable enable
|
||||
using Content.Server.GameObjects;
|
||||
using Content.Server.GameObjects.Components;
|
||||
using Content.Server.GameObjects.Components.Items.Storage;
|
||||
@@ -66,8 +66,8 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
}
|
||||
|
||||
var mover = entity.GetComponent<IMoverComponent>();
|
||||
var physics = entity.GetComponent<PhysicsComponent>();
|
||||
if (entity.TryGetComponent<CollidableComponent>(out var collider))
|
||||
var physics = entity.GetComponent<IPhysicsComponent>();
|
||||
if (entity.TryGetComponent<ICollidableComponent>(out var collider))
|
||||
{
|
||||
UpdateKinematics(entity.Transform, mover, physics, collider);
|
||||
}
|
||||
@@ -78,7 +78,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetController(PhysicsComponent physics)
|
||||
protected override void SetController(IPhysicsComponent physics)
|
||||
{
|
||||
physics.SetController<MoverController>();
|
||||
}
|
||||
@@ -98,7 +98,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
||||
ev.Entity.RemoveComponent<PlayerInputMoverComponent>();
|
||||
}
|
||||
|
||||
if (ev.Entity.TryGetComponent(out PhysicsComponent physics))
|
||||
if (ev.Entity.TryGetComponent(out IPhysicsComponent physics))
|
||||
{
|
||||
(physics.Controller as MoverController)?.StopMoving();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user