private void Convey(ConveyorComponent comp, TransformComponent xform, HashSet <EntityUid> conveyed, float frameTime) { // Use an event for conveyors to know what needs to run if (!_conveyor.CanRun(comp)) { return; } var speed = comp.Speed; if (speed <= 0f) { return; } var(conveyorPos, conveyorRot) = xform.GetWorldPositionRotation(); conveyorRot += comp.Angle; if (comp.State == ConveyorState.Reversed) { conveyorRot += MathF.PI; } var direction = conveyorRot.ToWorldVec(); foreach (var(entity, transform) in GetEntitiesToMove(comp, xform)) { if (!conveyed.Add(entity)) { continue; } var worldPos = transform.WorldPosition; var itemRelative = conveyorPos - worldPos; worldPos += Convey(direction, speed, frameTime, itemRelative); transform.WorldPosition = worldPos; if (TryComp <PhysicsComponent>(entity, out var body)) { body.Awake = true; } } }
private void Convey(ConveyorSystem system, ConveyorComponent comp, float frameTime) { // Use an event for conveyors to know what needs to run if (!system.CanRun(comp)) { return; } var direction = system.GetAngle(comp).ToVec(); var entMan = IoCManager.Resolve <IEntityManager>(); var ownerPos = entMan.GetComponent <TransformComponent>(comp.Owner).WorldPosition; foreach (var(entity, physics) in EntitySystem.Get <ConveyorSystem>().GetEntitiesToMove(comp)) { var itemRelativeToConveyor = entMan.GetComponent <TransformComponent>(entity).WorldPosition - ownerPos; physics.LinearVelocity += Convey(direction, comp.Speed, frameTime, itemRelativeToConveyor); } }