forked from mirror/openmw-tes3mp
Made code a bit more standardized and added a good bit of documentation.
This commit is contained in:
parent
8f90dd43ec
commit
10a5bb9464
11 changed files with 152 additions and 107 deletions
|
@ -46,10 +46,7 @@ namespace MyGUI
|
|||
|
||||
namespace MWInput
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief Class that handles all input and key bindings for OpenMW.
|
||||
*/
|
||||
/// \brief Class that handles all input and key bindings for OpenMW.
|
||||
class InputManager :
|
||||
public MWBase::InputManager,
|
||||
public SFO::KeyListener,
|
||||
|
@ -68,6 +65,7 @@ namespace MWInput
|
|||
/// Clear all savegame-specific data
|
||||
virtual void clear();
|
||||
|
||||
|
||||
virtual void update(float dt, bool disableControls=false, bool disableEvents=false);
|
||||
|
||||
void setPlayer (MWWorld::Player* player) { mPlayer = player; }
|
||||
|
|
|
@ -8,14 +8,15 @@
|
|||
|
||||
namespace MWMechanics
|
||||
{
|
||||
|
||||
/// \brief Causes actor to walk to activatable object and activate it
|
||||
class AiActivate : public AiPackage
|
||||
{
|
||||
public:
|
||||
/// Constructor
|
||||
/** \param objectId Reference to object to activate **/
|
||||
AiActivate(const std::string &objectId);
|
||||
virtual AiActivate *clone() const;
|
||||
virtual bool execute (const MWWorld::Ptr& actor,float duration);
|
||||
///< \return Package completed?
|
||||
virtual int getTypeId() const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -14,20 +14,23 @@
|
|||
|
||||
namespace MWMechanics
|
||||
{
|
||||
/// \brief Causes the actor to fight another actor
|
||||
class AiCombat : public AiPackage
|
||||
{
|
||||
public:
|
||||
///Constructor
|
||||
/** \param actor Actor to fight **/
|
||||
AiCombat(const MWWorld::Ptr& actor);
|
||||
|
||||
virtual AiCombat *clone() const;
|
||||
|
||||
virtual bool execute (const MWWorld::Ptr& actor,float duration);
|
||||
///< \return Package completed?
|
||||
|
||||
virtual int getTypeId() const;
|
||||
|
||||
virtual unsigned int getPriority() const;
|
||||
|
||||
///Returns target ID
|
||||
const std::string &getTargetId() const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -8,18 +8,22 @@
|
|||
|
||||
namespace MWMechanics
|
||||
{
|
||||
/// \brief AI Package to have an NPC lead the player to a specific point
|
||||
class AiEscort : public AiPackage
|
||||
{
|
||||
public:
|
||||
/// Implementation of AiEscort
|
||||
/** The Actor will escort the specified actor to the world position x, y, z until they reach their position, or they run out of time
|
||||
\implement AiEscort **/
|
||||
AiEscort(const std::string &actorId,int duration, float x, float y, float z);
|
||||
///< \implement AiEscort
|
||||
/// Implementation of AiEscortCell
|
||||
/** The Actor will escort the specified actor to the cell position x, y, z until they reach their position, or they run out of time
|
||||
\implement AiEscortCell **/
|
||||
AiEscort(const std::string &actorId,const std::string &cellId,int duration, float x, float y, float z);
|
||||
///< \implement AiEscortCell
|
||||
|
||||
virtual AiEscort *clone() const;
|
||||
|
||||
virtual bool execute (const MWWorld::Ptr& actor,float duration);
|
||||
///< \return Package completed?
|
||||
|
||||
virtual int getTypeId() const;
|
||||
|
||||
|
|
|
@ -8,22 +8,32 @@
|
|||
|
||||
namespace MWMechanics
|
||||
{
|
||||
|
||||
/// \brief AiPackage for an actor to follow another actor/the PC
|
||||
/** The AI will follow the target until a condition (time, or position) are set. Both can be disabled to cause the actor to follow the other indefinitely
|
||||
**/
|
||||
class AiFollow : public AiPackage
|
||||
{
|
||||
public:
|
||||
/// Follow Actor for duration or until you arrive at a world position
|
||||
AiFollow(const std::string &ActorId,float duration, float X, float Y, float Z);
|
||||
/// Follow Actor for duration or until you arrive at a position in a cell
|
||||
AiFollow(const std::string &ActorId,const std::string &CellId,float duration, float X, float Y, float Z);
|
||||
/// Follow Actor indefinitively
|
||||
AiFollow(const std::string &ActorId);
|
||||
|
||||
virtual AiFollow *clone() const;
|
||||
|
||||
virtual bool execute (const MWWorld::Ptr& actor,float duration);
|
||||
///< \return Package completed?
|
||||
|
||||
virtual int getTypeId() const;
|
||||
|
||||
/// Returns the actor being followed
|
||||
std::string getFollowedActor();
|
||||
|
||||
private:
|
||||
bool mAlwaysFollow; //this will make the actor always follow, thus ignoring mDuration and mX,mY,mZ (used for summoned creatures).
|
||||
/// This will make the actor always follow.
|
||||
/** Thus ignoring mDuration and mX,mY,mZ (used for summoned creatures). **/
|
||||
bool mAlwaysFollow;
|
||||
float mDuration;
|
||||
float mX;
|
||||
float mY;
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace MWMechanics
|
|||
class AiPackage
|
||||
{
|
||||
public:
|
||||
///Enumerates the various AITypes availible.
|
||||
enum TypeId {
|
||||
TypeIdNone = -1,
|
||||
TypeIdWander = 0,
|
||||
|
@ -23,18 +24,22 @@ namespace MWMechanics
|
|||
TypeIdPersue = 6
|
||||
};
|
||||
|
||||
///Default Deconstructor
|
||||
virtual ~AiPackage();
|
||||
|
||||
///Clones the package
|
||||
virtual AiPackage *clone() const = 0;
|
||||
|
||||
/// Updates and runs the package (Should run every frame)
|
||||
/// \return Package completed?
|
||||
virtual bool execute (const MWWorld::Ptr& actor,float duration) = 0;
|
||||
///< \return Package completed?
|
||||
|
||||
/// Returns the TypeID of the AiPackage
|
||||
/// \see enum TypeId
|
||||
virtual int getTypeId() const = 0;
|
||||
///< @see enum TypeId
|
||||
|
||||
/// Higher number is higher priority (0 beeing the lowest)
|
||||
virtual unsigned int getPriority() const {return 0;}
|
||||
///< higher number is higher priority (0 beeing the lowest)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -8,14 +8,16 @@
|
|||
|
||||
namespace MWMechanics
|
||||
{
|
||||
|
||||
/// \brief Makes the actor very closely follow the actor
|
||||
/** Used for getting closer to fight, or to arrest (I think?) **/
|
||||
class AiPersue : public AiPackage
|
||||
{
|
||||
public:
|
||||
///Constructor
|
||||
/** \param objectId Actor to pursue **/
|
||||
AiPersue(const std::string &objectId);
|
||||
virtual AiPersue *clone() const;
|
||||
virtual bool execute (const MWWorld::Ptr& actor,float duration);
|
||||
///< \return Package completed?
|
||||
virtual int getTypeId() const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -15,63 +15,77 @@ namespace MWMechanics
|
|||
class AiPackage;
|
||||
|
||||
/// \brief Sequence of AI-packages for a single actor
|
||||
/** Each package will be run in succession for an actor until completed **/
|
||||
class AiSequence
|
||||
{
|
||||
///AiPackages to run though
|
||||
std::list<AiPackage *> mPackages;
|
||||
|
||||
///Finished with all AiPackages
|
||||
bool mDone;
|
||||
|
||||
///Copy AiSequence
|
||||
void copy (const AiSequence& sequence);
|
||||
|
||||
// The type of AI package that ran last
|
||||
/// The type of AI package that ran last
|
||||
int mLastAiPackage;
|
||||
|
||||
public:
|
||||
|
||||
///Default constructor
|
||||
AiSequence();
|
||||
|
||||
/// Copy Constructor
|
||||
AiSequence (const AiSequence& sequence);
|
||||
|
||||
/// Assignment operator
|
||||
AiSequence& operator= (const AiSequence& sequence);
|
||||
|
||||
/// Destructor
|
||||
virtual ~AiSequence();
|
||||
|
||||
/// Returns currently executing AiPackage type
|
||||
/** \see enum AiPackage::TypeId **/
|
||||
int getTypeId() const;
|
||||
///< @see enum AiPackage::TypeId
|
||||
|
||||
/// Get the typeid of the Ai package that ran last
|
||||
/** NOT the currently "active" Ai package that will be run in the next frame.
|
||||
This difference is important when an Ai package has just finished and been removed.
|
||||
\see enum AiPackage::TypeId **/
|
||||
int getLastRunTypeId() const { return mLastAiPackage; }
|
||||
///< Get the typeid of the Ai package that ran last, NOT the currently "active" Ai package that will be run in the next frame.
|
||||
/// This difference is important when an Ai package has just finished and been removed.
|
||||
|
||||
/// Return true and assign target if combat package is currently active, return false otherwise
|
||||
bool getCombatTarget (std::string &targetActorId) const;
|
||||
///< Return true and assign target if combat package is currently
|
||||
/// active, return false otherwise
|
||||
|
||||
/// Removes all combat packages until first non-combat or stack empty.
|
||||
void stopCombat();
|
||||
///< Removes all combat packages until first non-combat or stack empty.
|
||||
|
||||
/// Removes all persue packages until first non-persue or stack empty.
|
||||
void stopPersue();
|
||||
///< Removes all persue packages until first non-persue or stack empty.
|
||||
|
||||
/// Has a package been completed during the last update?
|
||||
bool isPackageDone() const;
|
||||
///< Has a package been completed during the last update?
|
||||
|
||||
/// Execute current package, switching if needed.
|
||||
void execute (const MWWorld::Ptr& actor,float duration);
|
||||
///< Execute package.
|
||||
|
||||
/// Remove all packages.
|
||||
void clear();
|
||||
///< Remove all packages.
|
||||
|
||||
///< Add \a package to the front of the sequence
|
||||
/** Suspends current package **/
|
||||
void stack (const AiPackage& package, const MWWorld::Ptr& actor);
|
||||
///< Add \a package to the front of the sequence (suspends current package)
|
||||
|
||||
/// Add \a package to the end of the sequence
|
||||
/** Executed after all other packages have been completed **/
|
||||
void queue (const AiPackage& package);
|
||||
///< Add \a package to the end of the sequence (executed after all other packages have been
|
||||
/// completed)
|
||||
|
||||
/// Return the current active package.
|
||||
/** If there is no active package, it will throw an exception **/
|
||||
AiPackage* getActivePackage();
|
||||
///< return the current active package. If there is no active package, throw an exeption
|
||||
|
||||
/// Fills the AiSequence with packages
|
||||
/** Typically used for loading from the ESM
|
||||
\see ESM::AIPackageList **/
|
||||
void fill (const ESM::AIPackageList& list);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -7,14 +7,15 @@
|
|||
|
||||
namespace MWMechanics
|
||||
{
|
||||
/// \brief Causes the AI to travel to the specified point
|
||||
class AiTravel : public AiPackage
|
||||
{
|
||||
public:
|
||||
/// Default constructor
|
||||
AiTravel(float x, float y, float z);
|
||||
virtual AiTravel *clone() const;
|
||||
|
||||
virtual bool execute (const MWWorld::Ptr& actor,float duration);
|
||||
///< \return Package completed?
|
||||
|
||||
virtual int getTypeId() const;
|
||||
|
||||
|
|
|
@ -14,20 +14,27 @@
|
|||
|
||||
namespace MWMechanics
|
||||
{
|
||||
/// \brief Causes the Actor to wander within a specified range
|
||||
class AiWander : public AiPackage
|
||||
{
|
||||
public:
|
||||
|
||||
/// Constructor
|
||||
/** \param distance Max distance the ACtor will wander
|
||||
\param duration Time, in hours, that this package will be preformed
|
||||
\param timeOfDay Start time of the package, if it has a duration. Currently unimplemented
|
||||
\param idle Chances of each idle to play (9 in total)
|
||||
\param repeat Repeat wander or not **/
|
||||
AiWander(int distance, int duration, int timeOfDay, const std::vector<int>& idle, bool repeat);
|
||||
virtual AiPackage *clone() const;
|
||||
virtual bool execute (const MWWorld::Ptr& actor,float duration);
|
||||
///< \return Package completed?
|
||||
virtual int getTypeId() const;
|
||||
///< 0: Wander
|
||||
|
||||
virtual AiPackage *clone() const;
|
||||
|
||||
virtual bool execute (const MWWorld::Ptr& actor,float duration);
|
||||
|
||||
virtual int getTypeId() const;
|
||||
|
||||
/// Set the position to return to for a stationary (non-wandering) actor
|
||||
/** In case another AI package moved the actor elsewhere **/
|
||||
void setReturnPosition (const Ogre::Vector3& position);
|
||||
///< Set the position to return to for a stationary (non-wandering) actor, in case
|
||||
/// another AI package moved the actor elsewhere
|
||||
|
||||
private:
|
||||
void stopWalking(const MWWorld::Ptr& actor);
|
||||
|
|
|
@ -31,6 +31,8 @@ namespace MWMechanics
|
|||
typedef std::vector<ESM::ENAMstruct> TEffectsContainer;
|
||||
typedef TEffectsContainer::const_iterator TEffectsIterator;
|
||||
|
||||
/// Result of potion creation
|
||||
/** Only Result_Success results in success **/
|
||||
enum Result
|
||||
{
|
||||
Result_Success,
|
||||
|
@ -42,6 +44,46 @@ namespace MWMechanics
|
|||
Result_RandomFailure
|
||||
};
|
||||
|
||||
/// Set alchemist and configure alchemy setup accordingly.
|
||||
/** \a npc may be empty to indicate that there is no alchemist (alchemy session has ended). **/
|
||||
void setAlchemist (const MWWorld::Ptr& npc);
|
||||
|
||||
/// \attention Iterates over tool slots, not over tools. Some of the slots may be empty.
|
||||
TToolsIterator beginTools() const;
|
||||
|
||||
TToolsIterator endTools() const;
|
||||
|
||||
/// \attention Iterates over ingredient slots, not over ingredients. Some of the slots may be empty.
|
||||
TIngredientsIterator beginIngredients() const;
|
||||
|
||||
TIngredientsIterator endIngredients() const;
|
||||
|
||||
/// Remove alchemist, tools and ingredients.
|
||||
void clear();
|
||||
|
||||
/// Add ingredient into the next free slot.
|
||||
///
|
||||
/// \return Slot index or -1, if adding failed because of no free slot or the ingredient type being
|
||||
/// listed already.
|
||||
int addIngredient (const MWWorld::Ptr& ingredient);
|
||||
|
||||
/// Remove ingredient from slot (calling this function on an empty slot is a no-op).
|
||||
void removeIngredient (int index);
|
||||
|
||||
TEffectsIterator beginEffects() const;
|
||||
|
||||
TEffectsIterator endEffects() const;
|
||||
|
||||
/// Return the name of the potion that would be created when calling create (if a record for such
|
||||
/// a potion already exists) or return an empty string.
|
||||
std::string getPotionName() const;
|
||||
|
||||
/// Try to create a potion from the ingredients, place it in the inventory of the alchemist and
|
||||
/// adjust the skills of the alchemist accordingly.
|
||||
/// \param name must not be an empty string, unless there is already a potion record (
|
||||
/// getPotionName() does not return an empty string).
|
||||
Result create (const std::string& name);
|
||||
|
||||
private:
|
||||
|
||||
MWWorld::Ptr mAlchemist;
|
||||
|
@ -50,19 +92,19 @@ namespace MWMechanics
|
|||
TEffectsContainer mEffects;
|
||||
int mValue;
|
||||
|
||||
/// List all effects shared by at least two ingredients.
|
||||
std::set<EffectKey> listEffects() const;
|
||||
///< List all effects shared by at least two ingredients.
|
||||
|
||||
void applyTools (int flags, float& value) const;
|
||||
|
||||
void updateEffects();
|
||||
|
||||
/// Return existing recrod for created potion (may return 0)
|
||||
const ESM::Potion *getRecord() const;
|
||||
///< Return existing recrod for created potion (may return 0)
|
||||
|
||||
void removeIngredients();
|
||||
///< Remove selected ingredients from alchemist's inventory, cleanup selected ingredients and
|
||||
/// Remove selected ingredients from alchemist's inventory, cleanup selected ingredients and
|
||||
/// update effect list accordingly.
|
||||
void removeIngredients();
|
||||
|
||||
void addPotion (const std::string& name);
|
||||
///< Add a potion to the alchemist's inventory.
|
||||
|
@ -74,48 +116,6 @@ namespace MWMechanics
|
|||
///< Return chance of success.
|
||||
|
||||
int countIngredients() const;
|
||||
|
||||
public:
|
||||
|
||||
void setAlchemist (const MWWorld::Ptr& npc);
|
||||
///< Set alchemist and configure alchemy setup accordingly. \a npc may be empty to indicate that
|
||||
/// there is no alchemist (alchemy session has ended).
|
||||
|
||||
TToolsIterator beginTools() const;
|
||||
///< \attention Iterates over tool slots, not over tools. Some of the slots may be empty.
|
||||
|
||||
TToolsIterator endTools() const;
|
||||
|
||||
TIngredientsIterator beginIngredients() const;
|
||||
///< \attention Iterates over ingredient slots, not over ingredients. Some of the slots may be empty.
|
||||
|
||||
TIngredientsIterator endIngredients() const;
|
||||
|
||||
void clear();
|
||||
///< Remove alchemist, tools and ingredients.
|
||||
|
||||
int addIngredient (const MWWorld::Ptr& ingredient);
|
||||
///< Add ingredient into the next free slot.
|
||||
///
|
||||
/// \return Slot index or -1, if adding failed because of no free slot or the ingredient type being
|
||||
/// listed already.
|
||||
|
||||
void removeIngredient (int index);
|
||||
///< Remove ingredient from slot (calling this function on an empty slot is a no-op).
|
||||
|
||||
TEffectsIterator beginEffects() const;
|
||||
|
||||
TEffectsIterator endEffects() const;
|
||||
|
||||
std::string getPotionName() const;
|
||||
///< Return the name of the potion that would be created when calling create (if a record for such
|
||||
/// a potion already exists) or return an empty string.
|
||||
|
||||
Result create (const std::string& name);
|
||||
///< Try to create a potion from the ingredients, place it in the inventory of the alchemist and
|
||||
/// adjust the skills of the alchemist accordingly.
|
||||
/// \param name must not be an empty string, unless there is already a potion record (
|
||||
/// getPotionName() does not return an empty string).
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue