Converted everything to use collision and physics component interfaces.
This commit is contained in:
@@ -31,8 +31,8 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var physics = playerEnt.GetComponent<PhysicsComponent>();
|
var physics = playerEnt.GetComponent<IPhysicsComponent>();
|
||||||
playerEnt.TryGetComponent(out CollidableComponent? collidable);
|
playerEnt.TryGetComponent(out ICollidableComponent? collidable);
|
||||||
physics.Predict = true;
|
physics.Predict = true;
|
||||||
|
|
||||||
UpdateKinematics(playerEnt.Transform, mover, physics, collidable);
|
UpdateKinematics(playerEnt.Transform, mover, physics, collidable);
|
||||||
@@ -43,7 +43,7 @@ namespace Content.Client.GameObjects.EntitySystems
|
|||||||
FrameUpdate(frameTime);
|
FrameUpdate(frameTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void SetController(PhysicsComponent physics)
|
protected override void SetController(IPhysicsComponent physics)
|
||||||
{
|
{
|
||||||
physics.SetController<MoverController>();
|
physics.SetController<MoverController>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Content.Server.GameObjects.Components
|
|||||||
|
|
||||||
public bool InteractUsing(InteractUsingEventArgs eventArgs)
|
public bool InteractUsing(InteractUsingEventArgs eventArgs)
|
||||||
{
|
{
|
||||||
if (!Owner.TryGetComponent(out PhysicsComponent physics)
|
if (!Owner.TryGetComponent(out IPhysicsComponent physics)
|
||||||
|| !eventArgs.Using.TryGetComponent(out ToolComponent tool))
|
|| !eventArgs.Using.TryGetComponent(out ToolComponent tool))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace Content.Server.GameObjects
|
|||||||
protected const float AutoCloseDelay = 5;
|
protected const float AutoCloseDelay = 5;
|
||||||
protected float CloseSpeed = AutoCloseDelay;
|
protected float CloseSpeed = AutoCloseDelay;
|
||||||
|
|
||||||
private CollidableComponent collidableComponent;
|
private ICollidableComponent _collidableComponent;
|
||||||
private AppearanceComponent _appearance;
|
private AppearanceComponent _appearance;
|
||||||
private CancellationTokenSource _cancellationTokenSource;
|
private CancellationTokenSource _cancellationTokenSource;
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ namespace Content.Server.GameObjects
|
|||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
collidableComponent = Owner.GetComponent<CollidableComponent>();
|
_collidableComponent = Owner.GetComponent<ICollidableComponent>();
|
||||||
_appearance = Owner.GetComponent<AppearanceComponent>();
|
_appearance = Owner.GetComponent<AppearanceComponent>();
|
||||||
_cancellationTokenSource = new CancellationTokenSource();
|
_cancellationTokenSource = new CancellationTokenSource();
|
||||||
}
|
}
|
||||||
@@ -72,7 +72,7 @@ namespace Content.Server.GameObjects
|
|||||||
public override void OnRemove()
|
public override void OnRemove()
|
||||||
{
|
{
|
||||||
_cancellationTokenSource.Cancel();
|
_cancellationTokenSource.Cancel();
|
||||||
collidableComponent = null;
|
_collidableComponent = null;
|
||||||
_appearance = null;
|
_appearance = null;
|
||||||
|
|
||||||
base.OnRemove();
|
base.OnRemove();
|
||||||
@@ -164,7 +164,7 @@ namespace Content.Server.GameObjects
|
|||||||
|
|
||||||
Timer.Spawn(OpenTimeOne, async () =>
|
Timer.Spawn(OpenTimeOne, async () =>
|
||||||
{
|
{
|
||||||
collidableComponent.Hard = false;
|
_collidableComponent.Hard = false;
|
||||||
|
|
||||||
await Timer.Delay(OpenTimeTwo, _cancellationTokenSource.Token);
|
await Timer.Delay(OpenTimeTwo, _cancellationTokenSource.Token);
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ namespace Content.Server.GameObjects
|
|||||||
private void CheckCrush()
|
private void CheckCrush()
|
||||||
{
|
{
|
||||||
// Check if collides with something
|
// Check if collides with something
|
||||||
var collidesWith = collidableComponent.GetCollidingEntities(Vector2.Zero, false);
|
var collidesWith = _collidableComponent.GetCollidingEntities(Vector2.Zero, false);
|
||||||
if (collidesWith.Count() != 0)
|
if (collidesWith.Count() != 0)
|
||||||
{
|
{
|
||||||
// Crush
|
// Crush
|
||||||
@@ -236,7 +236,7 @@ namespace Content.Server.GameObjects
|
|||||||
public bool Close()
|
public bool Close()
|
||||||
{
|
{
|
||||||
bool shouldCheckCrush = false;
|
bool shouldCheckCrush = false;
|
||||||
if (collidableComponent.IsColliding(Vector2.Zero, false))
|
if (_collidableComponent.IsColliding(Vector2.Zero, false))
|
||||||
{
|
{
|
||||||
if (Safety)
|
if (Safety)
|
||||||
return false;
|
return false;
|
||||||
@@ -260,7 +260,7 @@ namespace Content.Server.GameObjects
|
|||||||
CheckCrush();
|
CheckCrush();
|
||||||
}
|
}
|
||||||
|
|
||||||
collidableComponent.Hard = true;
|
_collidableComponent.Hard = true;
|
||||||
|
|
||||||
await Timer.Delay(CloseTimeTwo, _cancellationTokenSource.Token);
|
await Timer.Delay(CloseTimeTwo, _cancellationTokenSource.Token);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -393,7 +393,7 @@ namespace Content.Server.GameObjects.Components.Fluids
|
|||||||
|
|
||||||
foreach (var entity in _snapGrid.GetInDir(direction))
|
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)
|
(collidable.CollisionLayer & (int) CollisionGroup.Impassable) != 0)
|
||||||
{
|
{
|
||||||
puddle = default;
|
puddle = default;
|
||||||
|
|||||||
@@ -568,7 +568,7 @@ namespace Content.Server.GameObjects
|
|||||||
|
|
||||||
Dirty();
|
Dirty();
|
||||||
|
|
||||||
if (!message.Entity.TryGetComponent(out PhysicsComponent physics))
|
if (!message.Entity.TryGetComponent(out IPhysicsComponent physics))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ namespace Content.Server.GameObjects.Components
|
|||||||
|
|
||||||
public void Fumble()
|
public void Fumble()
|
||||||
{
|
{
|
||||||
if (Owner.TryGetComponent<PhysicsComponent>(out var physicsComponent))
|
if (Owner.TryGetComponent<IPhysicsComponent>(out var physicsComponent))
|
||||||
{
|
{
|
||||||
physicsComponent.LinearVelocity += RandomOffset();
|
physicsComponent.LinearVelocity += RandomOffset();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ namespace Content.Server.GameObjects
|
|||||||
|
|
||||||
StandingStateHelper.Down(entity);
|
StandingStateHelper.Down(entity);
|
||||||
|
|
||||||
if (entity.TryGetComponent(out CollidableComponent collidable))
|
if (entity.TryGetComponent(out ICollidableComponent collidable))
|
||||||
{
|
{
|
||||||
collidable.CanCollide = false;
|
collidable.CanCollide = false;
|
||||||
}
|
}
|
||||||
@@ -197,7 +197,7 @@ namespace Content.Server.GameObjects
|
|||||||
{
|
{
|
||||||
StandingStateHelper.Standing(entity);
|
StandingStateHelper.Standing(entity);
|
||||||
|
|
||||||
if (entity.TryGetComponent(out CollidableComponent collidable))
|
if (entity.TryGetComponent(out ICollidableComponent collidable))
|
||||||
{
|
{
|
||||||
collidable.CanCollide = true;
|
collidable.CanCollide = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace Content.Server.GameObjects.Components.Movement
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
// This component requires a physics component.
|
// This component requires a physics component.
|
||||||
if (!Owner.HasComponent<PhysicsComponent>())
|
if (!Owner.HasComponent<IPhysicsComponent>())
|
||||||
Owner.AddComponent<PhysicsComponent>();
|
Owner.AddComponent<PhysicsComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace Content.Server.GameObjects.Components.Movement
|
|||||||
{
|
{
|
||||||
// This will blow up an entity it's attached to
|
// This will blow up an entity it's attached to
|
||||||
base.OnAdd();
|
base.OnAdd();
|
||||||
if (Owner.TryGetComponent<CollidableComponent>(out var collide))
|
if (Owner.TryGetComponent<ICollidableComponent>(out var collide))
|
||||||
{
|
{
|
||||||
//collide.IsHardCollidable = false;
|
//collide.IsHardCollidable = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ namespace Content.Server.GameObjects.Components.Movement
|
|||||||
{
|
{
|
||||||
// Added this component to avoid stacking portals and causing shenanigans
|
// Added this component to avoid stacking portals and causing shenanigans
|
||||||
// TODO: Doesn't do a great job of stopping stacking portals for directed
|
// TODO: Doesn't do a great job of stopping stacking portals for directed
|
||||||
if (entity.HasComponent<CollidableComponent>() || entity.HasComponent<ServerTeleporterComponent>())
|
if (entity.HasComponent<ICollidableComponent>() || entity.HasComponent<ServerTeleporterComponent>())
|
||||||
{
|
{
|
||||||
return;
|
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.
|
// 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))
|
foreach (var entity in _serverEntityManager.GetEntitiesIntersecting(user.Transform.MapID, target))
|
||||||
{
|
{
|
||||||
if (entity.HasComponent<CollidableComponent>() || entity.HasComponent<ServerPortalComponent>())
|
if (entity.HasComponent<ICollidableComponent>() || entity.HasComponent<ServerPortalComponent>())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace Content.Server.GameObjects.Components.Movement
|
|||||||
if (_mapManager.TryGetGrid(gridId, out var grid) && _entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity))
|
if (_mapManager.TryGetGrid(gridId, out var grid) && _entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity))
|
||||||
{
|
{
|
||||||
//TODO: Switch to shuttle component
|
//TODO: Switch to shuttle component
|
||||||
if (!gridEntity.TryGetComponent(out PhysicsComponent physComp))
|
if (!gridEntity.TryGetComponent(out IPhysicsComponent physComp))
|
||||||
{
|
{
|
||||||
physComp = gridEntity.AddComponent<PhysicsComponent>();
|
physComp = gridEntity.AddComponent<PhysicsComponent>();
|
||||||
physComp.Mass = 1;
|
physComp.Mass = 1;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
using Content.Server.GameObjects.Components.Mobs;
|
using Content.Server.GameObjects.Components.Mobs;
|
||||||
using Content.Server.Throw;
|
using Content.Server.Throw;
|
||||||
@@ -79,7 +79,7 @@ namespace Content.Server.GameObjects.Components.Movement
|
|||||||
|| _slipped.Contains(collidedWith.Uid)
|
|| _slipped.Contains(collidedWith.Uid)
|
||||||
|| !collidedWith.TryGetComponent(out StunnableComponent stun)
|
|| !collidedWith.TryGetComponent(out StunnableComponent stun)
|
||||||
|| !collidedWith.TryGetComponent(out ICollidableComponent otherBody)
|
|| !collidedWith.TryGetComponent(out ICollidableComponent otherBody)
|
||||||
|| !collidedWith.TryGetComponent(out PhysicsComponent otherPhysics)
|
|| !collidedWith.TryGetComponent(out IPhysicsComponent otherPhysics)
|
||||||
|| !Owner.TryGetComponent(out ICollidableComponent body))
|
|| !Owner.TryGetComponent(out ICollidableComponent body))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private bool Connectable => !_deleting && Anchored;
|
private bool Connectable => !_deleting && Anchored;
|
||||||
|
|
||||||
private bool Anchored => !Owner.TryGetComponent<PhysicsComponent>(out var physics) || physics.Anchored;
|
private bool Anchored => !Owner.TryGetComponent<IPhysicsComponent>(out var physics) || physics.Anchored;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Prevents a node from being used by other nodes while midway through removal.
|
/// 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();
|
TryAssignGroupIfNeeded();
|
||||||
CombineGroupWithReachable();
|
CombineGroupWithReachable();
|
||||||
if (Owner.TryGetComponent<PhysicsComponent>(out var physics))
|
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
|
||||||
{
|
{
|
||||||
AnchorUpdate();
|
AnchorUpdate();
|
||||||
physics.AnchoredChanged += AnchorUpdate;
|
physics.AnchoredChanged += AnchorUpdate;
|
||||||
@@ -70,9 +70,9 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
|
|||||||
public void OnContainerRemove()
|
public void OnContainerRemove()
|
||||||
{
|
{
|
||||||
_deleting = true;
|
_deleting = true;
|
||||||
if (Owner.TryGetComponent<PhysicsComponent>(out var physics))
|
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
|
||||||
{
|
{
|
||||||
physics.AnchoredChanged -= AnchorUpdate;
|
((IPhysicsComponent) physics).AnchoredChanged -= AnchorUpdate;
|
||||||
}
|
}
|
||||||
NodeGroup.RemoveNode(this);
|
NodeGroup.RemoveNode(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Connectable => Anchored;
|
public bool Connectable => Anchored;
|
||||||
|
|
||||||
private bool Anchored => !Owner.TryGetComponent<PhysicsComponent>(out var physics) || physics.Anchored;
|
private bool Anchored => !Owner.TryGetComponent<IPhysicsComponent>(out var physics) || physics.Anchored;
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public bool NeedsProvider { get; private set; } = true;
|
public bool NeedsProvider { get; private set; } = true;
|
||||||
@@ -86,18 +86,18 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
|
|||||||
{
|
{
|
||||||
TryFindAndSetProvider();
|
TryFindAndSetProvider();
|
||||||
}
|
}
|
||||||
if (Owner.TryGetComponent<PhysicsComponent>(out var physics))
|
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
|
||||||
{
|
{
|
||||||
AnchorUpdate();
|
AnchorUpdate();
|
||||||
physics.AnchoredChanged += AnchorUpdate;
|
((IPhysicsComponent) physics).AnchoredChanged += AnchorUpdate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnRemove()
|
public override void OnRemove()
|
||||||
{
|
{
|
||||||
if (Owner.TryGetComponent<PhysicsComponent>(out var physics))
|
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
|
||||||
{
|
{
|
||||||
physics.AnchoredChanged -= AnchorUpdate;
|
((IPhysicsComponent) physics).AnchoredChanged -= AnchorUpdate;
|
||||||
}
|
}
|
||||||
_provider.RemoveReceiver(this);
|
_provider.RemoveReceiver(this);
|
||||||
base.OnRemove();
|
base.OnRemove();
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ namespace Content.Server.GameObjects.Components.Projectiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!entity.Deleted && entity.TryGetComponent(out CameraRecoilComponent recoilComponent)
|
if (!entity.Deleted && entity.TryGetComponent(out CameraRecoilComponent recoilComponent)
|
||||||
&& Owner.TryGetComponent(out PhysicsComponent physicsComponent))
|
&& Owner.TryGetComponent(out IPhysicsComponent physicsComponent))
|
||||||
{
|
{
|
||||||
var direction = physicsComponent.LinearVelocity.Normalized;
|
var direction = physicsComponent.LinearVelocity.Normalized;
|
||||||
recoilComponent.Kick(direction);
|
recoilComponent.Kick(direction);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace Content.Server.GameObjects.Components
|
|||||||
// after impacting the first object.
|
// after impacting the first object.
|
||||||
// For realism this should actually be changed when the velocity of the object is less than a threshold.
|
// 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.
|
// 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;
|
_shouldCollide = false;
|
||||||
}
|
}
|
||||||
@@ -53,11 +53,11 @@ namespace Content.Server.GameObjects.Components
|
|||||||
return;
|
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;
|
body.PhysicsShapes[0].CollisionMask &= (int) ~CollisionGroup.ThrownItem;
|
||||||
|
|
||||||
var physics = Owner.GetComponent<PhysicsComponent>();
|
var physics = Owner.GetComponent<IPhysicsComponent>();
|
||||||
physics.LinearVelocity = Vector2.Zero;
|
physics.LinearVelocity = Vector2.Zero;
|
||||||
physics.Status = BodyStatus.OnGround;
|
physics.Status = BodyStatus.OnGround;
|
||||||
body.Status = BodyStatus.OnGround;
|
body.Status = BodyStatus.OnGround;
|
||||||
@@ -76,7 +76,7 @@ namespace Content.Server.GameObjects.Components
|
|||||||
|
|
||||||
public void StartThrow(Vector2 initialImpulse)
|
public void StartThrow(Vector2 initialImpulse)
|
||||||
{
|
{
|
||||||
var comp = Owner.GetComponent<PhysicsComponent>();
|
var comp = Owner.GetComponent<IPhysicsComponent>();
|
||||||
comp.Status = BodyStatus.InAir;
|
comp.Status = BodyStatus.InAir;
|
||||||
comp.Momentum = initialImpulse;
|
comp.Momentum = initialImpulse;
|
||||||
StartStopTimer();
|
StartStopTimer();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace Content.Server.GameObjects.Components
|
|||||||
|
|
||||||
private void TryRotate(IEntity user, Angle angle)
|
private void TryRotate(IEntity user, Angle angle)
|
||||||
{
|
{
|
||||||
if (Owner.TryGetComponent(out PhysicsComponent physics))
|
if (Owner.TryGetComponent(out IPhysicsComponent physics))
|
||||||
{
|
{
|
||||||
if (physics.Anchored)
|
if (physics.Anchored)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -347,13 +347,13 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
|
|||||||
projectileAngle = angle;
|
projectileAngle = angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
var physicsComponent = projectile.GetComponent<PhysicsComponent>();
|
var physicsComponent = projectile.GetComponent<IPhysicsComponent>();
|
||||||
physicsComponent.Status = BodyStatus.InAir;
|
physicsComponent.Status = BodyStatus.InAir;
|
||||||
projectile.Transform.GridPosition = Owner.Transform.GridPosition;
|
projectile.Transform.GridPosition = Owner.Transform.GridPosition;
|
||||||
|
|
||||||
var projectileComponent = projectile.GetComponent<ProjectileComponent>();
|
var projectileComponent = projectile.GetComponent<ProjectileComponent>();
|
||||||
projectileComponent.IgnoreEntity(shooter);
|
projectileComponent.IgnoreEntity(shooter);
|
||||||
projectile.GetComponent<PhysicsComponent>().LinearVelocity = projectileAngle.ToVec() * velocity;
|
projectile.GetComponent<IPhysicsComponent>().LinearVelocity = projectileAngle.ToVec() * velocity;
|
||||||
projectile.Transform.LocalRotation = projectileAngle.Theta;
|
projectile.Transform.LocalRotation = projectileAngle.Theta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Content.Server.GameObjects.Components.Access;
|
using Content.Server.GameObjects.Components.Access;
|
||||||
using Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Pathfinders;
|
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 targetNode = _pathfindingSystem.GetNode(targetTile);
|
||||||
|
|
||||||
var collisionMask = 0;
|
var collisionMask = 0;
|
||||||
if (entity.TryGetComponent(out CollidableComponent collidableComponent))
|
if (entity.TryGetComponent(out ICollidableComponent collidableComponent))
|
||||||
{
|
{
|
||||||
collisionMask = collidableComponent.CollisionMask;
|
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.Access;
|
||||||
using Content.Server.GameObjects.Components.Movement;
|
using Content.Server.GameObjects.Components.Movement;
|
||||||
using Robust.Shared.GameObjects.Components;
|
using Robust.Shared.GameObjects.Components;
|
||||||
@@ -27,7 +27,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
|||||||
public static ReachableArgs GetArgs(IEntity entity)
|
public static ReachableArgs GetArgs(IEntity entity)
|
||||||
{
|
{
|
||||||
var collisionMask = 0;
|
var collisionMask = 0;
|
||||||
if (entity.TryGetComponent(out CollidableComponent collidableComponent))
|
if (entity.TryGetComponent(out ICollidableComponent collidableComponent))
|
||||||
{
|
{
|
||||||
collisionMask = collidableComponent.CollisionMask;
|
collisionMask = collidableComponent.CollisionMask;
|
||||||
}
|
}
|
||||||
@@ -38,4 +38,4 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding.Accessible
|
|||||||
return new ReachableArgs(visionRadius, access, collisionMask);
|
return new ReachableArgs(visionRadius, access, collisionMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.GameObjects.Components.Access;
|
using Content.Server.GameObjects.Components.Access;
|
||||||
@@ -266,10 +266,10 @@ namespace Content.Server.GameObjects.EntitySystems.Pathfinding
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity.TryGetComponent(out CollidableComponent collidableComponent) &&
|
if (entity.TryGetComponent(out ICollidableComponent collidableComponent) &&
|
||||||
(PathfindingSystem.TrackedCollisionLayers & collidableComponent.CollisionLayer) != 0)
|
(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);
|
_physicsLayers.Add(entity.Uid, collidableComponent.CollisionLayer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Content.Server.GameObjects.Components.Access;
|
using Content.Server.GameObjects.Components.Access;
|
||||||
@@ -358,7 +358,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Pathfinding
|
|||||||
|
|
||||||
public bool CanTraverse(IEntity entity, PathfindingNode node)
|
public bool CanTraverse(IEntity entity, PathfindingNode node)
|
||||||
{
|
{
|
||||||
if (entity.TryGetComponent(out CollidableComponent collidableComponent) &&
|
if (entity.TryGetComponent(out ICollidableComponent collidableComponent) &&
|
||||||
(collidableComponent.CollisionMask & node.BlockedCollisionMask) != 0)
|
(collidableComponent.CollisionMask & node.BlockedCollisionMask) != 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -397,7 +397,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
|||||||
var startTile = gridManager.GetTileRef(entity.Transform.GridPosition);
|
var startTile = gridManager.GetTileRef(entity.Transform.GridPosition);
|
||||||
var endTile = gridManager.GetTileRef(steeringRequest.TargetGrid);
|
var endTile = gridManager.GetTileRef(steeringRequest.TargetGrid);
|
||||||
var collisionMask = 0;
|
var collisionMask = 0;
|
||||||
if (entity.TryGetComponent(out CollidableComponent collidableComponent))
|
if (entity.TryGetComponent(out ICollidableComponent collidableComponent))
|
||||||
{
|
{
|
||||||
collisionMask = collidableComponent.CollisionMask;
|
collisionMask = collidableComponent.CollisionMask;
|
||||||
}
|
}
|
||||||
@@ -581,7 +581,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
|||||||
return Vector2.Zero;
|
return Vector2.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target.TryGetComponent(out PhysicsComponent physicsComponent))
|
if (target.TryGetComponent(out IPhysicsComponent physicsComponent))
|
||||||
{
|
{
|
||||||
var targetDistance = (targetPos.Position - entityPos.Position);
|
var targetDistance = (targetPos.Position - entityPos.Position);
|
||||||
targetPos = targetPos.Offset(physicsComponent.LinearVelocity * targetDistance);
|
targetPos = targetPos.Offset(physicsComponent.LinearVelocity * targetDistance);
|
||||||
@@ -599,7 +599,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private Vector2 CollisionAvoidance(IEntity entity, Vector2 direction, ICollection<EntityUid> ignoredTargets)
|
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;
|
return Vector2.Zero;
|
||||||
}
|
}
|
||||||
@@ -637,7 +637,7 @@ namespace Content.Server.GameObjects.EntitySystems.AI.Steering
|
|||||||
// if we're moving in the same direction then ignore
|
// 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
|
// 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
|
// i.e. towards the right
|
||||||
if (collisionEntity.TryGetComponent(out PhysicsComponent physicsComponent) &&
|
if (collisionEntity.TryGetComponent(out IPhysicsComponent physicsComponent) &&
|
||||||
Vector2.Dot(physicsComponent.LinearVelocity, direction) > 0)
|
Vector2.Dot(physicsComponent.LinearVelocity, direction) > 0)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using Content.Server.GameObjects;
|
using Content.Server.GameObjects;
|
||||||
using Content.Server.GameObjects.Components;
|
using Content.Server.GameObjects.Components;
|
||||||
using Content.Server.GameObjects.Components.Items.Storage;
|
using Content.Server.GameObjects.Components.Items.Storage;
|
||||||
@@ -66,8 +66,8 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
}
|
}
|
||||||
|
|
||||||
var mover = entity.GetComponent<IMoverComponent>();
|
var mover = entity.GetComponent<IMoverComponent>();
|
||||||
var physics = entity.GetComponent<PhysicsComponent>();
|
var physics = entity.GetComponent<IPhysicsComponent>();
|
||||||
if (entity.TryGetComponent<CollidableComponent>(out var collider))
|
if (entity.TryGetComponent<ICollidableComponent>(out var collider))
|
||||||
{
|
{
|
||||||
UpdateKinematics(entity.Transform, mover, physics, 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>();
|
physics.SetController<MoverController>();
|
||||||
}
|
}
|
||||||
@@ -98,7 +98,7 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
ev.Entity.RemoveComponent<PlayerInputMoverComponent>();
|
ev.Entity.RemoveComponent<PlayerInputMoverComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ev.Entity.TryGetComponent(out PhysicsComponent physics))
|
if (ev.Entity.TryGetComponent(out IPhysicsComponent physics))
|
||||||
{
|
{
|
||||||
(physics.Controller as MoverController)?.StopMoving();
|
(physics.Controller as MoverController)?.StopMoving();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace Content.Server.Throw
|
|||||||
/// </param>
|
/// </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, GridCoordinates targetLoc, GridCoordinates sourceLoc, bool spread = false, IEntity throwSourceEnt = null)
|
||||||
{
|
{
|
||||||
if (!thrownEnt.TryGetComponent(out CollidableComponent colComp))
|
if (!thrownEnt.TryGetComponent(out ICollidableComponent colComp))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||||
@@ -75,7 +75,7 @@ namespace Content.Server.Throw
|
|||||||
throwSourceEnt.Transform.LocalRotation = angle.GetCardinalDir().ToAngle();
|
throwSourceEnt.Transform.LocalRotation = angle.GetCardinalDir().ToAngle();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!thrownEnt.TryGetComponent(out PhysicsComponent physComp))
|
if (!thrownEnt.TryGetComponent(out IPhysicsComponent physComp))
|
||||||
physComp = thrownEnt.AddComponent<PhysicsComponent>();
|
physComp = thrownEnt.AddComponent<PhysicsComponent>();
|
||||||
|
|
||||||
var timing = IoCManager.Resolve<IGameTiming>();
|
var timing = IoCManager.Resolve<IGameTiming>();
|
||||||
@@ -85,7 +85,7 @@ namespace Content.Server.Throw
|
|||||||
|
|
||||||
projComp.StartThrow(angle.ToVec() * spd);
|
projComp.StartThrow(angle.ToVec() * spd);
|
||||||
|
|
||||||
if (throwSourceEnt != null && throwSourceEnt.TryGetComponent<PhysicsComponent>(out var physics)
|
if (throwSourceEnt != null && throwSourceEnt.TryGetComponent<IPhysicsComponent>(out var physics)
|
||||||
&& physics.Controller is MoverController mover)
|
&& physics.Controller is MoverController mover)
|
||||||
{
|
{
|
||||||
var physicsMgr = IoCManager.Resolve<IPhysicsManager>();
|
var physicsMgr = IoCManager.Resolve<IPhysicsManager>();
|
||||||
@@ -136,7 +136,7 @@ namespace Content.Server.Throw
|
|||||||
var distance = (targetLoc.ToMapPos(mapManager) - sourceLoc.ToMapPos(mapManager)).Length;
|
var distance = (targetLoc.ToMapPos(mapManager) - sourceLoc.ToMapPos(mapManager)).Length;
|
||||||
var throwDuration = ThrownItemComponent.DefaultThrowTime;
|
var throwDuration = ThrownItemComponent.DefaultThrowTime;
|
||||||
var mass = 1f;
|
var mass = 1f;
|
||||||
if (thrownEnt.TryGetComponent(out PhysicsComponent physicsComponent))
|
if (thrownEnt.TryGetComponent(out IPhysicsComponent physicsComponent))
|
||||||
{
|
{
|
||||||
mass = physicsComponent.Mass;
|
mass = physicsComponent.Mass;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,10 +143,10 @@ namespace Content.Shared.GameObjects.Components.Movement
|
|||||||
public override void OnAdd()
|
public override void OnAdd()
|
||||||
{
|
{
|
||||||
// This component requires that the entity has a PhysicsComponent.
|
// This component requires that the entity has a PhysicsComponent.
|
||||||
if (!Owner.HasComponent<PhysicsComponent>())
|
if (!Owner.HasComponent<IPhysicsComponent>())
|
||||||
Logger.Error(
|
Logger.Error(
|
||||||
$"[ECS] {Owner.Prototype?.Name} - {nameof(SharedPlayerInputMoverComponent)} requires" +
|
$"[ECS] {Owner.Prototype?.Name} - {nameof(SharedPlayerInputMoverComponent)} requires" +
|
||||||
$" {nameof(PhysicsComponent)}. ");
|
$" {nameof(IPhysicsComponent)}. ");
|
||||||
|
|
||||||
base.OnAdd();
|
base.OnAdd();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ namespace Content.Shared.GameObjects.EntitySystems
|
|||||||
base.Shutdown();
|
base.Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void UpdateKinematics(ITransformComponent transform, IMoverComponent mover, PhysicsComponent physics,
|
protected void UpdateKinematics(ITransformComponent transform, IMoverComponent mover, IPhysicsComponent physics,
|
||||||
CollidableComponent? collider = null)
|
ICollidableComponent? collider = null)
|
||||||
{
|
{
|
||||||
if (physics.Controller == 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,
|
private bool IsAroundCollider(ITransformComponent transform, IMoverComponent mover,
|
||||||
CollidableComponent collider)
|
ICollidableComponent collider)
|
||||||
{
|
{
|
||||||
foreach (var entity in _entityManager.GetEntitiesInRange(transform.Owner, mover.GrabRange, true))
|
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!
|
continue; // Don't try to push off of yourself!
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entity.TryGetComponent<CollidableComponent>(out var otherCollider))
|
if (!entity.TryGetComponent<ICollidableComponent>(out var otherCollider))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace Content.Shared.Physics
|
|||||||
public class MoverController : VirtualController
|
public class MoverController : VirtualController
|
||||||
{
|
{
|
||||||
private Vector2 _velocity;
|
private Vector2 _velocity;
|
||||||
private PhysicsComponent _component = null;
|
private IPhysicsComponent _component = null;
|
||||||
|
|
||||||
public Vector2 Velocity
|
public Vector2 Velocity
|
||||||
{
|
{
|
||||||
@@ -18,7 +18,7 @@ namespace Content.Shared.Physics
|
|||||||
set => _velocity = value;
|
set => _velocity = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override PhysicsComponent ControlledComponent
|
public override IPhysicsComponent ControlledComponent
|
||||||
{
|
{
|
||||||
set => _component = value;
|
set => _component = value;
|
||||||
}
|
}
|
||||||
|
|||||||
Submodule RobustToolbox updated: eeabe9af02...4ed044ddb4
Reference in New Issue
Block a user