Tiles
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user