Merge branch 'debug/world_change' of yibble.dev:bulmanator/ld58 into debug
This commit is contained in:
@@ -61,6 +61,16 @@ void RenderWorld(World *world, D_Context *draw) {
|
||||
);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < world->navMesh->nodeCount; i++) {
|
||||
NavNode n = world->navMesh->nodes[i];
|
||||
D_Rect(
|
||||
draw,
|
||||
n.pos.x,
|
||||
n.pos.y,
|
||||
.texture = 0,
|
||||
.scale = 0.2f,
|
||||
);
|
||||
}
|
||||
for(U32 i = 0; i < world->npcCount; i++) {
|
||||
NPC npc = world->npcs[i];
|
||||
if(npc.currentArea == world->player.currentArea) {
|
||||
@@ -214,3 +224,36 @@ void LoadWorld(M_Arena *arena, World *world) {
|
||||
printf("--- Loaded World ---\n");
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateNavMesh(M_Arena *arena, World *world) {
|
||||
world->navMesh = M_ArenaPush(arena, NavMesh);
|
||||
world->navMesh->nodeCount = 0;
|
||||
for(int i = 0; i < WORLD_MAP_MAX; i++) {
|
||||
U32 x = (i % 96);
|
||||
U32 y = (i / 96);
|
||||
world->navMesh->nodes[world->navMesh->nodeCount].pos.x = x;
|
||||
world->navMesh->nodes[world->navMesh->nodeCount].pos.y = y;
|
||||
U32 cost = 20;
|
||||
if(Str8_Equal(world->tileTypes[world->map[i]].tag, S("path_middle"), STR8_EQUAL_IGNORE_CASE)) {
|
||||
cost = 10;
|
||||
}
|
||||
world->navMesh->nodes[world->navMesh->nodeCount].connectionCount = 0;
|
||||
for(int nx = -1; nx < 2; nx++){
|
||||
for(int ny = -1; ny < 2; ny++){
|
||||
if((nx==ny) && nx==0) {continue;}
|
||||
if(x+nx < 0 || x+nx > 95) {
|
||||
continue;
|
||||
}
|
||||
if(y+ny < 0 || y+ny > 49) {
|
||||
continue;
|
||||
}
|
||||
U32 index = x+nx + (y+ny)*96;
|
||||
U32 nCount = world->navMesh->nodeCount;
|
||||
world->navMesh->nodes[nCount].connections[world->navMesh->nodes[nCount].connectionCount].NodeIndex = index;
|
||||
world->navMesh->nodes[nCount].connections[world->navMesh->nodes[nCount].connectionCount].Cost = cost;
|
||||
world->navMesh->nodes[nCount].connectionCount++;
|
||||
}
|
||||
}
|
||||
world->navMesh->nodeCount++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user