osb/source/game/terrain/StarWormCave.hpp

40 lines
758 B
C++
Raw Normal View History

#pragma once
2023-06-20 04:33:09 +00:00
#include "StarTerrainDatabase.hpp"
#include "StarLruCache.hpp"
#include "StarVector.hpp"
namespace Star {
class WormCaveSector {
public:
WormCaveSector(int sectorSize, Vec2I sector, Json const& config, size_t seed, float commonality);
float get(int x, int y);
private:
bool inside(int x, int y);
void set(int x, int y, float value);
int m_sectorSize;
Vec2I m_sector;
List<float> m_values;
float m_maxValue;
};
class WormCaveSelector : public TerrainSelector {
public:
static char const* const Name;
WormCaveSelector(Json const& config, TerrainSelectorParameters const& parameters);
float get(int x, int y) const override;
private:
int m_sectorSize;
mutable HashLruCache<Vec2I, WormCaveSector> m_cache;
};
}