diff --git a/Content.Client/GameObjects/EntitySystems/MoverSystem.cs b/Content.Client/GameObjects/EntitySystems/MoverSystem.cs index 84fe87bf25..d6d972ae30 100644 --- a/Content.Client/GameObjects/EntitySystems/MoverSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/MoverSystem.cs @@ -31,8 +31,8 @@ namespace Content.Client.GameObjects.EntitySystems return; } - var physics = playerEnt.GetComponent(); - playerEnt.TryGetComponent(out CollidableComponent? collidable); + var physics = playerEnt.GetComponent(); + playerEnt.TryGetComponent(out ICollidableComponent? collidable); physics.Predict = true; UpdateKinematics(playerEnt.Transform, mover, physics, collidable); @@ -43,7 +43,7 @@ namespace Content.Client.GameObjects.EntitySystems FrameUpdate(frameTime); } - protected override void SetController(PhysicsComponent physics) + protected override void SetController(IPhysicsComponent physics) { physics.SetController(); } diff --git a/Content.Server/GameObjects/Components/AnchorableComponent.cs b/Content.Server/GameObjects/Components/AnchorableComponent.cs index 3c2311b6a3..ed0ace652e 100644 --- a/Content.Server/GameObjects/Components/AnchorableComponent.cs +++ b/Content.Server/GameObjects/Components/AnchorableComponent.cs @@ -19,7 +19,7 @@ namespace Content.Server.GameObjects.Components public bool InteractUsing(InteractUsingEventArgs eventArgs) { - if (!Owner.TryGetComponent(out PhysicsComponent physics) + if (!Owner.TryGetComponent(out IPhysicsComponent physics) || !eventArgs.Using.TryGetComponent(out ToolComponent tool)) return false; diff --git a/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs b/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs index c6d28ffd3f..e0ffed9177 100644 --- a/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs +++ b/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs @@ -36,7 +36,7 @@ namespace Content.Server.GameObjects protected const float AutoCloseDelay = 5; protected float CloseSpeed = AutoCloseDelay; - private CollidableComponent collidableComponent; + private ICollidableComponent _collidableComponent; private AppearanceComponent _appearance; private CancellationTokenSource _cancellationTokenSource; @@ -64,7 +64,7 @@ namespace Content.Server.GameObjects { base.Initialize(); - collidableComponent = Owner.GetComponent(); + _collidableComponent = Owner.GetComponent(); _appearance = Owner.GetComponent(); _cancellationTokenSource = new CancellationTokenSource(); } @@ -72,7 +72,7 @@ namespace Content.Server.GameObjects public override void OnRemove() { _cancellationTokenSource.Cancel(); - collidableComponent = null; + _collidableComponent = null; _appearance = null; base.OnRemove(); @@ -164,7 +164,7 @@ namespace Content.Server.GameObjects Timer.Spawn(OpenTimeOne, async () => { - collidableComponent.Hard = false; + _collidableComponent.Hard = false; await Timer.Delay(OpenTimeTwo, _cancellationTokenSource.Token); @@ -203,7 +203,7 @@ namespace Content.Server.GameObjects private void CheckCrush() { // Check if collides with something - var collidesWith = collidableComponent.GetCollidingEntities(Vector2.Zero, false); + var collidesWith = _collidableComponent.GetCollidingEntities(Vector2.Zero, false); if (collidesWith.Count() != 0) { // Crush @@ -236,7 +236,7 @@ namespace Content.Server.GameObjects public bool Close() { bool shouldCheckCrush = false; - if (collidableComponent.IsColliding(Vector2.Zero, false)) + if (_collidableComponent.IsColliding(Vector2.Zero, false)) { if (Safety) return false; @@ -260,7 +260,7 @@ namespace Content.Server.GameObjects CheckCrush(); } - collidableComponent.Hard = true; + _collidableComponent.Hard = true; await Timer.Delay(CloseTimeTwo, _cancellationTokenSource.Token); diff --git a/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs b/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs index 09c6ffbba2..92b8dbc5cb 100644 --- a/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs +++ b/Content.Server/GameObjects/Components/Fluids/PuddleComponent.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading; @@ -393,7 +393,7 @@ namespace Content.Server.GameObjects.Components.Fluids foreach (var entity in _snapGrid.GetInDir(direction)) { - if (entity.TryGetComponent(out CollidableComponent collidable) && + if (entity.TryGetComponent(out ICollidableComponent collidable) && (collidable.CollisionLayer & (int) CollisionGroup.Impassable) != 0) { puddle = default; diff --git a/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs b/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs index 0c5d7a21ef..a7088f3924 100644 --- a/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs +++ b/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs @@ -568,7 +568,7 @@ namespace Content.Server.GameObjects Dirty(); - if (!message.Entity.TryGetComponent(out PhysicsComponent physics)) + if (!message.Entity.TryGetComponent(out IPhysicsComponent physics)) { return; } diff --git a/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs index 992a31ebc5..7849847f36 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/ItemComponent.cs @@ -136,7 +136,7 @@ namespace Content.Server.GameObjects.Components public void Fumble() { - if (Owner.TryGetComponent(out var physicsComponent)) + if (Owner.TryGetComponent(out var physicsComponent)) { physicsComponent.LinearVelocity += RandomOffset(); } diff --git a/Content.Server/GameObjects/Components/Mobs/DamageStates.cs b/Content.Server/GameObjects/Components/Mobs/DamageStates.cs index 23c24eae1c..6ee267da41 100644 --- a/Content.Server/GameObjects/Components/Mobs/DamageStates.cs +++ b/Content.Server/GameObjects/Components/Mobs/DamageStates.cs @@ -187,7 +187,7 @@ namespace Content.Server.GameObjects StandingStateHelper.Down(entity); - if (entity.TryGetComponent(out CollidableComponent collidable)) + if (entity.TryGetComponent(out ICollidableComponent collidable)) { collidable.CanCollide = false; } @@ -197,7 +197,7 @@ namespace Content.Server.GameObjects { StandingStateHelper.Standing(entity); - if (entity.TryGetComponent(out CollidableComponent collidable)) + if (entity.TryGetComponent(out ICollidableComponent collidable)) { collidable.CanCollide = true; } diff --git a/Content.Server/GameObjects/Components/Movement/AiControllerComponent.cs b/Content.Server/GameObjects/Components/Movement/AiControllerComponent.cs index 1e48a30f04..0c89727f0c 100644 --- a/Content.Server/GameObjects/Components/Movement/AiControllerComponent.cs +++ b/Content.Server/GameObjects/Components/Movement/AiControllerComponent.cs @@ -43,7 +43,7 @@ namespace Content.Server.GameObjects.Components.Movement base.Initialize(); // This component requires a physics component. - if (!Owner.HasComponent()) + if (!Owner.HasComponent()) Owner.AddComponent(); } diff --git a/Content.Server/GameObjects/Components/Movement/ServerPortalComponent.cs b/Content.Server/GameObjects/Components/Movement/ServerPortalComponent.cs index 9dea2ae96d..f8fed63fc1 100644 --- a/Content.Server/GameObjects/Components/Movement/ServerPortalComponent.cs +++ b/Content.Server/GameObjects/Components/Movement/ServerPortalComponent.cs @@ -63,7 +63,7 @@ namespace Content.Server.GameObjects.Components.Movement { // This will blow up an entity it's attached to base.OnAdd(); - if (Owner.TryGetComponent(out var collide)) + if (Owner.TryGetComponent(out var collide)) { //collide.IsHardCollidable = false; } diff --git a/Content.Server/GameObjects/Components/Movement/ServerTeleporterComponent.cs b/Content.Server/GameObjects/Components/Movement/ServerTeleporterComponent.cs index 74170d8ba3..949b2cbbbe 100644 --- a/Content.Server/GameObjects/Components/Movement/ServerTeleporterComponent.cs +++ b/Content.Server/GameObjects/Components/Movement/ServerTeleporterComponent.cs @@ -114,7 +114,7 @@ namespace Content.Server.GameObjects.Components.Movement { // Added this component to avoid stacking portals and causing shenanigans // TODO: Doesn't do a great job of stopping stacking portals for directed - if (entity.HasComponent() || entity.HasComponent()) + if (entity.HasComponent() || entity.HasComponent()) { return; } @@ -159,7 +159,7 @@ namespace Content.Server.GameObjects.Components.Movement // TODO: Check the user's spot? Upside is no stacking TPs but downside is they can't unstuck themselves from walls. foreach (var entity in _serverEntityManager.GetEntitiesIntersecting(user.Transform.MapID, target)) { - if (entity.HasComponent() || entity.HasComponent()) + if (entity.HasComponent() || entity.HasComponent()) { return false; } diff --git a/Content.Server/GameObjects/Components/Movement/ShuttleControllerComponent.cs b/Content.Server/GameObjects/Components/Movement/ShuttleControllerComponent.cs index d541b4d686..19fca5c045 100644 --- a/Content.Server/GameObjects/Components/Movement/ShuttleControllerComponent.cs +++ b/Content.Server/GameObjects/Components/Movement/ShuttleControllerComponent.cs @@ -55,7 +55,7 @@ namespace Content.Server.GameObjects.Components.Movement if (_mapManager.TryGetGrid(gridId, out var grid) && _entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity)) { //TODO: Switch to shuttle component - if (!gridEntity.TryGetComponent(out PhysicsComponent physComp)) + if (!gridEntity.TryGetComponent(out IPhysicsComponent physComp)) { physComp = gridEntity.AddComponent(); physComp.Mass = 1; diff --git a/Content.Server/GameObjects/Components/Movement/SlipperyComponent.cs b/Content.Server/GameObjects/Components/Movement/SlipperyComponent.cs index 76204c2b86..bc9fc1b33b 100644 --- a/Content.Server/GameObjects/Components/Movement/SlipperyComponent.cs +++ b/Content.Server/GameObjects/Components/Movement/SlipperyComponent.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Timers; using Content.Server.GameObjects.Components.Mobs; using Content.Server.Throw; @@ -79,7 +79,7 @@ namespace Content.Server.GameObjects.Components.Movement || _slipped.Contains(collidedWith.Uid) || !collidedWith.TryGetComponent(out StunnableComponent stun) || !collidedWith.TryGetComponent(out ICollidableComponent otherBody) - || !collidedWith.TryGetComponent(out PhysicsComponent otherPhysics) + || !collidedWith.TryGetComponent(out IPhysicsComponent otherPhysics) || !Owner.TryGetComponent(out ICollidableComponent body)) return; diff --git a/Content.Server/GameObjects/Components/NodeContainer/Nodes/Node.cs b/Content.Server/GameObjects/Components/NodeContainer/Nodes/Node.cs index b0e6cefc40..630d4ff80a 100644 --- a/Content.Server/GameObjects/Components/NodeContainer/Nodes/Node.cs +++ b/Content.Server/GameObjects/Components/NodeContainer/Nodes/Node.cs @@ -38,7 +38,7 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes /// private bool Connectable => !_deleting && Anchored; - private bool Anchored => !Owner.TryGetComponent(out var physics) || physics.Anchored; + private bool Anchored => !Owner.TryGetComponent(out var physics) || physics.Anchored; /// /// Prevents a node from being used by other nodes while midway through removal. @@ -60,7 +60,7 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes { TryAssignGroupIfNeeded(); CombineGroupWithReachable(); - if (Owner.TryGetComponent(out var physics)) + if (Owner.TryGetComponent(out var physics)) { AnchorUpdate(); physics.AnchoredChanged += AnchorUpdate; @@ -70,9 +70,9 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes public void OnContainerRemove() { _deleting = true; - if (Owner.TryGetComponent(out var physics)) + if (Owner.TryGetComponent(out var physics)) { - physics.AnchoredChanged -= AnchorUpdate; + ((IPhysicsComponent) physics).AnchoredChanged -= AnchorUpdate; } NodeGroup.RemoveNode(this); } diff --git a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs index d8c0bfe9a1..54e0cba98d 100644 --- a/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs +++ b/Content.Server/GameObjects/Components/Power/ApcNetComponents/PowerReceiverComponent.cs @@ -45,7 +45,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents /// public bool Connectable => Anchored; - private bool Anchored => !Owner.TryGetComponent(out var physics) || physics.Anchored; + private bool Anchored => !Owner.TryGetComponent(out var physics) || physics.Anchored; [ViewVariables] public bool NeedsProvider { get; private set; } = true; @@ -86,18 +86,18 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents { TryFindAndSetProvider(); } - if (Owner.TryGetComponent(out var physics)) + if (Owner.TryGetComponent(out var physics)) { AnchorUpdate(); - physics.AnchoredChanged += AnchorUpdate; + ((IPhysicsComponent) physics).AnchoredChanged += AnchorUpdate; } } public override void OnRemove() { - if (Owner.TryGetComponent(out var physics)) + if (Owner.TryGetComponent(out var physics)) { - physics.AnchoredChanged -= AnchorUpdate; + ((IPhysicsComponent) physics).AnchoredChanged -= AnchorUpdate; } _provider.RemoveReceiver(this); base.OnRemove(); diff --git a/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs b/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs index 0cbbd5ab55..9ae3d114ec 100644 --- a/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs +++ b/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs @@ -91,7 +91,7 @@ namespace Content.Server.GameObjects.Components.Projectiles } if (!entity.Deleted && entity.TryGetComponent(out CameraRecoilComponent recoilComponent) - && Owner.TryGetComponent(out PhysicsComponent physicsComponent)) + && Owner.TryGetComponent(out IPhysicsComponent physicsComponent)) { var direction = physicsComponent.LinearVelocity.Normalized; recoilComponent.Kick(direction); diff --git a/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs b/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs index 5bc7f4660d..88fd81bc72 100644 --- a/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs +++ b/Content.Server/GameObjects/Components/Projectiles/ThrownItemComponent.cs @@ -40,7 +40,7 @@ namespace Content.Server.GameObjects.Components // after impacting the first object. // For realism this should actually be changed when the velocity of the object is less than a threshold. // This would allow ricochets off walls, and weird gravity effects from slowing the object. - if (Owner.TryGetComponent(out CollidableComponent body) && body.PhysicsShapes.Count >= 1) + if (Owner.TryGetComponent(out ICollidableComponent body) && body.PhysicsShapes.Count >= 1) { _shouldCollide = false; } @@ -53,11 +53,11 @@ namespace Content.Server.GameObjects.Components return; } - if (Owner.TryGetComponent(out CollidableComponent body) && body.PhysicsShapes.Count >= 1) + if (Owner.TryGetComponent(out ICollidableComponent body) && body.PhysicsShapes.Count >= 1) { body.PhysicsShapes[0].CollisionMask &= (int) ~CollisionGroup.ThrownItem; - var physics = Owner.GetComponent(); + var physics = Owner.GetComponent(); physics.LinearVelocity = Vector2.Zero; physics.Status = BodyStatus.OnGround; body.Status = BodyStatus.OnGround; @@ -76,7 +76,7 @@ namespace Content.Server.GameObjects.Components public void StartThrow(Vector2 initialImpulse) { - var comp = Owner.GetComponent(); + var comp = Owner.GetComponent(); comp.Status = BodyStatus.InAir; comp.Momentum = initialImpulse; StartStopTimer(); diff --git a/Content.Server/GameObjects/Components/RotatableComponent.cs b/Content.Server/GameObjects/Components/RotatableComponent.cs index a8f83cfdeb..dc575eb1b7 100644 --- a/Content.Server/GameObjects/Components/RotatableComponent.cs +++ b/Content.Server/GameObjects/Components/RotatableComponent.cs @@ -21,7 +21,7 @@ namespace Content.Server.GameObjects.Components private void TryRotate(IEntity user, Angle angle) { - if (Owner.TryGetComponent(out PhysicsComponent physics)) + if (Owner.TryGetComponent(out IPhysicsComponent physics)) { if (physics.Anchored) { diff --git a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs index 0adc736da0..0098b043c9 100644 --- a/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs +++ b/Content.Server/GameObjects/Components/Weapon/Ranged/Barrels/ServerRangedBarrelComponent.cs @@ -347,13 +347,13 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels projectileAngle = angle; } - var physicsComponent = projectile.GetComponent(); + var physicsComponent = projectile.GetComponent(); physicsComponent.Status = BodyStatus.InAir; projectile.Transform.GridPosition = Owner.Transform.GridPosition; var projectileComponent = projectile.GetComponent(); projectileComponent.IgnoreEntity(shooter); - projectile.GetComponent().LinearVelocity = projectileAngle.ToVec() * velocity; + projectile.GetComponent().LinearVelocity = projectileAngle.ToVec() * velocity; projectile.Transform.LocalRotation = projectileAngle.Theta; } } diff --git a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs index 8100bfba49..9905bc9c3b 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/AiReachableSystem.cs @@ -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; } diff --git a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/ReachableArgs.cs b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/ReachableArgs.cs index 54af0a73bd..2f2ab5c3e6 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/ReachableArgs.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/Accessible/ReachableArgs.cs @@ -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); } } -} \ No newline at end of file +} diff --git a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/PathfindingNode.cs b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/PathfindingNode.cs index 2d062bce59..6f9d665fac 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/PathfindingNode.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/PathfindingNode.cs @@ -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); } diff --git a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/PathfindingSystem.cs b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/PathfindingSystem.cs index bc39d819b9..6443a5e0b2 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/PathfindingSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Pathfinding/PathfindingSystem.cs @@ -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; diff --git a/Content.Server/GameObjects/EntitySystems/AI/Steering/AiSteeringSystem.cs b/Content.Server/GameObjects/EntitySystems/AI/Steering/AiSteeringSystem.cs index 08f50fcc8a..ff51d9af76 100644 --- a/Content.Server/GameObjects/EntitySystems/AI/Steering/AiSteeringSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/AI/Steering/AiSteeringSystem.cs @@ -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 /// private Vector2 CollisionAvoidance(IEntity entity, Vector2 direction, ICollection 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; diff --git a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs index 51b6fa4e32..69bebc4e66 100644 --- a/Content.Server/GameObjects/EntitySystems/MoverSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/MoverSystem.cs @@ -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(); - var physics = entity.GetComponent(); - if (entity.TryGetComponent(out var collider)) + var physics = entity.GetComponent(); + if (entity.TryGetComponent(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(); } @@ -98,7 +98,7 @@ namespace Content.Server.GameObjects.EntitySystems ev.Entity.RemoveComponent(); } - if (ev.Entity.TryGetComponent(out PhysicsComponent physics)) + if (ev.Entity.TryGetComponent(out IPhysicsComponent physics)) { (physics.Controller as MoverController)?.StopMoving(); } diff --git a/Content.Server/Throw/ThrowHelper.cs b/Content.Server/Throw/ThrowHelper.cs index 6866108b06..4609f69ee3 100644 --- a/Content.Server/Throw/ThrowHelper.cs +++ b/Content.Server/Throw/ThrowHelper.cs @@ -41,7 +41,7 @@ namespace Content.Server.Throw /// public static void Throw(IEntity thrownEnt, float throwForce, GridCoordinates targetLoc, GridCoordinates sourceLoc, bool spread = false, IEntity throwSourceEnt = null) { - if (!thrownEnt.TryGetComponent(out CollidableComponent colComp)) + if (!thrownEnt.TryGetComponent(out ICollidableComponent colComp)) return; var mapManager = IoCManager.Resolve(); @@ -75,7 +75,7 @@ namespace Content.Server.Throw throwSourceEnt.Transform.LocalRotation = angle.GetCardinalDir().ToAngle(); } - if (!thrownEnt.TryGetComponent(out PhysicsComponent physComp)) + if (!thrownEnt.TryGetComponent(out IPhysicsComponent physComp)) physComp = thrownEnt.AddComponent(); var timing = IoCManager.Resolve(); @@ -85,7 +85,7 @@ namespace Content.Server.Throw projComp.StartThrow(angle.ToVec() * spd); - if (throwSourceEnt != null && throwSourceEnt.TryGetComponent(out var physics) + if (throwSourceEnt != null && throwSourceEnt.TryGetComponent(out var physics) && physics.Controller is MoverController mover) { var physicsMgr = IoCManager.Resolve(); @@ -136,7 +136,7 @@ namespace Content.Server.Throw var distance = (targetLoc.ToMapPos(mapManager) - sourceLoc.ToMapPos(mapManager)).Length; var throwDuration = ThrownItemComponent.DefaultThrowTime; var mass = 1f; - if (thrownEnt.TryGetComponent(out PhysicsComponent physicsComponent)) + if (thrownEnt.TryGetComponent(out IPhysicsComponent physicsComponent)) { mass = physicsComponent.Mass; } diff --git a/Content.Shared/GameObjects/Components/Movement/SharedPlayerInputMoverComponent.cs b/Content.Shared/GameObjects/Components/Movement/SharedPlayerInputMoverComponent.cs index e12c56a42e..0244864fcb 100644 --- a/Content.Shared/GameObjects/Components/Movement/SharedPlayerInputMoverComponent.cs +++ b/Content.Shared/GameObjects/Components/Movement/SharedPlayerInputMoverComponent.cs @@ -143,10 +143,10 @@ namespace Content.Shared.GameObjects.Components.Movement public override void OnAdd() { // This component requires that the entity has a PhysicsComponent. - if (!Owner.HasComponent()) + if (!Owner.HasComponent()) Logger.Error( $"[ECS] {Owner.Prototype?.Name} - {nameof(SharedPlayerInputMoverComponent)} requires" + - $" {nameof(PhysicsComponent)}. "); + $" {nameof(IPhysicsComponent)}. "); base.OnAdd(); } diff --git a/Content.Shared/GameObjects/EntitySystems/SharedMoverSystem.cs b/Content.Shared/GameObjects/EntitySystems/SharedMoverSystem.cs index a9c6dfaa5c..3ced9a135e 100644 --- a/Content.Shared/GameObjects/EntitySystems/SharedMoverSystem.cs +++ b/Content.Shared/GameObjects/EntitySystems/SharedMoverSystem.cs @@ -54,8 +54,8 @@ namespace Content.Shared.GameObjects.EntitySystems base.Shutdown(); } - protected void UpdateKinematics(ITransformComponent transform, IMoverComponent mover, PhysicsComponent physics, - CollidableComponent? collider = null) + protected void UpdateKinematics(ITransformComponent transform, IMoverComponent mover, IPhysicsComponent physics, + ICollidableComponent? collider = null) { if (physics.Controller == null) { @@ -110,10 +110,10 @@ namespace Content.Shared.GameObjects.EntitySystems } - protected abstract void SetController(PhysicsComponent physics); + protected abstract void SetController(IPhysicsComponent physics); private bool IsAroundCollider(ITransformComponent transform, IMoverComponent mover, - CollidableComponent collider) + ICollidableComponent collider) { foreach (var entity in _entityManager.GetEntitiesInRange(transform.Owner, mover.GrabRange, true)) { @@ -122,7 +122,7 @@ namespace Content.Shared.GameObjects.EntitySystems continue; // Don't try to push off of yourself! } - if (!entity.TryGetComponent(out var otherCollider)) + if (!entity.TryGetComponent(out var otherCollider)) { continue; } diff --git a/Content.Shared/Physics/MoverController.cs b/Content.Shared/Physics/MoverController.cs index 2c09154cac..7a08beee11 100644 --- a/Content.Shared/Physics/MoverController.cs +++ b/Content.Shared/Physics/MoverController.cs @@ -10,7 +10,7 @@ namespace Content.Shared.Physics public class MoverController : VirtualController { private Vector2 _velocity; - private PhysicsComponent _component = null; + private IPhysicsComponent _component = null; public Vector2 Velocity { @@ -18,7 +18,7 @@ namespace Content.Shared.Physics set => _velocity = value; } - public override PhysicsComponent ControlledComponent + public override IPhysicsComponent ControlledComponent { set => _component = value; } diff --git a/RobustToolbox b/RobustToolbox index eeabe9af02..4ed044ddb4 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit eeabe9af0271ea863aa9e467edc576b0b9ed18b9 +Subproject commit 4ed044ddb4c85ff0cab8a119740b21b412d2e4b1