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

Method doSetAnchorState

source/game/StarActorMovementController.cpp:1089–1111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1087}
1088
1089void ActorMovementController::doSetAnchorState(Maybe<EntityAnchorState> anchorState) {
1090 EntityAnchorConstPtr entityAnchor;
1091 if (anchorState) {
1092 auto anchorableEntity = as<AnchorableEntity>(world()->entity(anchorState->entityId));
1093 if (!anchorableEntity)
1094 throw ActorMovementControllerException::format("No such anchorable entity id {} in ActorMovementController::setAnchorState", anchorState->entityId);
1095 entityAnchor = anchorableEntity->anchor(anchorState->positionIndex);
1096 if (!entityAnchor)
1097 throw ActorMovementControllerException::format("Anchor position {} is disabled ActorMovementController::setAnchorState", anchorState->positionIndex);
1098 }
1099
1100 if (!entityAnchor && m_entityAnchor && m_entityAnchor->exitBottomPosition) {
1101 auto boundBox = MovementController::localBoundBox();
1102 Vec2F bottomMid = {boundBox.center()[0], boundBox.yMin()};
1103 setPosition(*m_entityAnchor->exitBottomPosition - bottomMid);
1104 }
1105
1106 m_anchorState.set(anchorState);
1107 m_entityAnchor = std::move(entityAnchor);
1108
1109 if (m_entityAnchor)
1110 setPosition(m_entityAnchor->position);
1111}
1112
1113
1114PathController::PathController(World* world)

Callers

nothing calls this directly

Calls 6

yMinMethod · 0.80
formatFunction · 0.50
entityMethod · 0.45
anchorMethod · 0.45
centerMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected