Player::Player(Entity &e, ChunkIndex &c)
: entity(e)
-, chunks(c) {
+, chunks(c)
+, inv_slot(0) {
}
}
+bool Player::SuitableSpawn(BlockLookup &spawn_block) const noexcept {
+ if (!spawn_block || spawn_block.GetType().collide_block) {
+ return false;
+ }
+
+ BlockLookup head_block(spawn_block.Next(Block::FACE_UP));
+ if (!head_block || head_block.GetType().collide_block) {
+ return false;
+ }
+
+ return true;
+}
+
void Player::Update(int dt) {
chunks.Rebase(entity.ChunkCoords());
}
: config(config)
, block_type(types)
, chunks(types)
-// TODO: set spawn base and extent from config
-, spawn_index(chunks.MakeIndex(Chunk::Pos(0, 0, 0), 3))
, players()
, entities()
, light_direction(config.light_direction)
}
World::~World() {
- chunks.UnregisterIndex(spawn_index);
+
}
}
Entity &entity = AddEntity();
entity.Name(name);
- // TODO: load from save file here
entity.Bounds({ { -0.5f, -0.5f, -0.5f }, { 0.5f, 0.5f, 0.5f } });
entity.WorldCollidable(true);
- entity.Position(config.spawn);
ChunkIndex &index = chunks.MakeIndex(entity.ChunkCoords(), 6);
players.emplace_back(entity, index);
return &players.back();
return nullptr;
}
entity->Name(name);
- // TODO: load from save file here
entity->Bounds({ { -0.5f, -0.5f, -0.5f }, { 0.5f, 0.5f, 0.5f } });
entity->WorldCollidable(true);
- entity->Position(config.spawn);
ChunkIndex &index = chunks.MakeIndex(entity->ChunkCoords(), 6);
players.emplace_back(*entity, index);
return &players.back();