Download Tutorial C Files H Files

dg_system_require

This function is used to check if the needed components are in the entity.

Usage

int dg_system_require(dg_entity_t *entity, unsigned int len, ...);

Example

if (!dg_system_require(entity, 3, "pos", "sprite", "texture")) return;

Source code

int dg_system_require(dg_entity_t *entity, unsigned int len, ...)
{
    va_list arg;
    unsigned int test = 0;

    va_start(arg, len);
    for (int i = 0; i < len; i++) {
        if (dg_entity_has_component(entity, va_arg(arg, char *)) >= 0)
            test++;
    }
    if (test == len)
        return 1;
    return 0;
}