Rename usages of collidable to physics (#2230)

* Rename usages of collidable to physics

* high tier PANIQUE

* aaaaaaaaAAAAAa

* cursed commit dont research

* Fix urist and items being anchored

* Fix the rest
This commit is contained in:
DrSmugleaf
2020-10-11 16:36:58 +02:00
committed by GitHub
parent 413ca9812d
commit b64cb24059
79 changed files with 292 additions and 268 deletions

View File

@@ -165,9 +165,9 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
var targetNode = _pathfindingSystem.GetNode(targetTile);
var collisionMask = 0;
if (entity.TryGetComponent(out ICollidableComponent collidableComponent))
if (entity.TryGetComponent(out IPhysicsComponent physics))
{
collisionMask = collidableComponent.CollisionMask;
collisionMask = physics.CollisionMask;
}
var access = AccessReader.FindAccessTags(entity);

View File

@@ -27,14 +27,14 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
public static ReachableArgs GetArgs(IEntity entity)
{
var collisionMask = 0;
if (entity.TryGetComponent(out ICollidableComponent collidableComponent))
if (entity.TryGetComponent(out IPhysicsComponent physics))
{
collisionMask = collidableComponent.CollisionMask;
collisionMask = physics.CollisionMask;
}
var access = AccessReader.FindAccessTags(entity);
var visionRadius = entity.GetComponent<AiControllerComponent>().VisionRadius;
return new ReachableArgs(visionRadius, access, collisionMask);
}
}

View File

@@ -41,10 +41,10 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
GenerateMask();
}
public static bool IsRelevant(IEntity entity, ICollidableComponent collidableComponent)
public static bool IsRelevant(IEntity entity, IPhysicsComponent physicsComponent)
{
if (entity.Transform.GridID == GridId.Invalid ||
(PathfindingSystem.TrackedCollisionLayers & collidableComponent.CollisionLayer) == 0)
(PathfindingSystem.TrackedCollisionLayers & physicsComponent.CollisionLayer) == 0)
{
return false;
}
@@ -257,7 +257,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
/// <param name="entity"></param>
/// TODO: These 2 methods currently don't account for a bunch of changes (e.g. airlock unpowered, wrenching, etc.)
/// TODO: Could probably optimise this slightly more.
public void AddEntity(IEntity entity, ICollidableComponent collidableComponent)
public void AddEntity(IEntity entity, IPhysicsComponent physicsComponent)
{
// If we're a door
if (entity.HasComponent<AirlockComponent>() || entity.HasComponent<ServerDoorComponent>())
@@ -274,15 +274,15 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
return;
}
DebugTools.Assert((PathfindingSystem.TrackedCollisionLayers & collidableComponent.CollisionLayer) != 0);
DebugTools.Assert((PathfindingSystem.TrackedCollisionLayers & physicsComponent.CollisionLayer) != 0);
if (!collidableComponent.Anchored)
if (!physicsComponent.Anchored)
{
_physicsLayers.Add(entity, collidableComponent.CollisionLayer);
_physicsLayers.Add(entity, physicsComponent.CollisionLayer);
}
else
{
_blockedCollidables.Add(entity, collidableComponent.CollisionLayer);
_blockedCollidables.Add(entity, physicsComponent.CollisionLayer);
GenerateMask();
ParentChunk.Dirty();
}

View File

