"Fix" conveyors (#6301)

This commit is contained in:
metalgearsloth
2022-01-31 01:30:15 +11:00
committed by GitHub
parent f392997597
commit 9a5a8a55e1
4 changed files with 93 additions and 80 deletions

View File

@@ -21,7 +21,6 @@ namespace Content.Server.Conveyor
public class ConveyorSystem : EntitySystem
{
[Dependency] private StunSystem _stunSystem = default!;
[Dependency] private IEntityLookup _entityLookup = default!;
public override void Initialize()
{
@@ -111,55 +110,5 @@ namespace Content.Server.Conveyor
return true;
}
/// <summary>
/// Calculates the angle in which entities on top of this conveyor
/// belt are pushed in
/// </summary>
/// <returns>
/// The angle when taking into account if the conveyor is reversed
/// </returns>
public Angle GetAngle(ConveyorComponent component)
{
var adjustment = component.State == ConveyorState.Reversed ? MathHelper.Pi/2 : -MathHelper.Pi/2;
var radians = MathHelper.DegreesToRadians(component.Angle);
return new Angle(EntityManager.GetComponent<TransformComponent>(component.Owner).LocalRotation.Theta + radians + adjustment);
}
public IEnumerable<(EntityUid, IPhysBody)> GetEntitiesToMove(ConveyorComponent comp)
{
//todo uuuhhh cache this
foreach (var entity in _entityLookup.GetEntitiesIntersecting(comp.Owner, flags: LookupFlags.Approximate))
{
if (Deleted(entity))
{
continue;
}
if (entity == comp.Owner)
{
continue;
}
if (!EntityManager.TryGetComponent(entity, out IPhysBody? physics) ||
physics.BodyType == BodyType.Static || physics.BodyStatus == BodyStatus.InAir || entity.IsWeightless())
{
continue;
}
if (EntityManager.HasComponent<IMapGridComponent>(entity))
{
continue;
}
if (entity.IsInContainer())
{
continue;
}
yield return (entity, physics);
}
}
}
}