OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
mechanicsmanager.hpp
Go to the documentation of this file.
1 #ifndef GAME_MWBASE_MECHANICSMANAGER_H
2 #define GAME_MWBASE_MECHANICSMANAGER_H
3 
4 #include <string>
5 #include <vector>
6 #include <list>
7 #include <set>
8 #include <stdint.h>
9 
10 namespace osg
11 {
12  class Vec3f;
13 }
14 
15 namespace ESM
16 {
17  struct Class;
18 
19  class ESMReader;
20  class ESMWriter;
21 }
22 
23 namespace MWWorld
24 {
25  class Ptr;
26  class CellStore;
27  class CellRef;
28 }
29 
30 namespace Loading
31 {
32  class Listener;
33 }
34 
35 namespace MWBase
36 {
39  {
42 
45 
46  public:
47 
49 
50  virtual ~MechanicsManager() {}
51 
52  virtual void add (const MWWorld::Ptr& ptr) = 0;
54 
55  virtual void remove (const MWWorld::Ptr& ptr) = 0;
57 
58  virtual void updateCell(const MWWorld::Ptr &old, const MWWorld::Ptr &ptr) = 0;
60 
61  virtual void drop (const MWWorld::CellStore *cellStore) = 0;
63 
64  virtual void watchActor (const MWWorld::Ptr& ptr) = 0;
67 
68  virtual void update (float duration, bool paused) = 0;
73 
74  virtual void advanceTime (float duration) = 0;
75 
76  virtual void setPlayerName (const std::string& name) = 0;
78 
79  virtual void setPlayerRace (const std::string& id, bool male, const std::string &head, const std::string &hair) = 0;
81 
82  virtual void setPlayerBirthsign (const std::string& id) = 0;
84 
85  virtual void setPlayerClass (const std::string& id) = 0;
87 
88  virtual void setPlayerClass (const ESM::Class& class_) = 0;
90 
91  virtual void rest(bool sleep) = 0;
94 
95  virtual int getHoursToRest() const = 0;
97 
98  virtual int getBarterOffer(const MWWorld::Ptr& ptr,int basePrice, bool buying) = 0;
100 
101  virtual int getDerivedDisposition(const MWWorld::Ptr& ptr, bool addTemporaryDispositionChange = true) = 0;
103 
104  virtual int countDeaths (const std::string& id) const = 0;
106 
108  virtual bool awarenessCheck (const MWWorld::Ptr& ptr, const MWWorld::Ptr& observer) = 0;
109 
111  virtual void startCombat (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target) = 0;
112 
114  {
115  OT_Theft, // Taking items owned by an NPC or a faction you are not a member of
116  OT_Assault, // Attacking a peaceful NPC
117  OT_Murder, // Murdering a peaceful NPC
118  OT_Trespassing, // Picking the lock of an owned door/chest
119  OT_SleepingInOwnedBed, // Sleeping in a bed owned by an NPC or a faction you are not a member of
120  OT_Pickpocket // Entering pickpocket mode, leaving it, and being detected. Any items stolen are a separate crime (Theft)
121  };
129  virtual bool commitCrime (const MWWorld::Ptr& ptr, const MWWorld::Ptr& victim,
130  OffenseType type, int arg=0, bool victimAware=false) = 0;
132  virtual bool actorAttacked (const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker) = 0;
133 
136  virtual void actorKilled (const MWWorld::Ptr& victim, const MWWorld::Ptr& attacker) = 0;
137 
140  virtual void itemTaken (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item, const MWWorld::Ptr& container,
141  int count) = 0;
143  virtual void objectOpened (const MWWorld::Ptr& ptr, const MWWorld::Ptr& item) = 0;
146  virtual bool sleepInBed (const MWWorld::Ptr& ptr, const MWWorld::Ptr& bed) = 0;
147 
149  {
156  };
157  virtual void getPersuasionDispositionChange (const MWWorld::Ptr& npc, PersuasionType type, bool& success, float& tempChange, float& permChange) = 0;
159 
160  virtual void forceStateUpdate(const MWWorld::Ptr &ptr) = 0;
162 
163  virtual bool playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number=1, bool persist=false) = 0;
172 
173  virtual void skipAnimation(const MWWorld::Ptr& ptr) = 0;
176 
177  virtual bool checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string& groupName) = 0;
178 
180  virtual void persistAnimationStates() = 0;
181 
184  virtual void updateMagicEffects (const MWWorld::Ptr& ptr) = 0;
185 
186  virtual bool toggleAI() = 0;
187  virtual bool isAIActive() = 0;
188 
189  virtual void getObjectsInRange (const osg::Vec3f& position, float radius, std::vector<MWWorld::Ptr>& objects) = 0;
190  virtual void getActorsInRange(const osg::Vec3f &position, float radius, std::vector<MWWorld::Ptr> &objects) = 0;
191 
193 
194  virtual std::list<MWWorld::Ptr> getActorsSidingWith(const MWWorld::Ptr& actor) = 0;
195  virtual std::list<MWWorld::Ptr> getActorsFollowing(const MWWorld::Ptr& actor) = 0;
196  virtual std::list<int> getActorsFollowingIndices(const MWWorld::Ptr& actor) = 0;
197 
199 
200  virtual std::list<MWWorld::Ptr> getActorsFighting(const MWWorld::Ptr& actor) = 0;
201 
202  virtual std::list<MWWorld::Ptr> getEnemiesNearby(const MWWorld::Ptr& actor) = 0;
203 
205  virtual void getActorsFollowing(const MWWorld::Ptr& actor, std::set<MWWorld::Ptr>& out) = 0;
206  virtual void getActorsSidingWith(const MWWorld::Ptr& actor, std::set<MWWorld::Ptr>& out) = 0;
207 
208  virtual void playerLoaded() = 0;
209 
210  virtual int countSavedGameRecords() const = 0;
211 
212  virtual void write (ESM::ESMWriter& writer, Loading::Listener& listener) const = 0;
213 
214  virtual void readRecord (ESM::ESMReader& reader, uint32_t type) = 0;
215 
216  virtual void clear() = 0;
217 
218  virtual bool isAggressive (const MWWorld::Ptr& ptr, const MWWorld::Ptr& target) = 0;
219 
221  virtual void keepPlayerAlive() = 0;
222 
223  virtual bool isReadyToBlock (const MWWorld::Ptr& ptr) const = 0;
224 
225  virtual void confiscateStolenItems (const MWWorld::Ptr& player, const MWWorld::Ptr& targetContainer) = 0;
226 
229  virtual std::vector<std::pair<std::string, int> > getStolenItemOwners(const std::string& itemid) = 0;
230 
232  virtual bool isItemStolenFrom(const std::string& itemid, const std::string& ownerid) = 0;
233 
234  virtual bool isAllowedToUse (const MWWorld::Ptr& ptr, const MWWorld::CellRef& cellref, MWWorld::Ptr& victim) = 0;
235 
237  virtual void setWerewolf(const MWWorld::Ptr& actor, bool werewolf) = 0;
238 
241  virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor) = 0;
242 
243  virtual void cleanupSummonedCreature(const MWWorld::Ptr& caster, int creatureActorId) = 0;
244  };
245 }
246 
247 #endif
virtual int getHoursToRest() const =0
Calculate how many hours the player needs to rest in order to be fully healed.
Definition: mechanicsmanager.hpp:150
Encapsulated variant of ESM::CellRef with change tracking.
Definition: cellref.hpp:15
MechanicsManager & operator=(const MechanicsManager &)
not implemented
virtual void setPlayerRace(const std::string &id, bool male, const std::string &head, const std::string &hair)=0
Set player race.
virtual void update(float duration, bool paused)=0
virtual void setPlayerClass(const std::string &id)=0
Set player class to stock class.
virtual void keepPlayerAlive()=0
Resurrects the player if necessary.
virtual int countSavedGameRecords() const =0
virtual void setPlayerBirthsign(const std::string &id)=0
Set player birthsign.
virtual std::list< MWWorld::Ptr > getEnemiesNearby(const MWWorld::Ptr &actor)=0
Definition: esmreader.hpp:21
virtual void setWerewolf(const MWWorld::Ptr &actor, bool werewolf)=0
Turn actor into werewolf or normal form.
PersuasionType
Definition: mechanicsmanager.hpp:148
virtual void setPlayerName(const std::string &name)=0
Set player name.
virtual void cleanupSummonedCreature(const MWWorld::Ptr &caster, int creatureActorId)=0
virtual bool checkAnimationPlaying(const MWWorld::Ptr &ptr, const std::string &groupName)=0
virtual bool isReadyToBlock(const MWWorld::Ptr &ptr) const =0
virtual void clear()=0
Definition: mechanicsmanager.hpp:152
virtual bool isItemStolenFrom(const std::string &itemid, const std::string &ownerid)=0
Has the player stolen this item from the given owner?
virtual bool isAggressive(const MWWorld::Ptr &ptr, const MWWorld::Ptr &target)=0
Definition: mechanicsmanager.hpp:120
Definition: mechanicsmanager.hpp:119
virtual void persistAnimationStates()=0
Save the current animation state of managed references to their RefData.
Definition: loadinglistener.hpp:8
virtual bool actorAttacked(const MWWorld::Ptr &victim, const MWWorld::Ptr &attacker)=0
MechanicsManager()
Definition: mechanicsmanager.hpp:48
Definition: esmwriter.hpp:17
virtual bool awarenessCheck(const MWWorld::Ptr &ptr, const MWWorld::Ptr &observer)=0
Check if observer is potentially aware of ptr. Does not do a line of sight check! ...
virtual void actorKilled(const MWWorld::Ptr &victim, const MWWorld::Ptr &attacker)=0
virtual void getObjectsInRange(const osg::Vec3f &position, float radius, std::vector< MWWorld::Ptr > &objects)=0
virtual void getActorsInRange(const osg::Vec3f &position, float radius, std::vector< MWWorld::Ptr > &objects)=0
virtual void getPersuasionDispositionChange(const MWWorld::Ptr &npc, PersuasionType type, bool &success, float &tempChange, float &permChange)=0
Perform a persuasion action on NPC.
virtual int countDeaths(const std::string &id) const =0
Return the number of deaths for actors with the given ID.
virtual std::list< int > getActorsFollowingIndices(const MWWorld::Ptr &actor)=0
virtual void skipAnimation(const MWWorld::Ptr &ptr)=0
Definition: mechanicsmanager.hpp:151
virtual void drop(const MWWorld::CellStore *cellStore)=0
Deregister all objects in the given cell.
virtual void updateCell(const MWWorld::Ptr &old, const MWWorld::Ptr &ptr)=0
Moves an object to a new cell.
virtual int getDerivedDisposition(const MWWorld::Ptr &ptr, bool addTemporaryDispositionChange=true)=0
Calculate the diposition of an NPC toward the player.
virtual void updateMagicEffects(const MWWorld::Ptr &ptr)=0
virtual void objectOpened(const MWWorld::Ptr &ptr, const MWWorld::Ptr &item)=0
Utility to check if opening (i.e. unlocking) this object is illegal and calling commitCrime if so...
Mutable state of a cell.
Definition: cellstore.hpp:53
virtual bool playAnimationGroup(const MWWorld::Ptr &ptr, const std::string &groupName, int mode, int number=1, bool persist=false)=0
virtual void advanceTime(float duration)=0
virtual std::list< MWWorld::Ptr > getActorsFollowing(const MWWorld::Ptr &actor)=0
virtual void itemTaken(const MWWorld::Ptr &ptr, const MWWorld::Ptr &item, const MWWorld::Ptr &container, int count)=0
virtual void rest(bool sleep)=0
Definition: mechanicsmanager.hpp:117
virtual std::list< MWWorld::Ptr > getActorsSidingWith(const MWWorld::Ptr &actor)=0
Returns the list of actors which are siding with the given actor in fights.
virtual void applyWerewolfAcrobatics(const MWWorld::Ptr &actor)=0
virtual int getBarterOffer(const MWWorld::Ptr &ptr, int basePrice, bool buying)=0
This is used by every service to determine the price of objects given the trading skills of the playe...
virtual void watchActor(const MWWorld::Ptr &ptr)=0
virtual bool toggleAI()=0
Definition: mechanicsmanager.hpp:153
virtual bool commitCrime(const MWWorld::Ptr &ptr, const MWWorld::Ptr &victim, OffenseType type, int arg=0, bool victimAware=false)=0
virtual bool isAllowedToUse(const MWWorld::Ptr &ptr, const MWWorld::CellRef &cellref, MWWorld::Ptr &victim)=0
Definition: loadclas.hpp:18
virtual void confiscateStolenItems(const MWWorld::Ptr &player, const MWWorld::Ptr &targetContainer)=0
Interface for game mechanics manager (implemented in MWMechanics)
Definition: mechanicsmanager.hpp:38
Definition: mechanicsmanager.hpp:118
virtual std::vector< std::pair< std::string, int > > getStolenItemOwners(const std::string &itemid)=0
virtual void forceStateUpdate(const MWWorld::Ptr &ptr)=0
Forces an object to refresh its animation state.
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
Definition: mechanicsmanager.hpp:154
virtual void add(const MWWorld::Ptr &ptr)=0
Register an object for management.
Definition: mechanicsmanager.hpp:116
Definition: mechanicsmanager.hpp:115
Definition: mechanicsmanager.hpp:155
virtual std::list< MWWorld::Ptr > getActorsFighting(const MWWorld::Ptr &actor)=0
Returns a list of actors who are fighting the given actor within the fAlarmDistance.
virtual void playerLoaded()=0
virtual ~MechanicsManager()
Definition: mechanicsmanager.hpp:50
virtual bool sleepInBed(const MWWorld::Ptr &ptr, const MWWorld::Ptr &bed)=0
virtual void startCombat(const MWWorld::Ptr &ptr, const MWWorld::Ptr &target)=0
Makes ptr fight target. Also shouts a combat taunt.
OffenseType
Definition: mechanicsmanager.hpp:113
virtual void write(ESM::ESMWriter &writer, Loading::Listener &listener) const =0
virtual bool isAIActive()=0
const char * name
Definition: crashcatcher.cpp:59
virtual void readRecord(ESM::ESMReader &reader, uint32_t type)=0