@@ -275,8 +275,8 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
{
if (entity.Deleted ||
_lastKnownPositions.ContainsKey(entity) ||
!entity.TryGetComponent(out ICollidableComponent collidableComponent) ||
!PathfindingNode.IsRelevant(entity, collidableComponent))
!entity.TryGetComponent(out IPhysicsComponent physics) ||
!PathfindingNode.IsRelevant(entity, physics))
{
return;
}
@@ -286,7 +286,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
var chunk = GetChunk(tileRef);
var node = chunk.GetNode(tileRef);
node.AddEntity(entity, collidableComponent);
node.AddEntity(entity, physics);
_lastKnownPositions.Add(entity, node);
}
@@ -314,8 +314,8 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
{
// If we've moved to space or the likes then remove us.
if (moveEvent.Sender.Deleted ||
!moveEvent.Sender.TryGetComponent(out ICollidableComponent collidableComponent) ||
!PathfindingNode.IsRelevant(moveEvent.Sender, collidableComponent))
!moveEvent.Sender.TryGetComponent(out IPhysicsComponent physics) ||
!PathfindingNode.IsRelevant(moveEvent.Sender, physics))
{
HandleEntityRemove(moveEvent.Sender);
return;
@@ -350,7 +350,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
_lastKnownPositions[moveEvent.Sender] = newNode;
oldNode.RemoveEntity(moveEvent.Sender);
newNode.AddEntity(moveEvent.Sender, collidableComponent);
newNode.AddEntity(moveEvent.Sender, physics);
}
private void QueueCollisionChangeMessage(CollisionChangeMessage collisionMessage)
@@ -371,8 +371,8 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
public bool CanTraverse(IEntity entity, PathfindingNode node)
{
if (entity.TryGetComponent(out ICollidableComponent collidableComponent) &&
(collidableComponent.CollisionMask & node.BlockedCollisionMask) != 0)
if (entity.TryGetComponent(out IPhysicsComponent physics) &&
(physics.CollisionMask & node.BlockedCollisionMask) != 0)
{
return false;
}

View File

@@ -417,9 +417,9 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
var startTile = gridManager.GetTileRef(entity.Transform.Coordinates);
var endTile = gridManager.GetTileRef(steeringRequest.TargetGrid);
var collisionMask = 0;
if (entity.TryGetComponent(out ICollidableComponent collidableComponent))
if (entity.TryGetComponent(out IPhysicsComponent physics))
{
collisionMask = collidableComponent.CollisionMask;
collisionMask = physics.CollisionMask;
}
var access = AccessReader.FindAccessTags(entity);
@@ -603,10 +603,10 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
return Vector2.Zero;
}
if (target.TryGetComponent(out ICollidableComponent collidable))
if (target.TryGetComponent(out IPhysicsComponent physics))
{
var targetDistance = (targetPos.Position - entityPos.Position);
targetPos = targetPos.Offset(collidable.LinearVelocity * targetDistance);
targetPos = targetPos.Offset(physics.LinearVelocity * targetDistance);
}
return (targetPos.Position - entityPos.Position).Normalized;
@@ -621,7 +621,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
/// <returns></returns>
private Vector2 CollisionAvoidance(IEntity entity, Vector2 direction, ICollection<IEntity> ignoredTargets)
{
if (direction == Vector2.Zero || !entity.TryGetComponent(out ICollidableComponent collidableComponent))
if (direction == Vector2.Zero || !entity.TryGetComponent(out IPhysicsComponent physics))
{
return Vector2.Zero;
}
@@ -629,7 +629,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
// We'll check tile-by-tile
// Rewriting this frequently so not many comments as they'll go stale
// I realise this is bad so please rewrite it ;-;
var entityCollisionMask = collidableComponent.CollisionMask;
var entityCollisionMask = physics.CollisionMask;
var avoidanceVector = Vector2.Zero;
var checkTiles = new HashSet<TileRef>();
var avoidTiles = new HashSet<TileRef>();
@@ -662,8 +662,8 @@ 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 (physicsEntity.TryGetComponent(out ICollidableComponent collidable) &&
Vector2.Dot(collidable.LinearVelocity, direction) > 0)
if (physicsEntity.TryGetComponent(out IPhysicsComponent otherPhysics) &&
Vector2.Dot(otherPhysics.LinearVelocity, direction) > 0)
{
continue;
}

View File

@@ -288,13 +288,13 @@ namespace Content.Server.GameObjects.EntitySystems.Click
return false;
}
if (!pull.Owner.TryGetComponent(out ICollidableComponent collidable) ||
collidable.Anchored)
if (!pull.Owner.TryGetComponent(out IPhysicsComponent physics) ||
physics.Anchored)
{
return false;
}
var controller = collidable.EnsureController<PullController>();
var controller = physics.EnsureController<PullController>();
if (controller.GettingPulled)
{

View File

@@ -58,13 +58,13 @@ namespace Content.Server.GameObjects.EntitySystems
public override void Update(float frameTime)
{
foreach (var (moverComponent, collidableComponent) in EntityManager.ComponentManager.EntityQuery<IMoverComponent, ICollidableComponent>())
foreach (var (moverComponent, physics) in EntityManager.ComponentManager.EntityQuery<IMoverComponent, IPhysicsComponent>())
{
var entity = moverComponent.Owner;
if (_pauseManager.IsEntityPaused(entity))
continue;
UpdateKinematics(entity.Transform, moverComponent, collidableComponent);
UpdateKinematics(entity.Transform, moverComponent, physics);
}
}
@@ -83,7 +83,7 @@ namespace Content.Server.GameObjects.EntitySystems
ev.Entity.RemoveComponent<PlayerInputMoverComponent>();
}
if (ev.Entity.TryGetComponent(out ICollidableComponent? physics) &&
if (ev.Entity.TryGetComponent(out IPhysicsComponent? physics) &&
physics.TryGetController(out MoverController controller))
{
controller.StopMoving();