@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user