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

@@ -38,7 +38,7 @@ namespace Content.Server.GameObjects.Components
/// <returns>true if it is valid, false otherwise</returns>
private async Task<bool> Valid(IEntity user, IEntity? utilizing, [MaybeNullWhen(false)] bool force = false)
{
if (!Owner.HasComponent<ICollidableComponent>())
if (!Owner.HasComponent<IPhysicsComponent>())
{
return false;
}
@@ -70,7 +70,7 @@ namespace Content.Server.GameObjects.Components
return false;
}
var physics = Owner.GetComponent<ICollidableComponent>();
var physics = Owner.GetComponent<IPhysicsComponent>();
physics.Anchored = true;
return true;
@@ -90,7 +90,7 @@ namespace Content.Server.GameObjects.Components
return false;
}
var physics = Owner.GetComponent<ICollidableComponent>();
var physics = Owner.GetComponent<IPhysicsComponent>();
physics.Anchored = false;
return true;
@@ -105,12 +105,12 @@ namespace Content.Server.GameObjects.Components
/// <returns>true if toggled, false otherwise</returns>
private async Task<bool> TryToggleAnchor(IEntity user, IEntity? utilizing = null, bool force = false)
{
if (!Owner.TryGetComponent(out ICollidableComponent? collidable))
if (!Owner.TryGetComponent(out IPhysicsComponent? physics))
{
return false;
}
return collidable.Anchored ?
return physics.Anchored ?
await TryUnAnchor(user, utilizing, force) :
await TryAnchor(user, utilizing, force);
}
@@ -118,7 +118,7 @@ namespace Content.Server.GameObjects.Components
public override void Initialize()
{
base.Initialize();
Owner.EnsureComponent<CollidableComponent>();
Owner.EnsureComponent<PhysicsComponent>();
}
async Task<bool> IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)

View File

@@ -39,9 +39,9 @@ namespace Content.Server.GameObjects.Components.Atmos
airtightComponent.AirBlocked = false;
}
if (Owner.TryGetComponent(out ICollidableComponent collidableComponent))
if (Owner.TryGetComponent(out IPhysicsComponent physics))
{
collidableComponent.Hard = false;
physics.Hard = false;
}
AutoClose = false;

View File

@@ -142,10 +142,10 @@ namespace Content.Server.GameObjects.Components.Atmos
}
var entity = _entityManager.GetEntity(uid);
var collidable = Owner.GetComponent<ICollidableComponent>();
var otherCollidable = entity.GetComponent<ICollidableComponent>();
var physics = Owner.GetComponent<IPhysicsComponent>();
var otherPhysics = entity.GetComponent<IPhysicsComponent>();
if (!collidable.WorldAABB.Intersects(otherCollidable.WorldAABB))
if (!physics.WorldAABB.Intersects(otherPhysics.WorldAABB))
{
_collided.Remove(uid);
}

View File

@@ -20,7 +20,7 @@ namespace Content.Server.GameObjects.Components.Atmos
public GasMixture Air { get; set; }
[ViewVariables]
public bool Anchored => !Owner.TryGetComponent<ICollidableComponent>(out var collidable) || collidable.Anchored;
public bool Anchored => !Owner.TryGetComponent<IPhysicsComponent>(out var physics) || physics.Anchored;
[ViewVariables]
public GasCanisterPortComponent ConnectedPort { get; private set; }
@@ -39,19 +39,19 @@ namespace Content.Server.GameObjects.Components.Atmos
public override void Initialize()
{
base.Initialize();
if (Owner.TryGetComponent<ICollidableComponent>(out var collidable))
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
{
AnchorUpdate();
collidable.AnchoredChanged += AnchorUpdate;
physics.AnchoredChanged += AnchorUpdate;
}
}
public override void OnRemove()
{
base.OnRemove();
if (Owner.TryGetComponent<ICollidableComponent>(out var collidable))
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
{
collidable.AnchoredChanged -= AnchorUpdate;
physics.AnchoredChanged -= AnchorUpdate;
}
DisconnectFromPort();
}

View File

