new ecs system, hopefully better

This commit is contained in:
Carlos Sanchez 2024-08-18 19:07:45 -04:00
parent b919ac30f4
commit 7a14287e53
4 changed files with 322 additions and 67 deletions

95
ecs2.h Normal file
View File

@ -0,0 +1,95 @@
// A purely global, all macro-driven ecs implementation.
// You are expected to have only a need for a global
// ecs when using this.
#ifndef __HALOO3D_ECS2_H
#define __HALOO3D_ECS2_H
#include <stdint.h>
#ifndef ECS_MAXENTITIES
#define ECS_MAXENTITIES 1024
#endif
#define ECS_MAXCTYPES 63 // uint64 bits minus one
typedef uint64_t ecs_cid;
typedef int ecs_eid;
#define ECS_START(name) \
typedef struct { \
ecs_cid entities[ECS_MAXENTITIES]; \
ecs_eid entitytop;
#define ECS_END(name) \
} \
name; \
static void name##_init(name *_ecs) { memset(_ecs, 0, sizeof(name)); } \
static ecs_eid name##_newentity(name *_ecs, ecs_cid basecomponents) { \
for (int i = 0; i < ECS_MAXENTITIES; i++) { \
ecs_eid id = _ecs->entitytop++; \
if (_ecs->entities[id] == 0) { \
_ecs->entities[id] = (1ULL << ECS_MAXCTYPES) | basecomponents; \
return id; \
} \
} \
return -1; \
} \
static void name##_deleteentity(name *_ecs, ecs_eid eid) { \
if (eid >= 0 && eid < ECS_MAXENTITIES) \
_ecs->entities[eid] = 0; \
} \
static int name##_match(name *_ecs, ecs_eid _eid, ecs_cid _comps) { \
ecs_cid _realcomps = (1ULL << ECS_MAXCTYPES) | _comps; \
return (_ecs->entities[_eid] & _realcomps) == _realcomps; \
}
#define ECS_COMPONENT(type) type c_##type[ECS_MAXENTITIES];
#define ECS_CID(type, id) \
const int type##_id = id; \
const ecs_cid type##_fl = (1ULL << id);
// Set the given entity to have the given component (by type). Follow this
// macro immediately with the struct initializer
#define ECS_SETCOMPONENT(_ecs, eid, type) \
(_ecs)->entities[eid] |= type##_fl; \
(_ecs)->c_##type[eid] = (type)
// Add a system function which automatically calls your given function with
// pre-pulled items from the entity component arrays. The new function is
// named the same as the old one, just with _run appeneded
#define ECS_SYSTEM1(ecsname, fname, type1) \
void fname##_run(ecsname *_ecs, ecs_eid eid) { \
ecs_cid _ecsflags = type1##_fl; \
if (ecsname##_match(_ecs, eid, _ecsflags)) { \
fname(_ecs->c_##type1 + eid); \
} \
}
#define ECS_SYSTEM2(ecsname, fname, type1, type2) \
void fname##_run(ecsname *_ecs, ecs_eid eid) { \
ecs_cid _ecsflags = type1##_fl | type2##_fl; \
if (ecsname##_match(_ecs, eid, _ecsflags)) { \
fname(_ecs->c_##type1 + eid, _ecs->c_##type2 + eid); \
} \
}
#define ECS_SYSTEM3(ecsname, fname, type1, type2, type3) \
void fname##_run(ecsname *_ecs, ecs_eid eid) { \
ecs_cid _ecsflags = type1##_fl | type2##_fl | type3##_fl; \
if (ecsname##_match(_ecs, eid, _ecsflags)) { \
fname(_ecs->c_##type1 + eid, _ecs->c_##type2 + eid, \
_ecs->c_##type3 + eid); \
} \
}
#define ECS_SYSTEM4(ecsname, fname, type1, type2, type3, type4) \
void fname##_run(ecsname *_ecs, ecs_eid eid) { \
ecs_cid _ecsflags = type1##_fl | type2##_fl | type3##_fl | type4##_fl; \
if (ecsname##_match(_ecs, eid, _ecsflags)) { \
fname(_ecs->c_##type1 + eid, _ecs->c_##type2 + eid, \
_ecs->c_##type3 + eid, _ecs->c_##type4 + eid); \
} \
}
#endif

