mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-02 06:45:33 +00:00
Issue #324: Started turning NpcStats into a proper class; fixed a cmake script bug; fixed a namespace issue
This commit is contained in:
parent
1a5203749f
commit
771863e73b
8 changed files with 57 additions and 30 deletions
|
@ -60,7 +60,7 @@ add_openmw_dir (mwclass
|
|||
|
||||
add_openmw_dir (mwmechanics
|
||||
mechanicsmanager stat creaturestats magiceffects movement actors drawstate spells
|
||||
activespells
|
||||
activespells npcstats
|
||||
)
|
||||
|
||||
add_openmw_dir (mwbase
|
||||
|
|
|
@ -233,7 +233,8 @@ namespace MWClass
|
|||
|
||||
case Combat:
|
||||
|
||||
stats.mCombat = set;
|
||||
// Combat stance ignored for now; need to be determined based on draw state instead of
|
||||
// being maunally set.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -260,7 +261,7 @@ namespace MWClass
|
|||
|
||||
case Combat:
|
||||
|
||||
return stats.mCombat;
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -102,15 +102,15 @@ private:
|
|||
{
|
||||
if (windows.isGuiMode()) return;
|
||||
|
||||
DrawState state = player.getDrawState();
|
||||
if (state == DrawState_Weapon || state == DrawState_Nothing)
|
||||
MWMechanics::DrawState state = player.getDrawState();
|
||||
if (state == MWMechanics::DrawState_Weapon || state == MWMechanics::DrawState_Nothing)
|
||||
{
|
||||
player.setDrawState(DrawState_Spell);
|
||||
player.setDrawState(MWMechanics::DrawState_Spell);
|
||||
std::cout << "Player has now readied his hands for spellcasting!\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setDrawState(DrawState_Nothing);
|
||||
player.setDrawState(MWMechanics::DrawState_Nothing);
|
||||
std::cout << "Player does not have any kind of attack ready now.\n";
|
||||
}
|
||||
}
|
||||
|
@ -119,15 +119,15 @@ private:
|
|||
{
|
||||
if (windows.isGuiMode()) return;
|
||||
|
||||
DrawState state = player.getDrawState();
|
||||
if (state == DrawState_Spell || state == DrawState_Nothing)
|
||||
MWMechanics::DrawState state = player.getDrawState();
|
||||
if (state == MWMechanics::DrawState_Spell || state == MWMechanics::DrawState_Nothing)
|
||||
{
|
||||
player.setDrawState(DrawState_Weapon);
|
||||
player.setDrawState(MWMechanics::DrawState_Weapon);
|
||||
std::cout << "Player is now drawing his weapon.\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setDrawState(DrawState_Nothing);
|
||||
player.setDrawState(MWMechanics::DrawState_Nothing);
|
||||
std::cout << "Player does not have any kind of attack ready now.\n";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,14 @@
|
|||
|
||||
#undef DrawState
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
enum DrawState
|
||||
{
|
||||
DrawState_Weapon = 0,
|
||||
DrawState_Spell = 1,
|
||||
DrawState_Nothing = 2,
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
17
apps/openmw/mwmechanics/npcstats.cpp
Normal file
17
apps/openmw/mwmechanics/npcstats.cpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
|
||||
#include "npcstats.hpp"
|
||||
|
||||
MWMechanics::NpcStats::NpcStats()
|
||||
: mForceRun (false), mForceSneak (false), mRun (false), mSneak (false),
|
||||
mDrawState (DrawState_Nothing)
|
||||
{}
|
||||
|
||||
MWMechanics::DrawState MWMechanics::NpcStats::getDrawState() const
|
||||
{
|
||||
return mDrawState;
|
||||
}
|
||||
|
||||
void MWMechanics::NpcStats::setDrawState (DrawState state)
|
||||
{
|
||||
mDrawState = state;
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "stat.hpp"
|
||||
#include "drawstate.hpp"
|
||||
|
@ -16,10 +17,14 @@ namespace MWMechanics
|
|||
/// \note For technical reasons the spell list and the currently selected spell is also handled by
|
||||
/// CreatureStats, even though they are actually NPC stats.
|
||||
|
||||
struct NpcStats
|
||||
class NpcStats
|
||||
{
|
||||
// NPCs other than the player can only have one faction. But for the sake of consistency
|
||||
// we use the same data structure for the PC and the NPCs.
|
||||
DrawState mDrawState;
|
||||
|
||||
public:
|
||||
|
||||
/// NPCs other than the player can only have one faction. But for the sake of consistency
|
||||
/// we use the same data structure for the PC and the NPCs.
|
||||
/// \note the faction key must be in lowercase
|
||||
std::map<std::string, int> mFactionRank;
|
||||
|
||||
|
@ -29,11 +34,12 @@ namespace MWMechanics
|
|||
bool mForceSneak;
|
||||
bool mRun;
|
||||
bool mSneak;
|
||||
bool mCombat;
|
||||
DrawState mDrawState;
|
||||
|
||||
NpcStats() : mForceRun (false), mForceSneak (false), mRun (false), mSneak (false),
|
||||
mCombat (false) , mDrawState(DrawState_Nothing) {}
|
||||
NpcStats();
|
||||
|
||||
DrawState getDrawState() const;
|
||||
|
||||
void setDrawState (DrawState state);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -56,10 +56,10 @@ namespace MWWorld
|
|||
mClass = new_class;
|
||||
}
|
||||
|
||||
void Player::setDrawState(const DrawState& value)
|
||||
void Player::setDrawState (MWMechanics::DrawState state)
|
||||
{
|
||||
MWWorld::Ptr ptr = getPlayer();
|
||||
MWWorld::Class::get(ptr).getNpcStats(ptr).mDrawState = value;
|
||||
MWWorld::Class::get(ptr).getNpcStats(ptr).setDrawState (state);
|
||||
}
|
||||
|
||||
void Player::setAutoMove (bool enable)
|
||||
|
@ -111,10 +111,10 @@ namespace MWWorld
|
|||
MWWorld::Class::get (ptr).setStance (ptr, MWWorld::Class::Run, !running);
|
||||
}
|
||||
|
||||
DrawState Player::getDrawState()
|
||||
MWMechanics::DrawState Player::getDrawState()
|
||||
{
|
||||
MWWorld::Ptr ptr = getPlayer();
|
||||
return MWWorld::Class::get(ptr).getNpcStats(ptr).mDrawState;
|
||||
return MWWorld::Class::get(ptr).getNpcStats(ptr).getDrawState();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ namespace MWWorld
|
|||
|
||||
void setClass (const ESM::Class& class_);
|
||||
|
||||
void setDrawState(const DrawState& state);
|
||||
void setDrawState (MWMechanics::DrawState state);
|
||||
|
||||
std::string getName() const
|
||||
{
|
||||
|
@ -115,7 +115,7 @@ namespace MWWorld
|
|||
return mAutoMove;
|
||||
}
|
||||
|
||||
DrawState getDrawState();
|
||||
MWMechanics::DrawState getDrawState(); /// \todo constness
|
||||
|
||||
void setAutoMove (bool enable);
|
||||
|
||||
|
|
Loading…
Reference in a new issue