@@ -58,9 +58,9 @@ namespace Content.Server.GameObjects.Components.Chemistry
_velocity = velocity;
_aliveTime = aliveTime;
// Set Move
if (Owner.TryGetComponent(out ICollidableComponent collidable))
if (Owner.TryGetComponent(out IPhysicsComponent physics))
{
var controller = collidable.EnsureController<VaporController>();
var controller = physics.EnsureController<VaporController>();
controller.Move(_direction, _velocity);
}
}
@@ -82,7 +82,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
_timer += frameTime;
_reactTimer += frameTime;
if (_reactTimer >= ReactTime && Owner.TryGetComponent(out ICollidableComponent collidable))
if (_reactTimer >= ReactTime && Owner.TryGetComponent(out IPhysicsComponent physics))
{
_reactTimer = 0;
var mapGrid = _mapManager.GetGrid(Owner.Transform.GridID);
@@ -101,7 +101,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
{
_reached = true;
if (Owner.TryGetComponent(out ICollidableComponent coll))
if (Owner.TryGetComponent(out IPhysicsComponent coll))
{
var controller = coll.EnsureController<VaporController>();
controller.Stop();
@@ -150,11 +150,11 @@ namespace Content.Server.GameObjects.Components.Chemistry
}
// Check for collision with a impassable object (e.g. wall) and stop
if (collidedWith.TryGetComponent(out ICollidableComponent collidable))
if (collidedWith.TryGetComponent(out IPhysicsComponent physics))
{
if ((collidable.CollisionLayer & (int) CollisionGroup.Impassable) != 0 && collidable.Hard)
if ((physics.CollisionLayer & (int) CollisionGroup.Impassable) != 0 && physics.Hard)
{
if (Owner.TryGetComponent(out ICollidableComponent coll))
if (Owner.TryGetComponent(out IPhysicsComponent coll))
{
var controller = coll.EnsureController<VaporController>();
controller.Stop();

View File

@@ -422,10 +422,10 @@ namespace Content.Server.GameObjects.Components.Construction
}
}
if (Owner.TryGetComponent(out CollidableComponent? collidable) &&
entity.TryGetComponent(out CollidableComponent? otherCollidable))
if (Owner.TryGetComponent(out IPhysicsComponent? physics) &&
entity.TryGetComponent(out IPhysicsComponent? otherPhysics))
{
otherCollidable.Anchored = collidable.Anchored;
otherPhysics.Anchored = physics.Anchored;
}
Owner.Delete();

View File

@@ -111,8 +111,8 @@ namespace Content.Server.GameObjects.Components.Conveyor
return false;
}
if (!entity.TryGetComponent(out ICollidableComponent? collidable) ||
collidable.Anchored)
if (!entity.TryGetComponent(out IPhysicsComponent? physics) ||
physics.Anchored)
{
return false;
}
@@ -152,9 +152,9 @@ namespace Content.Server.GameObjects.Components.Conveyor
continue;
}
if (entity.TryGetComponent(out ICollidableComponent? collidable))
if (entity.TryGetComponent(out IPhysicsComponent? physics))
{
var controller = collidable.EnsureController<ConveyedController>();
var controller = physics.EnsureController<ConveyedController>();
controller.Move(direction, _speed * frameTime);
}
}

View File