123
ecs2_comps.h Normal file
View File

@ -0,0 +1,123 @@
// A bunch of component definitions that might not
// be useful in general, but who knows?
#ifndef __HALOO3D_ECS2COMP_H
#define __HALOO3D_ECS2COMP_H
#include "ecs2.h"
#include "haloo3d/haloo3d.h"
// A component that simply points back to an object instance. If combined
// with movement, will pull pos from objin at start of frame, then write
// pos back to obj at end of frame.
typedef haloo3d_obj_instance *ecs_objin;
// Like objin, this component simply points to a camera. It will set the
// position AND rotation at the start of the frame, and pull the pos/
// rotation back into the camera at the end.
typedef haloo3d_camera *ecs_camera;
typedef struct {
struct vec3 pos;
struct vec3 dst;
int timer;
} ecs_moveto;
typedef struct {
struct vec2 rot;
struct vec2 dstrot;
int timer;
} ecs_rotateto;
// Move object position into moveto
// static void sys_ecs_objin_moveto(haloo_ecs *ecs, hecs_eidt id, hecs_cidt
// oiid,
// hecs_cidt mtid) {
// eprintf("Objin moveto %ld, %ld\n", oiid, mtid);
// ecs_moveto *mt = HECS_ENTITYCOMPONENT(ecs_moveto *, id, mtid, ecs);
// ecs_objin *oi = HECS_ENTITYCOMPONENT(ecs_objin *, id, oiid, ecs);
// eprintf("Objin moveto END\n");
// mt->pos = (*oi)->pos;
// }
// // Move camera position into moveto
// static void sys_ecs_camera_moveto(haloo_ecs *ecs, hecs_eidt id, hecs_cidt
// camid,
// hecs_cidt mtid) {
// // eprintf("Camera moveto %ld, %ld\n", camid, mtid);
// ecs_moveto *mt = HECS_ENTITYCOMPONENT(ecs_moveto *, id, mtid, ecs);
// ecs_camera *cam = HECS_ENTITYCOMPONENT(ecs_camera *, id, camid, ecs);
// // eprintf("Camera moveto END\n");
// mt->pos = (*cam)->pos;
// }
//
// static void sys_ecs_camera_rotateto(haloo_ecs *ecs, hecs_eidt id,
// hecs_cidt camid, hecs_cidt rtid) {
// ecs_rotateto *rt = HECS_ENTITYCOMPONENT(ecs_rotateto *, id, rtid, ecs);
// ecs_camera *cam = HECS_ENTITYCOMPONENT(ecs_camera *, id, camid, ecs);
// rt->rot.x = (*cam)->yaw;
// rt->rot.y = (*cam)->pitch;
// }
static void sys_ecs_moveto(
ecs_moveto *mt) { // haloo_ecs *ecs, hecs_eidt id, hecs_cidt mtid) {
// ecs_moveto *mt = HECS_ENTITYCOMPONENT(ecs_moveto *, id, mtid, ecs);
if (mt->timer <= 0) {
mt->pos = mt->dst;
return;
}
mfloat_t xdiff = mt->dst.x - mt->pos.x;
mfloat_t ydiff = mt->dst.y - mt->pos.y;
mfloat_t zdiff = mt->dst.z - mt->pos.z;
mt->pos.x += xdiff / mt->timer;
mt->pos.y += ydiff / mt->timer;
mt->pos.z += zdiff / mt->timer;
mt->timer--;
}
static void sys_ecs_rotateto(
ecs_rotateto *rt) { // haloo_ecs *ecs, hecs_eidt id, hecs_cidt rtid) {
// static void sys_ecs_rotateto(haloo_ecs *ecs, hecs_eidt id, hecs_cidt rtid)
// { ecs_rotateto *rt = HECS_ENTITYCOMPONENT(ecs_rotateto *, id, rtid, ecs);
if (rt->timer <= 0) {
rt->rot = rt->dstrot;
return;
}
mfloat_t xdiff = rt->dstrot.x - rt->rot.x;
mfloat_t ydiff = rt->dstrot.y - rt->rot.y;
rt->rot.x += xdiff / rt->timer;
rt->rot.y += ydiff / rt->timer;
rt->timer--;
}
// // Move movement pos back into object
// static void sys_ecs_moveto_objin(haloo_ecs *ecs, hecs_eidt id, hecs_cidt
// mtid,
// hecs_cidt oiid) {
// ecs_moveto *mt = HECS_ENTITYCOMPONENT(ecs_moveto *, id, mtid, ecs);
// ecs_objin *oi = HECS_ENTITYCOMPONENT(ecs_objin *, id, oiid, ecs);
// (*oi)->pos = mt->pos;
// }
// Move movement pos back into camera
// static void sys_ecs_moveto_camera(haloo_ecs *ecs, hecs_eidt id, hecs_cidt
// mtid, hecs_cidt camid) {
static void sys_ecs_moveto_camera(ecs_moveto *mt, ecs_camera *cam) {
// haloo_ecs *ecs, hecs_eidt id, hecs_cidt mtid, hecs_cidt camid) {
// ecs_moveto *mt = HECS_ENTITYCOMPONENT(ecs_moveto *, id, mtid, ecs);
// ecs_camera *cam = HECS_ENTITYCOMPONENT(ecs_camera *, id, camid, ecs);
(*cam)->pos = mt->pos;
}
// Move rotation back into camera
// static void sys_ecs_rotateto_camera(haloo_ecs *ecs, hecs_eidt id, hecs_cidt
// rtid, hecs_cidt camid) {
static void sys_ecs_rotateto_camera(ecs_rotateto *rt, ecs_camera *cam) {
// haloo_ecs *ecs, hecs_eidt id, hecs_cidt rtid, hecs_cidt camid) {
// ecs_rotateto *rt = HECS_ENTITYCOMPONENT(ecs_rotateto *, id, rtid, ecs);
// ecs_camera *cam = HECS_ENTITYCOMPONENT(ecs_camera *, id, camid, ecs);
(*cam)->yaw = rt->rot.x;
(*cam)->pitch = rt->rot.y;
}
#endif

