Skip to content

Instantly share code, notes, and snippets.

Vector TransportBelt::calculateEntityMovement(MapPosition oldPosition) const
{
RotationDefinition rotationDefinition = this->rotationPoint;
if (rotationDefinition.empty())
return Vector(this->getPrototype()->speed, this->direction);
Vector originalVector(rotationDefinition.center, oldPosition);
double distance = originalVector.distance();
double orientation = originalVector.getOrientation().getFraction();
Direction PipeConnectionDefinition::calculateDirection(const Vector& offset, const BoundingBox& boundingBox)
{
// diagonal direction in order to fail when load is not successful
Direction direction(Direction::NorthEast);
MapPosition leftTop = boundingBox.getRotatedLeftTop();
MapPosition rightBottom = boundingBox.getRotatedRightBottom();
// calculate direction from the bounding box
if (leftTop.y < offset.dy && rightBottom.y > offset.dy)
{
@Rseding91
Rseding91 / TrainPathFinder.cpp
Last active April 18, 2025 15:52
Factorio TrainPathFinder
#include <Entity/Rail.hpp>
#include <Entity/RailSignalBase.hpp>
#include <Rail/RailBlock.hpp>
#include <Rail/RailPath.hpp>
#include <Rail/TrainPathFinder.hpp>
#include <Rail/RailSegment.hpp>
#include <Rail/RailUtil.hpp>
#include <Rail/Train.hpp>
#include <Util/Container/MinHeap.hpp>
#include <Log.hpp>