2010-08-03 09:14:57 +00:00
|
|
|
|
|
|
|
#include "class.hpp"
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
|
2011-02-03 10:37:17 +00:00
|
|
|
#include <OgreVector3.h>
|
|
|
|
|
2012-07-25 13:18:17 +00:00
|
|
|
#include <components/esm/defs.hpp>
|
|
|
|
|
2010-08-03 09:49:12 +00:00
|
|
|
#include "ptr.hpp"
|
2012-07-25 13:18:17 +00:00
|
|
|
#include "refdata.hpp"
|
2010-08-03 16:20:15 +00:00
|
|
|
#include "nullaction.hpp"
|
2012-02-20 11:44:17 +00:00
|
|
|
#include "containerstore.hpp"
|
2010-08-03 09:49:12 +00:00
|
|
|
|
2012-07-03 11:15:20 +00:00
|
|
|
#include "../mwgui/tooltips.hpp"
|
|
|
|
|
2010-08-03 09:14:57 +00:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
std::map<std::string, boost::shared_ptr<Class> > Class::sClasses;
|
|
|
|
|
|
|
|
Class::Class() {}
|
|
|
|
|
|
|
|
Class::~Class() {}
|
|
|
|
|
2010-08-08 12:28:35 +00:00
|
|
|
std::string Class::getId (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not support ID retrieval");
|
|
|
|
}
|
|
|
|
|
2011-11-09 20:47:06 +00:00
|
|
|
void Class::insertObjectRendering (const Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
2010-08-14 07:20:47 +00:00
|
|
|
{
|
|
|
|
|
2011-11-09 23:06:55 +00:00
|
|
|
}
|
2012-04-08 17:44:11 +00:00
|
|
|
|
2012-04-23 13:27:03 +00:00
|
|
|
void Class::insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics) const
|
2012-04-08 17:44:11 +00:00
|
|
|
{
|
2011-11-09 23:06:55 +00:00
|
|
|
|
2010-08-14 07:20:47 +00:00
|
|
|
}
|
|
|
|
|
2012-07-13 06:50:46 +00:00
|
|
|
bool Class::apply (const MWWorld::Ptr& ptr, const std::string& id, const MWWorld::Ptr& actor) const
|
2012-06-24 14:23:43 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-07-13 07:03:17 +00:00
|
|
|
void Class::skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not represent an actor");
|
|
|
|
}
|
|
|
|
|
2010-08-03 09:49:12 +00:00
|
|
|
MWMechanics::CreatureStats& Class::getCreatureStats (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have creature stats");
|
|
|
|
}
|
|
|
|
|
2010-08-19 10:49:13 +00:00
|
|
|
MWMechanics::NpcStats& Class::getNpcStats (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have NPC stats");
|
|
|
|
}
|
|
|
|
|
2010-08-03 12:14:04 +00:00
|
|
|
bool Class::hasItemHealth (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int Class::getItemMaxHealth (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have item health");
|
|
|
|
}
|
|
|
|
|
2012-04-23 13:27:03 +00:00
|
|
|
boost::shared_ptr<Action> Class::activate (const Ptr& ptr, const Ptr& actor) const
|
2010-08-03 16:20:15 +00:00
|
|
|
{
|
|
|
|
return boost::shared_ptr<Action> (new NullAction);
|
|
|
|
}
|
|
|
|
|
2012-04-23 13:27:03 +00:00
|
|
|
boost::shared_ptr<Action> Class::use (const Ptr& ptr) const
|
2010-08-03 16:20:15 +00:00
|
|
|
{
|
|
|
|
return boost::shared_ptr<Action> (new NullAction);
|
|
|
|
}
|
|
|
|
|
2012-01-28 10:45:55 +00:00
|
|
|
ContainerStore& Class::getContainerStore (const Ptr& ptr) const
|
2010-08-04 12:37:23 +00:00
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have a container store");
|
2010-08-06 20:20:20 +00:00
|
|
|
}
|
|
|
|
|
2012-03-10 11:49:54 +00:00
|
|
|
InventoryStore& Class::getInventoryStore (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have an inventory store");
|
|
|
|
}
|
|
|
|
|
2010-08-30 09:56:55 +00:00
|
|
|
void Class::lock (const Ptr& ptr, int lockLevel) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not support locking");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Class::unlock (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not support unlocking");
|
|
|
|
}
|
|
|
|
|
2010-08-05 13:40:03 +00:00
|
|
|
std::string Class::getScript (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return "";
|
2010-08-04 12:37:23 +00:00
|
|
|
}
|
|
|
|
|
2011-01-18 09:45:29 +00:00
|
|
|
void Class::setForceStance (const Ptr& ptr, Stance stance, bool force) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("stance not supported by class");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Class::setStance (const Ptr& ptr, Stance stance, bool set) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("stance not supported by class");
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Class::getStance (const Ptr& ptr, Stance stance, bool ignoreForce) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
float Class::getSpeed (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-02-24 11:30:33 +00:00
|
|
|
float Class::getJump (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-03-16 18:00:14 +00:00
|
|
|
short Class::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not support enchanting");
|
|
|
|
}
|
|
|
|
|
2011-02-03 10:37:17 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2013-03-31 08:29:24 +00:00
|
|
|
Ogre::Vector3 Class::getRotationVector (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return Ogre::Vector3 (0, 0, 0);
|
|
|
|
}
|
|
|
|
|
2012-03-13 13:12:07 +00:00
|
|
|
std::pair<std::vector<int>, bool> Class::getEquipmentSlots (const Ptr& ptr) const
|
2012-03-13 12:45:50 +00:00
|
|
|
{
|
|
|
|
return std::make_pair (std::vector<int>(), false);
|
|
|
|
}
|
|
|
|
|
2012-04-23 13:27:03 +00:00
|
|
|
int Class::getEquipmentSkill (const Ptr& ptr) const
|
2012-03-13 13:12:07 +00:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2012-04-07 17:53:49 +00:00
|
|
|
int Class::getValue (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::logic_error ("value not supported by this class");
|
|
|
|
}
|
|
|
|
|
2012-05-15 20:31:52 +00:00
|
|
|
float Class::getCapacity (const MWWorld::Ptr& ptr) const
|
2012-05-15 19:17:00 +00:00
|
|
|
{
|
2012-05-15 19:34:00 +00:00
|
|
|
throw std::runtime_error ("capacity not supported by this class");
|
|
|
|
}
|
|
|
|
|
|
|
|
float Class::getEncumbrance (const MWWorld::Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("encumbrance not supported by class");
|
2012-05-15 19:17:00 +00:00
|
|
|
}
|
|
|
|
|
2012-10-27 11:33:54 +00:00
|
|
|
bool Class::isEssential (const MWWorld::Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-17 21:29:12 +00:00
|
|
|
bool Class::hasDetected (const MWWorld::Ptr& ptr, const MWWorld::Ptr& ptr2) const
|
2012-11-15 19:00:27 +00:00
|
|
|
{
|
2013-03-17 02:17:05 +00:00
|
|
|
return true;
|
2012-11-15 19:00:27 +00:00
|
|
|
}
|
|
|
|
|
2013-03-17 21:29:12 +00:00
|
|
|
float Class::getArmorRating (const MWWorld::Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error("Class does not support armor rating");
|
|
|
|
}
|
|
|
|
|
2010-08-03 09:14:57 +00:00
|
|
|
const Class& Class::get (const std::string& key)
|
|
|
|
{
|
2013-03-31 08:16:02 +00:00
|
|
|
if (key.empty())
|
|
|
|
throw std::logic_error ("Class::get(): attempting to get an empty key");
|
|
|
|
|
2010-08-03 09:14:57 +00:00
|
|
|
std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key);
|
|
|
|
|
|
|
|
if (iter==sClasses.end())
|
2013-03-31 08:16:02 +00:00
|
|
|
throw std::logic_error ("Class::get(): unknown class key: " + key);
|
2010-08-03 09:14:57 +00:00
|
|
|
|
|
|
|
return *iter->second;
|
|
|
|
}
|
|
|
|
|
2010-08-03 09:49:12 +00:00
|
|
|
const Class& Class::get (const Ptr& ptr)
|
|
|
|
{
|
|
|
|
return get (ptr.getTypeName());
|
|
|
|
}
|
|
|
|
|
2010-08-03 09:14:57 +00:00
|
|
|
void Class::registerClass (const std::string& key, boost::shared_ptr<Class> instance)
|
|
|
|
{
|
|
|
|
sClasses.insert (std::make_pair (key, instance));
|
|
|
|
}
|
2012-03-13 16:05:38 +00:00
|
|
|
|
2012-04-23 13:27:03 +00:00
|
|
|
std::string Class::getUpSoundId (const Ptr& ptr) const
|
2012-03-13 16:05:38 +00:00
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have an up sound");
|
|
|
|
}
|
|
|
|
|
2012-04-23 13:27:03 +00:00
|
|
|
std::string Class::getDownSoundId (const Ptr& ptr) const
|
2012-03-13 16:05:38 +00:00
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have an down sound");
|
|
|
|
}
|
2012-04-15 18:56:45 +00:00
|
|
|
|
2012-05-11 08:40:40 +00:00
|
|
|
|
2012-04-15 18:56:45 +00:00
|
|
|
std::string Class::getInventoryIcon (const MWWorld::Ptr& ptr) const
|
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have any inventory icon");
|
|
|
|
}
|
2012-05-11 08:40:40 +00:00
|
|
|
|
2012-04-24 00:02:03 +00:00
|
|
|
MWGui::ToolTipInfo Class::getToolTipInfo (const Ptr& ptr) const
|
2012-04-16 17:30:52 +00:00
|
|
|
{
|
|
|
|
throw std::runtime_error ("class does not have a tool tip");
|
|
|
|
}
|
|
|
|
|
2012-04-16 17:34:46 +00:00
|
|
|
bool Class::hasToolTip (const Ptr& ptr) const
|
2012-04-16 17:30:52 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2012-05-12 14:17:03 +00:00
|
|
|
|
|
|
|
std::string Class::getEnchantment (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
2012-05-21 08:58:04 +00:00
|
|
|
|
2012-05-25 16:23:06 +00:00
|
|
|
void Class::adjustScale(const MWWorld::Ptr& ptr,float& scale) const
|
2012-05-21 08:58:04 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-05-25 16:23:06 +00:00
|
|
|
void Class::adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const
|
|
|
|
{
|
|
|
|
}
|
2012-07-24 14:52:08 +00:00
|
|
|
|
2012-07-24 16:22:11 +00:00
|
|
|
std::string Class::getModel(const MWWorld::Ptr &ptr) const
|
2012-07-24 14:52:08 +00:00
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
2012-07-25 13:18:17 +00:00
|
|
|
|
2013-03-29 11:00:09 +00:00
|
|
|
std::string Class::applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const
|
2013-03-28 16:41:00 +00:00
|
|
|
{
|
|
|
|
throw std::runtime_error ("class can't be enchanted");
|
|
|
|
}
|
|
|
|
|
2012-07-25 13:18:17 +00:00
|
|
|
MWWorld::Ptr
|
2012-07-26 12:14:11 +00:00
|
|
|
Class::copyToCellImpl(const Ptr &ptr, CellStore &cell) const
|
2012-07-25 13:18:17 +00:00
|
|
|
{
|
|
|
|
throw std::runtime_error("unable to move class to cell");
|
|
|
|
}
|
|
|
|
|
|
|
|
MWWorld::Ptr
|
2012-07-26 12:14:11 +00:00
|
|
|
Class::copyToCell(const Ptr &ptr, CellStore &cell) const
|
2012-07-25 13:18:17 +00:00
|
|
|
{
|
2012-07-26 12:14:11 +00:00
|
|
|
Ptr newPtr = copyToCellImpl(ptr, cell);
|
2012-07-25 13:18:17 +00:00
|
|
|
|
|
|
|
return newPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
MWWorld::Ptr
|
2012-07-26 12:14:11 +00:00
|
|
|
Class::copyToCell(const Ptr &ptr, CellStore &cell, const ESM::Position &pos) const
|
2012-07-25 13:18:17 +00:00
|
|
|
{
|
2012-07-26 12:14:11 +00:00
|
|
|
Ptr newPtr = copyToCell(ptr, cell);
|
2012-07-25 13:18:17 +00:00
|
|
|
newPtr.getRefData().getPosition() = pos;
|
|
|
|
|
|
|
|
return newPtr;
|
|
|
|
}
|
2010-08-03 09:14:57 +00:00
|
|
|
}
|