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