mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-01 17:45:34 +00:00
Undid some code clean up changes, and changed how some includes work
This commit is contained in:
parent
77d365e196
commit
ee36ace00b
6 changed files with 197 additions and 200 deletions
|
@ -46,7 +46,10 @@ namespace MyGUI
|
||||||
|
|
||||||
namespace MWInput
|
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 :
|
class InputManager :
|
||||||
public MWBase::InputManager,
|
public MWBase::InputManager,
|
||||||
public SFO::KeyListener,
|
public SFO::KeyListener,
|
||||||
|
@ -65,7 +68,6 @@ namespace MWInput
|
||||||
/// Clear all savegame-specific data
|
/// Clear all savegame-specific data
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
|
|
||||||
virtual void update(float dt, bool disableControls=false, bool disableEvents=false);
|
virtual void update(float dt, bool disableControls=false, bool disableEvents=false);
|
||||||
|
|
||||||
void setPlayer (MWWorld::Player* player) { mPlayer = player; }
|
void setPlayer (MWWorld::Player* player) { mPlayer = player; }
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "aipackage.hpp"
|
#include "aipackage.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "pathfinding.hpp"
|
#include "pathfinding.hpp"
|
||||||
#include "../../../components/esm/defs.hpp"
|
#include <components/esm/defs.hpp>
|
||||||
#include "../mwworld/class.hpp"
|
#include "../mwworld/class.hpp"
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "aipackage.hpp"
|
#include "aipackage.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "pathfinding.hpp"
|
#include "pathfinding.hpp"
|
||||||
#include "../../../components/esm/defs.hpp"
|
#include <components/esm/defs.hpp>
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#define GAME_MWMECHANICS_AIPACKAGE_H
|
#define GAME_MWMECHANICS_AIPACKAGE_H
|
||||||
|
|
||||||
#include "pathfinding.hpp"
|
#include "pathfinding.hpp"
|
||||||
#include "../../../components/esm/defs.hpp"
|
#include <components/esm/defs.hpp>
|
||||||
|
|
||||||
#include "obstacle.hpp"
|
#include "obstacle.hpp"
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,6 @@ namespace MWMechanics
|
||||||
typedef std::vector<ESM::ENAMstruct> TEffectsContainer;
|
typedef std::vector<ESM::ENAMstruct> TEffectsContainer;
|
||||||
typedef TEffectsContainer::const_iterator TEffectsIterator;
|
typedef TEffectsContainer::const_iterator TEffectsIterator;
|
||||||
|
|
||||||
/// Result of potion creation
|
|
||||||
/** Only Result_Success results in success **/
|
|
||||||
enum Result
|
enum Result
|
||||||
{
|
{
|
||||||
Result_Success,
|
Result_Success,
|
||||||
|
@ -44,46 +42,6 @@ namespace MWMechanics
|
||||||
Result_RandomFailure
|
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:
|
private:
|
||||||
|
|
||||||
MWWorld::Ptr mAlchemist;
|
MWWorld::Ptr mAlchemist;
|
||||||
|
@ -92,19 +50,19 @@ namespace MWMechanics
|
||||||
TEffectsContainer mEffects;
|
TEffectsContainer mEffects;
|
||||||
int mValue;
|
int mValue;
|
||||||
|
|
||||||
/// List all effects shared by at least two ingredients.
|
|
||||||
std::set<EffectKey> listEffects() const;
|
std::set<EffectKey> listEffects() const;
|
||||||
|
///< List all effects shared by at least two ingredients.
|
||||||
|
|
||||||
void applyTools (int flags, float& value) const;
|
void applyTools (int flags, float& value) const;
|
||||||
|
|
||||||
void updateEffects();
|
void updateEffects();
|
||||||
|
|
||||||
/// Return existing recrod for created potion (may return 0)
|
|
||||||
const ESM::Potion *getRecord() const;
|
const ESM::Potion *getRecord() const;
|
||||||
|
///< Return existing recrod for created potion (may return 0)
|
||||||
|
|
||||||
/// Remove selected ingredients from alchemist's inventory, cleanup selected ingredients and
|
|
||||||
/// update effect list accordingly.
|
|
||||||
void removeIngredients();
|
void removeIngredients();
|
||||||
|
///< Remove selected ingredients from alchemist's inventory, cleanup selected ingredients and
|
||||||
|
/// update effect list accordingly.
|
||||||
|
|
||||||
void addPotion (const std::string& name);
|
void addPotion (const std::string& name);
|
||||||
///< Add a potion to the alchemist's inventory.
|
///< Add a potion to the alchemist's inventory.
|
||||||
|
@ -116,6 +74,48 @@ namespace MWMechanics
|
||||||
///< Return chance of success.
|
///< Return chance of success.
|
||||||
|
|
||||||
int countIngredients() const;
|
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).
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,199 +21,194 @@ namespace MWRender
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
|
|
||||||
class Movement;
|
class Movement;
|
||||||
class CreatureStats;
|
class CreatureStats;
|
||||||
|
|
||||||
///Priority of actions
|
enum Priority {
|
||||||
enum Priority {
|
Priority_Default,
|
||||||
Priority_Default,
|
Priority_Jump,
|
||||||
Priority_Jump,
|
Priority_Movement,
|
||||||
Priority_Movement,
|
Priority_Hit,
|
||||||
Priority_Hit,
|
Priority_Weapon,
|
||||||
Priority_Weapon,
|
Priority_Knockdown,
|
||||||
Priority_Knockdown,
|
Priority_Torch,
|
||||||
Priority_Torch,
|
|
||||||
|
|
||||||
Priority_Death,
|
Priority_Death,
|
||||||
|
|
||||||
Num_Priorities
|
Num_Priorities
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Current action of the character
|
enum CharacterState {
|
||||||
enum CharacterState {
|
CharState_None,
|
||||||
CharState_None,
|
|
||||||
|
|
||||||
CharState_SpecialIdle,
|
CharState_SpecialIdle,
|
||||||
CharState_Idle,
|
CharState_Idle,
|
||||||
CharState_Idle2,
|
CharState_Idle2,
|
||||||
CharState_Idle3,
|
CharState_Idle3,
|
||||||
CharState_Idle4,
|
CharState_Idle4,
|
||||||
CharState_Idle5,
|
CharState_Idle5,
|
||||||
CharState_Idle6,
|
CharState_Idle6,
|
||||||
CharState_Idle7,
|
CharState_Idle7,
|
||||||
CharState_Idle8,
|
CharState_Idle8,
|
||||||
CharState_Idle9,
|
CharState_Idle9,
|
||||||
CharState_IdleSwim,
|
CharState_IdleSwim,
|
||||||
CharState_IdleSneak,
|
CharState_IdleSneak,
|
||||||
|
|
||||||
CharState_WalkForward,
|
CharState_WalkForward,
|
||||||
CharState_WalkBack,
|
CharState_WalkBack,
|
||||||
CharState_WalkLeft,
|
CharState_WalkLeft,
|
||||||
CharState_WalkRight,
|
CharState_WalkRight,
|
||||||
|
|
||||||
CharState_SwimWalkForward,
|
CharState_SwimWalkForward,
|
||||||
CharState_SwimWalkBack,
|
CharState_SwimWalkBack,
|
||||||
CharState_SwimWalkLeft,
|
CharState_SwimWalkLeft,
|
||||||
CharState_SwimWalkRight,
|
CharState_SwimWalkRight,
|
||||||
|
|
||||||
CharState_RunForward,
|
CharState_RunForward,
|
||||||
CharState_RunBack,
|
CharState_RunBack,
|
||||||
CharState_RunLeft,
|
CharState_RunLeft,
|
||||||
CharState_RunRight,
|
CharState_RunRight,
|
||||||
|
|
||||||
CharState_SwimRunForward,
|
CharState_SwimRunForward,
|
||||||
CharState_SwimRunBack,
|
CharState_SwimRunBack,
|
||||||
CharState_SwimRunLeft,
|
CharState_SwimRunLeft,
|
||||||
CharState_SwimRunRight,
|
CharState_SwimRunRight,
|
||||||
|
|
||||||
CharState_SneakForward,
|
CharState_SneakForward,
|
||||||
CharState_SneakBack,
|
CharState_SneakBack,
|
||||||
CharState_SneakLeft,
|
CharState_SneakLeft,
|
||||||
CharState_SneakRight,
|
CharState_SneakRight,
|
||||||
|
|
||||||
CharState_TurnLeft,
|
CharState_TurnLeft,
|
||||||
CharState_TurnRight,
|
CharState_TurnRight,
|
||||||
|
|
||||||
CharState_Jump,
|
CharState_Jump,
|
||||||
|
|
||||||
CharState_Death1,
|
CharState_Death1,
|
||||||
CharState_Death2,
|
CharState_Death2,
|
||||||
CharState_Death3,
|
CharState_Death3,
|
||||||
CharState_Death4,
|
CharState_Death4,
|
||||||
CharState_Death5,
|
CharState_Death5,
|
||||||
CharState_SwimDeath,
|
CharState_SwimDeath,
|
||||||
CharState_DeathKnockDown,
|
CharState_DeathKnockDown,
|
||||||
CharState_DeathKnockOut,
|
CharState_DeathKnockOut,
|
||||||
|
|
||||||
CharState_Hit,
|
CharState_Hit,
|
||||||
CharState_KnockDown,
|
CharState_KnockDown,
|
||||||
CharState_KnockOut,
|
CharState_KnockOut,
|
||||||
CharState_Block
|
CharState_Block
|
||||||
};
|
};
|
||||||
|
|
||||||
///Weapon type
|
enum WeaponType {
|
||||||
enum WeaponType {
|
WeapType_None,
|
||||||
WeapType_None,
|
|
||||||
|
|
||||||
WeapType_HandToHand,
|
WeapType_HandToHand,
|
||||||
WeapType_OneHand,
|
WeapType_OneHand,
|
||||||
WeapType_TwoHand,
|
WeapType_TwoHand,
|
||||||
WeapType_TwoWide,
|
WeapType_TwoWide,
|
||||||
WeapType_BowAndArrow,
|
WeapType_BowAndArrow,
|
||||||
WeapType_Crossbow,
|
WeapType_Crossbow,
|
||||||
WeapType_Thrown,
|
WeapType_Thrown,
|
||||||
WeapType_PickProbe,
|
WeapType_PickProbe,
|
||||||
|
|
||||||
WeapType_Spell
|
WeapType_Spell
|
||||||
};
|
};
|
||||||
|
|
||||||
///Specific, weapon based state of the character
|
enum UpperBodyCharacterState {
|
||||||
enum UpperBodyCharacterState {
|
UpperCharState_Nothing,
|
||||||
UpperCharState_Nothing,
|
UpperCharState_EquipingWeap,
|
||||||
UpperCharState_EquipingWeap,
|
UpperCharState_UnEquipingWeap,
|
||||||
UpperCharState_UnEquipingWeap,
|
UpperCharState_WeapEquiped,
|
||||||
UpperCharState_WeapEquiped,
|
UpperCharState_StartToMinAttack,
|
||||||
UpperCharState_StartToMinAttack,
|
UpperCharState_MinAttackToMaxAttack,
|
||||||
UpperCharState_MinAttackToMaxAttack,
|
UpperCharState_MaxAttackToMinHit,
|
||||||
UpperCharState_MaxAttackToMinHit,
|
UpperCharState_MinHitToHit,
|
||||||
UpperCharState_MinHitToHit,
|
UpperCharState_FollowStartToFollowStop,
|
||||||
UpperCharState_FollowStartToFollowStop,
|
UpperCharState_CastingSpell
|
||||||
UpperCharState_CastingSpell
|
};
|
||||||
};
|
|
||||||
|
|
||||||
///Current jumping state
|
enum JumpingState {
|
||||||
enum JumpingState {
|
JumpState_None,
|
||||||
JumpState_None,
|
JumpState_Falling,
|
||||||
JumpState_Falling,
|
JumpState_Landing
|
||||||
JumpState_Landing
|
};
|
||||||
};
|
|
||||||
|
|
||||||
class CharacterController
|
class CharacterController
|
||||||
{
|
{
|
||||||
MWWorld::Ptr mPtr;
|
MWWorld::Ptr mPtr;
|
||||||
MWRender::Animation *mAnimation;
|
MWRender::Animation *mAnimation;
|
||||||
|
|
||||||
typedef std::deque<std::pair<std::string,size_t> > AnimationQueue;
|
typedef std::deque<std::pair<std::string,size_t> > AnimationQueue;
|
||||||
AnimationQueue mAnimQueue;
|
AnimationQueue mAnimQueue;
|
||||||
|
|
||||||
CharacterState mIdleState;
|
CharacterState mIdleState;
|
||||||
std::string mCurrentIdle;
|
std::string mCurrentIdle;
|
||||||
|
|
||||||
CharacterState mMovementState;
|
CharacterState mMovementState;
|
||||||
std::string mCurrentMovement;
|
std::string mCurrentMovement;
|
||||||
float mMovementSpeed;
|
float mMovementSpeed;
|
||||||
float mMovementAnimVelocity;
|
float mMovementAnimVelocity;
|
||||||
|
|
||||||
CharacterState mDeathState;
|
CharacterState mDeathState;
|
||||||
std::string mCurrentDeath;
|
std::string mCurrentDeath;
|
||||||
|
|
||||||
CharacterState mHitState;
|
CharacterState mHitState;
|
||||||
std::string mCurrentHit;
|
std::string mCurrentHit;
|
||||||
|
|
||||||
UpperBodyCharacterState mUpperBodyState;
|
UpperBodyCharacterState mUpperBodyState;
|
||||||
|
|
||||||
JumpingState mJumpState;
|
JumpingState mJumpState;
|
||||||
std::string mCurrentJump;
|
std::string mCurrentJump;
|
||||||
|
|
||||||
WeaponType mWeaponType;
|
WeaponType mWeaponType;
|
||||||
std::string mCurrentWeapon;
|
std::string mCurrentWeapon;
|
||||||
|
|
||||||
bool mSkipAnim;
|
bool mSkipAnim;
|
||||||
|
|
||||||
// counted for skill increase
|
// counted for skill increase
|
||||||
float mSecondsOfSwimming;
|
float mSecondsOfSwimming;
|
||||||
float mSecondsOfRunning;
|
float mSecondsOfRunning;
|
||||||
|
|
||||||
std::string mAttackType; // slash, chop or thrust
|
std::string mAttackType; // slash, chop or thrust
|
||||||
void determineAttackType();
|
void determineAttackType();
|
||||||
|
|
||||||
void refreshCurrentAnims(CharacterState idle, CharacterState movement, bool force=false);
|
void refreshCurrentAnims(CharacterState idle, CharacterState movement, bool force=false);
|
||||||
|
|
||||||
void clearAnimQueue();
|
void clearAnimQueue();
|
||||||
|
|
||||||
bool updateWeaponState();
|
bool updateWeaponState();
|
||||||
bool updateCreatureState();
|
bool updateCreatureState();
|
||||||
|
|
||||||
void updateVisibility();
|
void updateVisibility();
|
||||||
|
|
||||||
void playRandomDeath(float startpoint = 0.0f);
|
void playRandomDeath(float startpoint = 0.0f);
|
||||||
|
|
||||||
/// choose a random animation group with \a prefix and numeric suffix
|
/// choose a random animation group with \a prefix and numeric suffix
|
||||||
/// @param num if non-NULL, the chosen animation number will be written here
|
/// @param num if non-NULL, the chosen animation number will be written here
|
||||||
std::string chooseRandomGroup (const std::string& prefix, int* num = NULL);
|
std::string chooseRandomGroup (const std::string& prefix, int* num = NULL);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim);
|
CharacterController(const MWWorld::Ptr &ptr, MWRender::Animation *anim);
|
||||||
virtual ~CharacterController();
|
virtual ~CharacterController();
|
||||||
|
|
||||||
// Be careful when to call this, see comment in Actors
|
// Be careful when to call this, see comment in Actors
|
||||||
void updateContinuousVfx();
|
void updateContinuousVfx();
|
||||||
|
|
||||||
void updatePtr(const MWWorld::Ptr &ptr);
|
void updatePtr(const MWWorld::Ptr &ptr);
|
||||||
|
|
||||||
void update(float duration);
|
void update(float duration);
|
||||||
|
|
||||||
void playGroup(const std::string &groupname, int mode, int count);
|
void playGroup(const std::string &groupname, int mode, int count);
|
||||||
void skipAnim();
|
void skipAnim();
|
||||||
bool isAnimPlaying(const std::string &groupName);
|
bool isAnimPlaying(const std::string &groupName);
|
||||||
|
|
||||||
bool kill();
|
bool kill();
|
||||||
void resurrect();
|
void resurrect();
|
||||||
bool isDead() const
|
bool isDead() const
|
||||||
{ return mDeathState != CharState_None; }
|
{ return mDeathState != CharState_None; }
|
||||||
|
|
||||||
void forceStateUpdate();
|
void forceStateUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
void getWeaponGroup(WeaponType weaptype, std::string &group);
|
void getWeaponGroup(WeaponType weaptype, std::string &group);
|
||||||
MWWorld::ContainerStoreIterator getActiveWeapon(CreatureStats &stats, MWWorld::InventoryStore &inv, WeaponType *weaptype);
|
MWWorld::ContainerStoreIterator getActiveWeapon(CreatureStats &stats, MWWorld::InventoryStore &inv, WeaponType *weaptype);
|
||||||
|
|
Loading…
Reference in a new issue