mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-24 20:51:35 +00:00
[ecs] Add basic entity and registry printing
Entities print their status and attached component names, registries print their component counts for each pool.
This commit is contained in:
parent
f5de553949
commit
9a74fb0a14
2 changed files with 32 additions and 0 deletions
|
@ -126,6 +126,8 @@ void ECS_SortComponentPoolRange (ecs_registry_t *registry, uint32_t component,
|
||||||
uint32_t ECS_NewEntity (ecs_registry_t *registry);
|
uint32_t ECS_NewEntity (ecs_registry_t *registry);
|
||||||
void ECS_DelEntity (ecs_registry_t *registry, uint32_t ent);
|
void ECS_DelEntity (ecs_registry_t *registry, uint32_t ent);
|
||||||
void ECS_RemoveEntities (ecs_registry_t *registry, uint32_t component);
|
void ECS_RemoveEntities (ecs_registry_t *registry, uint32_t component);
|
||||||
|
void ECS_PrintEntity (ecs_registry_t *registry, uint32_t ent);
|
||||||
|
void ECS_PrintRegistry (ecs_registry_t *registry);
|
||||||
|
|
||||||
uint32_t ECS_NewSubpoolRange (ecs_registry_t *registry, uint32_t component);
|
uint32_t ECS_NewSubpoolRange (ecs_registry_t *registry, uint32_t component);
|
||||||
void ECS_DelSubpoolRange (ecs_registry_t *registry, uint32_t component,
|
void ECS_DelSubpoolRange (ecs_registry_t *registry, uint32_t component,
|
||||||
|
|
|
@ -241,3 +241,33 @@ ECS_RemoveEntities (ecs_registry_t *registry, uint32_t component)
|
||||||
}
|
}
|
||||||
pool->count = 0;
|
pool->count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VISIBLE void
|
||||||
|
ECS_PrintEntity (ecs_registry_t *registry, uint32_t ent)
|
||||||
|
{
|
||||||
|
bool valid = ECS_EntValid (ent, registry);
|
||||||
|
printf ("%08x %s\n", ent,
|
||||||
|
valid ? "valid"
|
||||||
|
: ent < registry->num_entities ? "deleted"
|
||||||
|
: ent == nullent ? "null"
|
||||||
|
: "invalid");
|
||||||
|
if (!valid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (size_t i = 0; i < registry->components.size; i++) {
|
||||||
|
if (!Ent_HasComponent (ent, i, registry)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
printf ("%3zd %s\n", i, registry->components.a[i].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VISIBLE void
|
||||||
|
ECS_PrintRegistry (ecs_registry_t *registry)
|
||||||
|
{
|
||||||
|
printf ("%s\n", registry->name);
|
||||||
|
for (size_t i = 0; i < registry->components.size; i++) {
|
||||||
|
printf ("%3zd %7d %s\n", i, registry->comp_pools[i].count,
|
||||||
|
registry->components.a[i].name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue