Proper start spawn
This commit is contained in:
parent
9554d0062f
commit
c2ad4f64d2
2
haloo3d
2
haloo3d
@ -1 +1 @@
|
|||||||
Subproject commit e5ec412b3b20ff87106aae1dc50148b0af7a071d
|
Subproject commit a4b465b82d9d4160fbba59f7d61b749dea066a5a
|
34
maze.c
34
maze.c
@ -432,6 +432,7 @@ typedef struct {
|
|||||||
uint32_t timer;
|
uint32_t timer;
|
||||||
struct vec2i mpos;
|
struct vec2i mpos;
|
||||||
worldstate *ws;
|
worldstate *ws;
|
||||||
|
haloo3d_obj_instance *startmarker;
|
||||||
} ecs_smartai;
|
} ecs_smartai;
|
||||||
|
|
||||||
static void sys_smartai(ecs_smartai *smartai, ecs_placement *p,
|
static void sys_smartai(ecs_smartai *smartai, ecs_placement *p,
|
||||||
@ -444,16 +445,24 @@ static void sys_smartai(ecs_smartai *smartai, ecs_placement *p,
|
|||||||
// case we can spawn and face
|
// case we can spawn and face
|
||||||
if (smartai->ws->state == WSTATE_SPINUP) {
|
if (smartai->ws->state == WSTATE_SPINUP) {
|
||||||
smartai->mpos = smartai->ws->start;
|
smartai->mpos = smartai->ws->start;
|
||||||
p->pos.x = smartai->ws->cellsize * (smartai->ws->start.x + 0.5);
|
|
||||||
p->pos.z = smartai->ws->cellsize * (smartai->ws->start.y + 0.5);
|
|
||||||
// Reset autonav
|
|
||||||
anav->dest = p->pos;
|
|
||||||
anav->timer = 0;
|
|
||||||
smartai->dir =
|
smartai->dir =
|
||||||
maze_longesthallway(smartai->ws->maze, MAZESIZE, smartai->ws->start.x,
|
maze_longesthallway(smartai->ws->maze, MAZESIZE, smartai->ws->start.x,
|
||||||
smartai->ws->start.y);
|
smartai->ws->start.y);
|
||||||
|
p->pos.x = smartai->ws->cellsize * (smartai->ws->start.x + 0.5);
|
||||||
|
p->pos.z = smartai->ws->cellsize * (smartai->ws->start.y + 0.5);
|
||||||
p->rot.x = dirtoyaw(smartai->dir);
|
p->rot.x = dirtoyaw(smartai->dir);
|
||||||
// reset autorotate
|
// Move startmarker to in front of player.
|
||||||
|
struct vec2i lookdir = dirtovec(smartai->dir);
|
||||||
|
smartai->startmarker->pos.x = p->pos.x + lookdir.x;
|
||||||
|
smartai->startmarker->pos.y = 0.0;
|
||||||
|
smartai->startmarker->pos.z = p->pos.z + lookdir.y;
|
||||||
|
vec3_subtract(smartai->startmarker->lookvec.v, p->pos.v,
|
||||||
|
smartai->startmarker->pos.v);
|
||||||
|
// To not face up or down, always set y = 0;
|
||||||
|
smartai->startmarker->lookvec.y = 0;
|
||||||
|
// Reset autonav + autorotate
|
||||||
|
anav->dest = p->pos;
|
||||||
|
anav->timer = 0;
|
||||||
arot->dest = p->rot;
|
arot->dest = p->rot;
|
||||||
arot->timer = 0;
|
arot->timer = 0;
|
||||||
smartai->state = SAI_READY;
|
smartai->state = SAI_READY;
|
||||||
@ -662,7 +671,8 @@ int main() { // int argc, char **argv) {
|
|||||||
init_ceilingtexture(ceilt);
|
init_ceilingtexture(ceilt);
|
||||||
init_walltexture(wallt);
|
init_walltexture(wallt);
|
||||||
init_starttexture(startt);
|
init_starttexture(startt);
|
||||||
haloo3d_gen_quad(starto, startt);
|
struct vec3 center = {.x = 0, .y = 0.5, .z = 0};
|
||||||
|
haloo3d_gen_quad(starto, startt, center);
|
||||||
|
|
||||||
eprintf("Initialized models and textures\n");
|
eprintf("Initialized models and textures\n");
|
||||||
|
|
||||||
@ -751,8 +761,11 @@ int main() { // int argc, char **argv) {
|
|||||||
ECS_SETCOMPONENT(&ecs, playerid, ecs_camera){.camera = &render.camera};
|
ECS_SETCOMPONENT(&ecs, playerid, ecs_camera){.camera = &render.camera};
|
||||||
ECS_SETCOMPONENT(&ecs, playerid, ecs_autonav){.timer = 0};
|
ECS_SETCOMPONENT(&ecs, playerid, ecs_autonav){.timer = 0};
|
||||||
ECS_SETCOMPONENT(&ecs, playerid, ecs_autorotate){.timer = 0};
|
ECS_SETCOMPONENT(&ecs, playerid, ecs_autorotate){.timer = 0};
|
||||||
ECS_SETCOMPONENT(&ecs, playerid, ecs_smartai){
|
ECS_SETCOMPONENT(&ecs, playerid, ecs_smartai){.state = SAI_INIT,
|
||||||
.state = SAI_INIT, .ws = &wstate, .rotstate = 0, .timer = 0};
|
.ws = &wstate,
|
||||||
|
.rotstate = 0,
|
||||||
|
.timer = 0,
|
||||||
|
.startmarker = starti};
|
||||||
|
|
||||||
// -----------------------------------
|
// -----------------------------------
|
||||||
// Actual rendering
|
// Actual rendering
|
||||||
@ -805,9 +818,6 @@ int main() { // int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
haloo3d_easytimer_end(&logictimer);
|
haloo3d_easytimer_end(&logictimer);
|
||||||
|
|
||||||
starti->pos = render.camera.pos;
|
|
||||||
starti->pos.z -= 1;
|
|
||||||
|
|
||||||
totaldrawn = 0;
|
totaldrawn = 0;
|
||||||
|
|
||||||
haloo3d_obj_instance *object = NULL;
|
haloo3d_obj_instance *object = NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user