2012-01-24 11:23:22 +01:00
|
|
|
#ifndef GAME_MWWORLD_CUSTOMDATA_H
|
|
|
|
#define GAME_MWWORLD_CUSTOMDATA_H
|
|
|
|
|
2021-04-03 00:48:35 +02:00
|
|
|
#include <memory>
|
|
|
|
|
2015-11-29 14:13:14 +01:00
|
|
|
namespace MWClass
|
|
|
|
{
|
|
|
|
class CreatureCustomData;
|
|
|
|
class NpcCustomData;
|
|
|
|
class ContainerCustomData;
|
|
|
|
class DoorCustomData;
|
|
|
|
class CreatureLevListCustomData;
|
|
|
|
}
|
|
|
|
|
2012-01-24 11:23:22 +01:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
/// \brief Base class for the MW-class-specific part of RefData
|
|
|
|
class CustomData
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
virtual ~CustomData() {}
|
|
|
|
|
2021-04-03 00:48:35 +02:00
|
|
|
virtual std::unique_ptr<CustomData> clone() const = 0;
|
2015-11-29 14:13:14 +01:00
|
|
|
|
|
|
|
// Fast version of dynamic_cast<X&>. Needs to be overridden in the respective class.
|
|
|
|
|
|
|
|
virtual MWClass::CreatureCustomData& asCreatureCustomData();
|
2015-12-19 16:13:00 +01:00
|
|
|
virtual const MWClass::CreatureCustomData& asCreatureCustomData() const;
|
2015-11-29 14:13:14 +01:00
|
|
|
|
|
|
|
virtual MWClass::NpcCustomData& asNpcCustomData();
|
2015-12-18 15:27:06 +01:00
|
|
|
virtual const MWClass::NpcCustomData& asNpcCustomData() const;
|
2015-11-29 14:13:14 +01:00
|
|
|
|
|
|
|
virtual MWClass::ContainerCustomData& asContainerCustomData();
|
2018-12-03 20:21:40 +04:00
|
|
|
virtual const MWClass::ContainerCustomData& asContainerCustomData() const;
|
2015-11-29 14:13:14 +01:00
|
|
|
|
|
|
|
virtual MWClass::DoorCustomData& asDoorCustomData();
|
2015-12-19 15:57:37 +01:00
|
|
|
virtual const MWClass::DoorCustomData& asDoorCustomData() const;
|
2015-11-29 14:13:14 +01:00
|
|
|
|
|
|
|
virtual MWClass::CreatureLevListCustomData& asCreatureLevListCustomData();
|
2015-12-19 16:19:52 +01:00
|
|
|
virtual const MWClass::CreatureLevListCustomData& asCreatureLevListCustomData() const;
|
2012-01-24 11:23:22 +01:00
|
|
|
};
|
2021-04-03 12:59:44 +02:00
|
|
|
|
|
|
|
template <class T>
|
|
|
|
struct TypedCustomData : CustomData
|
|
|
|
{
|
|
|
|
std::unique_ptr<CustomData> clone() const final
|
|
|
|
{
|
|
|
|
return std::make_unique<T>(*static_cast<const T*>(this));
|
|
|
|
}
|
|
|
|
};
|
2012-01-24 11:23:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|