More work on the generator interface.

This commit is contained in:
Relintai 2019-11-11 17:25:17 +01:00
parent 0f00761468
commit 6a1669d646
16 changed files with 182 additions and 34 deletions

View File

@ -1,5 +1,19 @@
#include "biome_data.h"
String BiomeData::get_target_class_name() {
return _target_class_name;
}
void BiomeData::set_target_class_name(String name) {
_target_class_name = name;
}
Ref<Script> BiomeData::get_target_script() {
return _target_script;
}
void BiomeData::set_target_script(Ref<Script> script) {
_target_script = script;
}
Vector2 BiomeData::get_level_range() {
return _level_range;
}
@ -275,6 +289,14 @@ BiomeData::~BiomeData() {
}
void BiomeData::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_target_class_name"), &BiomeData::get_target_class_name);
ClassDB::bind_method(D_METHOD("set_target_class_name", "value"), &BiomeData::set_target_class_name);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "target_class_name"), "set_target_class_name", "get_target_class_name");
ClassDB::bind_method(D_METHOD("get_target_script"), &BiomeData::get_target_script);
ClassDB::bind_method(D_METHOD("set_target_script", "value"), &BiomeData::set_target_script);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "target_script", PROPERTY_HINT_RESOURCE_TYPE, "Script"), "set_target_script", "get_target_script");
ClassDB::bind_method(D_METHOD("get_level_range"), &BiomeData::get_level_range);
ClassDB::bind_method(D_METHOD("set_level_range", "value"), &BiomeData::set_level_range);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range");

View File

@ -4,6 +4,8 @@
#include "core/resource.h"
#include "core/vector.h"
#include "core/math/vector2.h"
#include "core/ustring.h"
#include "core/script_language.h"
#include "../main/biome.h"
#include "dungeon_data.h"
@ -16,6 +18,12 @@ class BiomeData : public Resource {
GDCLASS(BiomeData, Resource);
public:
String get_target_class_name();
void set_target_class_name(String name);
Ref<Script> get_target_script();
void set_target_script(Ref<Script> script);
Vector2 get_level_range();
void set_level_range(Vector2 value);
@ -93,6 +101,9 @@ protected:
static void _bind_methods();
private:
String _target_class_name;
Ref<Script> _target_script;
Vector2 _level_range;
Vector2 _humidity_range;

View File

@ -1,5 +1,19 @@
#include "dungeon_data.h"
String DungeonData::get_target_class_name() {
return _target_class_name;
}
void DungeonData::set_target_class_name(String name) {
_target_class_name = name;
}
Ref<Script> DungeonData::get_target_script() {
return _target_script;
}
void DungeonData::set_target_script(Ref<Script> script) {
_target_script = script;
}
Vector2 DungeonData::get_level_range() {
return _level_range;
}
@ -408,6 +422,14 @@ DungeonData::~DungeonData() {
}
void DungeonData::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_target_class_name"), &DungeonData::get_target_class_name);
ClassDB::bind_method(D_METHOD("set_target_class_name", "value"), &DungeonData::set_target_class_name);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "target_class_name"), "set_target_class_name", "get_target_class_name");
ClassDB::bind_method(D_METHOD("get_target_script"), &DungeonData::get_target_script);
ClassDB::bind_method(D_METHOD("set_target_script", "value"), &DungeonData::set_target_script);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "target_script", PROPERTY_HINT_RESOURCE_TYPE, "Script"), "set_target_script", "get_target_script");
ClassDB::bind_method(D_METHOD("get_level_range"), &DungeonData::get_level_range);
ClassDB::bind_method(D_METHOD("set_level_range", "value"), &DungeonData::set_level_range);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range");

View File

