Renamed BiomeBase to BiomeTerrarinGenerator, and now it's a Reference, because as it turns out inheriting a class from a different module causes crashes.

This commit is contained in:
Relintai 2020-07-21 21:15:27 +02:00
parent 0e5c54a70f
commit 8c4b32d393
5 changed files with 35 additions and 17 deletions

2
SCsub
View File

@ -12,7 +12,7 @@ sources = [
"register_types.cpp",
"biome_base.cpp"
"biome_terrarin_generator.cpp"
]
if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes':

View File

@ -20,7 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "biome_base.h"
#include "biome_terrarin_generator.h"
#include "core/math/math_funcs.h"
@ -33,7 +33,14 @@ SOFTWARE.
#include "../entity_spell_system/spawners/ess_entity_spawner.h"
#include "../opensimplex/open_simplex_noise.h"
void BiomeBase::generate_simple_terrarin(Ref<VoxelChunk> chunk, bool spawn_mobs) {
int BiomeTerrarinGenerator::get_current_seed() {
return _current_seed;
}
void BiomeTerrarinGenerator::set_current_seed(int value) {
_current_seed = value;
}
void BiomeTerrarinGenerator::generate_simple_terrarin(Ref<VoxelChunk> chunk, bool spawn_mobs) {
Ref<OpenSimplexNoise> noise;
noise.instance();
noise->set_seed(10 * get_current_seed());
@ -106,12 +113,17 @@ void BiomeBase::generate_simple_terrarin(Ref<VoxelChunk> chunk, bool spawn_mobs)
// }
}
BiomeBase::BiomeBase() {
BiomeTerrarinGenerator::BiomeTerrarinGenerator() {
_current_seed = 0;
}
BiomeBase::~BiomeBase() {
BiomeTerrarinGenerator::~BiomeTerrarinGenerator() {
}
void BiomeBase::_bind_methods() {
ClassDB::bind_method(D_METHOD("generate_simple_terrarin", "chunk", "spawn_mobs"), &BiomeBase::generate_simple_terrarin);
void BiomeTerrarinGenerator::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_current_seed"), &BiomeTerrarinGenerator::get_current_seed);
ClassDB::bind_method(D_METHOD("set_current_seed", "value"), &BiomeTerrarinGenerator::set_current_seed);
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_seed"), "set_current_seed", "get_current_seed");
ClassDB::bind_method(D_METHOD("generate_simple_terrarin", "chunk", "spawn_mobs"), &BiomeTerrarinGenerator::generate_simple_terrarin);
}

View File

@ -20,24 +20,30 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef BIOME_BASE_H
#define BIOME_BASE_H
#ifndef BIOME_TERRARIN_GENERATOR_H
#define BIOME_TERRARIN_GENERATOR_H
#include "../world_generator/main/biome.h"
#include "core/reference.h"
class VoxelChunk;
class BiomeBase : public Biome {
GDCLASS(BiomeBase, Biome);
class BiomeTerrarinGenerator : public Reference {
GDCLASS(BiomeTerrarinGenerator, Reference);
public:
int get_current_seed();
void set_current_seed(int value);
void generate_simple_terrarin(Ref<VoxelChunk> chunk, bool spawn_mobs);
BiomeBase();
~BiomeBase();
BiomeTerrarinGenerator();
~BiomeTerrarinGenerator();
protected:
static void _bind_methods();
private:
int _current_seed;
};
#endif

View File

@ -32,7 +32,7 @@ def configure(env):
def get_doc_classes():
return [
"BiomeBase"
"BiomeTerrarinGenerator"
]
def get_doc_path():

View File

@ -24,10 +24,10 @@ SOFTWARE.
*/
#include "biome_base.h"
#include "biome_terrarin_generator.h"
void register_broken_seals_module_types() {
ClassDB::register_class<BiomeBase>();
ClassDB::register_class<BiomeTerrarinGenerator>();
}
void unregister_broken_seals_module_types() {