1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-12 13:13:27 +00:00

replaced movement settings in ref data with new custom data implementation

This commit is contained in:
Marc Zinnschlag 2012-01-27 13:17:30 +01:00
parent aa87bd4030
commit b0256cea34
4 changed files with 12 additions and 28 deletions

View File

@ -3,6 +3,8 @@
#include <memory> #include <memory>
#include <OgreSceneNode.h>
#include <components/esm/loadnpc.hpp> #include <components/esm/loadnpc.hpp>
#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/creaturestats.hpp"
@ -12,9 +14,9 @@
#include "../mwworld/actiontalk.hpp" #include "../mwworld/actiontalk.hpp"
#include "../mwworld/environment.hpp" #include "../mwworld/environment.hpp"
#include "../mwworld/world.hpp" #include "../mwworld/world.hpp"
#include "../mwmechanics/movement.hpp"
#include "../mwmechanics/mechanicsmanager.hpp" #include "../mwmechanics/mechanicsmanager.hpp"
#include <OgreSceneNode.h>
namespace namespace
{ {
@ -25,6 +27,7 @@ namespace
{ {
MWMechanics::NpcStats mNpcStats; MWMechanics::NpcStats mNpcStats;
MWMechanics::CreatureStats mCreatureStats; MWMechanics::CreatureStats mCreatureStats;
MWMechanics::Movement mMovement;
virtual MWWorld::CustomData *clone() const; virtual MWWorld::CustomData *clone() const;
}; };
@ -253,29 +256,20 @@ namespace MWClass
MWMechanics::Movement& Npc::getMovementSettings (const MWWorld::Ptr& ptr) const MWMechanics::Movement& Npc::getMovementSettings (const MWWorld::Ptr& ptr) const
{ {
if (!ptr.getRefData().getMovement().get()) ensureCustomData (ptr);
{
boost::shared_ptr<MWMechanics::Movement> movement (
new MWMechanics::Movement);
ptr.getRefData().getMovement() = movement; return dynamic_cast<CustomData&> (*ptr.getRefData().getCustomData()).mMovement;
}
return *ptr.getRefData().getMovement();
} }
Ogre::Vector3 Npc::getMovementVector (const MWWorld::Ptr& ptr) const Ogre::Vector3 Npc::getMovementVector (const MWWorld::Ptr& ptr) const
{ {
Ogre::Vector3 vector (0, 0, 0); Ogre::Vector3 vector (0, 0, 0);
if (ptr.getRefData().getMovement().get()) vector.x = - getMovementSettings (ptr).mLeftRight * 200;
{ vector.y = getMovementSettings (ptr).mForwardBackward * 200;
vector.x = - ptr.getRefData().getMovement()->mLeftRight * 200;
vector.y = ptr.getRefData().getMovement()->mForwardBackward * 200;
if (getStance (ptr, Run, false)) if (getStance (ptr, Run, false))
vector *= 2; vector *= 2;
}
return vector; return vector;
} }

View File

@ -3,6 +3,8 @@
#include "../mwrender/player.hpp" #include "../mwrender/player.hpp"
#include "../mwmechanics/movement.hpp"
#include "world.hpp" #include "world.hpp"
#include "class.hpp" #include "class.hpp"

View File

@ -14,7 +14,6 @@ namespace MWWorld
mCount = refData.mCount; mCount = refData.mCount;
mPosition = refData.mPosition; mPosition = refData.mPosition;
mMovement = refData.mMovement;
mContainerStore = refData.mContainerStore; mContainerStore = refData.mContainerStore;
mCustomData = refData.mCustomData ? refData.mCustomData->clone() : 0; mCustomData = refData.mCustomData ? refData.mCustomData->clone() : 0;
@ -127,11 +126,6 @@ namespace MWWorld
mEnabled = true; mEnabled = true;
} }
boost::shared_ptr<MWMechanics::Movement>& RefData::getMovement()
{
return mMovement;
}
boost::shared_ptr<ContainerStore<RefData> >& RefData::getContainerStore() boost::shared_ptr<ContainerStore<RefData> >& RefData::getContainerStore()
{ {
return mContainerStore; return mContainerStore;

View File

@ -9,8 +9,6 @@
#include "../mwscript/locals.hpp" #include "../mwscript/locals.hpp"
#include "../mwmechanics/movement.hpp"
#include "containerstore.hpp" #include "containerstore.hpp"
namespace ESM namespace ESM
@ -42,8 +40,6 @@ namespace MWWorld
// assignment operator and destructor. As a consequence though copying a RefData object // assignment operator and destructor. As a consequence though copying a RefData object
// manually will probably give unexcepted results. This is not a problem since RefData // manually will probably give unexcepted results. This is not a problem since RefData
// are never copied outside of container operations. // are never copied outside of container operations.
boost::shared_ptr<MWMechanics::Movement> mMovement;
boost::shared_ptr<ContainerStore<RefData> > mContainerStore; boost::shared_ptr<ContainerStore<RefData> > mContainerStore;
void copy (const RefData& refData); void copy (const RefData& refData);
@ -86,8 +82,6 @@ namespace MWWorld
void disable(); void disable();
boost::shared_ptr<MWMechanics::Movement>& getMovement();
boost::shared_ptr<ContainerStore<RefData> >& getContainerStore(); boost::shared_ptr<ContainerStore<RefData> >& getContainerStore();
ESM::Position& getPosition(); ESM::Position& getPosition();