This commit is contained in:
2025-11-11 07:50:20 -06:00
parent c07d0b32a9
commit 26bfb912f1
6 changed files with 66 additions and 24 deletions

View File

@@ -76,17 +76,19 @@ void entityWalk(entity_t *entity, const entitydir_t direction) {
}
// Get tile under foot
chunkpos_t chunkPos;
worldPosToChunkPos(&newPos, &chunkPos);
chunkindex_t chunkIndex = mapGetChunkIndexAt(chunkPos);
tile_t tile = TILE_NULL;
if(chunkIndex != -1) {
chunk_t *chunk = mapGetChunk(chunkIndex);
assertNotNull(chunk, "Chunk pointer cannot be NULL");
chunktileindex_t tileIndex = woprldPosToChunkTileIndex(&newPos);
tile = chunk->tiles[tileIndex];
tile_t tile = mapGetTile(newPos);
if(tile == TILE_NULL && newPos.z > 0) {
// Check one level down for walkable tile (stairs down)
worldpos_t belowPos = newPos;
belowPos.z -= 1;
tile = mapGetTile(belowPos);
if(tile != TILE_NULL) newPos.z -= 1;
}
// Tile walkable?
if(!tileIsWalkable(tile)) return;
// Entity in way?
entity_t *other = ENTITIES;
do {
@@ -99,6 +101,8 @@ void entityWalk(entity_t *entity, const entitydir_t direction) {
entity->position = newPos;
entity->animation = ENTITY_ANIM_WALK;
entity->animTime = ENTITY_ANIM_WALK_DURATION;// TODO: Running vs walking
// We are comitting, we can run effects here.
}
entity_t * entityGetAt(const worldpos_t position) {