63 lines
1.5 KiB
C
63 lines
1.5 KiB
C
/**
|
|
* Copyright (c) 2026 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#pragma once
|
|
#include "component.h"
|
|
|
|
#define ENTITY_STATE_ACTIVE (1 << 0)
|
|
|
|
typedef struct {
|
|
uint8_t state;
|
|
} entity_t;
|
|
|
|
/**
|
|
* Initializes an entity with the given ID.
|
|
*
|
|
* @param entityId The ID of the entity to initialize.
|
|
*/
|
|
void entityInit(const entityid_t entityId);
|
|
|
|
/**
|
|
* Adds a component of the given type to the entity with the given ID.
|
|
*
|
|
* @param entityId The ID of the entity to add the component to.
|
|
* @param type The type of the component to add.
|
|
* @return The ID of the entity with component.
|
|
*/
|
|
componentid_t entityAddComponent(
|
|
const entityid_t entityId,
|
|
const componenttype_t type
|
|
);
|
|
|
|
/**
|
|
* Gets the ID of the component of the given type on the entity with the given
|
|
* ID, or COMPONENT_ID_INVALID if the entity lacks the component.
|
|
*
|
|
* @param entityId The ID of the entity to get the component from.
|
|
* @param type The type of the component to get.
|
|
* @return The ID of the component.
|
|
*/
|
|
componentid_t entityGetComponent(
|
|
const entityid_t entityId,
|
|
const componenttype_t type
|
|
);
|
|
|
|
/**
|
|
* Disposes of an entity with the given ID.
|
|
*
|
|
* @param entityId The ID of the entity to dispose of.
|
|
*/
|
|
void entityDispose(const entityid_t entityId);
|
|
|
|
/**
|
|
* Disposes of an entity and all of its position-component descendants
|
|
* recursively. If the entity has no position component, behaves like
|
|
* entityDispose.
|
|
*
|
|
* @param entityId The root entity ID.
|
|
*/
|
|
void entityDisposeDeep(const entityid_t entityId); |