2010-08-03 09:14:57 +00:00
|
|
|
|
|
|
|
#include "class.hpp"
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
|
2010-08-03 09:49:12 +00:00
|
|
|
#include "ptr.hpp"
|
2010-08-03 16:20:15 +00:00
|
|
|
#include "nullaction.hpp"
|
2010-08-03 09:49:12 +00:00
|
|
|
|
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-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-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");
|
|
|
|
}
|
|
|
|
|
2010-08-03 16:44:52 +00:00
|
|
|
boost::shared_ptr<Action> Class::activate (const Ptr& ptr, const Ptr& actor,
|
|
|
|
const Environment& environment) const
|
2010-08-03 16:20:15 +00:00
|
|
|
{
|
|
|
|
return boost::shared_ptr<Action> (new NullAction);
|
|
|
|
}
|
|
|
|
|
2010-08-03 16:44:52 +00:00
|
|
|
boost::shared_ptr<Action> Class::use (const Ptr& ptr,
|
|
|
|
const Environment& environment) const
|
2010-08-03 16:20:15 +00:00
|
|
|
{
|
|
|
|
return boost::shared_ptr<Action> (new NullAction);
|
|
|
|
}
|
|
|
|
|
2010-08-05 13:40:03 +00:00
|
|
|
std::string Class::getScript (const Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2010-08-03 09:14:57 +00:00
|
|
|
const Class& Class::get (const std::string& key)
|
|
|
|
{
|
|
|
|
std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key);
|
|
|
|
|
|
|
|
if (iter==sClasses.end())
|
|
|
|
throw std::logic_error ("unknown class key: " + key);
|
|
|
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
}
|