2013-04-04 09:23:17 +00:00
|
|
|
#ifndef GAME_MWWORLD_LIVECELLREF_H
|
|
|
|
#define GAME_MWWORLD_LIVECELLREF_H
|
|
|
|
|
2013-08-13 13:32:20 +00:00
|
|
|
#include <typeinfo>
|
|
|
|
|
2013-04-04 10:13:15 +00:00
|
|
|
#include <components/esm/cellref.hpp>
|
2013-04-04 09:23:17 +00:00
|
|
|
|
|
|
|
#include "refdata.hpp"
|
|
|
|
|
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
class Ptr;
|
|
|
|
class ESMStore;
|
2013-08-16 11:18:48 +00:00
|
|
|
class Class;
|
2013-04-04 09:23:17 +00:00
|
|
|
|
2013-08-13 13:32:20 +00:00
|
|
|
/// Used to create pointers to hold any type of LiveCellRef<> object.
|
|
|
|
struct LiveCellRefBase
|
|
|
|
{
|
2013-08-16 11:18:48 +00:00
|
|
|
const Class *mClass;
|
2013-08-13 13:32:20 +00:00
|
|
|
|
2013-08-14 08:55:51 +00:00
|
|
|
/** Information about this instance, such as 3D location and rotation
|
|
|
|
* and individual type-dependent data.
|
|
|
|
*/
|
|
|
|
ESM::CellRef mRef;
|
|
|
|
|
|
|
|
/** runtime-data */
|
|
|
|
RefData mData;
|
|
|
|
|
2013-08-16 11:18:48 +00:00
|
|
|
LiveCellRefBase(std::string type, const ESM::CellRef &cref=ESM::CellRef());
|
2013-08-15 03:26:50 +00:00
|
|
|
/* Need this for the class to be recognized as polymorphic */
|
|
|
|
virtual ~LiveCellRefBase() { }
|
2013-08-13 13:32:20 +00:00
|
|
|
};
|
|
|
|
|
2013-04-04 09:23:17 +00:00
|
|
|
/// A reference to one object (of any type) in a cell.
|
|
|
|
///
|
|
|
|
/// Constructing this with a CellRef instance in the constructor means that
|
|
|
|
/// in practice (where D is RefData) the possibly mutable data is copied
|
|
|
|
/// across to mData. If later adding data (such as position) to CellRef
|
|
|
|
/// this would have to be manually copied across.
|
|
|
|
template <typename X>
|
2013-08-13 13:32:20 +00:00
|
|
|
struct LiveCellRef : public LiveCellRefBase
|
2013-04-04 09:23:17 +00:00
|
|
|
{
|
|
|
|
LiveCellRef(const ESM::CellRef& cref, const X* b = NULL)
|
2013-08-14 08:55:51 +00:00
|
|
|
: LiveCellRefBase(typeid(X).name(), cref), mBase(b)
|
2013-04-04 09:23:17 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
LiveCellRef(const X* b = NULL)
|
2013-08-14 08:55:51 +00:00
|
|
|
: LiveCellRefBase(typeid(X).name()), mBase(b)
|
2013-04-04 09:23:17 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
// The object that this instance is based on.
|
|
|
|
const X* mBase;
|
|
|
|
};
|
|
|
|
|
2013-04-04 10:23:06 +00:00
|
|
|
// template<typename X> bool operator==(const LiveCellRef<X>& ref, int pRefnum);
|
2013-04-04 09:23:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|