MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / pathMove

Method pathMove

source/game/StarActorMovementController.cpp:667–689  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

665}
666
667Maybe<pair<Vec2F, bool>> ActorMovementController::pathMove(Vec2F const& position, bool, Maybe<PlatformerAStar::Parameters> const& parameters) {
668 if (!m_pathController)
669 m_pathController = make_shared<PathController>(world());
670
671 // set new parameters if they have changed
672 if (m_pathController->targetPosition().isNothing() || (parameters && m_pathController->parameters() != *parameters)) {
673 if (parameters)
674 m_pathController->setParameters(*parameters);
675 m_pathMoveResult = m_pathController->findPath(*this, position).apply([position](bool result) { return pair<Vec2F, bool>(position, result); });
676 }
677
678 // update target position if it has changed
679 if (m_pathController) {
680 m_pathController->findPath(*this, position);
681 }
682
683 if (m_pathMoveResult.isValid()) {
684 // path controller failed or succeeded, return the result and reset the controller
685 m_pathController->reset();
686 }
687
688 return take(m_pathMoveResult);
689}
690
691Maybe<pair<Vec2F, bool>> ActorMovementController::controlPathMove(Vec2F const& position, bool run, Maybe<PlatformerAStar::Parameters> const& parameters) {
692 auto result = pathMove(position, run, parameters);

Callers 1

Calls 9

takeFunction · 0.85
isNothingMethod · 0.80
targetPositionMethod · 0.80
findPathMethod · 0.80
isValidMethod · 0.80
parametersMethod · 0.45
setParametersMethod · 0.45
applyMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected