mirror of
https://github.com/Relintai/world_generator.git
synced 2025-02-20 17:24:22 +01:00
Add instance() helper to the data classes.
This commit is contained in:
parent
9a4f9f9809
commit
b70154cbdd
@ -280,6 +280,20 @@ void BiomeData::set_voxel_surfaces(const Vector<Variant> &voxel_surfaces) {
|
||||
|
||||
#endif
|
||||
|
||||
Ref<Biome> BiomeData::instance() {
|
||||
Ref<Biome> biome;
|
||||
|
||||
if (!_biome.is_valid()) {
|
||||
biome.instance();
|
||||
} else {
|
||||
biome = _biome->duplicate();
|
||||
}
|
||||
|
||||
biome->set_data(Ref<BiomeData>(this));
|
||||
|
||||
return biome;
|
||||
}
|
||||
|
||||
BiomeData::BiomeData() {
|
||||
}
|
||||
BiomeData::~BiomeData() {
|
||||
@ -372,4 +386,6 @@ void BiomeData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_voxel_surfaces", "voxel_surfaces"), &BiomeData::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"), &BiomeData::instance);
|
||||
}
|
||||
|
@ -115,6 +115,8 @@ public:
|
||||
void set_voxel_surfaces(const Vector<Variant> &voxel_surfaces);
|
||||
#endif
|
||||
|
||||
Ref<Biome> instance();
|
||||
|
||||
BiomeData();
|
||||
~BiomeData();
|
||||
|
||||
|
@ -407,6 +407,20 @@ void DungeonData::set_environment_datas(const Vector<Variant> &environment_datas
|
||||
}
|
||||
#endif
|
||||
|
||||
Ref<Dungeon> DungeonData::instance() {
|
||||
Ref<Dungeon> dungeon;
|
||||
|
||||
if (!_dungeon.is_valid()) {
|
||||
dungeon.instance();
|
||||
} else {
|
||||
dungeon = _dungeon->duplicate();
|
||||
}
|
||||
|
||||
dungeon->set_data(Ref<Dungeon>(this));
|
||||
|
||||
return dungeon;
|
||||
}
|
||||
|
||||
DungeonData::DungeonData() {
|
||||
_min_sizex = 0;
|
||||
_min_sizey = 0;
|
||||
@ -564,4 +578,6 @@ void DungeonData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_voxel_surfaces", "voxel_surfaces"), &DungeonData::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"), &DungeonData::instance);
|
||||
}
|
||||
|
@ -157,6 +157,8 @@ public:
|
||||
|
||||
#endif
|
||||
|
||||
Ref<Dungeon> instance();
|
||||
|
||||
DungeonData();
|
||||
~DungeonData();
|
||||
|
||||
|
@ -261,6 +261,20 @@ void DungeonRoomData::set_entity_datas(const Vector<Variant> &entity_datas) {
|
||||
|
||||
#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;
|
||||
@ -366,4 +380,6 @@ void DungeonRoomData::_bind_methods() {
|
||||
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);
|
||||
}
|
||||
|
@ -120,6 +120,8 @@ public:
|
||||
void set_entity_datas(const Vector<Variant> &entity_datas);
|
||||
#endif
|
||||
|
||||
Ref<DungeonRoom> instance();
|
||||
|
||||
DungeonRoomData();
|
||||
~DungeonRoomData();
|
||||
|
||||
|
@ -195,6 +195,20 @@ void PlanetData::set_voxel_surfaces(const Vector<Variant> &voxel_surfaces) {
|
||||
|
||||
#endif
|
||||
|
||||
Ref<Planet> PlanetData::instance() {
|
||||
Ref<Planet> planet;
|
||||
|
||||
if (!_planet.is_valid()) {
|
||||
planet.instance();
|
||||
} else {
|
||||
planet = _planet->duplicate();
|
||||
}
|
||||
|
||||
planet->set_data(Ref<Planet>(this));
|
||||
|
||||
return planet;
|
||||
}
|
||||
|
||||
PlanetData::PlanetData() {
|
||||
_id = 0;
|
||||
}
|
||||
@ -270,4 +284,6 @@ void PlanetData::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_voxel_surfaces", "voxel_surfaces"), &PlanetData::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"), &PlanetData::instance);
|
||||
}
|
||||
|
@ -95,6 +95,8 @@ public:
|
||||
|
||||
#endif
|
||||
|
||||
Ref<Planet> instance();
|
||||
|
||||
PlanetData();
|
||||
~PlanetData();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user