@@ -52,9 +52,9 @@ namespace Content.Server.GameObjects.Components.Damage
public void CollideWith(IEntity collidedWith)
{
if (!Owner.TryGetComponent(out ICollidableComponent collidable) || !Owner.TryGetComponent(out IDamageableComponent damageable)) return;
if (!Owner.TryGetComponent(out IPhysicsComponent physics) || !Owner.TryGetComponent(out IDamageableComponent damageable)) return;
var speed = collidable.LinearVelocity.Length;
var speed = physics.LinearVelocity.Length;
if (speed < MinimumSpeed) return;

View File

@@ -56,8 +56,8 @@ namespace Content.Server.GameObjects.Components.Disposal
return false;
}
if (!entity.TryGetComponent(out ICollidableComponent? collidable) ||
!collidable.CanCollide)
if (!entity.TryGetComponent(out IPhysicsComponent? physics) ||
!physics.CanCollide)
{
return false;
}
@@ -73,9 +73,9 @@ namespace Content.Server.GameObjects.Components.Disposal
return false;
}
if (entity.TryGetComponent(out ICollidableComponent? collidable))
if (entity.TryGetComponent(out IPhysicsComponent? physics))
{
collidable.CanCollide = false;
physics.CanCollide = false;
}
return true;
@@ -105,9 +105,9 @@ namespace Content.Server.GameObjects.Components.Disposal
foreach (var entity in _contents.ContainedEntities.ToArray())
{
if (entity.TryGetComponent(out ICollidableComponent? collidable))
if (entity.TryGetComponent(out IPhysicsComponent? physics))
{
collidable.CanCollide = true;
physics.CanCollide = true;
}
_contents.ForceRemove(entity);

View File

@@ -34,8 +34,8 @@ namespace Content.Server.GameObjects.Components.Disposal
[ViewVariables]
public bool Anchored =>
!Owner.TryGetComponent(out ICollidableComponent? collidable) ||
collidable.Anchored;
!Owner.TryGetComponent(out IPhysicsComponent? physics) ||
physics.Anchored;
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(DisposalRouterUiKey.Key);

View File

@@ -31,8 +31,8 @@ namespace Content.Server.GameObjects.Components.Disposal
[ViewVariables]
public bool Anchored =>
!Owner.TryGetComponent(out CollidableComponent? collidable) ||
collidable.Anchored;
!Owner.TryGetComponent(out PhysicsComponent? physics) ||
physics.Anchored;
[ViewVariables] private BoundUserInterface? UserInterface => Owner.GetUIOrNull(DisposalTaggerUiKey.Key);

View File

@@ -43,8 +43,8 @@ namespace Content.Server.GameObjects.Components.Disposal
[ViewVariables]
private bool Anchored =>
!Owner.TryGetComponent(out CollidableComponent? collidable) ||
collidable.Anchored;
!Owner.TryGetComponent(out PhysicsComponent? physics) ||
physics.Anchored;
/// <summary>
/// The directions that this tube can connect to others from
@@ -192,12 +192,12 @@ namespace Content.Server.GameObjects.Components.Disposal
private void AnchoredChanged()
{
if (!Owner.TryGetComponent(out CollidableComponent? collidable))
if (!Owner.TryGetComponent(out PhysicsComponent? physics))
{
return;
}
if (collidable.Anchored)
if (physics.Anchored)
{
OnAnchor();
}
@@ -232,16 +232,16 @@ namespace Content.Server.GameObjects.Components.Disposal
Contents = ContainerManagerComponent.Ensure<Container>(Name, Owner);
Owner.EnsureComponent<AnchorableComponent>();
var collidable = Owner.EnsureComponent<CollidableComponent>();
var physics = Owner.EnsureComponent<PhysicsComponent>();
collidable.AnchoredChanged += AnchoredChanged;
physics.AnchoredChanged += AnchoredChanged;
}
protected override void Startup()
{
base.Startup();
if (!Owner.EnsureComponent<CollidableComponent>().Anchored)
if (!Owner.EnsureComponent<PhysicsComponent>().Anchored)
{
return;
}
@@ -254,8 +254,8 @@ namespace Content.Server.GameObjects.Components.Disposal
{
base.OnRemove();
var collidable = Owner.EnsureComponent<CollidableComponent>();
collidable.AnchoredChanged -= AnchoredChanged;
var physics = Owner.EnsureComponent<PhysicsComponent>();
physics.AnchoredChanged -= AnchoredChanged;
Disconnect();
}

View File

@@ -136,8 +136,8 @@ namespace Content.Server.GameObjects.Components.Disposal
return false;
}
if (!entity.TryGetComponent(out ICollidableComponent? collidable) ||
!collidable.CanCollide)
if (!entity.TryGetComponent(out IPhysicsComponent? physics) ||
!physics.CanCollide)
{
return false;
}
@@ -409,7 +409,7 @@ namespace Content.Server.GameObjects.Components.Disposal
{
return;
}
if (!Anchored)
{
appearance.SetData(Visuals.VisualState, VisualState.UnAnchored);
@@ -549,9 +549,9 @@ namespace Content.Server.GameObjects.Components.Disposal
Logger.WarningS("VitalComponentMissing", $"Disposal unit {Owner.Uid} is missing an anchorable component");
}
if (Owner.TryGetComponent(out CollidableComponent? collidable))
if (Owner.TryGetComponent(out IPhysicsComponent? physics))
{
collidable.AnchoredChanged += UpdateVisualState;
physics.AnchoredChanged += UpdateVisualState;
}
if (Owner.TryGetComponent(out PowerReceiverComponent? receiver))
@@ -564,9 +564,9 @@ namespace Content.Server.GameObjects.Components.Disposal
public override void OnRemove()
{
if (Owner.TryGetComponent(out ICollidableComponent? collidable))
if (Owner.TryGetComponent(out IPhysicsComponent? physics))
{
collidable.AnchoredChanged -= UpdateVisualState;
physics.AnchoredChanged -= UpdateVisualState;
}
if (Owner.TryGetComponent(out PowerReceiverComponent? receiver))
@@ -608,7 +608,7 @@ namespace Content.Server.GameObjects.Components.Disposal
break;
}
}
bool IsValidInteraction(ITargetedInteractEventArgs eventArgs)
{
if (!ActionBlockerSystem.CanInteract(eventArgs.User))
@@ -640,8 +640,8 @@ namespace Content.Server.GameObjects.Components.Disposal
{
return false;
}
// Duplicated code here, not sure how else to get actor inside to make UserInterface happy.
// Duplicated code here, not sure how else to get actor inside to make UserInterface happy.
if (IsValidInteraction(eventArgs))
{
UserInterface?.Open(actor.playerSession);
@@ -682,11 +682,11 @@ namespace Content.Server.GameObjects.Components.Disposal
_ = TryInsert(eventArgs.Dropped, eventArgs.User);
return true;
}
void IThrowCollide.HitBy(ThrowCollideEventArgs eventArgs)
{
if (!CanInsert(eventArgs.Thrown) ||
IoCManager.Resolve<IRobustRandom>().NextDouble() > 0.75 ||
if (!CanInsert(eventArgs.Thrown) ||
IoCManager.Resolve<IRobustRandom>().NextDouble() > 0.75 ||
!_container.Insert(eventArgs.Thrown))
{
return;

View File

@@ -254,9 +254,9 @@ namespace Content.Server.GameObjects.Components.Doors
airtight.AirBlocked = false;
}
if (Owner.TryGetComponent(out ICollidableComponent? collidable))
if (Owner.TryGetComponent(out IPhysicsComponent? physics))
{
collidable.Hard = false;
physics.Hard = false;
}
await Timer.Delay(OpenTimeTwo, _cancellationTokenSource.Token);
@@ -297,7 +297,7 @@ namespace Content.Server.GameObjects.Components.Doors
private void CheckCrush()
{
if (!Owner.TryGetComponent(out ICollidableComponent? body))
if (!Owner.TryGetComponent(out IPhysicsComponent? body))
return;
// Crush
@@ -305,7 +305,7 @@ namespace Content.Server.GameObjects.Components.Doors
{
if (!e.TryGetComponent(out StunnableComponent? stun)
|| !e.TryGetComponent(out IDamageableComponent? damage)
|| !e.TryGetComponent(out ICollidableComponent? otherBody))
|| !e.TryGetComponent(out IPhysicsComponent? otherBody))
continue;
var percentage = otherBody.WorldAABB.IntersectPercentage(body.WorldAABB);
@@ -377,7 +377,8 @@ namespace Content.Server.GameObjects.Components.Doors
{
bool shouldCheckCrush = false;
if (_canCrush && Owner.TryGetComponent(out ICollidableComponent? collidable) && collidable.IsColliding(Vector2.Zero, false))
if (_canCrush && Owner.TryGetComponent(out IPhysicsComponent? physics) &&
physics.IsColliding(Vector2.Zero, false))
{
if (Safety)
return false;
@@ -406,7 +407,7 @@ namespace Content.Server.GameObjects.Components.Doors
airtight.AirBlocked = true;
}
if (Owner.TryGetComponent(out ICollidableComponent? body))
if (Owner.TryGetComponent(out IPhysicsComponent? body))
{
body.Hard = true;
}

View File

@@ -377,8 +377,8 @@ namespace Content.Server.GameObjects.Components.Fluids
foreach (var entity in _snapGrid.GetInDir(direction))
{
if (entity.TryGetComponent(out ICollidableComponent collidable) &&
(collidable.CollisionLayer & (int) CollisionGroup.Impassable) != 0)
if (entity.TryGetComponent(out IPhysicsComponent physics) &&
(physics.CollisionLayer & (int) CollisionGroup.Impassable) != 0)
{
puddle = default;
return false;

View File

@@ -533,9 +533,9 @@ namespace Content.Server.GameObjects.Components.GUI
StopPull();
}
PulledObject = pullable.Owner.GetComponent<ICollidableComponent>();
PulledObject = pullable.Owner.GetComponent<IPhysicsComponent>();
var controller = PulledObject.EnsureController<PullController>();
controller.StartPull(Owner.GetComponent<ICollidableComponent>());
controller.StartPull(Owner.GetComponent<IPhysicsComponent>());
}
public void MovePulledObject(EntityCoordinates puller, EntityCoordinates to)
@@ -686,13 +686,13 @@ namespace Content.Server.GameObjects.Components.GUI
Dirty();
if (!message.Entity.TryGetComponent(out ICollidableComponent? collidable))
if (!message.Entity.TryGetComponent(out IPhysicsComponent? physics))
{
return;
}
// set velocity to zero
collidable.Stop();
physics.Stop();
return;
}
}

View File

@@ -201,15 +201,15 @@ namespace Content.Server.GameObjects.Components.Items.Storage
private void ModifyComponents()
{
if (!_isCollidableWhenOpen && Owner.TryGetComponent<ICollidableComponent>(out var collidableComponent))
if (!_isCollidableWhenOpen && Owner.TryGetComponent<IPhysicsComponent>(out var physics))
{
if (Open)
{
collidableComponent.Hard = false;
physics.Hard = false;
}
else
{
collidableComponent.Hard = true;
physics.Hard = true;
}
}
@@ -226,31 +226,30 @@ namespace Content.Server.GameObjects.Components.Items.Storage
private bool AddToContents(IEntity entity)
{
var collidableComponent = Owner.GetComponent<ICollidableComponent>();
ICollidableComponent entityCollidableComponent;
if (entity.TryGetComponent(out entityCollidableComponent))
var physics = Owner.GetComponent<IPhysicsComponent>();
if (entity.TryGetComponent(out IPhysicsComponent entityPhysicsComponent))
{
if(MaxSize < entityCollidableComponent.WorldAABB.Size.X
|| MaxSize < entityCollidableComponent.WorldAABB.Size.Y)
if(MaxSize < entityPhysicsComponent.WorldAABB.Size.X
|| MaxSize < entityPhysicsComponent.WorldAABB.Size.Y)
{
return false;
}
if (collidableComponent.WorldAABB.Left > entityCollidableComponent.WorldAABB.Left)
if (physics.WorldAABB.Left > entityPhysicsComponent.WorldAABB.Left)
{
entity.Transform.WorldPosition += new Vector2(collidableComponent.WorldAABB.Left - entityCollidableComponent.WorldAABB.Left, 0);
entity.Transform.WorldPosition += new Vector2(physics.WorldAABB.Left - entityPhysicsComponent.WorldAABB.Left, 0);
}
else if (collidableComponent.WorldAABB.Right < entityCollidableComponent.WorldAABB.Right)
else if (physics.WorldAABB.Right < entityPhysicsComponent.WorldAABB.Right)
{
entity.Transform.WorldPosition += new Vector2(collidableComponent.WorldAABB.Right - entityCollidableComponent.WorldAABB.Right, 0);
entity.Transform.WorldPosition += new Vector2(physics.WorldAABB.Right - entityPhysicsComponent.WorldAABB.Right, 0);
}
if (collidableComponent.WorldAABB.Bottom > entityCollidableComponent.WorldAABB.Bottom)
if (physics.WorldAABB.Bottom > entityPhysicsComponent.WorldAABB.Bottom)
{
entity.Transform.WorldPosition += new Vector2(0, collidableComponent.WorldAABB.Bottom - entityCollidableComponent.WorldAABB.Bottom);
entity.Transform.WorldPosition += new Vector2(0, physics.WorldAABB.Bottom - entityPhysicsComponent.WorldAABB.Bottom);
}
else if (collidableComponent.WorldAABB.Top < entityCollidableComponent.WorldAABB.Top)
else if (physics.WorldAABB.Top < entityPhysicsComponent.WorldAABB.Top)
{
entity.Transform.WorldPosition += new Vector2(0, collidableComponent.WorldAABB.Top - entityCollidableComponent.WorldAABB.Top);
entity.Transform.WorldPosition += new Vector2(0, physics.WorldAABB.Top - entityPhysicsComponent.WorldAABB.Top);
}
}
if (Contents.CanInsert(entity))
@@ -268,9 +267,9 @@ namespace Content.Server.GameObjects.Components.Items.Storage
}
Contents.Insert(entity);
entity.Transform.WorldPosition = worldPos;
if (entityCollidableComponent != null)
if (entityPhysicsComponent != null)
{
entityCollidableComponent.CanCollide = false;
entityPhysicsComponent.CanCollide = false;
}
return true;
}
@@ -283,9 +282,9 @@ namespace Content.Server.GameObjects.Components.Items.Storage
{
if(Contents.Remove(contained))
{
if (contained.TryGetComponent<ICollidableComponent>(out var entityCollidableComponent))
if (contained.TryGetComponent<IPhysicsComponent>(out var physics))
{
entityCollidableComponent.CanCollide = true;
physics.CanCollide = true;
}
}
}

View File

@@ -85,7 +85,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
return false;
}
if (Owner.TryGetComponent(out ICollidableComponent physics) &&
if (Owner.TryGetComponent(out IPhysicsComponent physics) &&
physics.Anchored)
{
return false;

View File

@@ -36,9 +36,9 @@ namespace Content.Server.GameObjects.Components.Mobs.State
EntitySystem.Get<StandingStateSystem>().Down(entity);
if (entity.TryGetComponent(out CollidableComponent collidable))
if (entity.TryGetComponent(out IPhysicsComponent physics))
{
collidable.CanCollide = false;
physics.CanCollide = false;
}
}
@@ -46,9 +46,9 @@ namespace Content.Server.GameObjects.Components.Mobs.State
{
EntitySystem.Get<StandingStateSystem>().Standing(entity);
if (entity.TryGetComponent(out CollidableComponent collidable))
if (entity.TryGetComponent(out IPhysicsComponent physics))
{
collidable.CanCollide = true;
physics.CanCollide = true;
}
if (entity.TryGetComponent(out ServerOverlayEffectsComponent overlay))

View File

@@ -55,8 +55,8 @@ namespace Content.Server.GameObjects.Components.Movement
{
base.Initialize();
// This component requires a collidable component.
Owner.EnsureComponent<CollidableComponent>();
// This component requires a physics component.
Owner.EnsureComponent<PhysicsComponent>();
EntitySystem.Get<AiSystem>().ProcessorInitialize(this);
}

View File

@@ -46,9 +46,9 @@ namespace Content.Server.GameObjects.Components.Movement
{
base.Initialize();
if (!Owner.EnsureComponent(out CollidableComponent _))
if (!Owner.EnsureComponent(out PhysicsComponent _))
{
Logger.Warning($"Entity {Owner.Name} at {Owner.Transform.MapPosition} didn't have a {nameof(CollidableComponent)}");
Logger.Warning($"Entity {Owner.Name} at {Owner.Transform.MapPosition} didn't have a {nameof(PhysicsComponent)}");
}
_doAfterSystem = EntitySystem.Get<DoAfterSystem>();
@@ -178,7 +178,7 @@ namespace Content.Server.GameObjects.Components.Movement
var result = await _doAfterSystem.DoAfter(doAfterEventArgs);
if (result != DoAfterStatus.Cancelled && entityToMove.TryGetComponent(out ICollidableComponent body) && body.PhysicsShapes.Count >= 1)
if (result != DoAfterStatus.Cancelled && entityToMove.TryGetComponent(out IPhysicsComponent body) && body.PhysicsShapes.Count >= 1)
{
var direction = (Owner.Transform.WorldPosition - entityToMove.Transform.WorldPosition).Normalized;
var endPoint = Owner.Transform.WorldPosition;
@@ -220,7 +220,7 @@ namespace Content.Server.GameObjects.Components.Movement
var result = await _doAfterSystem.DoAfter(doAfterEventArgs);
if (result != DoAfterStatus.Cancelled && user.TryGetComponent(out ICollidableComponent body) && body.PhysicsShapes.Count >= 1)
if (result != DoAfterStatus.Cancelled && user.TryGetComponent(out IPhysicsComponent body) && body.PhysicsShapes.Count >= 1)
{
var direction = (Owner.Transform.WorldPosition - user.Transform.WorldPosition).Normalized;
var endPoint = Owner.Transform.WorldPosition;

View File

@@ -69,15 +69,15 @@ namespace Content.Server.GameObjects.Components.Movement
_entityManager.TryGetEntity(grid.GridEntityId, out var gridEntity))
{
//TODO: Switch to shuttle component
if (!gridEntity.TryGetComponent(out ICollidableComponent? collidable))
if (!gridEntity.TryGetComponent(out IPhysicsComponent? physics))
{
collidable = gridEntity.AddComponent<CollidableComponent>();
collidable.Mass = 1;
collidable.CanCollide = true;
collidable.PhysicsShapes.Add(new PhysShapeGrid(grid));
physics = gridEntity.AddComponent<PhysicsComponent>();
physics.Mass = 1;
physics.CanCollide = true;
physics.PhysicsShapes.Add(new PhysShapeGrid(grid));
}
var controller = collidable.EnsureController<ShuttleController>();
var controller = physics.EnsureController<ShuttleController>();
controller.Push(CalcNewVelocity(direction, enabled), CurrentWalkSpeed);
}
}

View File

@@ -39,7 +39,7 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
/// </summary>
private bool Connectable => !_deleting && Anchored;
private bool Anchored => !Owner.TryGetComponent<ICollidableComponent>(out var collidable) || collidable.Anchored;
private bool Anchored => !Owner.TryGetComponent<IPhysicsComponent>(out var physics) || physics.Anchored;
/// <summary>
/// Prevents a node from being used by other nodes while midway through removal.
@@ -63,19 +63,19 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes
{
TryAssignGroupIfNeeded();
CombineGroupWithReachable();
if (Owner.TryGetComponent<ICollidableComponent>(out var collidable))
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
{
AnchorUpdate();
collidable.AnchoredChanged += AnchorUpdate;
physics.AnchoredChanged += AnchorUpdate;
}
}
public void OnContainerRemove()
{
_deleting = true;
if (Owner.TryGetComponent<ICollidableComponent>(out var collidable))
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
{
collidable.AnchoredChanged -= AnchorUpdate;
physics.AnchoredChanged -= AnchorUpdate;
}
NodeGroup.RemoveNode(this);
}

View File

@@ -107,7 +107,7 @@ namespace Content.Server.GameObjects.Components.Portal
{
// 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<ICollidableComponent>() || entity.HasComponent<TeleporterComponent>())
if (entity.HasComponent<IPhysicsComponent>() || entity.HasComponent<TeleporterComponent>())
{
return;
}
@@ -151,7 +151,7 @@ namespace Content.Server.GameObjects.Components.Portal
// 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<ICollidableComponent>() || entity.HasComponent<PortalComponent>())
if (entity.HasComponent<IPhysicsComponent>() || entity.HasComponent<PortalComponent>())
{
return false;
}

View File

@@ -50,7 +50,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
/// </summary>
public bool Connectable => Anchored;
private bool Anchored => !Owner.TryGetComponent<ICollidableComponent>(out var collidable) || collidable.Anchored;
private bool Anchored => !Owner.TryGetComponent<IPhysicsComponent>(out var physics) || physics.Anchored;
[ViewVariables]
public bool NeedsProvider { get; private set; } = true;
@@ -92,18 +92,18 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents
{
TryFindAndSetProvider();
}
if (Owner.TryGetComponent<ICollidableComponent>(out var collidable))
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
{
AnchorUpdate();
collidable.AnchoredChanged += AnchorUpdate;
physics.AnchoredChanged += AnchorUpdate;
}
}
public override void OnRemove()
{
if (Owner.TryGetComponent<ICollidableComponent>(out var collidable))
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
{
collidable.AnchoredChanged -= AnchorUpdate;
physics.AnchoredChanged -= AnchorUpdate;
}
_provider.RemoveReceiver(this);
base.OnRemove();

View File

@@ -72,7 +72,7 @@ namespace Content.Server.GameObjects.Components.Projectiles
}
// This is so entities that shouldn't get a collision are ignored.
if (entity.TryGetComponent(out ICollidableComponent collidable) && collidable.Hard == false)
if (entity.TryGetComponent(out IPhysicsComponent otherPhysics) && otherPhysics.Hard == false)
{
_deleteOnCollide = false;
return;
@@ -103,9 +103,9 @@ namespace Content.Server.GameObjects.Components.Projectiles
}
if (!entity.Deleted && entity.TryGetComponent(out CameraRecoilComponent recoilComponent)
&& Owner.TryGetComponent(out ICollidableComponent collidableComponent))
&& Owner.TryGetComponent(out IPhysicsComponent ownPhysics))
{
var direction = collidableComponent.LinearVelocity.Normalized;
var direction = ownPhysics.LinearVelocity.Normalized;
recoilComponent.Kick(direction);
}
}

View File

@@ -33,7 +33,7 @@ namespace Content.Server.GameObjects.Components.Projectiles
void ICollideBehavior.CollideWith(IEntity entity)
{
if (!_shouldCollide) return;
if (entity.TryGetComponent(out CollidableComponent collid))
if (entity.TryGetComponent(out PhysicsComponent collid))
{
if (!collid.Hard) // ignore non hard
return;
@@ -52,7 +52,7 @@ namespace Content.Server.GameObjects.Components.Projectiles
// 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 ICollidableComponent body) && body.PhysicsShapes.Count >= 1)
if (Owner.TryGetComponent(out IPhysicsComponent body) && body.PhysicsShapes.Count >= 1)
{
_shouldCollide = false;
}
@@ -65,7 +65,7 @@ namespace Content.Server.GameObjects.Components.Projectiles
return;
}
if (Owner.TryGetComponent(out ICollidableComponent body) && body.PhysicsShapes.Count >= 1)
if (Owner.TryGetComponent(out IPhysicsComponent body) && body.PhysicsShapes.Count >= 1)
{
body.PhysicsShapes[0].CollisionMask &= (int) ~CollisionGroup.ThrownItem;
@@ -91,7 +91,7 @@ namespace Content.Server.GameObjects.Components.Projectiles
public void StartThrow(Vector2 direction, float speed)
{
var comp = Owner.GetComponent<ICollidableComponent>();
var comp = Owner.GetComponent<IPhysicsComponent>();
comp.Status = BodyStatus.InAir;
var controller = comp.EnsureController<ThrownController>();
@@ -125,7 +125,7 @@ namespace Content.Server.GameObjects.Components.Projectiles
{
base.Initialize();
Owner.EnsureComponent<CollidableComponent>().EnsureController<ThrownController>();
Owner.EnsureComponent<PhysicsComponent>().EnsureController<ThrownController>();
}
}
}

View File

@@ -126,8 +126,8 @@ namespace Content.Server.GameObjects.Components.Recycling
return false;
}
if (!entity.TryGetComponent(out ICollidableComponent collidable) ||
collidable.Anchored)
if (!entity.TryGetComponent(out IPhysicsComponent physics) ||
physics.Anchored)
{
return false;
}
@@ -163,16 +163,16 @@ namespace Content.Server.GameObjects.Components.Recycling
for (var i = _intersecting.Count - 1; i >= 0; i--)
{
var entity = _intersecting[i];
if (entity.Deleted || !CanMove(entity) || !_entityManager.IsIntersecting(Owner, entity))
{
_intersecting.RemoveAt(i);
continue;
}
if (entity.TryGetComponent(out ICollidableComponent collidable))
if (entity.TryGetComponent(out IPhysicsComponent physics))
{
var controller = collidable.EnsureController<ConveyedController>();
var controller = physics.EnsureController<ConveyedController>();
controller.Move(direction, frameTime);
}
}

View File

@@ -19,8 +19,8 @@ namespace Content.Server.GameObjects.Components.Rotatable
private void TryFlip(IEntity user)
{
if (Owner.TryGetComponent(out ICollidableComponent? collidable) &&
collidable.Anchored)
if (Owner.TryGetComponent(out IPhysicsComponent? physics) &&
physics.Anchored)
{
Owner.PopupMessage(user, Loc.GetString("It's stuck."));
return;

View File

@@ -16,9 +16,9 @@ namespace Content.Server.GameObjects.Components.Rotatable
private void TryRotate(IEntity user, Angle angle)
{
if (Owner.TryGetComponent(out ICollidableComponent collidable))
if (Owner.TryGetComponent(out IPhysicsComponent physics))
{
if (collidable.Anchored)
if (physics.Anchored)
{
Owner.PopupMessage(user, Loc.GetString("It's stuck."));
return;

View File

@@ -31,7 +31,7 @@ namespace Content.Server.GameObjects.Components.Temperature
[ViewVariables] public float HeatCapacity {
get
{
if (Owner.TryGetComponent<ICollidableComponent>(out var physics))
if (Owner.TryGetComponent<IPhysicsComponent>(out var physics))
{
return SpecificHeat * physics.Mass;
}

View File

@@ -389,15 +389,15 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
projectileAngle = angle;
}
var collidableComponent = projectile.GetComponent<ICollidableComponent>();
collidableComponent.Status = BodyStatus.InAir;
var physics = projectile.GetComponent<IPhysicsComponent>();
physics.Status = BodyStatus.InAir;
projectile.Transform.WorldPosition = Owner.Transform.MapPosition.Position;
var projectileComponent = projectile.GetComponent<ProjectileComponent>();
projectileComponent.IgnoreEntity(shooter);
projectile
.GetComponent<ICollidableComponent>()
.GetComponent<IPhysicsComponent>()
.EnsureController<BulletController>()
.LinearVelocity = projectileAngle.ToVec() * velocity;