world_generator/main/planet.cpp

51 lines
1.3 KiB
C++
Raw Normal View History

2019-09-24 02:42:42 +02:00
#include "planet.h"
2019-09-22 22:12:20 +02:00
Ref<Biome> Planet::get_biome(const int index) const {
ERR_FAIL_INDEX_V(index, _biomes.size(), Ref<Biome>());
return _biomes.get(index);
}
void Planet::set_biome(const int index, const Ref<Biome> biome) {
ERR_FAIL_INDEX(index, _biomes.size());
_biomes.set(index, biome);
}
void Planet::add_biome(const Ref<Biome> biome) {
_biomes.push_back(biome);
}
void Planet::remove_biome(const int index) {
ERR_FAIL_INDEX(index, _biomes.size());
_biomes.remove(index);
}
int Planet::get_biome_count() const {
return _biomes.size();
}
2019-09-24 02:42:42 +02:00
void Planet::generate_chunk(Ref<VoxelChunk> chunk) {
if (has_method("_generate_chunk")) {
call("_generate_chunk", chunk);
}
2019-09-22 22:12:20 +02:00
}
2019-09-24 02:42:42 +02:00
Planet::Planet() {
2019-09-22 22:12:20 +02:00
}
2019-09-24 02:42:42 +02:00
Planet::~Planet() {
2019-09-22 22:12:20 +02:00
}
2019-09-24 02:42:42 +02:00
void Planet::_bind_methods() {
BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "structure", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk")));
ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &Planet::generate_chunk);
ClassDB::bind_method(D_METHOD("get_biome", "index"), &Planet::get_biome);
ClassDB::bind_method(D_METHOD("set_biome", "index", "data"), &Planet::set_biome);
ClassDB::bind_method(D_METHOD("add_biome", "biome"), &Planet::add_biome);
ClassDB::bind_method(D_METHOD("remove_biome", "index"), &Planet::remove_biome);
ClassDB::bind_method(D_METHOD("get_biome_count"), &Planet::get_biome_count);
2019-09-22 22:12:20 +02:00
}