mirror of https://github.com/OpenMW/openmw.git
commit
69ea00455f
@ -0,0 +1,26 @@
|
||||
|
||||
#include "activator.hpp"
|
||||
|
||||
#include <components/esm/loadacti.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Activator::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Activator, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Activator>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Activator::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Activator);
|
||||
|
||||
registerClass (typeid (ESM::Activator).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef GAME_MWCLASS_ACTIVATOR_H
|
||||
#define GAME_MWCLASS_ACTIVATOR_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Activator : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,26 @@
|
||||
|
||||
#include "apparatus.hpp"
|
||||
|
||||
#include <components/esm/loadappa.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Apparatus::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Apparatus, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Apparatus>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Apparatus::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Apparatus);
|
||||
|
||||
registerClass (typeid (ESM::Apparatus).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef GAME_MWCLASS_APPARATUS_H
|
||||
#define GAME_MWCLASS_APPARATUS_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Apparatus : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,39 @@
|
||||
|
||||
#include "armor.hpp"
|
||||
|
||||
#include <components/esm/loadarmo.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Armor::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Armor>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
bool Armor::hasItemHealth (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int Armor::getItemMaxHealth (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Armor, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Armor>();
|
||||
|
||||
return ref->base->data.health;
|
||||
}
|
||||
|
||||
void Armor::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Armor);
|
||||
|
||||
registerClass (typeid (ESM::Armor).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
#ifndef GAME_MWCLASS_ARMOR_H
|
||||
#define GAME_MWCLASS_ARMOR_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Armor : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const;
|
||||
///< \return Item health data available?
|
||||
|
||||
virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const;
|
||||
///< Return item max health or throw an exception, if class does not have item health
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,26 @@
|
||||
|
||||
#include "book.hpp"
|
||||
|
||||
#include <components/esm/loadbook.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Book::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Book, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Book>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Book::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Book);
|
||||
|
||||
registerClass (typeid (ESM::Book).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef GAME_MWCLASS_BOOK_H
|
||||
#define GAME_MWCLASS_BOOK_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Book : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,50 @@
|
||||
|
||||
#include "classes.hpp"
|
||||
|
||||
#include "activator.hpp"
|
||||
#include "creature.hpp"
|
||||
#include "npc.hpp"
|
||||
#include "weapon.hpp"
|
||||
#include "armor.hpp"
|
||||
#include "potion.hpp"
|
||||
#include "apparatus.hpp"
|
||||
#include "book.hpp"
|
||||
#include "clothing.hpp"
|
||||
#include "container.hpp"
|
||||
#include "door.hpp"
|
||||
#include "ingredient.hpp"
|
||||
#include "creaturelevlist.hpp"
|
||||
#include "itemlevlist.hpp"
|
||||
#include "light.hpp"
|
||||
#include "lockpick.hpp"
|
||||
#include "misc.hpp"
|
||||
#include "probe.hpp"
|
||||
#include "repair.hpp"
|
||||
#include "static.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void registerClasses()
|
||||
{
|
||||
Activator::registerSelf();
|
||||
Creature::registerSelf();
|
||||
Npc::registerSelf();
|
||||
Weapon::registerSelf();
|
||||
Armor::registerSelf();
|
||||
Potion::registerSelf();
|
||||
Apparatus::registerSelf();
|
||||
Book::registerSelf();
|
||||
Clothing::registerSelf();
|
||||
Container::registerSelf();
|
||||
Door::registerSelf();
|
||||
Ingredient::registerSelf();
|
||||
CreatureLevList::registerSelf();
|
||||
ItemLevList::registerSelf();
|
||||
Light::registerSelf();
|
||||
Lockpick::registerSelf();
|
||||
Misc::registerSelf();
|
||||
Probe::registerSelf();
|
||||
Repair::registerSelf();
|
||||
Static::registerSelf();
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
#ifndef GAME_MWCLASS_CLASSES_H
|
||||
#define GAME_MWCLASS_CLASSES_H
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void registerClasses();
|
||||
///< register all known classes
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,26 @@
|
||||
|
||||
#include "clothing.hpp"
|
||||
|
||||
#include <components/esm/loadclot.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Clothing::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Clothing, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Clothing>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Clothing::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Clothing);
|
||||
|
||||
registerClass (typeid (ESM::Clothing).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef GAME_MWCLASS_CLOTHING_H
|
||||
#define GAME_MWCLASS_CLOTHING_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Clothing : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,26 @@
|
||||
|
||||
#include "container.hpp"
|
||||
|
||||
#include <components/esm/loadcont.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Container::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Container>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Container::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Container);
|
||||
|
||||
registerClass (typeid (ESM::Container).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef GAME_MWCLASS_CONTAINER_H
|
||||
#define GAME_MWCLASS_CONTAINER_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Container : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,53 @@
|
||||
|
||||
#include "creature.hpp"
|
||||
|
||||
#include <components/esm/loadcrea.hpp>
|
||||
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Creature::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Creature>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
MWMechanics::CreatureStats& Creature::getCreatureStats (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
if (!ptr.getRefData().getCreatureStats().get())
|
||||
{
|
||||
boost::shared_ptr<MWMechanics::CreatureStats> stats (
|
||||
new MWMechanics::CreatureStats);
|
||||
|
||||
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref = ptr.get<ESM::Creature>();
|
||||
|
||||
stats->mAttributes[0].set (ref->base->data.strength);
|
||||
stats->mAttributes[1].set (ref->base->data.intelligence);
|
||||
stats->mAttributes[2].set (ref->base->data.willpower);
|
||||
stats->mAttributes[3].set (ref->base->data.agility);
|
||||
stats->mAttributes[4].set (ref->base->data.speed);
|
||||
stats->mAttributes[5].set (ref->base->data.endurance);
|
||||
stats->mAttributes[6].set (ref->base->data.personality);
|
||||
stats->mAttributes[7].set (ref->base->data.luck);
|
||||
stats->mDynamic[0].set (ref->base->data.health);
|
||||
stats->mDynamic[1].set (ref->base->data.mana);
|
||||
stats->mDynamic[2].set (ref->base->data.fatigue);
|
||||
|
||||
ptr.getRefData().getCreatureStats() = stats;
|
||||
}
|
||||
|
||||
return *ptr.getRefData().getCreatureStats();
|
||||
}
|
||||
|
||||
void Creature::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Creature);
|
||||
|
||||
registerClass (typeid (ESM::Creature).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
#ifndef GAME_MWCLASS_CREATURE_H
|
||||
#define GAME_MWCLASS_CREATURE_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Creature : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
virtual MWMechanics::CreatureStats& getCreatureStats (const MWWorld::Ptr& ptr) const;
|
||||
///< Return creature stats
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,19 @@
|
||||
|
||||
#include "creaturelevlist.hpp"
|
||||
|
||||
#include <components/esm/loadlevlist.hpp>
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string CreatureLevList::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void CreatureLevList::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new CreatureLevList);
|
||||
|
||||
registerClass (typeid (ESM::CreatureLevList).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef GAME_MWCLASS_CREATURELEVLIST_H
|
||||
#define GAME_MWCLASS_CREATURELEVLIST_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class CreatureLevList : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,62 @@
|
||||
|
||||
#include "door.hpp"
|
||||
|
||||
#include <components/esm/loaddoor.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwrender/playerpos.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/nullaction.hpp"
|
||||
#include "../mwworld/actionteleport.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
#include "../mwworld/world.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Door::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Door>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
boost::shared_ptr<MWWorld::Action> Door::activate (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Door, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Door>();
|
||||
|
||||
if (ref->ref.teleport)
|
||||
{
|
||||
// teleport door
|
||||
if (environment.mWorld->getPlayerPos().getPlayer()==actor)
|
||||
{
|
||||
// the player is using the door
|
||||
return boost::shared_ptr<MWWorld::Action> (
|
||||
new MWWorld::ActionTeleportPlayer (ref->ref.destCell, ref->ref.doorDest));
|
||||
}
|
||||
else
|
||||
{
|
||||
// another NPC or a create is using the door
|
||||
// TODO return action for teleporting other NPC/creature
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// animated door
|
||||
// TODO return action for rotating the door
|
||||
return boost::shared_ptr<MWWorld::Action> (new MWWorld::NullAction);
|
||||
}
|
||||
}
|
||||
|
||||
void Door::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Door);
|
||||
|
||||
registerClass (typeid (ESM::Door).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
#ifndef GAME_MWCLASS_DOOR_H
|
||||
#define GAME_MWCLASS_DOOR_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Door : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
virtual boost::shared_ptr<MWWorld::Action> activate (const MWWorld::Ptr& ptr,
|
||||
const MWWorld::Ptr& actor, const MWWorld::Environment& environment) const;
|
||||
///< Generate action for activation
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,26 @@
|
||||
|
||||
#include "ingredient.hpp"
|
||||
|
||||
#include <components/esm/loadingr.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Ingredient::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Ingredient, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Ingredient>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Ingredient::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Ingredient);
|
||||
|
||||
registerClass (typeid (ESM::Ingredient).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef GAME_MWCLASS_INGREDIENT_H
|
||||
#define GAME_MWCLASS_INGREDIENT_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Ingredient : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,19 @@
|
||||
|
||||
#include "itemlevlist.hpp"
|
||||
|
||||
#include <components/esm/loadlevlist.hpp>
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string ItemLevList::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void ItemLevList::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new ItemLevList);
|
||||
|
||||
registerClass (typeid (ESM::ItemLevList).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef GAME_MWCLASS_ITEMLEVLIST_H
|
||||
#define GAME_MWCLASS_ITEMLEVLIST_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class ItemLevList : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,29 @@
|
||||
|
||||
#include "light.hpp"
|
||||
|
||||
#include <components/esm/loadligh.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Light::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Light, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Light>();
|
||||
|
||||
if (ref->base->model.empty())
|
||||
return "";
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Light::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Light);
|
||||
|
||||
registerClass (typeid (ESM::Light).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef GAME_MWCLASS_LIGHT_H
|
||||
#define GAME_MWCLASS_LIGHT_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Light : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,26 @@
|
||||
|
||||
#include "lockpick.hpp"
|
||||
|
||||
#include <components/esm/loadlocks.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Lockpick::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Tool, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Tool>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Lockpick::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Lockpick);
|
||||
|
||||
registerClass (typeid (ESM::Tool).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef GAME_MWCLASS_LOCKPICK_H
|
||||
#define GAME_MWCLASS_LOCKPICK_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Lockpick : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,26 @@
|
||||
|
||||
#include "misc.hpp"
|
||||
|
||||
#include <components/esm/loadmisc.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Misc::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Misc, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Misc>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Misc::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Misc);
|
||||
|
||||
registerClass (typeid (ESM::Misc).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef GAME_MWCLASS_MISC_H
|
||||
#define GAME_MWCLASS_MISC_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Misc : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,53 @@
|
||||
|
||||
#include "npc.hpp"
|
||||
|
||||
#include <components/esm/loadnpc.hpp>
|
||||
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Npc::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::NPC>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
MWMechanics::CreatureStats& Npc::getCreatureStats (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
if (!ptr.getRefData().getCreatureStats().get())
|
||||
{
|
||||
boost::shared_ptr<MWMechanics::CreatureStats> stats (
|
||||
new MWMechanics::CreatureStats);
|
||||
|
||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref = ptr.get<ESM::NPC>();
|
||||
|
||||
stats->mAttributes[0].set (ref->base->npdt52.strength);
|
||||
stats->mAttributes[1].set (ref->base->npdt52.intelligence);
|
||||
stats->mAttributes[2].set (ref->base->npdt52.willpower);
|
||||
stats->mAttributes[3].set (ref->base->npdt52.agility);
|
||||
stats->mAttributes[4].set (ref->base->npdt52.speed);
|
||||
stats->mAttributes[5].set (ref->base->npdt52.endurance);
|
||||
stats->mAttributes[6].set (ref->base->npdt52.personality);
|
||||
stats->mAttributes[7].set (ref->base->npdt52.luck);
|
||||
stats->mDynamic[0].set (ref->base->npdt52.health);
|
||||
stats->mDynamic[1].set (ref->base->npdt52.mana);
|
||||
stats->mDynamic[2].set (ref->base->npdt52.fatigue);
|
||||
|
||||
ptr.getRefData().getCreatureStats() = stats;
|
||||
}
|
||||
|
||||
return *ptr.getRefData().getCreatureStats();
|
||||
}
|
||||
|
||||
void Npc::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Npc);
|
||||
|
||||
registerClass (typeid (ESM::NPC).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
#ifndef GAME_MWCLASS_NPC_H
|
||||
#define GAME_MWCLASS_NPC_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Npc : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
virtual MWMechanics::CreatureStats& getCreatureStats (const MWWorld::Ptr& ptr) const;
|
||||
///< Return creature stats
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,26 @@
|
||||
|
||||
#include "potion.hpp"
|
||||
|
||||
#include <components/esm/loadalch.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Potion::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Potion, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Potion>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Potion::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Potion);
|
||||
|
||||
registerClass (typeid (ESM::Potion).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef GAME_MWCLASS_POTION_H
|
||||
#define GAME_MWCLASS_POTION_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Potion : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,26 @@
|
||||
|
||||
#include "probe.hpp"
|
||||
|
||||
#include <components/esm/loadlocks.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Probe::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Probe, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Probe>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Probe::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Probe);
|
||||
|
||||
registerClass (typeid (ESM::Probe).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef GAME_MWCLASS_PROBE_H
|
||||
#define GAME_MWCLASS_PROBE_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Probe : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,26 @@
|
||||
|
||||
#include "repair.hpp"
|
||||
|
||||
#include <components/esm/loadlocks.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Repair::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Repair, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Repair>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
void Repair::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Repair);
|
||||
|
||||
registerClass (typeid (ESM::Repair).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef GAME_MWCLASS_REPAIR_H
|
||||
#define GAME_MWCLASS_REPAIR_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Repair : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,19 @@
|
||||
|
||||
#include "static.hpp"
|
||||
|
||||
#include <components/esm/loadstat.hpp>
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Static::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void Static::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Static);
|
||||
|
||||
registerClass (typeid (ESM::Static).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef GAME_MWCLASS_STATIC_H
|
||||
#define GAME_MWCLASS_STATIC_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Static : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,39 @@
|
||||
|
||||
#include "weapon.hpp"
|
||||
|
||||
#include <components/esm/loadweap.hpp>
|
||||
|
||||
#include <components/esm_store/cell_store.hpp>
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
std::string Weapon::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Weapon>();
|
||||
|
||||
return ref->base->name;
|
||||
}
|
||||
|
||||
bool Weapon::hasItemHealth (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int Weapon::getItemMaxHealth (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Weapon, MWWorld::RefData> *ref =
|
||||
ptr.get<ESM::Weapon>();
|
||||
|
||||
return ref->base->data.health;
|
||||
}
|
||||
|
||||
void Weapon::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Weapon);
|
||||
|
||||
registerClass (typeid (ESM::Weapon).name(), instance);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
#ifndef GAME_MWCLASS_WEAPON_H
|
||||
#define GAME_MWCLASS_WEAPON_H
|
||||
|
||||
#include "../mwworld/class.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
class Weapon : public MWWorld::Class
|
||||
{
|
||||
public:
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
virtual bool hasItemHealth (const MWWorld::Ptr& ptr) const;
|
||||
///< \return Item health data available?
|
||||
|
||||
virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const;
|
||||
///< Return item max health or throw an exception, if class does not have item health
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,25 @@
|
||||
#ifndef GAME_MWWORLD_ACTION_H
|
||||
#define GAME_MWWORLD_ACTION_H
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Environment;
|
||||
|
||||
/// \brief Abstract base for actions
|
||||
class Action
|
||||
{
|
||||
// not implemented
|
||||
Action (const Action& action);
|
||||
Action& operator= (const Action& action);
|
||||
|
||||
public:
|
||||
|
||||
Action() {}
|
||||
|
||||
virtual ~Action() {}
|
||||
|
||||
virtual void execute (Environment& environment) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,18 @@
|
||||
|
||||
#include "actionteleport.hpp"
|
||||
|
||||
#include "environment.hpp"
|
||||
#include "world.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
ActionTeleportPlayer::ActionTeleportPlayer (const std::string& cellName,
|
||||
const ESM::Position& position)
|
||||
: mCellName (cellName), mPosition (position)
|
||||
{}
|
||||
|
||||
void ActionTeleportPlayer::ActionTeleportPlayer::execute (Environment& environment)
|
||||
{
|
||||
environment.mWorld->changeCell (mCellName, mPosition);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
#ifndef GAME_MWWORLD_ACTIONTELEPORT_H
|
||||
#define GAME_MWWORLD_ACTIONTELEPORT_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <components/esm/defs.hpp>
|
||||
|
||||
#include "action.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class ActionTeleportPlayer : public Action
|
||||
{
|
||||
std::string mCellName;
|
||||
ESM::Position mPosition;
|
||||
|
||||
public:
|
||||
|
||||
ActionTeleportPlayer (const std::string& cellName, const ESM::Position& position);
|
||||
|
||||
virtual void execute (Environment& environment);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,63 @@
|
||||
|
||||
#include "class.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "ptr.hpp"
|
||||
#include "nullaction.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
std::map<std::string, boost::shared_ptr<Class> > Class::sClasses;
|
||||
|
||||
Class::Class() {}
|
||||
|
||||
Class::~Class() {}
|
||||
|
||||
MWMechanics::CreatureStats& Class::getCreatureStats (const Ptr& ptr) const
|
||||
{
|
||||
throw std::runtime_error ("class does not have creature stats");
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
boost::shared_ptr<Action> Class::activate (const Ptr& ptr, const Ptr& actor,
|
||||
const Environment& environment) const
|
||||
{
|
||||
return boost::shared_ptr<Action> (new NullAction);
|
||||
}
|
||||
|
||||
boost::shared_ptr<Action> Class::use (const Ptr& ptr,
|
||||
const Environment& environment) const
|
||||
{
|
||||
return boost::shared_ptr<Action> (new NullAction);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
const Class& Class::get (const Ptr& ptr)
|
||||
{
|
||||
return get (ptr.getTypeName());
|
||||
}
|
||||
|
||||
void Class::registerClass (const std::string& key, boost::shared_ptr<Class> instance)
|
||||
{
|
||||
sClasses.insert (std::make_pair (key, instance));
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
#ifndef GAME_MWWORLD_CLASS_H
|
||||
#define GAME_MWWORLD_CLASS_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "action.hpp"
|
||||
|
||||
namespace MWMechanics
|
||||
{
|
||||
struct CreatureStats;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Ptr;
|
||||
|
||||
/// \brief Base class for referenceable esm records
|
||||
class Class
|
||||
{
|
||||
static std::map<std::string, boost::shared_ptr<Class> > sClasses;
|
||||
|
||||
// not implemented
|
||||
Class (const Class&);
|
||||
Class& operator= (const Class&);
|
||||
|
||||
protected:
|
||||
|
||||
Class();
|
||||
|
||||
public:
|
||||
|
||||
virtual ~Class();
|
||||
|
||||
virtual std::string getName (const Ptr& ptr) const = 0;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
||||
virtual MWMechanics::CreatureStats& getCreatureStats (const Ptr& ptr) const;
|
||||
///< Return creature stats or throw an exception, if class does not have creature stats
|
||||
/// (default implementation: throw an exceoption)
|
||||
|
||||
virtual bool hasItemHealth (const Ptr& ptr) const;
|
||||
///< \return Item health data available? (default implementation: false)
|
||||
|
||||
virtual int getItemMaxHealth (const Ptr& ptr) const;
|
||||
///< Return item max health or throw an exception, if class does not have item health
|
||||
/// (default implementation: throw an exceoption)
|
||||
|
||||
virtual boost::shared_ptr<Action> activate (const Ptr& ptr, const Ptr& actor,
|
||||
const Environment& environment) const;
|
||||
///< Generate action for activation (default implementation: return a null action).
|
||||
|
||||
virtual boost::shared_ptr<Action> use (const Ptr& ptr, const Environment& environment)
|
||||
const;
|
||||
///< Generate action for using via inventory menu (default implementation: return a
|
||||
/// null action).
|
||||
|
||||
static const Class& get (const std::string& key);
|
||||
///< If there is no class for this \a key, an exception is thrown.
|
||||
|
||||
static const Class& get (const Ptr& ptr);
|
||||
///< If there is no class for this pointer, an exception is thrown.
|
||||
|
||||
static void registerClass (const std::string& key, boost::shared_ptr<Class> instance);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -0,0 +1,17 @@
|
||||
#ifndef GAME_MWWORLD_NULLACTION_H
|
||||
#define GAME_MWWORLD_NULLACTION_H
|
||||
|
||||
#include "action.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
/// \brief Action: do nothing
|
||||
class NullAction : public Action
|
||||
{
|
||||
public:
|
||||
|
||||
virtual void execute (Environment& environment) {}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue