|
@@ -5,6 +5,12 @@
|
|
|
|
|
|
|
|
#define ENTITY_DEBUG(...) FURI_LOG_D("Entity", __VA_ARGS__)
|
|
#define ENTITY_DEBUG(...) FURI_LOG_D("Entity", __VA_ARGS__)
|
|
|
|
|
|
|
|
|
|
+static size_t entities_count = 0;
|
|
|
|
|
+
|
|
|
|
|
+size_t entities_get_count(void) {
|
|
|
|
|
+ return entities_count;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
struct Entity {
|
|
struct Entity {
|
|
|
Vector position;
|
|
Vector position;
|
|
|
const EntityDescription* behaviour;
|
|
const EntityDescription* behaviour;
|
|
@@ -12,6 +18,7 @@ struct Entity {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
Entity* entity_alloc(const EntityDescription* behaviour) {
|
|
Entity* entity_alloc(const EntityDescription* behaviour) {
|
|
|
|
|
+ entities_count++;
|
|
|
Entity* entity = malloc(sizeof(Entity));
|
|
Entity* entity = malloc(sizeof(Entity));
|
|
|
entity->position = VECTOR_ZERO;
|
|
entity->position = VECTOR_ZERO;
|
|
|
entity->behaviour = behaviour;
|
|
entity->behaviour = behaviour;
|
|
@@ -24,6 +31,7 @@ Entity* entity_alloc(const EntityDescription* behaviour) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void entity_free(Entity* entity) {
|
|
void entity_free(Entity* entity) {
|
|
|
|
|
+ entities_count--;
|
|
|
ENTITY_DEBUG("Freeing entity at %p", entity);
|
|
ENTITY_DEBUG("Freeing entity at %p", entity);
|
|
|
if(entity->context) {
|
|
if(entity->context) {
|
|
|
free(entity->context);
|
|
free(entity->context);
|