@ -3,6 +3,8 @@
#include "core/resource.h"
#include "core/vector.h"
#include "core/ustring.h"
#include "core/script_language.h"
#include "../main/dungeon.h"
#include "dungeon_room_data.h"
@ -16,6 +18,12 @@ class DungeonData : public Resource {
GDCLASS(DungeonData, Resource);
public:
String get_target_class_name();
void set_target_class_name(String name);
Ref<Script> get_target_script();
void set_target_script(Ref<Script> script);
Vector2 get_level_range();
void set_level_range(Vector2 value);
@ -133,6 +141,9 @@ protected:
static void _bind_methods();
private:
String _target_class_name;
Ref<Script> _target_script;
Vector2 _level_range;
int _min_sizex;

View File

@ -1,5 +1,19 @@
#include "dungeon_room_data.h"
String DungeonRoomData::get_target_class_name() {
return _target_class_name;
}
void DungeonRoomData::set_target_class_name(String name) {
_target_class_name = name;
}
Ref<Script> DungeonRoomData::get_target_script() {
return _target_script;
}
void DungeonRoomData::set_target_script(Ref<Script> script) {
_target_script = script;
}
Vector2 DungeonRoomData::get_level_range() {
return _level_range;
}
@ -264,6 +278,14 @@ DungeonRoomData::~DungeonRoomData() {
}
void DungeonRoomData::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_target_class_name"), &DungeonRoomData::get_target_class_name);
ClassDB::bind_method(D_METHOD("set_target_class_name", "value"), &DungeonRoomData::set_target_class_name);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "target_class_name"), "set_target_class_name", "get_target_class_name");
ClassDB::bind_method(D_METHOD("get_target_script"), &DungeonRoomData::get_target_script);
ClassDB::bind_method(D_METHOD("set_target_script", "value"), &DungeonRoomData::set_target_script);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "target_script", PROPERTY_HINT_RESOURCE_TYPE, "Script"), "set_target_script", "get_target_script");
ClassDB::bind_method(D_METHOD("get_level_range"), &DungeonRoomData::get_level_range);
ClassDB::bind_method(D_METHOD("set_level_range", "value"), &DungeonRoomData::set_level_range);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range");

View File

@ -2,6 +2,8 @@
#define DUNGEON_ROOM_DATA_H
#include "core/resource.h"
#include "core/ustring.h"
#include "core/script_language.h"
#include "../main/dungeon_room.h"
#include "world_generator_prop_data.h"
@ -14,6 +16,12 @@ class DungeonRoomData : public Resource {
GDCLASS(DungeonRoomData, Resource);
public:
String get_target_class_name();
void set_target_class_name(String name);
Ref<Script> get_target_script();
void set_target_script(Ref<Script> script);
Vector2 get_level_range();
void set_level_range(Vector2 value);
@ -94,6 +102,9 @@ protected:
static void _bind_methods();
private:
String _target_class_name;
Ref<Script> _target_script;
Vector2 _level_range;
int _min_sizex;

View File

@ -7,6 +7,20 @@ void PlanetData::set_id(const int value) {
_id = value;
}
String PlanetData::get_target_class_name() {
return _target_class_name;
}
void PlanetData::set_target_class_name(String name) {
_target_class_name = name;
}
Ref<Script> PlanetData::get_target_script() {
return _target_script;
}
void PlanetData::set_target_script(Ref<Script> script) {
_target_script = script;
}
Vector2 PlanetData::get_level_range() {
return _level_range;
}
@ -203,6 +217,14 @@ void PlanetData::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_id", "value"), &PlanetData::set_id);
ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id");
ClassDB::bind_method(D_METHOD("get_target_class_name"), &PlanetData::get_target_class_name);
ClassDB::bind_method(D_METHOD("set_target_class_name", "value"), &PlanetData::set_target_class_name);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "target_class_name"), "set_target_class_name", "get_target_class_name");
ClassDB::bind_method(D_METHOD("get_target_script"), &PlanetData::get_target_script);
ClassDB::bind_method(D_METHOD("set_target_script", "value"), &PlanetData::set_target_script);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "target_script", PROPERTY_HINT_RESOURCE_TYPE, "Script"), "set_target_script", "get_target_script");
ClassDB::bind_method(D_METHOD("get_level_range"), &PlanetData::get_level_range);
ClassDB::bind_method(D_METHOD("set_level_range", "value"), &PlanetData::set_level_range);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range");

View File

