Revert "Physics (#3452)"

This reverts commit 3e64fd56a1.
This commit is contained in:
Pieter-Jan Briers
2021-02-28 18:49:48 +01:00
parent eddec5fcce
commit 1eb0fbd8d0
211 changed files with 2560 additions and 2600 deletions

View File

@@ -17,7 +17,6 @@ using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
using Robust.Shared.ViewVariables;
@@ -227,7 +226,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
private void ModifyComponents()
{
if (!_isCollidableWhenOpen && Owner.TryGetComponent<IPhysBody>(out var physics))
if (!_isCollidableWhenOpen && Owner.TryGetComponent<IPhysicsComponent>(out var physics))
{
if (Open)
{
@@ -253,10 +252,10 @@ namespace Content.Server.GameObjects.Components.Items.Storage
protected virtual bool AddToContents(IEntity entity)
{
if (entity == Owner) return false;
if (entity.TryGetComponent(out IPhysBody? entityPhysicsComponent))
if (entity.TryGetComponent(out IPhysicsComponent? entityPhysicsComponent))
{
if(MaxSize < entityPhysicsComponent.GetWorldAABB().Size.X
|| MaxSize < entityPhysicsComponent.GetWorldAABB().Size.Y)
if(MaxSize < entityPhysicsComponent.WorldAABB.Size.X
|| MaxSize < entityPhysicsComponent.WorldAABB.Size.Y)
{
return false;
}
@@ -286,7 +285,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
if(Contents.Remove(contained))
{
contained.Transform.WorldPosition = ContentsDumpPosition();
if (contained.TryGetComponent<IPhysBody>(out var physics))
if (contained.TryGetComponent<IPhysicsComponent>(out var physics))
{
physics.CanCollide = true;
}

View File

@@ -1,5 +1,6 @@
using Content.Server.GameObjects.Components.GUI;
using Content.Server.Interfaces.GameObjects.Components.Items;
using Content.Server.Throw;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Items;
using Content.Shared.GameObjects.Components.Storage;
@@ -13,7 +14,6 @@ using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Players;
using Robust.Shared.Physics;
using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Items.Storage
@@ -87,8 +87,8 @@ namespace Content.Server.GameObjects.Components.Items.Storage
return false;
}
if (Owner.TryGetComponent(out IPhysBody physics) &&
physics.BodyType == BodyType.Static)
if (Owner.TryGetComponent(out IPhysicsComponent physics) &&
physics.Anchored)
{
return false;
}
@@ -141,22 +141,22 @@ namespace Content.Server.GameObjects.Components.Items.Storage
var targetLocation = eventArgs.Target.Transform.Coordinates;
var dirVec = (targetLocation.ToMapPos(Owner.EntityManager) - sourceLocation.ToMapPos(Owner.EntityManager)).Normalized;
float throwForce;
var throwForce = 1.0f;
switch (eventArgs.Severity)
{
case ExplosionSeverity.Destruction:
throwForce = 30.0f;
throwForce = 3.0f;
break;
case ExplosionSeverity.Heavy:
throwForce = 20.0f;
throwForce = 2.0f;
break;
default:
throwForce = 10.0f;
case ExplosionSeverity.Light:
throwForce = 1.0f;
break;
}
Owner.TryThrow(dirVec * throwForce);
Owner.Throw(throwForce, targetLocation, sourceLocation, true);
}
}
}

View File

@@ -1,49 +0,0 @@
#nullable enable
using Content.Server.GameObjects.Components.Items.Storage;
using Content.Server.GameObjects.EntitySystems.Click;
using Content.Shared.GameObjects.Components.Mobs.State;
using Robust.Shared.GameObjects;
using Robust.Shared.Log;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
namespace Content.Server.GameObjects.Components.Items
{
internal static class ThrowHelper
{
/// <summary>
/// Tries to throw the entity if it has a physics component, otherwise does nothing.
/// </summary>
/// <param name="entity"></param>
/// <param name="direction">Will use the vector's magnitude as the strength of the impulse</param>
internal static void TryThrow(this IEntity entity, Vector2 direction, IEntity? user = null)
{
if (direction == Vector2.Zero || !entity.TryGetComponent(out PhysicsComponent? physicsComponent))
{
return;
}
if (physicsComponent.BodyType == BodyType.Static)
{
Logger.Warning("Tried to throw entity {entity} but can't throw static bodies!");
return;
}
if (entity.HasComponent<IMobStateComponent>())
{
Logger.Warning("Throwing not supported for mobs!");
return;
}
if (entity.HasComponent<ItemComponent>())
{
entity.EnsureComponent<ThrownItemComponent>().Thrower = user;
if (user != null)
EntitySystem.Get<InteractionSystem>().ThrownInteraction(user, entity);
}
physicsComponent.ApplyLinearImpulse(direction);
}
}
}

View File

@@ -1,33 +0,0 @@
#nullable enable
using Content.Server.GameObjects.EntitySystems.Click;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Physics;
namespace Content.Server.GameObjects.Components.Items
{
[RegisterComponent]
public class ThrownItemComponent : Component, ICollideBehavior
{
public override string Name => "ThrownItem";
public IEntity? Thrower { get; set; }
public override void HandleMessage(ComponentMessage message, IComponent? component)
{
base.HandleMessage(message, component);
switch (message)
{
case PhysicsSleepCompMessage:
EntitySystem.Get<InteractionSystem>().LandInteraction(Thrower, Owner, Owner.Transform.Coordinates);
IoCManager.Resolve<IComponentManager>().RemoveComponent(Owner.Uid, this);
break;
}
}
public void CollideWith(IPhysBody ourBody, IPhysBody otherBody)
{
EntitySystem.Get<InteractionSystem>().ThrowCollideInteraction(Thrower, ourBody, otherBody);
}
}
}