It's clear enough what the type will be so no need to repeat it.
inline Handle<T> Entity::get_component()
{
for(Handle<Component> c: components)
- if(Handle<T> tc = dynamic_handle_cast<T>(c))
+ if(auto tc = dynamic_handle_cast<T>(c))
return tc;
return nullptr;
}
void Landscape::spawn_sent(Handle<Entity> entity, unsigned target)
{
- if(Handle<TerrainBlock> block = dynamic_handle_cast<TerrainBlock>(entity))
+ if(auto block = dynamic_handle_cast<TerrainBlock>(entity))
{
Messages::LandscapeData message;
block->terrain->send_data(message.heightmap);
if(!entity)
return; // TODO report the error somehow
- Handle<E> cast_entity = dynamic_handle_cast<E>(entity);
+ auto cast_entity = dynamic_handle_cast<E>(entity);
if(!cast_entity)
return;
void Replicator::component_created(const Events::ComponentCreated &event)
{
- if(Handle<Zygote> zygote = dynamic_handle_cast<Zygote>(event.component))
+ if(auto zygote = dynamic_handle_cast<Zygote>(event.component))
{
Handle<Entity> entity = zygote->get_entity();
Handle<Transform> transform = entity->get_transform();
else if(received_entity_id!=Zygote::NO_ID)
zygote->set_entity_id(received_entity_id);
}
- else if(Handle<Possessed> possessed = dynamic_handle_cast<Possessed>(event.component))
+ else if(auto possessed = dynamic_handle_cast<Possessed>(event.component))
{
Handle<Transform> transform = possessed->get_entity()->get_transform();
auto i = lower_bound_member(entities, transform, &ReplicatedEntity::transform);
{
event_observer.observe<Events::ComponentCreated>([this](auto &e){
if(!active_camera)
- if(Handle<Camera> camera = dynamic_handle_cast<Camera>(e.component))
+ if(auto camera = dynamic_handle_cast<Camera>(e.component))
set_active_camera(camera);
});
}
void Renderer::component_created(const Game::Events::ComponentCreated &event)
{
- Game::Handle<Game::Shape> shape = dynamic_handle_cast<Game::Shape>(event.component);
- if(shape)
+ if(auto shape = dynamic_handle_cast<Game::Shape>(event.component))
{
RenderedEntity &re = get_rendered_entity(event.component->get_entity());
if(!re.generated_mesh)
}
}
- Game::Handle<Game::MeshSource> mesh_source = dynamic_handle_cast<Game::MeshSource>(event.component);
- Game::Handle<DynamicMeshSource> dyn_mesh_src = dynamic_handle_cast<DynamicMeshSource>(event.component);
+ auto mesh_source = dynamic_handle_cast<Game::MeshSource>(event.component);
+ auto dyn_mesh_src = dynamic_handle_cast<DynamicMeshSource>(event.component);
if(mesh_source || dyn_mesh_src)
{
RenderedEntity &re = get_rendered_entity(event.component->get_entity());
}
}
- Game::Handle<Game::Light> light = dynamic_handle_cast<Game::Light>(event.component);
+ auto light = dynamic_handle_cast<Game::Light>(event.component);
if(light)
{
RenderedEntity &re = get_rendered_entity(event.component->get_entity());
void TerrainMeshCreator::component_created(const Game::Events::ComponentCreated &event)
{
- if(Game::Handle<Game::HeightmapTerrain> terrain = dynamic_handle_cast<Game::HeightmapTerrain>(event.component))
+ if(auto terrain = dynamic_handle_cast<Game::HeightmapTerrain>(event.component))
{
const GL::Technique &tech = stage.get_resources().get<GL::Technique>(terrain->get_technique_name());
GL::VertexFormat fmt = (GL::VERTEX3, GL::TEXCOORD2, GL::NORMAL3,GL::UNSIGNED_BYTE,