Big changes
This commit is contained in:
59
engine/server/entity.cpp
Normal file
59
engine/server/entity.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#include "utils/logger.h"
|
||||
|
||||
#include "server/entity.h"
|
||||
|
||||
IMPLEMENT_RTTI_BASE( Entity );
|
||||
|
||||
Entity::Entity() :
|
||||
m_position(0.0f), m_rotation(0.0f), m_scale(1.0f),
|
||||
m_model(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Entity::~Entity()
|
||||
{
|
||||
}
|
||||
|
||||
void Entity::LoadModel(const char* filename)
|
||||
{
|
||||
//m_model = g_modelManager->LoadModel(filename);
|
||||
//if (!m_model)
|
||||
//{
|
||||
// Msg("Failed to load %s, no physic or animation", filename);
|
||||
// return;
|
||||
//}
|
||||
|
||||
//// get model bounds
|
||||
//m_boundingBox = m_model->GetBoundingBox();
|
||||
}
|
||||
|
||||
IMPLEMENT_RTTI( LightEntity, Entity );
|
||||
|
||||
LightEntity::LightEntity()
|
||||
{
|
||||
}
|
||||
|
||||
LightEntity::~LightEntity()
|
||||
{
|
||||
}
|
||||
|
||||
void TestRTTI()
|
||||
{
|
||||
Entity* entity = new Entity();
|
||||
LogMsg("entity classname: %s", entity->GetRuntimeClass()->m_pClassName);
|
||||
|
||||
LightEntity* light = new LightEntity();
|
||||
LogMsg("light classname: %s", light->GetRuntimeClass()->m_pClassName);
|
||||
|
||||
LightEntity* lightCasted = DynamicCast< LightEntity, Entity >( entity );
|
||||
LogMsg("light from entity casted: %s", lightCasted ? "successful" : "failed");
|
||||
|
||||
delete entity;
|
||||
entity = light;
|
||||
|
||||
lightCasted = DynamicCast< LightEntity, Entity >( entity );
|
||||
LogMsg("light from entity(LightEntity) casted: %s", lightCasted ? "successful" : "failed");
|
||||
|
||||
entity = NULL;
|
||||
delete light;
|
||||
}
|
||||
58
engine/server/entity.h
Normal file
58
engine/server/entity.h
Normal file
@@ -0,0 +1,58 @@
|
||||
#ifndef GAME_OBJECT_H
|
||||
#define GAME_OBJECT_H
|
||||
|
||||
#include "utils/rtti.h"
|
||||
#include "utils/maths.h"
|
||||
#include "utils/str.h"
|
||||
|
||||
class Model;
|
||||
|
||||
enum EntityComponents
|
||||
{
|
||||
ENTITY_COMPONENTS_NONE,
|
||||
ENTITY_COMPONENTS_VISUAL,
|
||||
ENTITY_COMPONENTS_PHYSICS,
|
||||
ENTITY_COMPONENTS_COLLIDER,
|
||||
ENTITY_COMPONENTS_TRIGGER,
|
||||
ENTITY_COMPONENTS_GHOST,
|
||||
ENTITY_COMPONENTS_SOUND,
|
||||
ENTITY_COMPONENTS_PARTICLESYSTEM,
|
||||
|
||||
ENTITY_COMPONENTS_MAX
|
||||
};
|
||||
|
||||
class Entity
|
||||
{
|
||||
public:
|
||||
DECLARE_RTTI;
|
||||
|
||||
public:
|
||||
Entity();
|
||||
~Entity();
|
||||
|
||||
virtual void LoadModel(const char* filename);
|
||||
|
||||
public:
|
||||
Str m_name;
|
||||
|
||||
Vec3 m_position;
|
||||
Vec3 m_rotation;
|
||||
Vec3 m_scale;
|
||||
|
||||
Model* m_model;
|
||||
|
||||
};
|
||||
|
||||
class LightEntity : public Entity
|
||||
{
|
||||
public:
|
||||
DECLARE_RTTI;
|
||||
|
||||
public:
|
||||
LightEntity();
|
||||
~LightEntity();
|
||||
};
|
||||
|
||||
void TestRTTI();
|
||||
|
||||
#endif // !GAME_OBJECT_H
|
||||
Reference in New Issue
Block a user