Same thing with DungonRooms and Corridors.

This commit is contained in:
Relintai 2020-07-21 19:32:21 +02:00
parent 3911f42894
commit e7acee7614
10 changed files with 325 additions and 690 deletions

2
SCsub
View File

@ -27,8 +27,6 @@ sources = [
"main/biome.cpp",
"main/planet.cpp",
"data/dungeon_room_data.cpp",
"data/dungeon_corridor_data.cpp",
"data/world_generator_prop_data.cpp",
"world_generator.cpp",

View File

@ -6,8 +6,6 @@ def configure(env):
def get_doc_classes():
return [
"DungeonCorridorData",
"DungeonRoomData",
"WorldGeneratorPropData",
"Planet",

View File

@ -1,54 +0,0 @@
/*
Copyright (c) 2019-2020 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "dungeon_corridor_data.h"
int DungeonCorridorData::get_max_connections() {
return _max_connections;
}
void DungeonCorridorData::set_max_connections(int value) {
_max_connections = value;
}
Ref<DungeonCorridor> DungeonCorridorData::setup_corridor(int seed) {
if (has_method("_setup_corridor")) {
return call("_setup_corridor", seed);
}
return Ref<DungeonCorridor>();
}
DungeonCorridorData::DungeonCorridorData() {
_max_connections = 2;
}
DungeonCorridorData::~DungeonCorridorData() {
}
void DungeonCorridorData::_bind_methods() {
BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "corridor", PROPERTY_HINT_RESOURCE_TYPE, "DungeonCorridor"), "_setup_corridor", PropertyInfo(Variant::INT, "seed")));
ClassDB::bind_method(D_METHOD("setup_corridor", "seed"), &DungeonCorridorData::setup_corridor);
ClassDB::bind_method(D_METHOD("get_max_connections"), &DungeonCorridorData::get_max_connections);
ClassDB::bind_method(D_METHOD("set_max_connections", "value"), &DungeonCorridorData::set_max_connections);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_connections"), "set_max_connections", "get_max_connections");
}

View File

@ -1,49 +0,0 @@
/*
Copyright (c) 2019-2020 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef DUNGEON_CORRIDOR_DATA_H
#define DUNGEON_CORRIDOR_DATA_H
#include "dungeon_room_data.h"
#include "../main/dungeon_corridor.h"
class DungeonCorridorData : public DungeonRoomData {
GDCLASS(DungeonCorridorData, DungeonRoomData);
public:
int get_max_connections();
void set_max_connections(int value);
Ref<DungeonCorridor> setup_corridor(int seed);
DungeonCorridorData();
~DungeonCorridorData();
protected:
static void _bind_methods();
private:
int _max_connections;
};
#endif

View File

@ -1,385 +0,0 @@
/*
Copyright (c) 2019-2020 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "dungeon_room_data.h"
#include "core/version.h"
Ref<DungeonRoom> DungeonRoomData::get_dungeon_room() {
return _dungeon_room;
}
void DungeonRoomData::set_dungeon_room(const Ref<DungeonRoom> &room) {
_dungeon_room = room;
}
Vector2 DungeonRoomData::get_level_range() {
return _level_range;
}
void DungeonRoomData::set_level_range(Vector2 value) {
_level_range = value;
}
//Min Size
int DungeonRoomData::get_min_sizex() {
return _min_sizex;
}
void DungeonRoomData::set_min_sizex(int value) {
_min_sizex = value;
}
int DungeonRoomData::get_min_sizey() {
return _min_sizey;
}
void DungeonRoomData::set_min_sizey(int value) {
_min_sizey = value;
}
int DungeonRoomData::get_min_sizez() {
return _min_sizez;
}
void DungeonRoomData::set_min_sizez(int value) {
_min_sizez = value;
}
//Max Size
int DungeonRoomData::get_max_sizex() {
return _max_sizex;
}
void DungeonRoomData::set_max_sizex(int value) {
_max_sizex = value;
}
int DungeonRoomData::get_max_sizey() {
return _max_sizey;
}
void DungeonRoomData::set_max_sizey(int value) {
_max_sizey = value;
}
int DungeonRoomData::get_max_sizez() {
return _max_sizez;
}
void DungeonRoomData::set_max_sizez(int value) {
_max_sizez = value;
}
//Props
Ref<WorldGeneratorPropData> DungeonRoomData::get_prop_data(const int index) const {
ERR_FAIL_INDEX_V(index, _prop_datas.size(), Ref<WorldGeneratorPropData>());
return _prop_datas.get(index);
}
void DungeonRoomData::set_prop_data(const int index, const Ref<WorldGeneratorPropData> prop_data) {
ERR_FAIL_INDEX(index, _prop_datas.size());
_prop_datas.set(index, prop_data);
}
void DungeonRoomData::add_prop_data(const Ref<WorldGeneratorPropData> prop_data) {
_prop_datas.push_back(prop_data);
}
void DungeonRoomData::remove_prop_data(const int index) {
ERR_FAIL_INDEX(index, _prop_datas.size());
_prop_datas.remove(index);
}
int DungeonRoomData::get_prop_data_count() const {
return _prop_datas.size();
}
Vector<Variant> DungeonRoomData::get_prop_datas() {
Vector<Variant> r;
for (int i = 0; i < _prop_datas.size(); i++) {
#if VERSION_MAJOR < 4
r.push_back(_prop_datas[i].get_ref_ptr());
#else
r.push_back(_prop_datas[i]);
#endif
}
return r;
}
void DungeonRoomData::set_prop_datas(const Vector<Variant> &prop_datas) {
_prop_datas.clear();
for (int i = 0; i < prop_datas.size(); i++) {
Ref<WorldGeneratorPropData> prop_data = Ref<WorldGeneratorPropData>(prop_datas[i]);
_prop_datas.push_back(prop_data);
}
}
#ifdef VOXELMAN_PRESENT
//Environments
Ref<EnvironmentData> DungeonRoomData::get_environment_data(const int index) const {
ERR_FAIL_INDEX_V(index, _environment_datas.size(), Ref<EnvironmentData>());
return _environment_datas.get(index);
}
void DungeonRoomData::set_environment_data(const int index, const Ref<EnvironmentData> environment_data) {
ERR_FAIL_INDEX(index, _environment_datas.size());
_environment_datas.set(index, environment_data);
}
void DungeonRoomData::add_environment_data(const Ref<EnvironmentData> environment_data) {
_environment_datas.push_back(environment_data);
}
void DungeonRoomData::remove_environment_data(const int index) {
ERR_FAIL_INDEX(index, _environment_datas.size());
_environment_datas.remove(index);
}
int DungeonRoomData::get_environment_data_count() const {
return _environment_datas.size();
}
Vector<Variant> DungeonRoomData::get_environment_datas() {
Vector<Variant> r;
for (int i = 0; i < _environment_datas.size(); i++) {
#if VERSION_MAJOR < 4
r.push_back(_environment_datas[i].get_ref_ptr());
#else
r.push_back(_environment_datas[i]);
#endif
}
return r;
}
void DungeonRoomData::set_environment_datas(const Vector<Variant> &environment_datas) {
_environment_datas.clear();
for (int i = 0; i < environment_datas.size(); i++) {
Ref<EnvironmentData> environment_data = Ref<EnvironmentData>(environment_datas[i]);
_environment_datas.push_back(environment_data);
}
}
//// Surfaces ////
Ref<VoxelSurface> DungeonRoomData::get_voxel_surface(const int index) const {
ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref<VoxelSurface>());
return _voxel_surfaces.get(index);
}
void DungeonRoomData::set_voxel_surface(const int index, const Ref<VoxelSurface> voxel_surface) {
ERR_FAIL_INDEX(index, _voxel_surfaces.size());
_voxel_surfaces.set(index, voxel_surface);
}
void DungeonRoomData::add_voxel_surface(const Ref<VoxelSurface> voxel_surface) {
_voxel_surfaces.push_back(voxel_surface);
}
void DungeonRoomData::remove_voxel_surface(const int index) {
ERR_FAIL_INDEX(index, _voxel_surfaces.size());
_voxel_surfaces.remove(index);
}
int DungeonRoomData::get_voxel_surface_count() const {
return _voxel_surfaces.size();
}
Vector<Variant> DungeonRoomData::get_voxel_surfaces() {
Vector<Variant> r;
for (int i = 0; i < _voxel_surfaces.size(); i++) {
#if VERSION_MAJOR < 4
r.push_back(_voxel_surfaces[i].get_ref_ptr());
#else
r.push_back(_voxel_surfaces[i]);
#endif
}
return r;
}
void DungeonRoomData::set_voxel_surfaces(const Vector<Variant> &voxel_surfaces) {
_voxel_surfaces.clear();
for (int i = 0; i < voxel_surfaces.size(); i++) {
Ref<EnvironmentData> voxel_surface = Ref<EnvironmentData>(voxel_surfaces[i]);
_voxel_surfaces.push_back(voxel_surface);
}
}
#endif
#ifdef ESS_PRESENT
//Entities
Ref<EntityData> DungeonRoomData::get_entity_data(const int index) const {
ERR_FAIL_INDEX_V(index, _entity_datas.size(), Ref<EntityData>());
return _entity_datas.get(index);
}
void DungeonRoomData::set_entity_data(const int index, const Ref<EntityData> entity_data) {
ERR_FAIL_INDEX(index, _entity_datas.size());
_entity_datas.set(index, entity_data);
}
void DungeonRoomData::add_entity_data(const Ref<EntityData> entity_data) {
_entity_datas.push_back(entity_data);
}
void DungeonRoomData::remove_entity_data(const int index) {
ERR_FAIL_INDEX(index, _entity_datas.size());
_entity_datas.remove(index);
}
int DungeonRoomData::get_entity_data_count() const {
return _entity_datas.size();
}
Vector<Variant> DungeonRoomData::get_entity_datas() {
Vector<Variant> r;
for (int i = 0; i < _entity_datas.size(); i++) {
#if VERSION_MAJOR < 4
r.push_back(_entity_datas[i].get_ref_ptr());
#else
r.push_back(_entity_datas[i]);
#endif
}
return r;
}
void DungeonRoomData::set_entity_datas(const Vector<Variant> &entity_datas) {
_entity_datas.clear();
for (int i = 0; i < entity_datas.size(); i++) {
Ref<EntityData> entity_data = Ref<EntityData>(entity_datas[i]);
_entity_datas.push_back(entity_data);
}
}
#endif
Ref<DungeonRoom> DungeonRoomData::instance() {
Ref<DungeonRoom> dungeon_room;
if (!_dungeon_room.is_valid()) {
dungeon_room.instance();
} else {
dungeon_room = _dungeon_room->duplicate();
}
dungeon_room->set_data(Ref<DungeonRoomData>(this));
return dungeon_room;
}
DungeonRoomData::DungeonRoomData() {
_min_sizex = 0;
_min_sizey = 0;
_min_sizez = 0;
_max_sizex = 0;
_max_sizey = 0;
_max_sizez = 0;
}
DungeonRoomData::~DungeonRoomData() {
_prop_datas.clear();
#ifdef ESS_PRESENT
_entity_datas.clear();
#endif
#ifdef VOXELMAN_PRESENT
_environment_datas.clear();
_voxel_surfaces.clear();
_liquid_voxel_surfaces.clear();
#endif
}
void DungeonRoomData::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_dungeon_room"), &DungeonRoomData::get_dungeon_room);
ClassDB::bind_method(D_METHOD("set_dungeon_room", "value"), &DungeonRoomData::set_dungeon_room);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "dungeon_room", PROPERTY_HINT_RESOURCE_TYPE, "DungeonRoom"), "set_dungeon_room", "get_dungeon_room");
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");
//Min Size
ClassDB::bind_method(D_METHOD("get_min_sizex"), &DungeonRoomData::get_min_sizex);
ClassDB::bind_method(D_METHOD("set_min_sizex", "value"), &DungeonRoomData::set_min_sizex);
ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizex"), "set_min_sizex", "get_min_sizex");
ClassDB::bind_method(D_METHOD("get_min_sizey"), &DungeonRoomData::get_min_sizey);
ClassDB::bind_method(D_METHOD("set_min_sizey", "value"), &DungeonRoomData::set_min_sizey);
ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizey"), "set_min_sizey", "get_min_sizey");
ClassDB::bind_method(D_METHOD("get_min_sizez"), &DungeonRoomData::get_min_sizez);
ClassDB::bind_method(D_METHOD("set_min_sizez", "value"), &DungeonRoomData::set_min_sizez);
ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizez"), "set_min_sizez", "get_min_sizez");
//Max Size
ClassDB::bind_method(D_METHOD("get_max_sizex"), &DungeonRoomData::get_max_sizex);
ClassDB::bind_method(D_METHOD("set_max_sizex", "value"), &DungeonRoomData::set_max_sizex);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizex"), "set_max_sizex", "get_max_sizex");
ClassDB::bind_method(D_METHOD("get_max_sizey"), &DungeonRoomData::get_max_sizey);
ClassDB::bind_method(D_METHOD("set_max_sizey", "value"), &DungeonRoomData::set_max_sizey);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizey"), "set_max_sizey", "get_max_sizey");
ClassDB::bind_method(D_METHOD("get_max_sizez"), &DungeonRoomData::get_max_sizez);
ClassDB::bind_method(D_METHOD("set_max_sizez", "value"), &DungeonRoomData::set_max_sizez);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizez"), "set_max_sizez", "get_max_sizez");
//Props
ClassDB::bind_method(D_METHOD("get_prop_data", "index"), &DungeonRoomData::get_prop_data);
ClassDB::bind_method(D_METHOD("set_prop_data", "index", "data"), &DungeonRoomData::set_prop_data);
ClassDB::bind_method(D_METHOD("add_prop_data", "prop_data"), &DungeonRoomData::add_prop_data);
ClassDB::bind_method(D_METHOD("remove_prop_data", "index"), &DungeonRoomData::remove_prop_data);
ClassDB::bind_method(D_METHOD("get_prop_data_count"), &DungeonRoomData::get_prop_data_count);
ClassDB::bind_method(D_METHOD("get_prop_datas"), &DungeonRoomData::get_prop_datas);
ClassDB::bind_method(D_METHOD("set_prop_datas", "prop_datas"), &DungeonRoomData::set_prop_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "prop_datas", PROPERTY_HINT_NONE, "17/17:WorldGeneratorPropData", PROPERTY_USAGE_DEFAULT, "WorldGeneratorPropData"), "set_prop_datas", "get_prop_datas");
#ifdef ESS_PRESENT
//Entities
ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &DungeonRoomData::get_entity_data);
ClassDB::bind_method(D_METHOD("set_entity_data", "index", "data"), &DungeonRoomData::set_entity_data);
ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &DungeonRoomData::add_entity_data);
ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &DungeonRoomData::remove_entity_data);
ClassDB::bind_method(D_METHOD("get_entity_data_count"), &DungeonRoomData::get_entity_data_count);
ClassDB::bind_method(D_METHOD("get_entity_datas"), &DungeonRoomData::get_entity_datas);
ClassDB::bind_method(D_METHOD("set_entity_datas", "entity_datas"), &DungeonRoomData::set_entity_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_datas", PROPERTY_HINT_NONE, "17/17:EntityData", PROPERTY_USAGE_DEFAULT, "EntityData"), "set_entity_datas", "get_entity_datas");
#endif
#ifdef VOXELMAN_PRESENT
//Environments
ClassDB::bind_method(D_METHOD("get_environment_data", "index"), &DungeonRoomData::get_environment_data);
ClassDB::bind_method(D_METHOD("set_environment_data", "index", "data"), &DungeonRoomData::set_environment_data);
ClassDB::bind_method(D_METHOD("add_environment_data", "environment_data"), &DungeonRoomData::add_environment_data);
ClassDB::bind_method(D_METHOD("remove_environment_data", "index"), &DungeonRoomData::remove_environment_data);
ClassDB::bind_method(D_METHOD("get_environment_data_count"), &DungeonRoomData::get_environment_data_count);
ClassDB::bind_method(D_METHOD("get_environment_datas"), &DungeonRoomData::get_environment_datas);
ClassDB::bind_method(D_METHOD("set_environment_datas", "environment_datas"), &DungeonRoomData::set_environment_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "environment_datas", PROPERTY_HINT_NONE, "17/17:EnvironmentData", PROPERTY_USAGE_DEFAULT, "EnvironmentData"), "set_environment_datas", "get_environment_datas");
//Surfaces
ClassDB::bind_method(D_METHOD("get_voxel_surface", "index"), &DungeonRoomData::get_voxel_surface);
ClassDB::bind_method(D_METHOD("set_voxel_surface", "index", "data"), &DungeonRoomData::set_voxel_surface);
ClassDB::bind_method(D_METHOD("add_voxel_surface", "voxel_surface"), &DungeonRoomData::add_voxel_surface);
ClassDB::bind_method(D_METHOD("remove_voxel_surface", "index"), &DungeonRoomData::remove_voxel_surface);
ClassDB::bind_method(D_METHOD("get_voxel_surface_count"), &DungeonRoomData::get_voxel_surface_count);
ClassDB::bind_method(D_METHOD("get_voxel_surfaces"), &DungeonRoomData::get_voxel_surfaces);
ClassDB::bind_method(D_METHOD("set_voxel_surfaces", "voxel_surfaces"), &DungeonRoomData::set_voxel_surfaces);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurface", PROPERTY_USAGE_DEFAULT, "VoxelSurface"), "set_voxel_surfaces", "get_voxel_surfaces");
#endif
ClassDB::bind_method(D_METHOD("instance"), &DungeonRoomData::instance);
}

View File

@ -1,157 +0,0 @@
/*
Copyright (c) 2019-2020 Péter Magyar
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef DUNGEON_ROOM_DATA_H
#define DUNGEON_ROOM_DATA_H
#include "core/resource.h"
#include "core/script_language.h"
#include "core/ustring.h"
#include "../main/dungeon_room.h"
#include "world_generator_prop_data.h"
#ifdef ESS_PRESENT
#include "../../entity_spell_system/entities/data/entity_data.h"
#endif
#ifdef VOXELMAN_PRESENT
#include "../../voxelman/library/voxel_surface.h"
#include "../../voxelman/world/environment_data.h"
#endif
class DungeonRoom;
class DungeonRoomData : public Resource {
GDCLASS(DungeonRoomData, Resource);
public:
Ref<DungeonRoom> get_dungeon_room();
void set_dungeon_room(const Ref<DungeonRoom> &room);
Vector2 get_level_range();
void set_level_range(Vector2 value);
//Min Size
int get_min_sizex();
void set_min_sizex(int value);
int get_min_sizey();
void set_min_sizey(int value);
int get_min_sizez();
void set_min_sizez(int value);
//Max Size
int get_max_sizex();
void set_max_sizex(int value);
int get_max_sizey();
void set_max_sizey(int value);
int get_max_sizez();
void set_max_sizez(int value);
//Prop Data
Ref<WorldGeneratorPropData> get_prop_data(const int index) const;
void set_prop_data(const int index, const Ref<WorldGeneratorPropData> prop_data);
void add_prop_data(const Ref<WorldGeneratorPropData> prop_data);
void remove_prop_data(const int index);
int get_prop_data_count() const;
Vector<Variant> get_prop_datas();
void set_prop_datas(const Vector<Variant> &prop_datas);
#ifdef VOXELMAN_PRESENT
//TOO: Environments are useful for every game, this should be decoupled from voxelman.
//Environments
Ref<EnvironmentData> get_environment_data(const int index) const;
void set_environment_data(const int index, const Ref<EnvironmentData> environment_data);
void add_environment_data(const Ref<EnvironmentData> environment_data);
void remove_environment_data(const int index);
int get_environment_data_count() const;
Vector<Variant> get_environment_datas();
void set_environment_datas(const Vector<Variant> &environment_datas);
//Surfaces
Ref<VoxelSurface> get_voxel_surface(const int index) const;
void set_voxel_surface(const int index, const Ref<VoxelSurface> voxel_surface);
void add_voxel_surface(const Ref<VoxelSurface> voxel_surface);
void remove_voxel_surface(const int index);
int get_voxel_surface_count() const;
Vector<Variant> get_voxel_surfaces();
void set_voxel_surfaces(const Vector<Variant> &voxel_surfaces);
#else
//TODO Create generic binds
#endif
#ifdef ESS_PRESENT
//Entities
Ref<EntityData> get_entity_data(const int index) const;
void set_entity_data(const int index, const Ref<EntityData> entity_data);
void add_entity_data(const Ref<EntityData> entity_data);
void remove_entity_data(const int index);
int get_entity_data_count() const;
Vector<Variant> get_entity_datas();
void set_entity_datas(const Vector<Variant> &entity_datas);
#endif
Ref<DungeonRoom> instance();
DungeonRoomData();
~DungeonRoomData();
protected:
static void _bind_methods();
private:
Ref<DungeonRoom> _dungeon_room;
Vector2 _level_range;
int _min_sizex;
int _min_sizey;
int _min_sizez;
int _max_sizex;
int _max_sizey;
int _max_sizez;
Vector<Ref<WorldGeneratorPropData> > _prop_datas;
#ifdef ESS_PRESENT
Vector<Ref<EntityData> > _entity_datas;
#endif
#ifdef VOXELMAN_PRESENT
Vector<Ref<EnvironmentData> > _environment_datas;
Vector<Ref<VoxelSurface> > _voxel_surfaces;
Vector<Ref<VoxelSurface> > _liquid_voxel_surfaces;
#endif
};
#endif

View File

@ -192,7 +192,7 @@ Vector<Variant> Dungeon::get_dungeon_rooms() {
void Dungeon::set_dungeon_rooms(const Vector<Variant> &dungeon_rooms) {
_dungeon_rooms.clear();
for (int i = 0; i < dungeon_rooms.size(); i++) {
Ref<DungeonRoomData> dungeon_room_data = Ref<DungeonRoomData>(dungeon_rooms[i]);
Ref<DungeonRoom> dungeon_room_data = Ref<DungeonRoom>(dungeon_rooms[i]);
_dungeon_rooms.push_back(dungeon_room_data);
}
@ -236,7 +236,7 @@ Vector<Variant> Dungeon::get_dungeon_start_rooms() {
void Dungeon::set_dungeon_start_rooms(const Vector<Variant> &dungeon_start_rooms) {
_dungeon_start_rooms.clear();
for (int i = 0; i < dungeon_start_rooms.size(); i++) {
Ref<DungeonRoomData> dungeon_start_room_data = Ref<DungeonRoomData>(dungeon_start_rooms[i]);
Ref<DungeonRoom> dungeon_start_room_data = Ref<DungeonRoom>(dungeon_start_rooms[i]);
_dungeon_start_rooms.push_back(dungeon_start_room_data);
}
@ -280,7 +280,7 @@ Vector<Variant> Dungeon::get_dungeon_end_rooms() {
void Dungeon::set_dungeon_end_rooms(const Vector<Variant> &dungeon_end_rooms) {
_dungeon_end_rooms.clear();
for (int i = 0; i < dungeon_end_rooms.size(); i++) {
Ref<DungeonRoomData> dungeon_end_room_data = Ref<DungeonRoomData>(dungeon_end_rooms[i]);
Ref<DungeonRoom> dungeon_end_room_data = Ref<DungeonRoom>(dungeon_end_rooms[i]);
_dungeon_end_rooms.push_back(dungeon_end_room_data);
}
@ -323,7 +323,7 @@ Vector<Variant> Dungeon::get_dungeon_corridors() {
void Dungeon::set_dungeon_corridors(const Vector<Variant> &dungeon_corridors) {
_dungeon_corridors.clear();
for (int i = 0; i < dungeon_corridors.size(); i++) {
Ref<DungeonRoomData> dungeon_corridor_data = Ref<DungeonRoomData>(dungeon_corridors[i]);
Ref<DungeonRoom> dungeon_corridor_data = Ref<DungeonRoom>(dungeon_corridors[i]);
_dungeon_corridors.push_back(dungeon_corridor_data);
}
@ -719,7 +719,7 @@ void Dungeon::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_dungeon_rooms"), &Dungeon::get_dungeon_rooms);
ClassDB::bind_method(D_METHOD("set_dungeon_rooms", "dungeon_rooms"), &Dungeon::set_dungeon_rooms);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_rooms", PROPERTY_HINT_NONE, "17/17:DungeonRoomData", PROPERTY_USAGE_DEFAULT, "DungeonRoomData"), "set_dungeon_rooms", "get_dungeon_rooms");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_rooms", PROPERTY_HINT_NONE, "17/17:DungeonRoom", PROPERTY_USAGE_DEFAULT, "DungeonRoom"), "set_dungeon_rooms", "get_dungeon_rooms");
//Start Rooms
ClassDB::bind_method(D_METHOD("get_dungeon_start_room", "index"), &Dungeon::get_dungeon_start_room);
@ -731,7 +731,7 @@ void Dungeon::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_dungeon_start_rooms"), &Dungeon::get_dungeon_start_rooms);
ClassDB::bind_method(D_METHOD("set_dungeon_start_rooms", "dungeon_start_rooms"), &Dungeon::set_dungeon_start_rooms);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_start_rooms", PROPERTY_HINT_NONE, "17/17:DungeonRoomData", PROPERTY_USAGE_DEFAULT, "DungeonRoomData"), "set_dungeon_start_rooms", "get_dungeon_start_rooms");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_start_rooms", PROPERTY_HINT_NONE, "17/17:DungeonRoom", PROPERTY_USAGE_DEFAULT, "DungeonRoom"), "set_dungeon_start_rooms", "get_dungeon_start_rooms");
//End Rooms
ClassDB::bind_method(D_METHOD("get_dungeon_end_room", "index"), &Dungeon::get_dungeon_end_room);
@ -742,7 +742,7 @@ void Dungeon::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_dungeon_end_rooms"), &Dungeon::get_dungeon_end_rooms);
ClassDB::bind_method(D_METHOD("set_dungeon_end_rooms", "dungeon_end_rooms"), &Dungeon::set_dungeon_end_rooms);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_end_rooms", PROPERTY_HINT_NONE, "17/17:DungeonRoomData", PROPERTY_USAGE_DEFAULT, "DungeonRoomData"), "set_dungeon_end_rooms", "get_dungeon_end_rooms");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_end_rooms", PROPERTY_HINT_NONE, "17/17:DungeonRoom", PROPERTY_USAGE_DEFAULT, "DungeonRoom"), "set_dungeon_end_rooms", "get_dungeon_end_rooms");
//Corridors
ClassDB::bind_method(D_METHOD("get_dungeon_corridor", "index"), &Dungeon::get_dungeon_corridor);
@ -753,7 +753,7 @@ void Dungeon::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_dungeon_corridors"), &Dungeon::get_dungeon_corridors);
ClassDB::bind_method(D_METHOD("set_dungeon_corridors", "dungeon_corridors"), &Dungeon::set_dungeon_corridors);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_corridors", PROPERTY_HINT_NONE, "17/17:DungeonCorridorData", PROPERTY_USAGE_DEFAULT, "DungeonCorridorData"), "set_dungeon_corridors", "get_dungeon_corridors");
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "dungeon_corridors", PROPERTY_HINT_NONE, "17/17:DungeonCorridor", PROPERTY_USAGE_DEFAULT, "DungeonCorridor"), "set_dungeon_corridors", "get_dungeon_corridors");
#ifdef ESS_PRESENT
//Entities

View File

@ -36,6 +36,50 @@ void DungeonRoom::set_level_range(Vector2 value) {
_level_range = value;
}
//Min Size
int DungeonRoom::get_min_sizex() {
return _min_sizex;
}
void DungeonRoom::set_min_sizex(int value) {
_min_sizex = value;
}
int DungeonRoom::get_min_sizey() {
return _min_sizey;
}
void DungeonRoom::set_min_sizey(int value) {
_min_sizey = value;
}
int DungeonRoom::get_min_sizez() {
return _min_sizez;
}
void DungeonRoom::set_min_sizez(int value) {
_min_sizez = value;
}
//Max Size
int DungeonRoom::get_max_sizex() {
return _max_sizex;
}
void DungeonRoom::set_max_sizex(int value) {
_max_sizex = value;
}
int DungeonRoom::get_max_sizey() {
return _max_sizey;
}
void DungeonRoom::set_max_sizey(int value) {
_max_sizey = value;
}
int DungeonRoom::get_max_sizez() {
return _max_sizez;
}
void DungeonRoom::set_max_sizez(int value) {
_max_sizez = value;
}
//Position
int DungeonRoom::get_posx() {
return _posx;
@ -89,13 +133,6 @@ void DungeonRoom::set_environment(Ref<EnvironmentData> value) {
}
#endif
Ref<DungeonRoomData> DungeonRoom::get_data() {
return _data;
}
void DungeonRoom::set_data(Ref<DungeonRoomData> value) {
_data = value;
}
#ifdef VOXELMAN_PRESENT
Ref<VoxelStructure> DungeonRoom::get_structure() {
return _structure;
@ -128,6 +165,115 @@ int DungeonRoom::get_prop_data_count() const {
return _prop_datas.size();
}
Vector<Variant> DungeonRoom::get_prop_datas() {
Vector<Variant> r;
for (int i = 0; i < _prop_datas.size(); i++) {
#if VERSION_MAJOR < 4
r.push_back(_prop_datas[i].get_ref_ptr());
#else
r.push_back(_prop_datas[i]);
#endif
}
return r;
}
void DungeonRoom::set_prop_datas(const Vector<Variant> &prop_datas) {
_prop_datas.clear();
for (int i = 0; i < prop_datas.size(); i++) {
Ref<WorldGeneratorPropData> prop_data = Ref<WorldGeneratorPropData>(prop_datas[i]);
_prop_datas.push_back(prop_data);
}
}
#ifdef VOXELMAN_PRESENT
//Environments
Ref<EnvironmentData> DungeonRoom::get_environment_data(const int index) const {
ERR_FAIL_INDEX_V(index, _environment_datas.size(), Ref<EnvironmentData>());
return _environment_datas.get(index);
}
void DungeonRoom::set_environment_data(const int index, const Ref<EnvironmentData> environment_data) {
ERR_FAIL_INDEX(index, _environment_datas.size());
_environment_datas.set(index, environment_data);
}
void DungeonRoom::add_environment_data(const Ref<EnvironmentData> environment_data) {
_environment_datas.push_back(environment_data);
}
void DungeonRoom::remove_environment_data(const int index) {
ERR_FAIL_INDEX(index, _environment_datas.size());
_environment_datas.remove(index);
}
int DungeonRoom::get_environment_data_count() const {
return _environment_datas.size();
}
Vector<Variant> DungeonRoom::get_environment_datas() {
Vector<Variant> r;
for (int i = 0; i < _environment_datas.size(); i++) {
#if VERSION_MAJOR < 4
r.push_back(_environment_datas[i].get_ref_ptr());
#else
r.push_back(_environment_datas[i]);
#endif
}
return r;
}
void DungeonRoom::set_environment_datas(const Vector<Variant> &environment_datas) {
_environment_datas.clear();
for (int i = 0; i < environment_datas.size(); i++) {
Ref<EnvironmentData> environment_data = Ref<EnvironmentData>(environment_datas[i]);
_environment_datas.push_back(environment_data);
}
}
//// Surfaces ////
Ref<VoxelSurface> DungeonRoom::get_voxel_surface(const int index) const {
ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref<VoxelSurface>());
return _voxel_surfaces.get(index);
}
void DungeonRoom::set_voxel_surface(const int index, const Ref<VoxelSurface> voxel_surface) {
ERR_FAIL_INDEX(index, _voxel_surfaces.size());
_voxel_surfaces.set(index, voxel_surface);
}
void DungeonRoom::add_voxel_surface(const Ref<VoxelSurface> voxel_surface) {
_voxel_surfaces.push_back(voxel_surface);
}
void DungeonRoom::remove_voxel_surface(const int index) {
ERR_FAIL_INDEX(index, _voxel_surfaces.size());
_voxel_surfaces.remove(index);
}
int DungeonRoom::get_voxel_surface_count() const {
return _voxel_surfaces.size();
}
Vector<Variant> DungeonRoom::get_voxel_surfaces() {
Vector<Variant> r;
for (int i = 0; i < _voxel_surfaces.size(); i++) {
#if VERSION_MAJOR < 4
r.push_back(_voxel_surfaces[i].get_ref_ptr());
#else
r.push_back(_voxel_surfaces[i]);
#endif
}
return r;
}
void DungeonRoom::set_voxel_surfaces(const Vector<Variant> &voxel_surfaces) {
_voxel_surfaces.clear();
for (int i = 0; i < voxel_surfaces.size(); i++) {
Ref<EnvironmentData> voxel_surface = Ref<EnvironmentData>(voxel_surfaces[i]);
_voxel_surfaces.push_back(voxel_surface);
}
}
#endif
#ifdef ESS_PRESENT
//Entities
Ref<EntityData> DungeonRoom::get_entity_data(const int index) const {
@ -151,12 +297,30 @@ void DungeonRoom::remove_entity_data(const int index) {
int DungeonRoom::get_entity_data_count() const {
return _entity_datas.size();
}
Vector<Variant> DungeonRoom::get_entity_datas() {
Vector<Variant> r;
for (int i = 0; i < _entity_datas.size(); i++) {
#if VERSION_MAJOR < 4
r.push_back(_entity_datas[i].get_ref_ptr());
#else
r.push_back(_entity_datas[i]);
#endif
}
return r;
}
void DungeonRoom::set_entity_datas(const Vector<Variant> &entity_datas) {
_entity_datas.clear();
for (int i = 0; i < entity_datas.size(); i++) {
Ref<EntityData> entity_data = Ref<EntityData>(entity_datas[i]);
_entity_datas.push_back(entity_data);
}
}
#endif
void DungeonRoom::setup() {
if (!_data.is_valid())
return;
if (has_method("_setup")) {
call("_setup");
}
@ -164,17 +328,14 @@ void DungeonRoom::setup() {
#ifdef VOXELMAN_PRESENT
void DungeonRoom::setup_library(Ref<VoxelmanLibrary> library) {
if (!_data.is_valid())
return;
if (has_method("_setup_library")) {
call("_setup_library", library);
}
}
void DungeonRoom::_setup_library(Ref<VoxelmanLibrary> library) {
for (int i = 0; i < _data->get_voxel_surface_count(); ++i) {
Ref<VoxelSurface> s = _data->get_voxel_surface(i);
for (int i = 0; i < get_voxel_surface_count(); ++i) {
Ref<VoxelSurface> s = get_voxel_surface(i);
if (s.is_valid()) {
library->add_voxel_surface(s);
@ -182,8 +343,8 @@ void DungeonRoom::_setup_library(Ref<VoxelmanLibrary> library) {
}
#ifdef PROPS_PRESENT
for (int i = 0; i < _data->get_prop_data_count(); ++i) {
Ref<WorldGeneratorPropData> s = _data->get_prop_data(i);
for (int i = 0; i < get_prop_data_count(); ++i) {
Ref<WorldGeneratorPropData> s = get_prop_data(i);
if (s.is_valid()) {
Ref<PackedScene> pd = s->get_prop();
@ -232,6 +393,14 @@ void DungeonRoom::generate_chunk(Ref<Resource> chunk, bool spawn_mobs) {
DungeonRoom::DungeonRoom() {
_current_seed = 0;
_min_sizex = 0;
_min_sizey = 0;
_min_sizez = 0;
_max_sizex = 0;
_max_sizey = 0;
_max_sizez = 0;
_posx = 0;
_posy = 0;
_posz = 0;
@ -241,7 +410,6 @@ DungeonRoom::DungeonRoom() {
_sizez = 0;
}
DungeonRoom::~DungeonRoom() {
_data.unref();
_prop_datas.clear();
#ifdef VOXELMAN_PRESENT
@ -252,6 +420,12 @@ DungeonRoom::~DungeonRoom() {
#ifdef ESS_PRESENT
_entity_datas.clear();
#endif
#ifdef VOXELMAN_PRESENT
_environment_datas.clear();
_voxel_surfaces.clear();
_liquid_voxel_surfaces.clear();
#endif
}
void DungeonRoom::_bind_methods() {
@ -288,6 +462,32 @@ void DungeonRoom::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_level_range", "value"), &DungeonRoom::set_level_range);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "level_range"), "set_level_range", "get_level_range");
//Min Size
ClassDB::bind_method(D_METHOD("get_min_sizex"), &DungeonRoom::get_min_sizex);
ClassDB::bind_method(D_METHOD("set_min_sizex", "value"), &DungeonRoom::set_min_sizex);
ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizex"), "set_min_sizex", "get_min_sizex");
ClassDB::bind_method(D_METHOD("get_min_sizey"), &DungeonRoom::get_min_sizey);
ClassDB::bind_method(D_METHOD("set_min_sizey", "value"), &DungeonRoom::set_min_sizey);
ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizey"), "set_min_sizey", "get_min_sizey");
ClassDB::bind_method(D_METHOD("get_min_sizez"), &DungeonRoom::get_min_sizez);
ClassDB::bind_method(D_METHOD("set_min_sizez", "value"), &DungeonRoom::set_min_sizez);
ADD_PROPERTY(PropertyInfo(Variant::INT, "min_sizez"), "set_min_sizez", "get_min_sizez");
//Max Size
ClassDB::bind_method(D_METHOD("get_max_sizex"), &DungeonRoom::get_max_sizex);
ClassDB::bind_method(D_METHOD("set_max_sizex", "value"), &DungeonRoom::set_max_sizex);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizex"), "set_max_sizex", "get_max_sizex");
ClassDB::bind_method(D_METHOD("get_max_sizey"), &DungeonRoom::get_max_sizey);
ClassDB::bind_method(D_METHOD("set_max_sizey", "value"), &DungeonRoom::set_max_sizey);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizey"), "set_max_sizey", "get_max_sizey");
ClassDB::bind_method(D_METHOD("get_max_sizez"), &DungeonRoom::get_max_sizez);
ClassDB::bind_method(D_METHOD("set_max_sizez", "value"), &DungeonRoom::set_max_sizez);
ADD_PROPERTY(PropertyInfo(Variant::INT, "max_sizez"), "set_max_sizez", "get_max_sizez");
//Position
ClassDB::bind_method(D_METHOD("get_posx"), &DungeonRoom::get_posx);
ClassDB::bind_method(D_METHOD("set_posx", "value"), &DungeonRoom::set_posx);
@ -320,10 +520,6 @@ void DungeonRoom::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "environment", PROPERTY_HINT_RESOURCE_TYPE, "EnvironmentData"), "set_environment", "get_environment");
#endif
ClassDB::bind_method(D_METHOD("get_data"), &DungeonRoom::get_data);
ClassDB::bind_method(D_METHOD("set_data", "value"), &DungeonRoom::set_data);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "data", PROPERTY_HINT_RESOURCE_TYPE, "DungeonRoomData", 0), "set_data", "get_data");
#ifdef VOXELMAN_PRESENT
ClassDB::bind_method(D_METHOD("get_structure"), &DungeonRoom::get_structure);
ClassDB::bind_method(D_METHOD("set_structure", "value"), &DungeonRoom::set_structure);
@ -337,6 +533,10 @@ void DungeonRoom::_bind_methods() {
ClassDB::bind_method(D_METHOD("remove_prop_data", "index"), &DungeonRoom::remove_prop_data);
ClassDB::bind_method(D_METHOD("get_prop_data_count"), &DungeonRoom::get_prop_data_count);
ClassDB::bind_method(D_METHOD("get_prop_datas"), &DungeonRoom::get_prop_datas);
ClassDB::bind_method(D_METHOD("set_prop_datas", "prop_datas"), &DungeonRoom::set_prop_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "prop_datas", PROPERTY_HINT_NONE, "17/17:WorldGeneratorPropData", PROPERTY_USAGE_DEFAULT, "WorldGeneratorPropData"), "set_prop_datas", "get_prop_datas");
#ifdef ESS_PRESENT
//Entities
ClassDB::bind_method(D_METHOD("get_entity_data", "index"), &DungeonRoom::get_entity_data);
@ -344,5 +544,33 @@ void DungeonRoom::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_entity_data", "entity_data"), &DungeonRoom::add_entity_data);
ClassDB::bind_method(D_METHOD("remove_entity_data", "index"), &DungeonRoom::remove_entity_data);
ClassDB::bind_method(D_METHOD("get_entity_data_count"), &DungeonRoom::get_entity_data_count);
ClassDB::bind_method(D_METHOD("get_entity_datas"), &DungeonRoom::get_entity_datas);
ClassDB::bind_method(D_METHOD("set_entity_datas", "entity_datas"), &DungeonRoom::set_entity_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "entity_datas", PROPERTY_HINT_NONE, "17/17:EntityData", PROPERTY_USAGE_DEFAULT, "EntityData"), "set_entity_datas", "get_entity_datas");
#endif
#ifdef VOXELMAN_PRESENT
//Environments
ClassDB::bind_method(D_METHOD("get_environment_data", "index"), &DungeonRoom::get_environment_data);
ClassDB::bind_method(D_METHOD("set_environment_data", "index", "data"), &DungeonRoom::set_environment_data);
ClassDB::bind_method(D_METHOD("add_environment_data", "environment_data"), &DungeonRoom::add_environment_data);
ClassDB::bind_method(D_METHOD("remove_environment_data", "index"), &DungeonRoom::remove_environment_data);
ClassDB::bind_method(D_METHOD("get_environment_data_count"), &DungeonRoom::get_environment_data_count);
ClassDB::bind_method(D_METHOD("get_environment_datas"), &DungeonRoom::get_environment_datas);
ClassDB::bind_method(D_METHOD("set_environment_datas", "environment_datas"), &DungeonRoom::set_environment_datas);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "environment_datas", PROPERTY_HINT_NONE, "17/17:EnvironmentData", PROPERTY_USAGE_DEFAULT, "EnvironmentData"), "set_environment_datas", "get_environment_datas");
//Surfaces
ClassDB::bind_method(D_METHOD("get_voxel_surface", "index"), &DungeonRoom::get_voxel_surface);
ClassDB::bind_method(D_METHOD("set_voxel_surface", "index", "data"), &DungeonRoom::set_voxel_surface);
ClassDB::bind_method(D_METHOD("add_voxel_surface", "voxel_surface"), &DungeonRoom::add_voxel_surface);
ClassDB::bind_method(D_METHOD("remove_voxel_surface", "index"), &DungeonRoom::remove_voxel_surface);
ClassDB::bind_method(D_METHOD("get_voxel_surface_count"), &DungeonRoom::get_voxel_surface_count);
ClassDB::bind_method(D_METHOD("get_voxel_surfaces"), &DungeonRoom::get_voxel_surfaces);
ClassDB::bind_method(D_METHOD("set_voxel_surfaces", "voxel_surfaces"), &DungeonRoom::set_voxel_surfaces);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurface", PROPERTY_USAGE_DEFAULT, "VoxelSurface"), "set_voxel_surfaces", "get_voxel_surfaces");
#endif
}

View File

@ -27,7 +27,6 @@ SOFTWARE.
#include "core/resource.h"
#include "core/vector.h"
#include "../data/dungeon_room_data.h"
#include "../data/world_generator_prop_data.h"
#include "scene/resources/packed_scene.h"
@ -45,8 +44,6 @@ SOFTWARE.
#include "../../entity_spell_system/entities/data/entity_data.h"
#endif
class DungeonRoomData;
class DungeonRoom : public Resource {
GDCLASS(DungeonRoom, Resource);
@ -57,6 +54,26 @@ public:
Vector2 get_level_range();
void set_level_range(Vector2 value);
//Min Size
int get_min_sizex();
void set_min_sizex(int value);
int get_min_sizey();
void set_min_sizey(int value);
int get_min_sizez();
void set_min_sizez(int value);
//Max Size
int get_max_sizex();
void set_max_sizex(int value);
int get_max_sizey();
void set_max_sizey(int value);
int get_max_sizez();
void set_max_sizez(int value);
//Pos
int get_posx();
void set_posx(int value);
@ -83,9 +100,6 @@ public:
void set_environment(Ref<EnvironmentData> value);
#endif
Ref<DungeonRoomData> get_data();
void set_data(Ref<DungeonRoomData> value);
#ifdef VOXELMAN_PRESENT
//Structure
Ref<VoxelStructure> get_structure();
@ -99,6 +113,36 @@ public:
void remove_prop_data(const int index);
int get_prop_data_count() const;
Vector<Variant> get_prop_datas();
void set_prop_datas(const Vector<Variant> &prop_datas);
#ifdef VOXELMAN_PRESENT
//TOO: Environments are useful for every game, this should be decoupled from voxelman.
//Environments
Ref<EnvironmentData> get_environment_data(const int index) const;
void set_environment_data(const int index, const Ref<EnvironmentData> environment_data);
void add_environment_data(const Ref<EnvironmentData> environment_data);
void remove_environment_data(const int index);
int get_environment_data_count() const;
Vector<Variant> get_environment_datas();
void set_environment_datas(const Vector<Variant> &environment_datas);
//Surfaces
Ref<VoxelSurface> get_voxel_surface(const int index) const;
void set_voxel_surface(const int index, const Ref<VoxelSurface> voxel_surface);
void add_voxel_surface(const Ref<VoxelSurface> voxel_surface);
void remove_voxel_surface(const int index);
int get_voxel_surface_count() const;
Vector<Variant> get_voxel_surfaces();
void set_voxel_surfaces(const Vector<Variant> &voxel_surfaces);
#else
//TODO Create generic binds
#endif
#ifdef ESS_PRESENT
//Entities
Ref<EntityData> get_entity_data(const int index) const;
@ -106,6 +150,9 @@ public:
void add_entity_data(const Ref<EntityData> entity_data);
void remove_entity_data(const int index);
int get_entity_data_count() const;
Vector<Variant> get_entity_datas();
void set_entity_datas(const Vector<Variant> &entity_datas);
#endif
void setup();
@ -132,6 +179,14 @@ private:
Vector2 _level_range;
int _min_sizex;
int _min_sizey;
int _min_sizez;
int _max_sizex;
int _max_sizey;
int _max_sizez;
int _posx;
int _posy;
int _posz;
@ -145,12 +200,17 @@ private:
Ref<VoxelStructure> _structure;
#endif
Ref<DungeonRoomData> _data;
Vector<Ref<WorldGeneratorPropData> > _prop_datas;
#ifdef ESS_PRESENT
Vector<Ref<EntityData> > _entity_datas;
#endif
#ifdef VOXELMAN_PRESENT
Vector<Ref<EnvironmentData> > _environment_datas;
Vector<Ref<VoxelSurface> > _voxel_surfaces;
Vector<Ref<VoxelSurface> > _liquid_voxel_surfaces;
#endif
};
#endif

View File

@ -22,8 +22,6 @@ SOFTWARE.
#include "register_types.h"
#include "data/dungeon_corridor_data.h"
#include "data/dungeon_room_data.h"
#include "data/world_generator_prop_data.h"
#include "main/biome.h"
@ -35,8 +33,6 @@ SOFTWARE.
#include "world_generator.h"
void register_world_generator_types() {
ClassDB::register_class<DungeonRoomData>();
ClassDB::register_class<DungeonCorridorData>();
ClassDB::register_class<WorldGeneratorPropData>();
ClassDB::register_class<DungeonRoom>();