Fix grid entities set update bug for OOB entities
When entities are marked for deletion, the tilecoord components still exists, which can update the grid entities set, even if the entity is not alivescene_man
parent
e1afdf696a
commit
cd8ec0c7ed
|
@ -4,6 +4,8 @@
|
|||
void remove_entity_from_tilemap(EntityManager_t *p_manager, TileGrid_t* tilemap, Entity_t* p_ent)
|
||||
{
|
||||
CTileCoord_t* p_tilecoord = get_component(p_ent, CTILECOORD_COMP_T);
|
||||
if (p_tilecoord != NULL)
|
||||
{
|
||||
for (size_t i = 0;i < p_tilecoord->n_tiles; ++i)
|
||||
{
|
||||
// Use previously store tile position
|
||||
|
@ -11,6 +13,7 @@ void remove_entity_from_tilemap(EntityManager_t *p_manager, TileGrid_t* tilemap,
|
|||
unsigned int tile_idx = p_tilecoord->tiles[i];
|
||||
sc_map_del_64v(&(tilemap->tiles[tile_idx].entities_set), p_ent->m_id);
|
||||
}
|
||||
}
|
||||
remove_entity(p_manager, p_ent->m_id);
|
||||
}
|
||||
|
||||
|
|
|
@ -1305,6 +1305,7 @@ void update_tilemap_system(Scene_t* scene)
|
|||
sc_map_foreach(&scene->ent_manager.component_map[CTILECOORD_COMP_T], ent_idx, p_tilecoord)
|
||||
{
|
||||
Entity_t* p_ent = get_entity(&scene->ent_manager, ent_idx);
|
||||
if (!p_ent->m_alive) continue;
|
||||
CTransform_t* p_ctransform = get_component(p_ent, CTRANSFORM_COMP_T);
|
||||
if (p_ctransform == NULL) continue;
|
||||
CBBox_t* p_bbox = get_component(p_ent, CBBOX_COMP_T);
|
||||
|
|
Loading…
Reference in New Issue