Example global ent

This commit is contained in:
2026-07-04 13:03:24 -05:00
parent bd7fa154b4
commit 589e4224f3
10 changed files with 167 additions and 37 deletions
+1 -19
View File
@@ -45,25 +45,7 @@ errorret_t rpgInit(void) {
if(ci != -1) entitySetChunk(ent, (uint8_t)ci);
}
uint8_t npcIndex = entityGetAvailable();
entity_t *npc = &ENTITIES[npcIndex];
entityInit(npc, ENTITY_TYPE_NPC);
npc->globalId = ENTITY_GLOBAL_ID_START;
npcSetMoveType(npc, NPC_MOVE_TYPE_PATH);
entityPositionSet(npc, (worldpos_t){ 8, 8, 1 });
npc->interact.type = ENTITY_INTERACT_CUTSCENE;
npc->interact.data.cutscene = CUTSCENE_REFERENCE(TEST_TWO);
{
chunkpos_t cp;
worldPosToChunkPos(&npc->position, &cp);
chunkindex_t ci = mapGetChunkIndexAt(cp);
if(ci != -1) entitySetChunk(npc, (uint8_t)ci);
}
npcPathAddNode(&npc->data.npc, (worldpos_t){ 4, 4, 0 });
npcPathAddNode(&npc->data.npc, (worldpos_t){ 10, 10, 1 });
npcPathAddNode(&npc->data.npc, (worldpos_t){ 4, 4, 0 });
npcPathAddNode(&npc->data.npc, (worldpos_t){ 10, 10, 1 });
mapSpawnEntity(3, (worldpos_t){ 8, 8, 1 });
// All Good!
errorOk();