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

@@ -4,13 +4,11 @@ using Content.Server.GameObjects.Components.MachineLinking;
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
using Content.Shared.GameObjects.Components.Conveyor;
using Content.Shared.GameObjects.Components.MachineLinking;
using Content.Shared.GameObjects.Components.Movement;
using Content.Shared.Physics;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -29,8 +27,6 @@ namespace Content.Server.GameObjects.Components.Conveyor
[ViewVariables(VVAccess.ReadWrite)]
private Angle _angle;
public float Speed => _speed;
/// <summary>
/// The amount of units to move the entity by per second.
/// </summary>
@@ -90,7 +86,7 @@ namespace Content.Server.GameObjects.Components.Conveyor
/// <returns>
/// The angle when taking into account if the conveyor is reversed
/// </returns>
public Angle GetAngle()
private Angle GetAngle()
{
var adjustment = _state == ConveyorState.Reversed ? MathHelper.Pi : 0;
var radians = MathHelper.DegreesToRadians(_angle);
@@ -98,7 +94,7 @@ namespace Content.Server.GameObjects.Components.Conveyor
return new Angle(Owner.Transform.LocalRotation.Theta + radians + adjustment);
}
public bool CanRun()
private bool CanRun()
{
if (State == ConveyorState.Off)
{
@@ -119,16 +115,15 @@ namespace Content.Server.GameObjects.Components.Conveyor
return true;
}
public bool CanMove(IEntity entity)
private bool CanMove(IEntity entity)
{
// TODO We should only check status InAir or Static or MapGrid or /mayber/ container
if (entity == Owner)
{
return false;
}
if (!entity.TryGetComponent(out IPhysBody? physics) ||
physics.BodyType == BodyType.Static)
if (!entity.TryGetComponent(out IPhysicsComponent? physics) ||
physics.Anchored)
{
return false;
}
@@ -151,6 +146,31 @@ namespace Content.Server.GameObjects.Components.Conveyor
return true;
}
public void Update(float frameTime)
{
if (!CanRun())
{
return;
}
var intersecting = Owner.EntityManager.GetEntitiesIntersecting(Owner, true);
var direction = GetAngle().ToVec();
foreach (var entity in intersecting)
{
if (!CanMove(entity))
{
continue;
}
if (entity.TryGetComponent(out IPhysicsComponent? physics))
{
var controller = physics.EnsureController<ConveyedController>();
controller.Move(direction, _speed, entity.Transform.WorldPosition - Owner.Transform.WorldPosition);
}
}
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);