Command *Command::opItemLookDirection(Script *script, const ResourceReference &itemRef, int32 direction, bool suspend) { FloorPositionedItem *item = itemRef.resolve<FloorPositionedItem>(); Current *current = StarkGlobal->getCurrent(); Camera *camera = current->getCamera(); Math::Angle cameraAngle = camera->getHorizontalAngle(); Math::Angle targetAngle = direction + cameraAngle; Math::Matrix3 rot; rot.buildAroundZ(-targetAngle); Math::Vector3d directionVector(1.0, 0.0, 0.0); rot.transformVector(&directionVector); Turn *movement = new Turn(item); movement->setTargetDirection(directionVector); movement->start(); item->setMovement(movement); if (suspend) { script->suspend(item); item->setMovementSuspendedScript(script); return this; // Stay on the same command while suspended } else { return nextCommand(); } }
Command *Command::opItemPlaceDirection(const ResourceReference &itemRef, int32 direction) { FloorPositionedItem *item = itemRef.resolve<FloorPositionedItem>(); Current *current = StarkGlobal->getCurrent(); Camera *camera = current->getCamera(); Math::Angle cameraAngle = camera->getHorizontalAngle(); item->setDirection(direction + cameraAngle); return nextCommand(); }
void ResourceProvider::setAprilInitialPosition() { Current *current = _global->getCurrent(); Resources::ModelItem *april = current->getInteractive(); if (!april) { return; // No character } // Set the initial position for April if (!_nextPositionBookmarkReference.empty()) { Resources::Bookmark *position = _nextPositionBookmarkReference.resolve<Resources::Bookmark>(); april->placeOnBookmark(position); Resources::Camera *camera = current->getCamera(); Math::Angle cameraAngle = camera->getHorizontalAngle(); april->setDirection(_nextDirection + cameraAngle); } else if (april->getFloorFaceIndex() <= 0) { // No target location provided, place April on the first floor face april->placeDefaultPosition(); } _nextPositionBookmarkReference = ResourceReference(); _nextDirection = 0; }