@ -2,6 +2,8 @@
#define biome_data_H
#include "core/resource.h"
#include "core/ustring.h"
#include "core/script_language.h"
#include "../../../fastnoise/fastnoise_noise_params.h"
@ -17,6 +19,12 @@ public:
int get_id() const;
void set_id(const int value);
String get_target_class_name();
void set_target_class_name(String name);
Ref<Script> get_target_script();
void set_target_script(Ref<Script> script);
Vector2 get_level_range();
void set_level_range(Vector2 value);
@ -75,6 +83,9 @@ protected:
private:
int _id;
String _target_class_name;
Ref<Script> _target_script;
Vector2 _level_range;
Ref<FastnoiseNoiseParams> _humidity_noise_params;

View File

@ -1,5 +1,12 @@
#include "biome.h"
int Biome::get_current_seed() {
return _current_seed;
}
void Biome::set_current_seed(int value) {
_current_seed = value;
}
Vector2 Biome::get_level_range() {
return _level_range;
}
@ -151,7 +158,7 @@ void Biome::_setup_library(Ref<VoxelmanLibrary> library) {
}
Biome::Biome() {
_current_seed = 0;
}
Biome::~Biome() {
_environment.unref();
@ -174,6 +181,10 @@ void Biome::_bind_methods() {
ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &Biome::generate_chunk_bind);
ClassDB::bind_method(D_METHOD("generate_stack", "chunk", "x", "z", "spawn_mobs"), &Biome::generate_stack_bind);
ClassDB::bind_method(D_METHOD("get_current_seed"), &Biome::get_current_seed);
ClassDB::bind_method(D_METHOD("set_current_seed", "value"), &Biome::set_current_seed);
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_seed"), "set_current_seed", "get_current_seed");
ClassDB::bind_method(D_METHOD("get_level_range"), &Biome::get_level_range);
ClassDB::bind_method(D_METHOD("set_level_range", "value"), &Biome::set_level_range);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range");

View File

@ -18,6 +18,9 @@ class Biome : public Reference {
GDCLASS(Biome, Reference);
public:
int get_current_seed();
void set_current_seed(int value);
Vector2 get_level_range();
void set_level_range(Vector2 value);
@ -66,6 +69,8 @@ protected:
static void _bind_methods();
private:
int _current_seed;
Vector2 _level_range;
Ref<EnvironmentData> _environment;

View File

@ -1,10 +1,10 @@
#include "dungeon.h"
int Dungeon::get_seed() {
return _seed;
int Dungeon::get_current_seed() {
return _current_seed;
}
void Dungeon::set_seed(int value) {
_seed = value;
void Dungeon::set_current_seed(int value) {
_current_seed = value;
}
Vector2 Dungeon::get_level_range() {
@ -259,7 +259,7 @@ Ref<Image> Dungeon::generate_map() {
}
Dungeon::Dungeon() {
_seed = 0;
_current_seed = 0;
_posx = 0;
_posy = 0;
@ -294,9 +294,9 @@ void Dungeon::_bind_methods() {
ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &Dungeon::generate_chunk_bind);
ClassDB::bind_method(D_METHOD("generate_structure", "structure", "spawn_mobs"), &Dungeon::generate_structure);
ClassDB::bind_method(D_METHOD("get_seed"), &Dungeon::get_seed);
ClassDB::bind_method(D_METHOD("set_seed", "value"), &Dungeon::set_seed);
ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
ClassDB::bind_method(D_METHOD("get_current_seed"), &Dungeon::get_current_seed);
ClassDB::bind_method(D_METHOD("set_current_seed", "value"), &Dungeon::set_current_seed);
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_seed"), "set_current_seed", "get_current_seed");
ClassDB::bind_method(D_METHOD("get_level_range"), &Dungeon::get_level_range);
ClassDB::bind_method(D_METHOD("set_level_range", "value"), &Dungeon::set_level_range);

View File

@ -21,8 +21,8 @@ class Dungeon : public Reference {
GDCLASS(Dungeon, Reference);
public:
int get_seed();
void set_seed(int value);
int get_current_seed();
void set_current_seed(int value);
Vector2 get_level_range();
void set_level_range(Vector2 value);
@ -110,7 +110,7 @@ protected:
static void _bind_methods();
private:
int _seed;
int _current_seed;
Vector2 _level_range;

View File

@ -1,10 +1,10 @@
#include "dungeon_room.h"
int DungeonRoom::get_seed() {
return _seed;
int DungeonRoom::get_current_seed() {
return _current_seed;
}
void DungeonRoom::set_seed(int value) {
_seed = value;
void DungeonRoom::set_current_seed(int value) {
_current_seed = value;
}
Vector2 DungeonRoom::get_level_range() {
@ -182,7 +182,7 @@ void DungeonRoom::generate_room(Ref<VoxelStructure> structure, bool spawn_mobs)
}
DungeonRoom::DungeonRoom() {
_seed = 0;
_current_seed = 0;
_posx = 0;
_posy = 0;
@ -213,9 +213,9 @@ void DungeonRoom::_bind_methods() {
ClassDB::bind_method(D_METHOD("generate_chunk", "chunk", "spawn_mobs"), &DungeonRoom::generate_chunk_bind);
ClassDB::bind_method(D_METHOD("generate_room", "structure", "spawn_mobs"), &DungeonRoom::generate_room);
ClassDB::bind_method(D_METHOD("get_seed"), &DungeonRoom::get_seed);
ClassDB::bind_method(D_METHOD("set_seed", "value"), &DungeonRoom::set_seed);
ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
ClassDB::bind_method(D_METHOD("get_current_seed"), &DungeonRoom::get_current_seed);
ClassDB::bind_method(D_METHOD("set_current_seed", "value"), &DungeonRoom::set_current_seed);
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_seed"), "set_current_seed", "get_current_seed");
ClassDB::bind_method(D_METHOD("get_level_range"), &DungeonRoom::get_level_range);
ClassDB::bind_method(D_METHOD("set_level_range", "value"), &DungeonRoom::set_level_range);

View File

@ -19,8 +19,8 @@ class DungeonRoom : public Reference {
GDCLASS(DungeonRoom, Reference);
public:
int get_seed();
void set_seed(int value);
int get_current_seed();
void set_current_seed(int value);
Vector2 get_level_range();
void set_level_range(Vector2 value);
@ -85,7 +85,7 @@ protected:
static void _bind_methods();
private:
int _seed;
int _current_seed;
Vector2 _level_range;

View File

@ -1,10 +1,10 @@
#include "planet.h"
int Planet::get_seed() {
return _seed;
int Planet::get_current_seed() {
return _current_seed;
}
void Planet::set_seed(int value) {
_seed = value;
void Planet::set_current_seed(int value) {
_current_seed = value;
}
Vector2 Planet::get_level_range() {
@ -131,7 +131,7 @@ Ref<Image> Planet::generate_map() {
}
Planet::Planet() {
_seed = 0;
_current_seed = 0;
}
Planet::~Planet() {
_environment.unref();
@ -150,9 +150,9 @@ void Planet::_bind_methods() {
ClassDB::bind_method(D_METHOD("setup_library", "library"), &Planet::setup_library);
ClassDB::bind_method(D_METHOD("_setup_library", "library"), &Planet::_setup_library);
ClassDB::bind_method(D_METHOD("get_seed"), &Planet::get_seed);
ClassDB::bind_method(D_METHOD("set_seed", "value"), &Planet::set_seed);
ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
ClassDB::bind_method(D_METHOD("get_current_seed"), &Planet::get_current_seed);
ClassDB::bind_method(D_METHOD("set_current_seed", "value"), &Planet::set_current_seed);
ADD_PROPERTY(PropertyInfo(Variant::INT, "current_seed"), "set_current_seed", "get_current_seed");
ClassDB::bind_method(D_METHOD("get_level_range"), &Planet::get_level_range);
ClassDB::bind_method(D_METHOD("set_level_range", "value"), &Planet::set_level_range);

View File

@ -19,8 +19,8 @@ class Planet : public Reference {
GDCLASS(Planet, Reference);
public:
int get_seed();
void set_seed(int value);
int get_current_seed();
void set_current_seed(int value);
Vector2 get_level_range();
void set_level_range(Vector2 value);
@ -61,7 +61,7 @@ protected:
static void _bind_methods();
private:
int _seed;
int _current_seed;
Vector2 _level_range;
Ref<EnvironmentData> _environment;
Ref<PlanetData> _data;