OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
aisequence.hpp
Go to the documentation of this file.
1 #ifndef GAME_MWMECHANICS_AISEQUENCE_H
2 #define GAME_MWMECHANICS_AISEQUENCE_H
3 
4 #include <list>
5 
7 
8 namespace MWWorld
9 {
10  class Ptr;
11 }
12 
13 namespace ESM
14 {
15  namespace AiSequence
16  {
17  struct AiSequence;
18  }
19 }
20 
21 
22 
23 namespace MWMechanics
24 {
25  class AiPackage;
26  class CharacterController;
27 
28  template< class Base > class DerivedClassStorage;
31 
33 
34  class AiSequence
35  {
37  std::list<AiPackage *> mPackages;
38 
40  bool mDone;
41 
43  bool mRepeat;
44 
46  void copy (const AiSequence& sequence);
47 
50 
51  public:
53  AiSequence();
54 
56  AiSequence (const AiSequence& sequence);
57 
59  AiSequence& operator= (const AiSequence& sequence);
60 
61  virtual ~AiSequence();
62 
64  std::list<AiPackage*>::const_iterator begin() const;
65  std::list<AiPackage*>::const_iterator end() const;
66 
67  std::list<AiPackage*>::const_iterator erase (std::list<AiPackage*>::const_iterator package);
68 
70 
71  int getTypeId() const;
72 
74 
77  int getLastRunTypeId() const { return mLastAiPackage; }
78 
80  bool getCombatTarget (MWWorld::Ptr &targetActor) const;
81 
83  bool isInCombat () const;
84 
86  bool isInCombat (const MWWorld::Ptr& actor) const;
87 
88  bool canAddTarget(const ESM::Position& actorPos, float distToTarget) const;
90 
92  void stopCombat();
93 
95  bool isPackageDone() const;
96 
98  void stopPursuit();
99 
101  void execute (const MWWorld::Ptr& actor, CharacterController& characterController, MWMechanics::AiState& state, float duration);
102 
104  void fastForward(const MWWorld::Ptr &actor, AiState &state);
105 
107  void clear();
108 
110 
112  void stack (const AiPackage& package, const MWWorld::Ptr& actor);
113 
115 
117 
119 
121  void fill (const ESM::AIPackageList& list);
122 
123  void writeState (ESM::AiSequence::AiSequence& sequence) const;
124  void readState (const ESM::AiSequence::AiSequence& sequence);
125  };
126 }
127 
128 #endif
base class for the temporary storage of AiPackages.
Definition: aistate.hpp:90
bool mRepeat
Does this AI sequence repeat (repeating of Wander packages handled separately)
Definition: aisequence.hpp:43
void stopCombat()
Removes all combat packages until first non-combat or stack empty.
Definition: aisequence.cpp:125
Definition: aipackage.hpp:90
stores one object of any class derived from Base. Requesting a certain derived class via get() either...
Definition: aisequence.hpp:28
bool isPackageDone() const
Has a package been completed during the last update?
Definition: aisequence.cpp:153
DerivedClassStorage< AiTemporaryBase > AiState
Container for AI package status.
Definition: aisequence.hpp:29
std::list< AiPackage * >::const_iterator end() const
Definition: aisequence.cpp:82
AiSequence()
Default constructor.
Definition: aisequence.cpp:31
void readState(const ESM::AiSequence::AiSequence &sequence)
Definition: aisequence.cpp:375
int list(Bsa::BSAFile &bsa, Arguments &info)
Definition: bsatool.cpp:183
void stopPursuit()
Removes all pursue packages until first non-pursue or stack empty.
Definition: aisequence.cpp:139
void writeState(ESM::AiSequence::AiSequence &sequence) const
Definition: aisequence.cpp:367
Base class for AI packages.
Definition: aipackage.hpp:32
virtual ~AiSequence()
Definition: aisequence.cpp:54
bool mDone
Finished with top AIPackage, set for one frame.
Definition: aisequence.hpp:40
Sequence of AI-packages for a single actor.
Definition: aisequence.hpp:34
Definition: character.hpp:145
bool canAddTarget(const ESM::Position &actorPos, float distToTarget) const
Function assumes that actor can have only 1 target apart player.
void stack(const AiPackage &package, const MWWorld::Ptr &actor)
Definition: aisequence.cpp:264
int getLastRunTypeId() const
Get the typeid of the Ai package that ran last.
Definition: aisequence.hpp:77
void fill(const ESM::AIPackageList &list)
Fills the AiSequence with packages.
Definition: aisequence.cpp:325
std::list< AiPackage * >::const_iterator begin() const
Iterator may be invalidated by any function calls other than begin() or end().
Definition: aisequence.cpp:77
void copy(const AiSequence &sequence)
Copy AiSequence.
Definition: aisequence.cpp:24
std::list< AiPackage * >::const_iterator erase(std::list< AiPackage * >::const_iterator package)
Definition: aisequence.cpp:87
Definition: defs.hpp:38
void execute(const MWWorld::Ptr &actor, CharacterController &characterController, MWMechanics::AiState &state, float duration)
Execute current package, switching if needed.
Definition: aisequence.cpp:166
Definition: aisequence.hpp:148
void fastForward(const MWWorld::Ptr &actor, AiState &state)
Simulate the passing of time using the currently active AI package.
Definition: aisequence.cpp:445
bool getCombatTarget(MWWorld::Ptr &targetActor) const
Return true and assign target if combat package is currently active, return false otherwise...
Definition: aisequence.cpp:67
bool isInCombat() const
Is there any combat package?
Definition: aisequence.cpp:102
int mLastAiPackage
The type of AI package that ran last.
Definition: aisequence.hpp:49
void clear()
Remove all packages.
Definition: aisequence.cpp:256
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
AiSequence & operator=(const AiSequence &sequence)
Assignment operator.
Definition: aisequence.cpp:41
std::list< AiPackage * > mPackages
AiPackages to run though.
Definition: aisequence.hpp:37
int getTypeId() const
Returns currently executing AiPackage type.
Definition: aisequence.cpp:59
AiPackage * getActivePackage()
Return the current active package.
Definition: aisequence.cpp:317