convert all instances of copy+pasted type-system code to use the new macros
This commit is contained in:
parent
2ae39ff14f
commit
c9d9152e45
|
@ -2,6 +2,7 @@
|
||||||
#define __EFFECTS_DIMEFFECT_H_INCLUDED__
|
#define __EFFECTS_DIMEFFECT_H_INCLUDED__
|
||||||
|
|
||||||
#include "../framework/common.h"
|
#include "../framework/common.h"
|
||||||
|
#include "../framework/util/typesystem.h"
|
||||||
#include "effect.h"
|
#include "effect.h"
|
||||||
#include "../framework/graphics/color.h"
|
#include "../framework/graphics/color.h"
|
||||||
|
|
||||||
|
@ -10,12 +11,7 @@ class RenderContext;
|
||||||
class DimEffect : public Effect
|
class DimEffect : public Effect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static EFFECT_TYPE GetType()
|
TYPE_DEFINE(EFFECT_TYPE, "DimEffect");
|
||||||
{
|
|
||||||
static EFFECT_TYPE typeName = "DimEffect";
|
|
||||||
return typeName;
|
|
||||||
}
|
|
||||||
EFFECT_TYPE GetTypeOf() const { return GetType(); }
|
|
||||||
|
|
||||||
DimEffect();
|
DimEffect();
|
||||||
virtual ~DimEffect();
|
virtual ~DimEffect();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __EFFECTS_EFFECT_H_INCLUDED__
|
#define __EFFECTS_EFFECT_H_INCLUDED__
|
||||||
|
|
||||||
#include "../framework/common.h"
|
#include "../framework/common.h"
|
||||||
|
#include "../framework/util/typesystem.h"
|
||||||
|
|
||||||
class RenderContext;
|
class RenderContext;
|
||||||
|
|
||||||
|
@ -10,6 +11,8 @@ typedef const char* EFFECT_TYPE;
|
||||||
class Effect
|
class Effect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
TYPE_BASE(EFFECT_TYPE);
|
||||||
|
|
||||||
Effect();
|
Effect();
|
||||||
virtual ~Effect();
|
virtual ~Effect();
|
||||||
|
|
||||||
|
@ -28,13 +31,6 @@ public:
|
||||||
BOOL IsActive() const { return m_isActive; }
|
BOOL IsActive() const { return m_isActive; }
|
||||||
void MarkInactive();
|
void MarkInactive();
|
||||||
|
|
||||||
virtual EFFECT_TYPE GetTypeOf() const = 0;
|
|
||||||
|
|
||||||
template<class T> BOOL Is() const;
|
|
||||||
BOOL Is(EFFECT_TYPE type) const;
|
|
||||||
template<class T> T* As();
|
|
||||||
template<class T> const T* As() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BOOL m_isActive;
|
BOOL m_isActive;
|
||||||
};
|
};
|
||||||
|
@ -53,34 +49,5 @@ inline void Effect::MarkInactive()
|
||||||
m_isActive = FALSE;
|
m_isActive = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline BOOL Effect::Is() const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == T::GetType());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline BOOL Effect::Is(EFFECT_TYPE type) const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == type);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline T* Effect::As()
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const T* Effect::As() const
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (const T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __EFFECTS_FADEEFFECT_H_INCLUDED__
|
#define __EFFECTS_FADEEFFECT_H_INCLUDED__
|
||||||
|
|
||||||
#include "../framework/common.h"
|
#include "../framework/common.h"
|
||||||
|
#include "../framework/util/typesystem.h"
|
||||||
#include "effect.h"
|
#include "effect.h"
|
||||||
#include "../framework/graphics/color.h"
|
#include "../framework/graphics/color.h"
|
||||||
|
|
||||||
|
@ -10,12 +11,7 @@ class RenderContext;
|
||||||
class FadeEffect : public Effect
|
class FadeEffect : public Effect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static EFFECT_TYPE GetType()
|
TYPE_DEFINE(EFFECT_TYPE, "FadeEffect");
|
||||||
{
|
|
||||||
static EFFECT_TYPE typeName = "FadeEffect";
|
|
||||||
return typeName;
|
|
||||||
}
|
|
||||||
EFFECT_TYPE GetTypeOf() const { return GetType(); }
|
|
||||||
|
|
||||||
FadeEffect();
|
FadeEffect();
|
||||||
virtual ~FadeEffect();
|
virtual ~FadeEffect();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __EFFECTS_FLASHEFFECT_H_INCLUDED__
|
#define __EFFECTS_FLASHEFFECT_H_INCLUDED__
|
||||||
|
|
||||||
#include "../framework/common.h"
|
#include "../framework/common.h"
|
||||||
|
#include "../framework/util/typesystem.h"
|
||||||
#include "effect.h"
|
#include "effect.h"
|
||||||
#include "../framework/graphics/color.h"
|
#include "../framework/graphics/color.h"
|
||||||
|
|
||||||
|
@ -10,12 +11,7 @@ class RenderContext;
|
||||||
class FlashEffect : public Effect
|
class FlashEffect : public Effect
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static EFFECT_TYPE GetType()
|
TYPE_DEFINE(EFFECT_TYPE, "FlashEffect");
|
||||||
{
|
|
||||||
static EFFECT_TYPE typeName = "FlashEffect";
|
|
||||||
return typeName;
|
|
||||||
}
|
|
||||||
EFFECT_TYPE GetTypeOf() const { return GetType(); }
|
|
||||||
|
|
||||||
FlashEffect();
|
FlashEffect();
|
||||||
virtual ~FlashEffect();
|
virtual ~FlashEffect();
|
||||||
|
|
|
@ -2,21 +2,17 @@
|
||||||
#define __ENTITIES_COMPONENT_H_INCLUDED__
|
#define __ENTITIES_COMPONENT_H_INCLUDED__
|
||||||
|
|
||||||
#include "../framework/common.h"
|
#include "../framework/common.h"
|
||||||
|
#include "../framework/util/typesystem.h"
|
||||||
|
|
||||||
typedef const char* COMPONENT_TYPE;
|
typedef const char* COMPONENT_TYPE;
|
||||||
|
|
||||||
class Component
|
class Component
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
TYPE_BASE(COMPONENT_TYPE);
|
||||||
|
|
||||||
virtual ~Component();
|
virtual ~Component();
|
||||||
virtual void Reset();
|
virtual void Reset();
|
||||||
|
|
||||||
virtual COMPONENT_TYPE GetTypeOf() const = 0;
|
|
||||||
|
|
||||||
template<class T> BOOL Is() const;
|
|
||||||
BOOL Is(COMPONENT_TYPE type) const;
|
|
||||||
template<class T> T* As();
|
|
||||||
template<class T> const T* As() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline Component::~Component()
|
inline Component::~Component()
|
||||||
|
@ -27,34 +23,5 @@ inline void Component::Reset()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline BOOL Component::Is() const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == T::GetType());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline BOOL Component::Is(COMPONENT_TYPE type) const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == type);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline T* Component::As()
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const T* Component::As() const
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (const T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -3,16 +3,12 @@
|
||||||
|
|
||||||
#include "../component.h"
|
#include "../component.h"
|
||||||
#include "../entitypreset.h"
|
#include "../entitypreset.h"
|
||||||
|
#include "../../framework/util/typesystem.h"
|
||||||
|
|
||||||
class EntityPresetComponent : public Component
|
class EntityPresetComponent : public Component
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static COMPONENT_TYPE GetType()
|
TYPE_DEFINE(COMPONENT_TYPE, "EntityPresetComponent");
|
||||||
{
|
|
||||||
static COMPONENT_TYPE typeName = "EntityPresetComponent";
|
|
||||||
return typeName;
|
|
||||||
}
|
|
||||||
COMPONENT_TYPE GetTypeOf() const { return GetType(); }
|
|
||||||
|
|
||||||
EntityPresetComponent();
|
EntityPresetComponent();
|
||||||
void Reset();
|
void Reset();
|
||||||
|
|
|
@ -2,16 +2,12 @@
|
||||||
#define __ENTITIES_COMPONENTS_INACTIVECOMPONENT_H_INCLUDED__
|
#define __ENTITIES_COMPONENTS_INACTIVECOMPONENT_H_INCLUDED__
|
||||||
|
|
||||||
#include "../component.h"
|
#include "../component.h"
|
||||||
|
#include "../../framework/util/typesystem.h"
|
||||||
|
|
||||||
class InactiveComponent : public Component
|
class InactiveComponent : public Component
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static COMPONENT_TYPE GetType()
|
TYPE_DEFINE(COMPONENT_TYPE, "InactiveComponent");
|
||||||
{
|
|
||||||
static COMPONENT_TYPE typeName = "InactiveComponent";
|
|
||||||
return typeName;
|
|
||||||
}
|
|
||||||
COMPONENT_TYPE GetTypeOf() const { return GetType(); }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __ENTITIES_COMPONENTSYSTEM_H_INCLUDED__
|
#define __ENTITIES_COMPONENTSYSTEM_H_INCLUDED__
|
||||||
|
|
||||||
#include "../framework/common.h"
|
#include "../framework/common.h"
|
||||||
|
#include "../framework/util/typesystem.h"
|
||||||
#include "../events/eventlistenerex.h"
|
#include "../events/eventlistenerex.h"
|
||||||
|
|
||||||
class EntityManager;
|
class EntityManager;
|
||||||
|
@ -14,6 +15,8 @@ typedef const char* COMPONENTSYSTEM_TYPE;
|
||||||
class ComponentSystem : public EventListenerEx
|
class ComponentSystem : public EventListenerEx
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
TYPE_BASE(COMPONENTSYSTEM_TYPE);
|
||||||
|
|
||||||
virtual ~ComponentSystem();
|
virtual ~ComponentSystem();
|
||||||
|
|
||||||
virtual void OnLostContext() {}
|
virtual void OnLostContext() {}
|
||||||
|
@ -24,13 +27,6 @@ public:
|
||||||
|
|
||||||
virtual BOOL Handle(const Event *event);
|
virtual BOOL Handle(const Event *event);
|
||||||
|
|
||||||
virtual COMPONENTSYSTEM_TYPE GetTypeOf() const = 0;
|
|
||||||
|
|
||||||
template<class T> BOOL Is() const;
|
|
||||||
BOOL Is(COMPONENTSYSTEM_TYPE type) const;
|
|
||||||
template<class T> T* As();
|
|
||||||
template<class T> const T* As() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ComponentSystem(EntityManager *entityManager, EventManager *eventManager);
|
ComponentSystem(EntityManager *entityManager, EventManager *eventManager);
|
||||||
|
|
||||||
|
@ -55,34 +51,5 @@ inline BOOL ComponentSystem::Handle(const Event *event)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline BOOL ComponentSystem::Is() const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == T::GetType());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline BOOL ComponentSystem::Is(COMPONENTSYSTEM_TYPE type) const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == type);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline T* ComponentSystem::As()
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const T* ComponentSystem::As() const
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (const T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __ENTITIES_ENTITYPRESET_H_INCLUDED__
|
#define __ENTITIES_ENTITYPRESET_H_INCLUDED__
|
||||||
|
|
||||||
#include "../framework/common.h"
|
#include "../framework/common.h"
|
||||||
|
#include "../framework/util/typesystem.h"
|
||||||
#include "entitypresetargs.h"
|
#include "entitypresetargs.h"
|
||||||
|
|
||||||
typedef const char* ENTITYPRESET_TYPE;
|
typedef const char* ENTITYPRESET_TYPE;
|
||||||
|
@ -12,16 +13,11 @@ class EntityManager;
|
||||||
class EntityPreset
|
class EntityPreset
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
TYPE_BASE(ENTITYPRESET_TYPE);
|
||||||
|
|
||||||
EntityPreset(EntityManager *entityManager);
|
EntityPreset(EntityManager *entityManager);
|
||||||
virtual ~EntityPreset();
|
virtual ~EntityPreset();
|
||||||
|
|
||||||
virtual ENTITYPRESET_TYPE GetTypeOf() const = 0;
|
|
||||||
|
|
||||||
template<class T> BOOL Is() const;
|
|
||||||
BOOL Is(ENTITYPRESET_TYPE type) const;
|
|
||||||
template<class T> T* As();
|
|
||||||
template<class T> const T* As() const;
|
|
||||||
|
|
||||||
virtual Entity* Create(EntityPresetArgs *args = NULL) = 0;
|
virtual Entity* Create(EntityPresetArgs *args = NULL) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -40,33 +36,4 @@ inline EntityPreset::~EntityPreset()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline BOOL EntityPreset::Is() const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == T::GetType());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline BOOL EntityPreset::Is(ENTITYPRESET_TYPE type) const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == type);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline T* EntityPreset::As()
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const T* EntityPreset::As() const
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (const T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,46 +2,13 @@
|
||||||
#define __ENTITIES_ENTITYPRESETARGS_H_INCLUDED__
|
#define __ENTITIES_ENTITYPRESETARGS_H_INCLUDED__
|
||||||
|
|
||||||
#include "../framework/common.h"
|
#include "../framework/common.h"
|
||||||
|
#include "../framework/util/typesystem.h"
|
||||||
|
|
||||||
typedef const char* ENTITYPRESETARGS_TYPE;
|
typedef const char* ENTITYPRESETARGS_TYPE;
|
||||||
|
|
||||||
struct EntityPresetArgs
|
struct EntityPresetArgs
|
||||||
{
|
{
|
||||||
virtual ENTITYPRESETARGS_TYPE GetTypeOf() const = 0;
|
TYPE_BASE(ENTITYPRESETARGS_TYPE);
|
||||||
|
|
||||||
template<class T> BOOL Is() const;
|
|
||||||
BOOL Is(ENTITYPRESETARGS_TYPE type) const;
|
|
||||||
template<class T> T* As();
|
|
||||||
template<class T> const T* As() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline BOOL EntityPresetArgs::Is() const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == T::GetType());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline BOOL EntityPresetArgs::Is(ENTITYPRESETARGS_TYPE type) const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == type);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline T* EntityPresetArgs::As()
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const T* EntityPresetArgs::As() const
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (const T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,21 +2,17 @@
|
||||||
#define __ENTITIES_GLOBALCOMPONENT_H_INCLUDED__
|
#define __ENTITIES_GLOBALCOMPONENT_H_INCLUDED__
|
||||||
|
|
||||||
#include "../framework/common.h"
|
#include "../framework/common.h"
|
||||||
|
#include "../framework/util/typesystem.h"
|
||||||
|
|
||||||
typedef const char* GLOBAL_COMPONENT_TYPE;
|
typedef const char* GLOBAL_COMPONENT_TYPE;
|
||||||
|
|
||||||
class GlobalComponent
|
class GlobalComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
TYPE_BASE(GLOBAL_COMPONENT_TYPE);
|
||||||
|
|
||||||
virtual ~GlobalComponent();
|
virtual ~GlobalComponent();
|
||||||
virtual void Reset();
|
virtual void Reset();
|
||||||
|
|
||||||
virtual GLOBAL_COMPONENT_TYPE GetTypeOf() const = 0;
|
|
||||||
|
|
||||||
template<class T> BOOL Is() const;
|
|
||||||
BOOL Is(GLOBAL_COMPONENT_TYPE type) const;
|
|
||||||
template<class T> T* As();
|
|
||||||
template<class T> const T* As() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline GlobalComponent::~GlobalComponent()
|
inline GlobalComponent::~GlobalComponent()
|
||||||
|
@ -27,34 +23,5 @@ inline void GlobalComponent::Reset()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline BOOL GlobalComponent::Is() const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == T::GetType());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline BOOL GlobalComponent::Is(GLOBAL_COMPONENT_TYPE type) const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == type);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline T* GlobalComponent::As()
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const T* GlobalComponent::As() const
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (const T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __EVENTS_EVENT_H_INCLUDED__
|
#define __EVENTS_EVENT_H_INCLUDED__
|
||||||
|
|
||||||
#include "../framework/common.h"
|
#include "../framework/common.h"
|
||||||
|
#include "../framework/util/typesystem.h"
|
||||||
|
|
||||||
typedef const char* EVENT_TYPE;
|
typedef const char* EVENT_TYPE;
|
||||||
|
|
||||||
|
@ -9,46 +10,13 @@ const EVENT_TYPE EVENT_TYPE_WILDCARD = "EventWildcard";
|
||||||
|
|
||||||
struct Event
|
struct Event
|
||||||
{
|
{
|
||||||
virtual ~Event();
|
TYPE_BASE(EVENT_TYPE);
|
||||||
virtual EVENT_TYPE GetTypeOf() const = 0;
|
|
||||||
|
|
||||||
template<class T> BOOL Is() const;
|
virtual ~Event();
|
||||||
BOOL Is(EVENT_TYPE type) const;
|
|
||||||
template<class T> T* As();
|
|
||||||
template<class T> const T* As() const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inline Event::~Event()
|
inline Event::~Event()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline BOOL Event::Is() const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == T::GetType());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline BOOL Event::Is(EVENT_TYPE type) const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == type);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline T* Event::As()
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const T* Event::As() const
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (const T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <stl/string.h>
|
#include <stl/string.h>
|
||||||
#include "../../support/animationsequence.h"
|
#include "../../support/animationsequence.h"
|
||||||
#include "../../content/content.h"
|
#include "../../content/content.h"
|
||||||
|
#include "../../util/typesystem.h"
|
||||||
|
|
||||||
class Keyframe;
|
class Keyframe;
|
||||||
class KeyframeMeshFile;
|
class KeyframeMeshFile;
|
||||||
|
@ -19,12 +20,7 @@ class VertexBuffer;
|
||||||
class KeyframeMesh : public Content
|
class KeyframeMesh : public Content
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static CONTENT_TYPE GetType()
|
TYPE_DEFINE(CONTENT_TYPE, "KeyframeMesh");
|
||||||
{
|
|
||||||
static CONTENT_TYPE typeName = "KeyframeMesh";
|
|
||||||
return typeName;
|
|
||||||
}
|
|
||||||
CONTENT_TYPE GetTypeOf() const { return GetType(); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a keyframe mesh object.
|
* Creates a keyframe mesh object.
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "../../common.h"
|
#include "../../common.h"
|
||||||
#include "../../support/animationsequence.h"
|
#include "../../support/animationsequence.h"
|
||||||
#include "../../content/content.h"
|
#include "../../content/content.h"
|
||||||
|
#include "../../util/typesystem.h"
|
||||||
#include <stl/string.h>
|
#include <stl/string.h>
|
||||||
|
|
||||||
class SkeletalMeshFile;
|
class SkeletalMeshFile;
|
||||||
|
@ -18,12 +19,7 @@ class SkeletalMesh : public Content
|
||||||
friend class SkeletalMeshFile;
|
friend class SkeletalMeshFile;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static CONTENT_TYPE GetType()
|
TYPE_DEFINE(CONTENT_TYPE, "SkeletalMesh");
|
||||||
{
|
|
||||||
static CONTENT_TYPE typeName = "SkeletalMesh";
|
|
||||||
return typeName;
|
|
||||||
}
|
|
||||||
CONTENT_TYPE GetTypeOf() const { return GetType(); }
|
|
||||||
|
|
||||||
virtual ~SkeletalMesh();
|
virtual ~SkeletalMesh();
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "../../common.h"
|
#include "../../common.h"
|
||||||
#include "../../content/content.h"
|
#include "../../content/content.h"
|
||||||
|
#include "../../util/typesystem.h"
|
||||||
|
|
||||||
class ContentManager;
|
class ContentManager;
|
||||||
class StaticMeshFile;
|
class StaticMeshFile;
|
||||||
|
@ -14,12 +15,7 @@ class StaticMeshSubset;
|
||||||
class StaticMesh : public Content
|
class StaticMesh : public Content
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static CONTENT_TYPE GetType()
|
TYPE_DEFINE(CONTENT_TYPE, "StaticMesh");
|
||||||
{
|
|
||||||
static CONTENT_TYPE typeName = "StaticMesh";
|
|
||||||
return typeName;
|
|
||||||
}
|
|
||||||
CONTENT_TYPE GetTypeOf() const { return GetType(); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a static mesh object.
|
* Creates a static mesh object.
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __FRAMEWORK_CONTENT_CONTENT_H_INCLUDED__
|
#define __FRAMEWORK_CONTENT_CONTENT_H_INCLUDED__
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
|
#include "../util/typesystem.h"
|
||||||
|
|
||||||
class ContentLoaderBase;
|
class ContentLoaderBase;
|
||||||
|
|
||||||
|
@ -16,6 +17,8 @@ class Content
|
||||||
friend class ContentLoaderBase;
|
friend class ContentLoaderBase;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
TYPE_BASE(CONTENT_TYPE);
|
||||||
|
|
||||||
Content();
|
Content();
|
||||||
virtual ~Content();
|
virtual ~Content();
|
||||||
|
|
||||||
|
@ -39,37 +42,6 @@ public:
|
||||||
*/
|
*/
|
||||||
uint32_t GetNumReferences() const { return m_referenceCount; }
|
uint32_t GetNumReferences() const { return m_referenceCount; }
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the type of content being held in this object
|
|
||||||
*/
|
|
||||||
virtual CONTENT_TYPE GetTypeOf() const = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param <T> the type of content to check
|
|
||||||
* @return TRUE if this content object is of type T
|
|
||||||
*/
|
|
||||||
template<class T> BOOL Is() const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param type the content type to check
|
|
||||||
* @return TRUE if this content object is the same as the type specified
|
|
||||||
*/
|
|
||||||
BOOL Is(CONTENT_TYPE type) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param <T> the type of content to attempt to cast to
|
|
||||||
* @return this content object casted to type T if this content object
|
|
||||||
* is of type T, or NULL if the types don't match
|
|
||||||
*/
|
|
||||||
template<class T> T* As();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param <T> the type of content to attempt to cast to
|
|
||||||
* @return this content object casted to type T if this content object
|
|
||||||
* is of type T, or NULL if the types don't match
|
|
||||||
*/
|
|
||||||
template<class T> const T* As() const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Increments the reference counter by 1.
|
* Increments the reference counter by 1.
|
||||||
|
@ -86,34 +58,5 @@ private:
|
||||||
uint32_t m_referenceCount;
|
uint32_t m_referenceCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline BOOL Content::Is() const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == T::GetType());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline BOOL Content::Is(CONTENT_TYPE type) const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == type);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline T* Content::As()
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const T* Content::As() const
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (const T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../content/content.h"
|
#include "../content/content.h"
|
||||||
|
#include "../util/typesystem.h"
|
||||||
|
|
||||||
#include "color.h"
|
#include "color.h"
|
||||||
#include "imageformats.h"
|
#include "imageformats.h"
|
||||||
|
@ -15,12 +16,7 @@ class File;
|
||||||
class Image : public Content
|
class Image : public Content
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static CONTENT_TYPE GetType()
|
TYPE_DEFINE(CONTENT_TYPE, "Image");
|
||||||
{
|
|
||||||
static CONTENT_TYPE typeName = "Image";
|
|
||||||
return typeName;
|
|
||||||
}
|
|
||||||
CONTENT_TYPE GetTypeOf() const { return GetType(); }
|
|
||||||
|
|
||||||
Image();
|
Image();
|
||||||
virtual ~Image() { Release(); }
|
virtual ~Image() { Release(); }
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../content/content.h"
|
#include "../content/content.h"
|
||||||
|
#include "../util/typesystem.h"
|
||||||
|
|
||||||
class Texture;
|
class Texture;
|
||||||
class TextureAtlas;
|
class TextureAtlas;
|
||||||
|
@ -18,12 +19,7 @@ const uint8_t HIGH_GLYPH = 127;
|
||||||
class SpriteFont : public Content
|
class SpriteFont : public Content
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static CONTENT_TYPE GetType()
|
TYPE_DEFINE(CONTENT_TYPE, "SpriteFont");
|
||||||
{
|
|
||||||
static CONTENT_TYPE typeName = "SpriteFont";
|
|
||||||
return typeName;
|
|
||||||
}
|
|
||||||
CONTENT_TYPE GetTypeOf() const { return GetType(); }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an uninitialized sprite font object.
|
* Creates an uninitialized sprite font object.
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
#include "../content/content.h"
|
#include "../content/content.h"
|
||||||
|
#include "../util/typesystem.h"
|
||||||
#include "textureformats.h"
|
#include "textureformats.h"
|
||||||
|
|
||||||
class GraphicsDevice;
|
class GraphicsDevice;
|
||||||
|
@ -14,12 +15,7 @@ class Image;
|
||||||
class Texture : public Content
|
class Texture : public Content
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static CONTENT_TYPE GetType()
|
TYPE_DEFINE(CONTENT_TYPE, "Texture");
|
||||||
{
|
|
||||||
static CONTENT_TYPE typeName = "Texture";
|
|
||||||
return typeName;
|
|
||||||
}
|
|
||||||
CONTENT_TYPE GetTypeOf() const { return GetType(); }
|
|
||||||
|
|
||||||
Texture();
|
Texture();
|
||||||
virtual ~Texture();
|
virtual ~Texture();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __GAME_DEBUGINFOPROCESS_H_INCLUDED__
|
#define __GAME_DEBUGINFOPROCESS_H_INCLUDED__
|
||||||
|
|
||||||
#include "../processes/gameprocess.h"
|
#include "../processes/gameprocess.h"
|
||||||
|
#include "../framework/util/typesystem.h"
|
||||||
|
|
||||||
class GameState;
|
class GameState;
|
||||||
class ProcessManager;
|
class ProcessManager;
|
||||||
|
@ -10,12 +11,7 @@ class RenderContext;
|
||||||
class DebugInfoProcess : public GameProcess
|
class DebugInfoProcess : public GameProcess
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GAMEPROCESS_TYPE GetType()
|
TYPE_DEFINE(GAMEPROCESS_TYPE, "DebugInfoProcess");
|
||||||
{
|
|
||||||
static GAMEPROCESS_TYPE typeName = "DebugInfoProcess";
|
|
||||||
return typeName;
|
|
||||||
}
|
|
||||||
GAMEPROCESS_TYPE GetTypeOf() const { return GetType(); }
|
|
||||||
|
|
||||||
DebugInfoProcess(GameState *gameState, ProcessManager *processManager);
|
DebugInfoProcess(GameState *gameState, ProcessManager *processManager);
|
||||||
virtual ~DebugInfoProcess();
|
virtual ~DebugInfoProcess();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __GAME_TESTINGSTATE_H_INCLUDED__
|
#define __GAME_TESTINGSTATE_H_INCLUDED__
|
||||||
|
|
||||||
#include "../states/gamestate.h"
|
#include "../states/gamestate.h"
|
||||||
|
#include "../framework/util/typesystem.h"
|
||||||
|
|
||||||
class FreeCamera;
|
class FreeCamera;
|
||||||
class GameApp;
|
class GameApp;
|
||||||
|
@ -12,12 +13,7 @@ class StateManager;
|
||||||
class TestingState : public GameState
|
class TestingState : public GameState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GAMESTATE_TYPE GetType()
|
TYPE_DEFINE(GAMESTATE_TYPE, "TestingState");
|
||||||
{
|
|
||||||
static GAMESTATE_TYPE typeName = "TestingState";
|
|
||||||
return typeName;
|
|
||||||
}
|
|
||||||
GAMESTATE_TYPE GetTypeOf() const { return GetType(); }
|
|
||||||
|
|
||||||
TestingState(GameApp *gameApp, StateManager *stateManager);
|
TestingState(GameApp *gameApp, StateManager *stateManager);
|
||||||
virtual ~TestingState();
|
virtual ~TestingState();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __PROCESSES_GAMEPROCESS_H_INCLUDED__
|
#define __PROCESSES_GAMEPROCESS_H_INCLUDED__
|
||||||
|
|
||||||
#include "../framework/common.h"
|
#include "../framework/common.h"
|
||||||
|
#include "../framework/util/typesystem.h"
|
||||||
|
|
||||||
#include "../states/gamestate.h"
|
#include "../states/gamestate.h"
|
||||||
#include "../events/eventlistenerex.h"
|
#include "../events/eventlistenerex.h"
|
||||||
|
@ -16,6 +17,8 @@ struct Event;
|
||||||
class GameProcess : public EventListenerEx
|
class GameProcess : public EventListenerEx
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
TYPE_BASE(GAMEPROCESS_TYPE);
|
||||||
|
|
||||||
GameProcess(GameState *gameState, ProcessManager *processManager);
|
GameProcess(GameState *gameState, ProcessManager *processManager);
|
||||||
virtual ~GameProcess();
|
virtual ~GameProcess();
|
||||||
|
|
||||||
|
@ -36,13 +39,6 @@ public:
|
||||||
|
|
||||||
virtual BOOL Handle(const Event *event);
|
virtual BOOL Handle(const Event *event);
|
||||||
|
|
||||||
virtual GAMEPROCESS_TYPE GetTypeOf() const = 0;
|
|
||||||
|
|
||||||
template<class T> BOOL Is() const;
|
|
||||||
BOOL Is(GAMEPROCESS_TYPE type) const;
|
|
||||||
template<class T> T* As();
|
|
||||||
template<class T> const T* As() const;
|
|
||||||
|
|
||||||
GameApp* GetGameApp() const { return m_gameState->GetGameApp(); }
|
GameApp* GetGameApp() const { return m_gameState->GetGameApp(); }
|
||||||
|
|
||||||
BOOL IsFinished() const { return m_finished; }
|
BOOL IsFinished() const { return m_finished; }
|
||||||
|
@ -60,34 +56,5 @@ private:
|
||||||
BOOL m_finished;
|
BOOL m_finished;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline BOOL GameProcess::Is() const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == T::GetType());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline BOOL GameProcess::Is(GAMEPROCESS_TYPE type) const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == type);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline T* GameProcess::As()
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const T* GameProcess::As() const
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (const T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include "../framework/common.h"
|
#include "../framework/common.h"
|
||||||
#include "../framework/debug.h"
|
#include "../framework/debug.h"
|
||||||
|
#include "../framework/util/typesystem.h"
|
||||||
#include "gameprocess.h"
|
#include "gameprocess.h"
|
||||||
|
|
||||||
class GwenGameProcessUIController;
|
class GwenGameProcessUIController;
|
||||||
|
@ -14,12 +15,7 @@ struct Event;
|
||||||
class GwenGameProcess : public GameProcess
|
class GwenGameProcess : public GameProcess
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GAMEPROCESS_TYPE GetType()
|
TYPE_DEFINE(GAMEPROCESS_TYPE, "GwenGameProcess");
|
||||||
{
|
|
||||||
static GAMEPROCESS_TYPE typeName = "GwenGameProcess";
|
|
||||||
return typeName;
|
|
||||||
}
|
|
||||||
GAMEPROCESS_TYPE GetTypeOf() const { return GetType(); }
|
|
||||||
|
|
||||||
GwenGameProcess(GameState *gameState, ProcessManager *processManager);
|
GwenGameProcess(GameState *gameState, ProcessManager *processManager);
|
||||||
virtual ~GwenGameProcess();
|
virtual ~GwenGameProcess();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __STATES_GAMESTATE_H_INCLUDED__
|
#define __STATES_GAMESTATE_H_INCLUDED__
|
||||||
|
|
||||||
#include "../framework/common.h"
|
#include "../framework/common.h"
|
||||||
|
#include "../framework/util/typesystem.h"
|
||||||
#include "../events/eventlistenerex.h"
|
#include "../events/eventlistenerex.h"
|
||||||
|
|
||||||
typedef const char* GAMESTATE_TYPE;
|
typedef const char* GAMESTATE_TYPE;
|
||||||
|
@ -16,6 +17,8 @@ struct Event;
|
||||||
class GameState : public EventListenerEx
|
class GameState : public EventListenerEx
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
TYPE_BASE(GAMESTATE_TYPE);
|
||||||
|
|
||||||
GameState(GameApp *gameApp, StateManager *stateManager);
|
GameState(GameApp *gameApp, StateManager *stateManager);
|
||||||
virtual ~GameState();
|
virtual ~GameState();
|
||||||
|
|
||||||
|
@ -36,13 +39,6 @@ public:
|
||||||
|
|
||||||
virtual BOOL Handle(const Event *event);
|
virtual BOOL Handle(const Event *event);
|
||||||
|
|
||||||
virtual GAMESTATE_TYPE GetTypeOf() const = 0;
|
|
||||||
|
|
||||||
template<class T> BOOL Is() const;
|
|
||||||
BOOL Is(GAMESTATE_TYPE type) const;
|
|
||||||
template<class T> T* As();
|
|
||||||
template<class T> const T* As() const;
|
|
||||||
|
|
||||||
GameApp* GetGameApp() const { return m_gameApp; }
|
GameApp* GetGameApp() const { return m_gameApp; }
|
||||||
ProcessManager* GetProcessManager() const { return m_processManager; }
|
ProcessManager* GetProcessManager() const { return m_processManager; }
|
||||||
EffectManager* GetEffectManager() const { return m_effectManager; }
|
EffectManager* GetEffectManager() const { return m_effectManager; }
|
||||||
|
@ -69,34 +65,5 @@ private:
|
||||||
BOOL m_hasReturnValue;
|
BOOL m_hasReturnValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline BOOL GameState::Is() const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == T::GetType());
|
|
||||||
}
|
|
||||||
|
|
||||||
inline BOOL GameState::Is(GAMESTATE_TYPE type) const
|
|
||||||
{
|
|
||||||
return (GetTypeOf() == type);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline T* GameState::As()
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline const T* GameState::As() const
|
|
||||||
{
|
|
||||||
if (Is<T>())
|
|
||||||
return (const T*)this;
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define __STATES_GWENGAMESTATE_H_INCLUDED__
|
#define __STATES_GWENGAMESTATE_H_INCLUDED__
|
||||||
|
|
||||||
#include "../framework/common.h"
|
#include "../framework/common.h"
|
||||||
|
#include "../framework/util/typesystem.h"
|
||||||
#include "../framework/debug.h"
|
#include "../framework/debug.h"
|
||||||
#include "gamestate.h"
|
#include "gamestate.h"
|
||||||
|
|
||||||
|
@ -14,12 +15,7 @@ struct Event;
|
||||||
class GwenGameState : public GameState
|
class GwenGameState : public GameState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static GAMESTATE_TYPE GetType()
|
TYPE_DEFINE(GAMESTATE_TYPE, "GwenGameState");
|
||||||
{
|
|
||||||
static GAMESTATE_TYPE typeName = "GwenGameState";
|
|
||||||
return typeName;
|
|
||||||
}
|
|
||||||
GAMESTATE_TYPE GetTypeOf() const { return GetType(); }
|
|
||||||
|
|
||||||
GwenGameState(GameApp *gameApp, StateManager *stateManager);
|
GwenGameState(GameApp *gameApp, StateManager *stateManager);
|
||||||
virtual ~GwenGameState();
|
virtual ~GwenGameState();
|
||||||
|
|
Reference in a new issue