2021-01-18 12:16:38 +00:00
|
|
|
#pragma once
|
|
|
|
#include "flecs/flecs.h"
|
|
|
|
#include "flecs/flecs_meta.h"
|
|
|
|
|
|
|
|
#include "components/general.h"
|
|
|
|
#include "components/physics.h"
|
|
|
|
|
|
|
|
ECS_STRUCT(Input, {
|
|
|
|
double x;
|
|
|
|
double y;
|
|
|
|
uint8_t use;
|
|
|
|
});
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
ECS_DECLARE_COMPONENT(Input);
|
2021-01-18 13:45:16 +00:00
|
|
|
ECS_DECLARE_ENTITY(EcsActor);
|
2021-01-18 12:16:38 +00:00
|
|
|
ECS_DECLARE_ENTITY(EcsPlayer);
|
|
|
|
ECS_DECLARE_ENTITY(EcsBuilder);
|
|
|
|
ECS_DECLARE_TYPE(Player);
|
|
|
|
ECS_DECLARE_TYPE(Builder);
|
|
|
|
} Controllers;
|
|
|
|
|
|
|
|
#define ControllersImportHandles(handles)\
|
|
|
|
ECS_IMPORT_COMPONENT(handles, Input);\
|
|
|
|
ECS_IMPORT_TYPE(handles, Player);\
|
|
|
|
ECS_IMPORT_TYPE(handles, Builder);\
|
2021-01-18 13:45:16 +00:00
|
|
|
ECS_IMPORT_ENTITY(handles, EcsActor);\
|
2021-01-18 12:16:38 +00:00
|
|
|
ECS_IMPORT_ENTITY(handles, EcsPlayer);\
|
|
|
|
ECS_IMPORT_ENTITY(handles, EcsBuilder);\
|
|
|
|
|
|
|
|
static inline void ControllersImport(ecs_world_t *ecs) {
|
|
|
|
ECS_MODULE(ecs, Controllers);
|
|
|
|
ecs_set_name_prefix(ecs, "Controllers");
|
|
|
|
|
|
|
|
ECS_IMPORT(ecs, General);
|
|
|
|
ECS_IMPORT(ecs, Physics);
|
|
|
|
|
|
|
|
ECS_IMPORT(ecs, FlecsMeta);
|
|
|
|
ECS_META(ecs, Input);
|
|
|
|
|
2021-01-18 13:45:16 +00:00
|
|
|
ECS_TAG(ecs, EcsActor);
|
2021-01-18 12:16:38 +00:00
|
|
|
ECS_TAG(ecs, EcsPlayer);
|
|
|
|
ECS_TAG(ecs, EcsBuilder);
|
|
|
|
|
2021-01-18 13:48:28 +00:00
|
|
|
ECS_PREFAB(ecs, Base, general.Position, physics.Velocity, Input, EcsActor);
|
2021-01-18 13:45:16 +00:00
|
|
|
ECS_TYPE(ecs, Player, INSTANCEOF | Base, SWITCH | physics.Movement, CASE | physics.Walking, EcsActor, EcsPlayer);
|
|
|
|
ECS_TYPE(ecs, Builder, INSTANCEOF | Base, SWITCH | physics.Movement, CASE | physics.Flying, EcsActor, EcsBuilder);
|
2021-01-18 12:16:38 +00:00
|
|
|
|
|
|
|
ECS_SET_COMPONENT(Input);
|
2021-01-18 13:45:16 +00:00
|
|
|
ECS_SET_ENTITY(EcsActor);
|
2021-01-18 12:16:38 +00:00
|
|
|
ECS_SET_ENTITY(EcsPlayer);
|
|
|
|
ECS_SET_ENTITY(EcsBuilder);
|
|
|
|
ECS_SET_TYPE(Builder);
|
|
|
|
ECS_SET_TYPE(Player);
|
|
|
|
}
|