1 #ifndef GAME_MWWORLD_WORLDIMP_H 2 #define GAME_MWWORLD_WORLDIMP_H 3 4 #include <osg/ref_ptr> 5 6 #include <components/settings/settings.hpp> 7 8 #include "../mwbase/world.hpp" 9 10 #include "ptr.hpp" 11 #include "scene.hpp" 12 #include "esmstore.hpp" 13 #include "cells.hpp" 14 #include "localscripts.hpp" 15 #include "timestamp.hpp" 16 #include "globals.hpp" 17 #include "contentloader.hpp" 18 19 namespace osg 20 { 21 class Group; 22 class Stats; 23 } 24 25 namespace osgViewer 26 { 27 class Viewer; 28 } 29 30 namespace Resource 31 { 32 class ResourceSystem; 33 } 34 35 namespace SceneUtil 36 { 37 class WorkQueue; 38 } 39 40 namespace ESM 41 { 42 struct Position; 43 } 44 45 namespace Files 46 { 47 class Collections; 48 } 49 50 namespace MWRender 51 { 52 class SkyManager; 53 class Animation; 54 class Camera; 55 } 56 57 namespace ToUTF8 58 { 59 class Utf8Encoder; 60 } 61 62 namespace MWPhysics 63 { 64 class Object; 65 } 66 67 namespace MWWorld 68 { 69 class DateTimeManager; 70 class WeatherManager; 71 class Player; 72 class ProjectileManager; 73 74 /// \brief The game world and its visual representation 75 76 class World final: public MWBase::World 77 { 78 private: 79 Resource::ResourceSystem* mResourceSystem; 80 81 std::vector<ESM::ESMReader> mEsm; 82 MWWorld::ESMStore mStore; 83 LocalScripts mLocalScripts; 84 MWWorld::Globals mGlobalVariables; 85 86 Cells mCells; 87 88 std::string mCurrentWorldSpace; 89 90 std::unique_ptr<MWWorld::Player> mPlayer; 91 std::unique_ptr<MWPhysics::PhysicsSystem> mPhysics; 92 std::unique_ptr<DetourNavigator::Navigator> mNavigator; 93 std::unique_ptr<MWRender::RenderingManager> mRendering; 94 std::unique_ptr<MWWorld::Scene> mWorldScene; 95 std::unique_ptr<MWWorld::WeatherManager> mWeatherManager; 96 std::unique_ptr<MWWorld::DateTimeManager> mCurrentDate; 97 std::shared_ptr<ProjectileManager> mProjectileManager; 98 99 bool mSky; 100 bool mGodMode; 101 bool mScriptsEnabled; 102 bool mDiscardMovements; 103 std::vector<std::string> mContentFiles; 104 105 std::string mUserDataPath; 106 107 osg::Vec3f mDefaultHalfExtents; 108 bool mShouldUpdateNavigator; 109 110 int mActivationDistanceOverride; 111 112 std::string mStartCell; 113 114 float mSwimHeightScale; 115 116 float mDistanceToFacedObject; 117 118 bool mTeleportEnabled; 119 bool mLevitationEnabled; 120 bool mGoToJail; 121 int mDaysInPrison; 122 bool mPlayerTraveling; 123 bool mPlayerInJail; 124 125 float mSpellPreloadTimer; 126 127 std::map<MWWorld::Ptr, MWWorld::DoorState> mDoorStates; 128 ///< only holds doors that are currently moving. 1 = opening, 2 = closing 129 130 // not implemented 131 World (const World&); 132 World& operator= (const World&); 133 134 void updateWeather(float duration, bool paused = false); 135 136 void rotateObjectImp (const Ptr& ptr, const osg::Vec3f& rot, MWBase::RotationFlags flags); 137 138 Ptr copyObjectToCell(const ConstPtr &ptr, CellStore* cell, ESM::Position pos, int count, bool adjustPos); 139 140 void updateSoundListener(); 141 void updatePlayer(); 142 143 void preloadSpells(); 144 145 MWWorld::Ptr getFacedObject(float maxDistance, bool ignorePlayer=true); 146 147 void PCDropped (const Ptr& item); 148 149 bool rotateDoor(const Ptr door, DoorState state, float duration); 150 151 void processDoors(float duration); 152 ///< Run physics simulation and modify \a world accordingly. 153 154 void doPhysics(float duration, osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats); 155 ///< Run physics simulation and modify \a world accordingly. 156 157 void updateNavigator(); 158 159 void updateNavigatorObject(const MWPhysics::Object& object); 160 161 void ensureNeededRecords(); 162 163 void fillGlobalVariables(); 164 165 void updateSkyDate(); 166 167 /** 168 * @brief loadContentFiles - Loads content files (esm,esp,omwgame,omwaddon) 169 * @param fileCollections- Container which holds content file names and their paths 170 * @param content - Container which holds content file names 171 * @param contentLoader - 172 */ 173 void loadContentFiles(const Files::Collections& fileCollections, 174 const std::vector<std::string>& content, const std::vector<std::string>& groundcover, ContentLoader& contentLoader); 175 176 float feetToGameUnits(float feet); 177 float getActivationDistancePlusTelekinesis(); 178 179 MWWorld::ConstPtr getClosestMarker( const MWWorld::Ptr &ptr, const std::string &id ); 180 MWWorld::ConstPtr getClosestMarkerFromExteriorPosition( const osg::Vec3f& worldPos, const std::string &id ); 181 182 public: 183 // FIXME 184 void addContainerScripts(const Ptr& reference, CellStore* cell) override; 185 void removeContainerScripts(const Ptr& reference) override; 186 187 World ( 188 osgViewer::Viewer* viewer, 189 osg::ref_ptr<osg::Group> rootNode, 190 Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, 191 const Files::Collections& fileCollections, 192 const std::vector<std::string>& contentFiles, 193 const std::vector<std::string>& groundcoverFiles, 194 ToUTF8::Utf8Encoder* encoder, int activationDistanceOverride, 195 const std::string& startCell, const std::string& startupScript, 196 const std::string& resourcePath, const std::string& userDataPath); 197 198 virtual ~World(); 199 200 void startNewGame (bool bypass) override; 201 ///< \param bypass Bypass regular game start. 202 203 void clear() override; 204 205 int countSavedGameRecords() const override; 206 int countSavedGameCells() const override; 207 208 void write (ESM::ESMWriter& writer, Loading::Listener& progress) const override; 209 210 void readRecord (ESM::ESMReader& reader, uint32_t type, 211 const std::map<int, int>& contentFileMap) override; 212 213 CellStore *getExterior (int x, int y) override; 214 215 CellStore *getInterior (const std::string& name) override; 216 217 CellStore *getCell (const ESM::CellId& id) override; 218 219 void testExteriorCells() override; 220 void testInteriorCells() override; 221 222 //switch to POV before showing player's death animation 223 void useDeathCamera() override; 224 225 void setWaterHeight(const float height) override; 226 227 void rotateWorldObject (const MWWorld::Ptr& ptr, osg::Quat rotate) override; 228 229 bool toggleWater() override; 230 bool toggleWorld() override; 231 bool toggleBorders() override; 232 233 void adjustSky() override; 234 235 Player& getPlayer() override; 236 MWWorld::Ptr getPlayerPtr() override; 237 MWWorld::ConstPtr getPlayerConstPtr() const override; 238 239 const MWWorld::ESMStore& getStore() const override; 240 241 std::vector<ESM::ESMReader>& getEsmReader() override; 242 243 LocalScripts& getLocalScripts() override; 244 245 bool hasCellChanged() const override; 246 ///< Has the set of active cells changed, since the last frame? 247 248 bool isCellExterior() const override; 249 250 bool isCellQuasiExterior() const override; 251 252 osg::Vec2f getNorthVector (const CellStore* cell) override; 253 ///< get north vector for given interior cell 254 255 void getDoorMarkers (MWWorld::CellStore* cell, std::vector<DoorMarker>& out) override; 256 ///< get a list of teleport door markers for a given cell, to be displayed on the local map 257 258 void setGlobalInt (const std::string& name, int value) override; 259 ///< Set value independently from real type. 260 261 void setGlobalFloat (const std::string& name, float value) override; 262 ///< Set value independently from real type. 263 264 int getGlobalInt (const std::string& name) const override; 265 ///< Get value independently from real type. 266 267 float getGlobalFloat (const std::string& name) const override; 268 ///< Get value independently from real type. 269 270 char getGlobalVariableType (const std::string& name) const override; 271 ///< Return ' ', if there is no global variable with this name. 272 273 std::string getCellName (const MWWorld::CellStore *cell = nullptr) const override; 274 ///< Return name of the cell. 275 /// 276 /// \note If cell==0, the cell the player is currently in will be used instead to 277 /// generate a name. 278 std::string getCellName(const ESM::Cell* cell) const override; 279 280 void removeRefScript (MWWorld::RefData *ref) override; 281 //< Remove the script attached to ref from mLocalScripts 282 283 Ptr getPtr (const std::string& name, bool activeOnly) override; 284 ///< Return a pointer to a liveCellRef with the given name. 285 /// \param activeOnly do non search inactive cells. 286 287 Ptr searchPtr (const std::string& name, bool activeOnly, bool searchInContainers = false) override; 288 ///< Return a pointer to a liveCellRef with the given name. 289 /// \param activeOnly do not search inactive cells. 290 291 Ptr searchPtrViaActorId (int actorId) override; 292 ///< Search is limited to the active cells. 293 294 Ptr searchPtrViaRefNum (const std::string& id, const ESM::RefNum& refNum) override; 295 296 MWWorld::Ptr findContainer (const MWWorld::ConstPtr& ptr) override; 297 ///< Return a pointer to a liveCellRef which contains \a ptr. 298 /// \note Search is limited to the active cells. 299 300 void adjustPosition (const Ptr& ptr, bool force) override; 301 ///< Adjust position after load to be on ground. Must be called after model load. 302 /// @param force do this even if the ptr is flying 303 304 void fixPosition () override; 305 ///< Attempt to fix position so that the player is not stuck inside the geometry. 306 307 void enable (const Ptr& ptr) override; 308 309 void disable (const Ptr& ptr) override; 310 311 void advanceTime (double hours, bool incremental = false) override; 312 ///< Advance in-game time. 313 314 std::string getMonthName (int month = -1) const override; 315 ///< Return name of month (-1: current month) 316 317 TimeStamp getTimeStamp() const override; 318 ///< Return current in-game time and number of day since new game start. 319 320 ESM::EpochTimeStamp getEpochTimeStamp() const override; 321 ///< Return current in-game date and time. 322 323 bool toggleSky() override; 324 ///< \return Resulting mode 325 326 void changeWeather (const std::string& region, const unsigned int id) override; 327 328 int getCurrentWeather() const override; 329 330 unsigned int getNightDayMode() const override; 331 332 int getMasserPhase() const override; 333 334 int getSecundaPhase() const override; 335 336 void setMoonColour (bool red) override; 337 338 void modRegion(const std::string ®ionid, const std::vector<char> &chances) override; 339 340 float getTimeScaleFactor() const override; 341 342 void changeToInteriorCell (const std::string& cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent = true) override; 343 ///< Move to interior cell. 344 ///< @param changeEvent If false, do not trigger cell change flag or detect worldspace changes 345 346 void changeToExteriorCell (const ESM::Position& position, bool adjustPlayerPos, bool changeEvent = true) override; 347 ///< Move to exterior cell. 348 ///< @param changeEvent If false, do not trigger cell change flag or detect worldspace changes 349 350 void changeToCell (const ESM::CellId& cellId, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent=true) override; 351 ///< @param changeEvent If false, do not trigger cell change flag or detect worldspace changes 352 353 const ESM::Cell *getExterior (const std::string& cellName) const override; 354 ///< Return a cell matching the given name or a 0-pointer, if there is no such cell. 355 356 void markCellAsUnchanged() override; 357 358 MWWorld::Ptr getFacedObject() override; 359 ///< Return pointer to the object the player is looking at, if it is within activation range 360 361 float getDistanceToFacedObject() override; 362 363 /// Returns a pointer to the object the provided object would hit (if within the 364 /// specified distance), and the point where the hit occurs. This will attempt to 365 /// use the "Head" node as a basis. 366 std::pair<MWWorld::Ptr,osg::Vec3f> getHitContact(const MWWorld::ConstPtr &ptr, float distance, std::vector<MWWorld::Ptr> &targets) override; 367 368 /// @note No-op for items in containers. Use ContainerStore::removeItem instead. 369 void deleteObject (const Ptr& ptr) override; 370 371 void undeleteObject (const Ptr& ptr) override; 372 373 MWWorld::Ptr moveObject (const Ptr& ptr, float x, float y, float z, bool movePhysics=true, bool moveToActive=false) override; 374 ///< @return an updated Ptr in case the Ptr's cell changes 375 376 MWWorld::Ptr moveObject (const Ptr& ptr, CellStore* newCell, float x, float y, float z, bool movePhysics=true) override; 377 ///< @return an updated Ptr 378 379 MWWorld::Ptr moveObjectBy(const Ptr& ptr, osg::Vec3f vec, bool moveToActive, bool ignoreCollisions) override; 380 ///< @return an updated Ptr 381 382 void scaleObject (const Ptr& ptr, float scale) override; 383 384 /// World rotates object, uses radians 385 /// @note Rotations via this method use a different rotation order than the initial rotations in the CS. This 386 /// could be considered a bug, but is needed for MW compatibility. 387 /// \param adjust indicates rotation should be set or adjusted 388 void rotateObject (const Ptr& ptr, float x, float y, float z, 389 MWBase::RotationFlags flags = MWBase::RotationFlag_inverseOrder) override; 390 391 MWWorld::Ptr placeObject(const MWWorld::ConstPtr& ptr, MWWorld::CellStore* cell, ESM::Position pos) override; 392 ///< Place an object. Makes a copy of the Ptr. 393 394 MWWorld::Ptr safePlaceObject (const MWWorld::ConstPtr& ptr, const MWWorld::ConstPtr& referenceObject, MWWorld::CellStore* referenceCell, int direction, float distance) override; 395 ///< Place an object in a safe place next to \a referenceObject. \a direction and \a distance specify the wanted placement 396 /// relative to \a referenceObject (but the object may be placed somewhere else if the wanted location is obstructed). 397 398 float getMaxActivationDistance() override; 399 400 void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false) 401 const override; 402 ///< Convert cell numbers to position. 403 404 void positionToIndex (float x, float y, int &cellX, int &cellY) const override; 405 ///< Convert position to cell numbers 406 407 void queueMovement(const Ptr &ptr, const osg::Vec3f &velocity) override; 408 ///< Queues movement for \a ptr (in local space), to be applied in the next call to 409 /// doPhysics. 410 411 void updateAnimatedCollisionShape(const Ptr &ptr) override; 412 413 const MWPhysics::RayCastingInterface* getRayCasting() const override; 414 415 bool castRay (float x1, float y1, float z1, float x2, float y2, float z2, int mask) override; 416 ///< cast a Ray and return true if there is an object in the ray path. 417 418 bool castRay (float x1, float y1, float z1, float x2, float y2, float z2) override; 419 420 bool castRay(const osg::Vec3f& from, const osg::Vec3f& to, int mask, const MWWorld::ConstPtr& ignore) override; 421 422 void setActorCollisionMode(const Ptr& ptr, bool internal, bool external) override; 423 bool isActorCollisionEnabled(const Ptr& ptr) override; 424 425 bool toggleCollisionMode() override; 426 ///< Toggle collision mode for player. If disabled player object should ignore 427 /// collisions and gravity. 428 ///< \return Resulting mode 429 430 bool toggleRenderMode (MWRender::RenderMode mode) override; 431 ///< Toggle a render mode. 432 ///< \return Resulting mode 433 434 const ESM::Potion *createRecord (const ESM::Potion& record) override; 435 ///< Create a new record (of type potion) in the ESM store. 436 /// \return pointer to created record 437 438 const ESM::Spell *createRecord (const ESM::Spell& record) override; 439 ///< Create a new record (of type spell) in the ESM store. 440 /// \return pointer to created record 441 442 const ESM::Class *createRecord (const ESM::Class& record) override; 443 ///< Create a new record (of type class) in the ESM store. 444 /// \return pointer to created record 445 446 const ESM::Cell *createRecord (const ESM::Cell& record) override; 447 ///< Create a new record (of type cell) in the ESM store. 448 /// \return pointer to created record 449 450 const ESM::NPC *createRecord(const ESM::NPC &record) override; 451 ///< Create a new record (of type npc) in the ESM store. 452 /// \return pointer to created record 453 454 const ESM::Armor *createRecord (const ESM::Armor& record) override; 455 ///< Create a new record (of type armor) in the ESM store. 456 /// \return pointer to created record 457 458 const ESM::Weapon *createRecord (const ESM::Weapon& record) override; 459 ///< Create a new record (of type weapon) in the ESM store. 460 /// \return pointer to created record 461 462 const ESM::Clothing *createRecord (const ESM::Clothing& record) override; 463 ///< Create a new record (of type clothing) in the ESM store. 464 /// \return pointer to created record 465 466 const ESM::Enchantment *createRecord (const ESM::Enchantment& record) override; 467 ///< Create a new record (of type enchantment) in the ESM store. 468 /// \return pointer to created record 469 470 const ESM::Book *createRecord (const ESM::Book& record) override; 471 ///< Create a new record (of type book) in the ESM store. 472 /// \return pointer to created record 473 474 const ESM::CreatureLevList *createOverrideRecord (const ESM::CreatureLevList& record) override; 475 ///< Write this record to the ESM store, allowing it to override a pre-existing record with the same ID. 476 /// \return pointer to created record 477 478 const ESM::ItemLevList *createOverrideRecord (const ESM::ItemLevList& record) override; 479 ///< Write this record to the ESM store, allowing it to override a pre-existing record with the same ID. 480 /// \return pointer to created record 481 482 const ESM::Creature *createOverrideRecord (const ESM::Creature& record) override; 483 ///< Write this record to the ESM store, allowing it to override a pre-existing record with the same ID. 484 /// \return pointer to created record 485 486 const ESM::NPC *createOverrideRecord (const ESM::NPC& record) override; 487 ///< Write this record to the ESM store, allowing it to override a pre-existing record with the same ID. 488 /// \return pointer to created record 489 490 const ESM::Container *createOverrideRecord (const ESM::Container& record) override; 491 ///< Write this record to the ESM store, allowing it to override a pre-existing record with the same ID. 492 /// \return pointer to created record 493 494 void update (float duration, bool paused) override; 495 void updatePhysics (float duration, bool paused, osg::Timer_t frameStart, unsigned int frameNumber, osg::Stats& stats) override; 496 497 void updateWindowManager () override; 498 499 MWWorld::Ptr placeObject (const MWWorld::ConstPtr& object, float cursorX, float cursorY, int amount) override; 500 ///< copy and place an object into the gameworld at the specified cursor position 501 /// @param object 502 /// @param cursor X (relative 0-1) 503 /// @param cursor Y (relative 0-1) 504 /// @param number of objects to place 505 506 MWWorld::Ptr dropObjectOnGround (const MWWorld::Ptr& actor, const MWWorld::ConstPtr& object, int amount) override; 507 ///< copy and place an object into the gameworld at the given actor's position 508 /// @param actor giving the dropped object position 509 /// @param object 510 /// @param number of objects to place 511 512 bool canPlaceObject(float cursorX, float cursorY) override; 513 ///< @return true if it is possible to place on object at specified cursor location 514 515 void processChangedSettings(const Settings::CategorySettingVector& settings) override; 516 517 bool isFlying(const MWWorld::Ptr &ptr) const override; 518 bool isSlowFalling(const MWWorld::Ptr &ptr) const override; 519 ///Is the head of the creature underwater? 520 bool isSubmerged(const MWWorld::ConstPtr &object) const override; 521 bool isSwimming(const MWWorld::ConstPtr &object) const override; 522 bool isUnderwater(const MWWorld::CellStore* cell, const osg::Vec3f &pos) const override; 523 bool isUnderwater(const MWWorld::ConstPtr &object, const float heightRatio) const override; 524 bool isWading(const MWWorld::ConstPtr &object) const override; 525 bool isWaterWalkingCastableOnTarget(const MWWorld::ConstPtr &target) const override; 526 bool isOnGround(const MWWorld::Ptr &ptr) const override; 527 528 osg::Matrixf getActorHeadTransform(const MWWorld::ConstPtr& actor) const override; 529 530 void togglePOV(bool force = false) override; 531 532 bool isFirstPerson() const override; 533 bool isPreviewModeEnabled() const override; 534 535 void togglePreviewMode(bool enable) override; 536 537 bool toggleVanityMode(bool enable) override; 538 539 void allowVanityMode(bool allow) override; 540 bool vanityRotateCamera(float * rot) override; 541 void adjustCameraDistance(float dist) override; 542 543 void applyDeferredPreviewRotationToPlayer(float dt) override; 544 void disableDeferredPreviewRotation() override; 545 546 void saveLoaded() override; 547 548 void setupPlayer() override; 549 void renderPlayer() override; 550 551 /// open or close a non-teleport door (depending on current state) 552 void activateDoor(const MWWorld::Ptr& door) override; 553 554 /// update movement state of a non-teleport door as specified 555 /// @param state see MWClass::setDoorState 556 /// @note throws an exception when invoked on a teleport door 557 void activateDoor(const MWWorld::Ptr& door, MWWorld::DoorState state) override; 558 559 void getActorsStandingOn (const MWWorld::ConstPtr& object, std::vector<MWWorld::Ptr> &actors) override; ///< get a list of actors standing on \a object 560 bool getPlayerStandingOn (const MWWorld::ConstPtr& object) override; ///< @return true if the player is standing on \a object 561 bool getActorStandingOn (const MWWorld::ConstPtr& object) override; ///< @return true if any actor is standing on \a object 562 bool getPlayerCollidingWith(const MWWorld::ConstPtr& object) override; ///< @return true if the player is colliding with \a object 563 bool getActorCollidingWith (const MWWorld::ConstPtr& object) override; ///< @return true if any actor is colliding with \a object 564 void hurtStandingActors (const MWWorld::ConstPtr& object, float dmgPerSecond) override; 565 ///< Apply a health difference to any actors standing on \a object. 566 /// To hurt actors, healthPerSecond should be a positive value. For a negative value, actors will be healed. 567 void hurtCollidingActors (const MWWorld::ConstPtr& object, float dmgPerSecond) override; 568 ///< Apply a health difference to any actors colliding with \a object. 569 /// To hurt actors, healthPerSecond should be a positive value. For a negative value, actors will be healed. 570 571 float getWindSpeed() override; 572 573 void getContainersOwnedBy (const MWWorld::ConstPtr& npc, std::vector<MWWorld::Ptr>& out) override; 574 ///< get all containers in active cells owned by this Npc 575 void getItemsOwnedBy (const MWWorld::ConstPtr& npc, std::vector<MWWorld::Ptr>& out) override; 576 ///< get all items in active cells owned by this Npc 577 578 bool getLOS(const MWWorld::ConstPtr& actor,const MWWorld::ConstPtr& targetActor) override; 579 ///< get Line of Sight (morrowind stupid implementation) 580 581 float getDistToNearestRayHit(const osg::Vec3f& from, const osg::Vec3f& dir, float maxDist, bool includeWater = false) override; 582 583 void enableActorCollision(const MWWorld::Ptr& actor, bool enable) override; 584 585 RestPermitted canRest() const override; 586 ///< check if the player is allowed to rest 587 588 void rest(double hours) override; 589 void rechargeItems(double duration, bool activeOnly) override; 590 591 /// \todo Probably shouldn't be here 592 MWRender::Animation* getAnimation(const MWWorld::Ptr &ptr) override; 593 const MWRender::Animation* getAnimation(const MWWorld::ConstPtr &ptr) const override; 594 void reattachPlayerCamera() override; 595 596 /// \todo this does not belong here 597 void screenshot (osg::Image* image, int w, int h) override; 598 bool screenshot360 (osg::Image* image) override; 599 600 /// Find center of exterior cell above land surface 601 /// \return false if exterior with given name not exists, true otherwise 602 bool findExteriorPosition(const std::string &name, ESM::Position &pos) override; 603 604 /// Find position in interior cell near door entrance 605 /// \return false if interior with given name not exists, true otherwise 606 bool findInteriorPosition(const std::string &name, ESM::Position &pos) override; 607 608 /// Enables or disables use of teleport spell effects (recall, intervention, etc). 609 void enableTeleporting(bool enable) override; 610 611 /// Returns true if teleport spell effects are allowed. 612 bool isTeleportingEnabled() const override; 613 614 /// Enables or disables use of levitation spell effect. 615 void enableLevitation(bool enable) override; 616 617 /// Returns true if levitation spell effect is allowed. 618 bool isLevitationEnabled() const override; 619 620 bool getGodModeState() const override; 621 622 bool toggleGodMode() override; 623 624 bool toggleScripts() override; 625 bool getScriptsEnabled() const override; 626 627 /** 628 * @brief startSpellCast attempt to start casting a spell. Might fail immediately if conditions are not met. 629 * @param actor 630 * @return true if the spell can be casted (i.e. the animation should start) 631 */ 632 bool startSpellCast (const MWWorld::Ptr& actor) override; 633 634 /** 635 * @brief Cast the actual spell, should be called mid-animation 636 * @param actor 637 */ 638 void castSpell (const MWWorld::Ptr& actor, bool manualSpell=false) override; 639 640 void launchMagicBolt (const std::string& spellId, const MWWorld::Ptr& caster, const osg::Vec3f& fallbackDirection) override; 641 void launchProjectile (MWWorld::Ptr& actor, MWWorld::Ptr& projectile, 642 const osg::Vec3f& worldPos, const osg::Quat& orient, MWWorld::Ptr& bow, float speed, float attackStrength) override; 643 void updateProjectilesCasters() override; 644 645 void applyLoopingParticles(const MWWorld::Ptr& ptr) override; 646 647 const std::vector<std::string>& getContentFiles() const override; 648 void breakInvisibility (const MWWorld::Ptr& actor) override; 649 650 // Allow NPCs to use torches? 651 bool useTorches() const override; 652 653 bool findInteriorPositionInWorldSpace(const MWWorld::CellStore* cell, osg::Vec3f& result) override; 654 655 /// Teleports \a ptr to the closest reference of \a id (e.g. DivineMarker, PrisonMarker, TempleMarker) 656 /// @note id must be lower case 657 void teleportToClosestMarker (const MWWorld::Ptr& ptr, 658 const std::string& id) override; 659 660 /// List all references (filtered by \a type) detected by \a ptr. The range 661 /// is determined by the current magnitude of the "Detect X" magic effect belonging to \a type. 662 /// @note This also works for references in containers. 663 void listDetectedReferences (const MWWorld::Ptr& ptr, std::vector<MWWorld::Ptr>& out, 664 DetectionType type) override; 665 666 /// Update the value of some globals according to the world state, which may be used by dialogue entries. 667 /// This should be called when initiating a dialogue. 668 void updateDialogueGlobals() override; 669 670 /// Moves all stolen items from \a ptr to the closest evidence chest. 671 void confiscateStolenItems(const MWWorld::Ptr& ptr) override; 672 673 void goToJail () override; 674 675 /// Spawn a random creature from a levelled list next to the player 676 void spawnRandomCreature(const std::string& creatureList) override; 677 678 /// Spawn a blood effect for \a ptr at \a worldPosition 679 void spawnBloodEffect (const MWWorld::Ptr& ptr, const osg::Vec3f& worldPosition) override; 680 681 void spawnEffect (const std::string& model, const std::string& textureOverride, const osg::Vec3f& worldPos, float scale = 1.f, bool isMagicVFX = true) override; 682 683 void explodeSpell(const osg::Vec3f& origin, const ESM::EffectList& effects, const MWWorld::Ptr& caster, const MWWorld::Ptr& ignore, 684 ESM::RangeType rangeType, const std::string& id, const std::string& sourceName, 685 const bool fromProjectile=false) override; 686 687 void activate (const MWWorld::Ptr& object, const MWWorld::Ptr& actor) override; 688 689 /// @see MWWorld::WeatherManager::isInStorm 690 bool isInStorm() const override; 691 692 /// @see MWWorld::WeatherManager::getStormDirection 693 osg::Vec3f getStormDirection() const override; 694 695 /// Resets all actors in the current active cells to their original location within that cell. 696 void resetActors() override; 697 698 bool isWalkingOnWater (const MWWorld::ConstPtr& actor) const override; 699 700 /// Return a vector aiming the actor's weapon towards a target. 701 /// @note The length of the vector is the distance between actor and target. 702 osg::Vec3f aimToTarget(const MWWorld::ConstPtr& actor, const MWWorld::ConstPtr& target, bool isRangedCombat) override; 703 704 /// Return the distance between actor's weapon and target's collision box. 705 float getHitDistance(const MWWorld::ConstPtr& actor, const MWWorld::ConstPtr& target) override; 706 707 bool isPlayerInJail() const override; 708 709 void setPlayerTraveling(bool traveling) override; 710 bool isPlayerTraveling() const override; 711 712 /// Return terrain height at \a worldPos position. 713 float getTerrainHeightAt(const osg::Vec3f& worldPos) const override; 714 715 /// Return physical or rendering half extents of the given actor. 716 osg::Vec3f getHalfExtents(const MWWorld::ConstPtr& actor, bool rendering=false) const override; 717 718 /// Export scene graph to a file and return the filename. 719 /// \param ptr object to export scene graph for (if empty, export entire scene graph) 720 std::string exportSceneGraph(const MWWorld::Ptr& ptr) override; 721 722 /// Preload VFX associated with this effect list 723 void preloadEffects(const ESM::EffectList* effectList) override; 724 725 DetourNavigator::Navigator* getNavigator() const override; 726 727 void updateActorPath(const MWWorld::ConstPtr& actor, const std::deque<osg::Vec3f>& path, 728 const osg::Vec3f& halfExtents, const osg::Vec3f& start, const osg::Vec3f& end) const override; 729 730 void removeActorPath(const MWWorld::ConstPtr& actor) const override; 731 732 void setNavMeshNumberToRender(const std::size_t value) override; 733 734 /// Return physical half extents of the given actor to be used in pathfinding 735 osg::Vec3f getPathfindingHalfExtents(const MWWorld::ConstPtr& actor) const override; 736 737 bool hasCollisionWithDoor(const MWWorld::ConstPtr& door, const osg::Vec3f& position, const osg::Vec3f& destination) const override; 738 739 bool isAreaOccupiedByOtherActor(const osg::Vec3f& position, const float radius, const MWWorld::ConstPtr& ignore) const override; 740 741 void reportStats(unsigned int frameNumber, osg::Stats& stats) const override; 742 743 std::vector<MWWorld::Ptr> getAll(const std::string& id) override; 744 }; 745 } 746 747 #endif 748