ValidCoords is no longer required with Vector2i
This commit is contained in:
@@ -174,7 +174,6 @@ namespace CaveGame::Core {
|
||||
}
|
||||
virtual void AutoSave();
|
||||
|
||||
bool ValidCoords(const Vector2i &cell) const;
|
||||
protected:
|
||||
std::vector<Entity*> entities;
|
||||
const std::filesystem::path worlds {"worlds"};
|
||||
|
@@ -106,25 +106,13 @@ namespace CaveGame::Core
|
||||
}
|
||||
|
||||
Chunk* World::GetChunkAtCell(const Vector2i& cell) {
|
||||
if (ValidCoords(cell))
|
||||
if (HasChunkAtCell(cell))
|
||||
return loaded_chunks.at(cell);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool World::ValidCoords(const Vector2i& cell) const {
|
||||
if (Math::Floor(cell.x) != cell.x || Math::Floor(cell.y) != cell.y) {
|
||||
// TODO: Implement ostream on Vector2i
|
||||
//std::cerr << "Invalid cell coordinate: " << cell << ", must be whole numbers!";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool World::HasChunkAtCell(const Vector2i &cell) const {
|
||||
if (ValidCoords(cell))
|
||||
return loaded_chunks.contains(cell);
|
||||
return false;
|
||||
return loaded_chunks.contains(cell);
|
||||
}
|
||||
|
||||
std::unordered_map<Vector2i, Chunk*> World::GetChunkList() { return loaded_chunks; }
|
||||
@@ -183,7 +171,7 @@ namespace CaveGame::Core
|
||||
|
||||
if (HasChunkAtCell(chunkCoords))
|
||||
return loaded_chunks.at(chunkCoords)->GetTileUpdateFlag(tileCoords.x, tileCoords.y);
|
||||
|
||||
// This is bad.
|
||||
}
|
||||
|
||||
Vector2 World::ToUnitDirection(float rotation) {
|
||||
|
Reference in New Issue
Block a user