View File

@ -59,8 +59,9 @@ typedef struct {
// rt->rot.y = (*cam)->pitch; // rt->rot.y = (*cam)->pitch;
// } // }
static void sys_ecs_moveto(haloo_ecs *ecs, hecs_eidt id, hecs_cidt mtid) { static void sys_ecs_moveto(
ecs_moveto *mt = HECS_ENTITYCOMPONENT(ecs_moveto *, id, mtid, ecs); ecs_moveto *mt) { // haloo_ecs *ecs, hecs_eidt id, hecs_cidt mtid) {
// ecs_moveto *mt = HECS_ENTITYCOMPONENT(ecs_moveto *, id, mtid, ecs);
if (mt->timer <= 0) { if (mt->timer <= 0) {
mt->pos = mt->dst; mt->pos = mt->dst;
return; return;
@ -74,8 +75,10 @@ static void sys_ecs_moveto(haloo_ecs *ecs, hecs_eidt id, hecs_cidt mtid) {
mt->timer--; mt->timer--;
} }
static void sys_ecs_rotateto(haloo_ecs *ecs, hecs_eidt id, hecs_cidt rtid) { static void sys_ecs_rotateto(
ecs_rotateto *rt = HECS_ENTITYCOMPONENT(ecs_rotateto *, id, rtid, ecs); ecs_rotateto *rt) { // haloo_ecs *ecs, hecs_eidt id, hecs_cidt rtid) {
// static void sys_ecs_rotateto(haloo_ecs *ecs, hecs_eidt id, hecs_cidt rtid)
// { ecs_rotateto *rt = HECS_ENTITYCOMPONENT(ecs_rotateto *, id, rtid, ecs);
if (rt->timer <= 0) { if (rt->timer <= 0) {
rt->rot = rt->dstrot; rt->rot = rt->dstrot;
return; return;
@ -97,18 +100,22 @@ static void sys_ecs_rotateto(haloo_ecs *ecs, hecs_eidt id, hecs_cidt rtid) {
// } // }
// Move movement pos back into camera // Move movement pos back into camera
static void sys_ecs_moveto_camera(haloo_ecs *ecs, hecs_eidt id, hecs_cidt mtid, // static void sys_ecs_moveto_camera(haloo_ecs *ecs, hecs_eidt id, hecs_cidt
hecs_cidt camid) { // mtid, hecs_cidt camid) {
ecs_moveto *mt = HECS_ENTITYCOMPONENT(ecs_moveto *, id, mtid, ecs); static void sys_ecs_moveto_camera(ecs_moveto *mt, ecs_camera *cam) {
ecs_camera *cam = HECS_ENTITYCOMPONENT(ecs_camera *, id, camid, ecs); // haloo_ecs *ecs, hecs_eidt id, hecs_cidt mtid, hecs_cidt camid) {
// ecs_moveto *mt = HECS_ENTITYCOMPONENT(ecs_moveto *, id, mtid, ecs);
// ecs_camera *cam = HECS_ENTITYCOMPONENT(ecs_camera *, id, camid, ecs);
(*cam)->pos = mt->pos; (*cam)->pos = mt->pos;
} }
// Move rotation back into camera // Move rotation back into camera
static void sys_ecs_rotateto_camera(haloo_ecs *ecs, hecs_eidt id, // static void sys_ecs_rotateto_camera(haloo_ecs *ecs, hecs_eidt id, hecs_cidt
hecs_cidt rtid, hecs_cidt camid) { // rtid, hecs_cidt camid) {
ecs_rotateto *rt = HECS_ENTITYCOMPONENT(ecs_rotateto *, id, rtid, ecs); static void sys_ecs_rotateto_camera(ecs_rotateto *rt, ecs_camera *cam) {
ecs_camera *cam = HECS_ENTITYCOMPONENT(ecs_camera *, id, camid, ecs); // haloo_ecs *ecs, hecs_eidt id, hecs_cidt rtid, hecs_cidt camid) {
// ecs_rotateto *rt = HECS_ENTITYCOMPONENT(ecs_rotateto *, id, rtid, ecs);
// ecs_camera *cam = HECS_ENTITYCOMPONENT(ecs_camera *, id, camid, ecs);
(*cam)->yaw = rt->rot.x; (*cam)->yaw = rt->rot.x;
(*cam)->pitch = rt->rot.y; (*cam)->pitch = rt->rot.y;
} }

140
maze.c
View File

@ -9,8 +9,8 @@
#include "unigi/unigi.headers/src/main.h" #include "unigi/unigi.headers/src/main.h"
#include "unigi/unigi.platform.sdl1/src/main.c" #include "unigi/unigi.platform.sdl1/src/main.c"
#include "ecs.h" #include "ecs2.h"
#include "ecs_comps.h" #include "ecs2_comps.h"
#include "keys.h" #include "keys.h"
#include <stdlib.h> #include <stdlib.h>
@ -59,22 +59,6 @@ float minlight = 0.25;
int fps = 30; int fps = 30;
uint16_t sky = 0xF000; uint16_t sky = 0xF000;
// A general position within the maze, and a pointer to the maze itself.
// Can be used to traverse the maze
typedef struct {
uint8_t *maze;
struct vec2i pos; // tile position within maze
int size;
uint8_t dir; // facing dir (see DIREAST/DIRSOUTH/etc);
} ecs_maze;
// State for tracking ai moving through the maze.
typedef struct {
uint8_t state;
// uint8_t nextdir;
uint32_t timer;
} ecs_smartai;
struct vec2i dirtovec(uint8_t dir) { struct vec2i dirtovec(uint8_t dir) {
struct vec2i result; struct vec2i result;
switch (dir) { switch (dir) {
@ -200,15 +184,33 @@ void maze_wall_generate(uint8_t *maze, int size, haloo3d_obj *obj) {
} }
} }
// A general position within the maze, and a pointer to the maze itself.
// Can be used to traverse the maze
typedef struct {
uint8_t *maze;
struct vec2i pos; // tile position within maze
int size;
uint8_t dir; // facing dir (see DIREAST/DIRSOUTH/etc);
} ecs_maze;
// State for tracking ai moving through the maze.
typedef struct {
uint8_t state;
// uint8_t nextdir;
uint32_t timer;
} ecs_smartai;
// everything in the maze is controlled by the CPU. As such, movement // everything in the maze is controlled by the CPU. As such, movement
// is as simple as "go here by this time". No need to complicate the // is as simple as "go here by this time". No need to complicate the
// components? // components?
static void sys_ecs_smartai(haloo_ecs *ecs, hecs_eidt id, hecs_cidt said, static void sys_ecs_smartai(ecs_smartai *smartai, ecs_maze *maze,
hecs_cidt mzid, hecs_cidt mtid, hecs_cidt rtid) { ecs_moveto *mt, ecs_rotateto *rt) {
ecs_smartai *smartai = HECS_ENTITYCOMPONENT(ecs_smartai *, id, said, ecs); // haloo_ecs *ecs, hecs_eidt id, hecs_cidt said, hecs_cidt mzid, hecs_cidt
ecs_maze *maze = HECS_ENTITYCOMPONENT(ecs_maze *, id, mzid, ecs); // mtid, hecs_cidt rtid) {
ecs_moveto *mt = HECS_ENTITYCOMPONENT(ecs_moveto *, id, mtid, ecs); // ecs_smartai *smartai = HECS_ENTITYCOMPONENT(ecs_smartai *, id, said, ecs);
ecs_rotateto *rt = HECS_ENTITYCOMPONENT(ecs_rotateto *, id, rtid, ecs); // ecs_maze *maze = HECS_ENTITYCOMPONENT(ecs_maze *, id, mzid, ecs);
// ecs_moveto *mt = HECS_ENTITYCOMPONENT(ecs_moveto *, id, mtid, ecs);
// ecs_rotateto *rt = HECS_ENTITYCOMPONENT(ecs_rotateto *, id, rtid, ecs);
int actiontime = fps / 2; int actiontime = fps / 2;
// Some states are triggered based on the timer // Some states are triggered based on the timer
if (smartai->timer > 0) { if (smartai->timer > 0) {
@ -272,6 +274,33 @@ static void sys_ecs_smartai(haloo_ecs *ecs, hecs_eidt id, hecs_cidt said,
} }
} }
// Setup ECS system for our game
ECS_START(mecs)
ECS_COMPONENT(ecs_moveto);
ECS_COMPONENT(ecs_rotateto);
ECS_COMPONENT(ecs_smartai);
ECS_COMPONENT(ecs_camera);
ECS_COMPONENT(ecs_maze);
ECS_END(mecs)
// And then a copy of the components here... that sucksssss
ECS_CID(ecs_moveto, 0);
ECS_CID(ecs_rotateto, 1);
ECS_CID(ecs_smartai, 2);
ECS_CID(ecs_camera, 3);
ECS_CID(ecs_maze, 4);
ECS_SYSTEM1(mecs, sys_ecs_moveto, ecs_moveto);
ECS_SYSTEM1(mecs, sys_ecs_rotateto, ecs_rotateto);
ECS_SYSTEM2(mecs, sys_ecs_moveto_camera, ecs_moveto, ecs_camera);
ECS_SYSTEM2(mecs, sys_ecs_rotateto_camera, ecs_rotateto, ecs_camera);
ECS_SYSTEM4(mecs, sys_ecs_smartai, ecs_smartai, ecs_maze, ecs_moveto,
ecs_rotateto);
// ECS_SYSTEM1(mecs, sys2_moveto, ecs_moveto, mt) {
// mt->pos.x = 1;
// }
int main() { // int argc, char **argv) { int main() { // int argc, char **argv) {
haloo3d_easystore storage; haloo3d_easystore storage;
@ -361,13 +390,13 @@ int main() { // int argc, char **argv) {
vec3(floori->scale.v, HSCALE, 1, HSCALE); vec3(floori->scale.v, HSCALE, 1, HSCALE);
vec3(ceili->scale.v, HSCALE, 1, HSCALE); vec3(ceili->scale.v, HSCALE, 1, HSCALE);
vec3(walli->scale.v, HSCALE, 1, HSCALE); vec3(walli->scale.v, HSCALE, 1, HSCALE);
// vec3(walli->scale.v, HSCALE, 0, HSCALE);
floori->pos.x += MAZESIZE / 2.0 * HSCALE; floori->pos.x += MAZESIZE / 2.0 * HSCALE;
floori->pos.z += MAZESIZE / 2.0 * HSCALE; floori->pos.z += MAZESIZE / 2.0 * HSCALE;
ceili->pos.x += MAZESIZE / 2.0 * HSCALE; ceili->pos.x += MAZESIZE / 2.0 * HSCALE;
ceili->pos.z += MAZESIZE / 2.0 * HSCALE; ceili->pos.z += MAZESIZE / 2.0 * HSCALE;
walli->pos.x += MAZESIZE / 2.0 * HSCALE; walli->pos.x += MAZESIZE / 2.0 * HSCALE;
walli->pos.z += MAZESIZE / 2.0 * HSCALE; walli->pos.z += MAZESIZE / 2.0 * HSCALE;
// vec3(walli->scale.v, HSCALE, 0, HSCALE);
ceili->pos.y = 1; //-1; ceili->pos.y = 1; //-1;
eprintf("Setup all object instances\n"); eprintf("Setup all object instances\n");
@ -394,40 +423,31 @@ int main() { // int argc, char **argv) {
haloo3d_debugconsole_set(&dc, "obj/ceil/pos_y.f", &ceili->pos.y); haloo3d_debugconsole_set(&dc, "obj/ceil/pos_y.f", &ceili->pos.y);
// Set up the various systems // Set up the various systems
haloo_ecs ecs; mecs ecs;
haloo_ecs_init(&ecs); mecs_init(&ecs);
HECS_ADDNEWCOMPONENT(ecs_moveto, &ecs); ecs_eid playerid = mecs_newentity(&ecs, 0);
HECS_ADDNEWCOMPONENT(ecs_rotateto, &ecs);
HECS_ADDNEWCOMPONENT(ecs_maze, &ecs);
// HECS_ADDNEWCOMPONENT(ecs_objin, &ecs);
HECS_ADDNEWCOMPONENT(ecs_camera, &ecs);
HECS_ADDNEWCOMPONENT(ecs_smartai, &ecs);
hecs_eidt playerid = haloo_ecs_newentity(&ecs, 0);
if (playerid == -1) { if (playerid == -1) {
dieerr("WHY IS PLAYERID -1???\n"); dieerr("WHY IS PLAYERID -1???\n");
} }
eprintf("Player eid: %d\n", playerid); eprintf("Player eid: %d\n", playerid);
// This is VERY critical: the player start is at 0 0 but in the maze that's // System is setup such that camera position matches maze index
// the center of the maze! This should probably be fixed or something!
render.camera.pos.x = 0.5 * HSCALE; render.camera.pos.x = 0.5 * HSCALE;
render.camera.pos.z = 0.5 * HSCALE; render.camera.pos.z = 0.5 * HSCALE;
struct vec2i playerstart = {.x = 0, struct vec2i playerstart = {.x = 0, .y = 0};
.y = 0}; // MAZESIZE / 2, .y = MAZESIZE / 2};
struct vec2 playerrotation = {.x = render.camera.yaw, struct vec2 playerrotation = {.x = render.camera.yaw,
.y = render.camera.pitch}; .y = render.camera.pitch};
HECS_SETCOMPONENT(ecs_moveto, &ecs, playerid){ ECS_SETCOMPONENT(&ecs, playerid, ecs_moveto){
.pos = render.camera.pos, .dst = render.camera.pos, .timer = 0}; .pos = render.camera.pos, .dst = render.camera.pos, .timer = 0};
HECS_SETCOMPONENT(ecs_rotateto, &ecs, playerid){ ECS_SETCOMPONENT(&ecs, playerid, ecs_rotateto){
.rot = playerrotation, .dstrot = playerrotation, .timer = 0}; .rot = playerrotation, .dstrot = playerrotation, .timer = 0};
HECS_SETCOMPONENT(ecs_maze, &ecs, playerid){ ECS_SETCOMPONENT(&ecs, playerid, ecs_maze){
.maze = maze, .pos = playerstart, .size = MAZESIZE, .dir = DIRSOUTH}; .maze = maze, .pos = playerstart, .size = MAZESIZE, .dir = DIRSOUTH};
HECS_SETCOMPONENT(ecs_camera, &ecs, playerid) & render.camera; ECS_SETCOMPONENT(&ecs, playerid, ecs_camera) & render.camera;
HECS_SETCOMPONENT(ecs_smartai, &ecs, playerid){.state = 0, ECS_SETCOMPONENT(&ecs, playerid, ecs_smartai){.state = 0, .timer = 0};
.timer = 0}; //, .nextdir = 0};
eprintf("Player component mask: %lx\n", ecs.e_components[playerid]); eprintf("Player component mask: %lx\n", ecs.entities[playerid]);
// ----------------------------------- // -----------------------------------
// Actual rendering // Actual rendering
@ -465,7 +485,7 @@ int main() { // int argc, char **argv) {
// Game logic? // Game logic?
// --------------------------- // ---------------------------
for (int i = 0; i < HECS_MAXENTITIES; i++) { for (int i = 0; i < ECS_MAXENTITIES; i++) {
// eprintf("CHECKING EID %d\n", i); // eprintf("CHECKING EID %d\n", i);
// HECS_RUNSYS(&ecs, i, sys_ecs_objin_moveto, ecs_objin_id, // HECS_RUNSYS(&ecs, i, sys_ecs_objin_moveto, ecs_objin_id,
// ecs_moveto_id); // ecs_moveto_id);
@ -473,13 +493,22 @@ int main() { // int argc, char **argv) {
// ecs_rotateto_id); // ecs_rotateto_id);
// HECS_RUNSYS(&ecs, i, sys_ecs_camera_moveto, ecs_camera_id, // HECS_RUNSYS(&ecs, i, sys_ecs_camera_moveto, ecs_camera_id,
// ecs_moveto_id); // ecs_moveto_id);
HECS_RUNSYS(&ecs, i, sys_ecs_smartai, ecs_smartai_id, ecs_maze_id,
ecs_moveto_id, ecs_rotateto_id); sys_ecs_smartai_run(&ecs, i);
HECS_RUNSYS(&ecs, i, sys_ecs_moveto, ecs_moveto_id); sys_ecs_moveto_run(&ecs, i);
HECS_RUNSYS(&ecs, i, sys_ecs_rotateto, ecs_rotateto_id); sys_ecs_rotateto_run(&ecs, i);
HECS_RUNSYS(&ecs, i, sys_ecs_moveto_camera, ecs_moveto_id, ecs_camera_id); sys_ecs_moveto_camera_run(&ecs, i);
HECS_RUNSYS(&ecs, i, sys_ecs_rotateto_camera, ecs_rotateto_id, sys_ecs_rotateto_camera_run(&ecs, i);
ecs_camera_id);
// HECS_RUNSYS(&ecs, i, sys_ecs_smartai, ecs_smartai_id, ecs_maze_id,
// ecs_moveto_id, ecs_rotateto_id);
// HECS_RUNSYS(&ecs, i, sys_ecs_moveto, ecs_moveto_id);
// HECS_RUNSYS(&ecs, i, sys_ecs_rotateto, ecs_rotateto_id);
// HECS_RUNSYS(&ecs, i, sys_ecs_moveto_camera, ecs_moveto_id,
// ecs_camera_id); HECS_RUNSYS(&ecs, i, sys_ecs_rotateto_camera,
// ecs_rotateto_id,
// ecs_camera_id);
// HECS_RUNSYS(&ecs, i, sys_ecs_moveto_objin, ecs_moveto_id, // HECS_RUNSYS(&ecs, i, sys_ecs_moveto_objin, ecs_moveto_id,
// ecs_objin_id); // ecs_objin_id);
} }
@ -534,7 +563,8 @@ int main() { // int argc, char **argv) {
} }
// Just to get the compiler to STOP COMPLAINING about unused // Just to get the compiler to STOP COMPLAINING about unused
haloo_ecs_removeentity(&ecs, playerid); //, int eid) mecs_deleteentity(&ecs, playerid);
// haloo_ecs_removeentity(&ecs, playerid); //, int eid)
haloo3d_easystore_deleteallobj(&storage, haloo3d_obj_free); haloo3d_easystore_deleteallobj(&storage, haloo3d_obj_free);
haloo3d_easystore_deletealltex(&storage, haloo3d_fb_free); haloo3d_easystore_deletealltex(&storage, haloo3d_fb_free);