forked from mirror/openmw-tes3mp
added movement data to MW references; added movement interface to MWWorld::Class
This commit is contained in:
parent
ca44b3640a
commit
4468a2b6a8
7 changed files with 83 additions and 0 deletions
|
@ -207,6 +207,7 @@ set(GAMEMECHANICS_HEADER
|
|||
mwmechanics/stat.hpp
|
||||
mwmechanics/creaturestats.hpp
|
||||
mwmechanics/magiceffects.hpp
|
||||
mwmechanics/movement.hpp
|
||||
)
|
||||
source_group(apps\\openmw\\mwmechanics FILES ${GAMEMECHANICS} ${GAMEMECHANICS_HEADER})
|
||||
|
||||
|
|
|
@ -439,6 +439,33 @@ namespace MWClass
|
|||
return getStance (ptr, Run) ? 600 : 300; // TODO calculate these values from stats
|
||||
}
|
||||
|
||||
MWMechanics::Movement& Npc::getMovementSettings (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
if (!ptr.getRefData().getMovement().get())
|
||||
{
|
||||
boost::shared_ptr<MWMechanics::Movement> movement (
|
||||
new MWMechanics::Movement);
|
||||
}
|
||||
|
||||
return *ptr.getRefData().getMovement();
|
||||
}
|
||||
|
||||
Ogre::Vector3 Npc::getMovementVector (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
Ogre::Vector3 vector (0, 0, 0);
|
||||
|
||||
if (ptr.getRefData().getMovement().get())
|
||||
{
|
||||
vector.x = - ptr.getRefData().getMovement()->mLeftRight * 200;
|
||||
vector.z = - ptr.getRefData().getMovement()->mForwardBackward * 200;
|
||||
|
||||
if (getStance (ptr, Run, false))
|
||||
vector *= 2;
|
||||
}
|
||||
|
||||
return vector;
|
||||
}
|
||||
|
||||
void Npc::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Npc);
|
||||
|
|
|
@ -56,6 +56,13 @@ namespace MWClass
|
|||
virtual float getSpeed (const MWWorld::Ptr& ptr) const;
|
||||
///< Return movement speed.
|
||||
|
||||
virtual MWMechanics::Movement& getMovementSettings (const MWWorld::Ptr& ptr) const;
|
||||
///< Return desired movement.
|
||||
|
||||
virtual Ogre::Vector3 getMovementVector (const MWWorld::Ptr& ptr) const;
|
||||
///< Return desired movement vector (determined based on movement settings,
|
||||
/// stance and stats).
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
|
16
apps/openmw/mwmechanics/movement.hpp
Normal file
16
apps/openmw/mwmechanics/movement.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef GAME_MWMECHANICS_MOVEMENT_H
|
||||
#define GAME_MWMECHANICS_MOVEMENT_H
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
/// Desired movement for an actor
|
||||
struct Movement
|
||||
{
|
||||
signed char mLeftRight; // 1: wants to move left, -1: wants to move right
|
||||
signed char mForwardBackward; // 1:wants to move forward, -1: wants to move backward
|
||||
|
||||
Movement() : mLeftRight (0), mForwardBackward (0) {}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <stdexcept>
|
||||
|
||||
#include <OgreVector3.h>
|
||||
|
||||
#include "ptr.hpp"
|
||||
#include "nullaction.hpp"
|
||||
|
||||
|
@ -112,6 +114,16 @@ namespace MWWorld
|
|||
return 0;
|
||||
}
|
||||
|
||||
MWMechanics::Movement& Class::getMovementSettings (const Ptr& ptr) const
|
||||
{
|
||||
throw std::runtime_error ("movement settings not supported by class");
|
||||
}
|
||||
|
||||
Ogre::Vector3 Class::getMovementVector (const Ptr& ptr) const
|
||||
{
|
||||
return Ogre::Vector3 (0, 0, 0);
|
||||
}
|
||||
|
||||
const Class& Class::get (const std::string& key)
|
||||
{
|
||||
std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key);
|
||||
|
|
|
@ -10,6 +10,11 @@
|
|||
#include "containerstore.hpp"
|
||||
#include "refdata.hpp"
|
||||
|
||||
namespace Ogre
|
||||
{
|
||||
class Vector3;
|
||||
}
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
class CellRenderImp;
|
||||
|
@ -19,6 +24,7 @@ namespace MWMechanics
|
|||
{
|
||||
struct CreatureStats;
|
||||
struct NpcStats;
|
||||
struct Movement;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
|
@ -126,6 +132,13 @@ namespace MWWorld
|
|||
virtual float getSpeed (const Ptr& ptr) const;
|
||||
///< Return movement speed.
|
||||
|
||||
virtual MWMechanics::Movement& getMovementSettings (const Ptr& ptr) const;
|
||||
///< Return desired movement.
|
||||
|
||||
virtual Ogre::Vector3 getMovementVector (const Ptr& ptr) const;
|
||||
///< Return desired movement vector (determined based on movement settings,
|
||||
/// stance and stats).
|
||||
|
||||
static const Class& get (const std::string& key);
|
||||
///< If there is no class for this \a key, an exception is thrown.
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
#include "../mwmechanics/npcstats.hpp"
|
||||
#include "../mwmechanics/movement.hpp"
|
||||
|
||||
#include "containerstore.hpp"
|
||||
|
||||
|
@ -36,6 +37,7 @@ namespace MWWorld
|
|||
// are never copied outside of container operations.
|
||||
boost::shared_ptr<MWMechanics::CreatureStats> mCreatureStats;
|
||||
boost::shared_ptr<MWMechanics::NpcStats> mNpcStats;
|
||||
boost::shared_ptr<MWMechanics::Movement> mMovement;
|
||||
|
||||
boost::shared_ptr<ContainerStore<RefData> > mContainerStore;
|
||||
|
||||
|
@ -102,6 +104,11 @@ namespace MWWorld
|
|||
return mNpcStats;
|
||||
}
|
||||
|
||||
boost::shared_ptr<MWMechanics::Movement>& getMovement()
|
||||
{
|
||||
return mMovement;
|
||||
}
|
||||
|
||||
boost::shared_ptr<ContainerStore<RefData> >& getContainerStore()
|
||||
{
|
||||
return mContainerStore;
|
||||
|
|
Loading…
Reference in a new issue