mirror of
https://github.com/Relintai/world_generator.git
synced 2024-11-12 10:15:07 +01:00
Now instance() will create the proper class instance, and also set up the script on it.
This commit is contained in:
parent
eed7f40e51
commit
bc2ee7171a
@ -281,22 +281,18 @@ void Biome::set_voxel_surfaces(const Vector<Variant> &voxel_surfaces) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Ref<Biome> Biome::instance(const int seed) {
|
Ref<Biome> Biome::instance(const int seed) {
|
||||||
if (has_method("_instance")) {
|
Ref<Biome> inst;
|
||||||
return call("_instance", seed, Ref<Biome>());
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ref<Biome>();
|
inst = Ref<Biome>(Object::cast_to<Biome>(ClassDB::instance(get_class_name())));
|
||||||
}
|
ERR_FAIL_COND_V(!inst.is_valid(), inst);
|
||||||
|
|
||||||
Ref<Biome> Biome::_instance(const int seed, Ref<Biome> biome) {
|
if (!get_script().is_null())
|
||||||
Ref<Biome> inst = biome;
|
|
||||||
|
|
||||||
if (!inst.is_valid())
|
|
||||||
inst.instance();
|
|
||||||
|
|
||||||
if (inst->get_script().is_null() && !get_script().is_null())
|
|
||||||
inst->set_script(get_script());
|
inst->set_script(get_script());
|
||||||
|
|
||||||
|
return call("_instance", seed, inst);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Biome> Biome::_instance(const int seed, Ref<Biome> inst) {
|
||||||
inst->set_current_seed(seed);
|
inst->set_current_seed(seed);
|
||||||
inst->set_level_range(_level_range);
|
inst->set_level_range(_level_range);
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Ref<Biome> instance(const int seed);
|
Ref<Biome> instance(const int seed);
|
||||||
virtual Ref<Biome> _instance(const int seed, Ref<Biome> biome);
|
virtual Ref<Biome> _instance(const int seed, Ref<Biome> inst);
|
||||||
|
|
||||||
void setup();
|
void setup();
|
||||||
|
|
||||||
|
@ -463,22 +463,18 @@ void Dungeon::set_environment_datas(const Vector<Variant> &environment_datas) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Ref<Dungeon> Dungeon::instance(const int seed) {
|
Ref<Dungeon> Dungeon::instance(const int seed) {
|
||||||
if (has_method("_instance")) {
|
Ref<Dungeon> inst;
|
||||||
return call("_instance", seed, Ref<Dungeon>());
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ref<Dungeon>();
|
inst = Ref<Dungeon>(Object::cast_to<Dungeon>(ClassDB::instance(get_class_name())));
|
||||||
}
|
ERR_FAIL_COND_V(!inst.is_valid(), inst);
|
||||||
|
|
||||||
Ref<Dungeon> Dungeon::_instance(const int seed, Ref<Dungeon> dungeon) {
|
if (!get_script().is_null())
|
||||||
Ref<Dungeon> inst = dungeon;
|
|
||||||
|
|
||||||
if (!inst.is_valid())
|
|
||||||
inst.instance();
|
|
||||||
|
|
||||||
if (inst->get_script().is_null() && !get_script().is_null())
|
|
||||||
inst->set_script(get_script());
|
inst->set_script(get_script());
|
||||||
|
|
||||||
|
return call("_instance", seed, inst);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Dungeon> Dungeon::_instance(const int seed, Ref<Dungeon> inst) {
|
||||||
inst->set_current_seed(seed);
|
inst->set_current_seed(seed);
|
||||||
inst->set_level_range(_level_range);
|
inst->set_level_range(_level_range);
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Ref<Dungeon> instance(const int seed);
|
Ref<Dungeon> instance(const int seed);
|
||||||
virtual Ref<Dungeon> _instance(const int seed, Ref<Dungeon> dungeon);
|
virtual Ref<Dungeon> _instance(const int seed, Ref<Dungeon> inst);
|
||||||
|
|
||||||
void setup();
|
void setup();
|
||||||
|
|
||||||
|
@ -53,17 +53,13 @@ int DungeonCorridor::get_dungeon_room_count() const {
|
|||||||
return _dungeon_rooms.size();
|
return _dungeon_rooms.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ref<DungeonRoom> DungeonCorridor::_instance(const int seed, Ref<DungeonRoom> dungeon_room) {
|
Ref<DungeonRoom> DungeonCorridor::_instance(const int seed, Ref<DungeonRoom> inst) {
|
||||||
Ref<DungeonCorridor> inst = dungeon_room;
|
|
||||||
|
|
||||||
if (!inst.is_valid())
|
|
||||||
inst.instance();
|
|
||||||
|
|
||||||
DungeonRoom::_instance(seed, inst);
|
DungeonRoom::_instance(seed, inst);
|
||||||
|
|
||||||
inst->set_max_connections(_max_connections);
|
Ref<DungeonCorridor> cinst = inst;
|
||||||
|
cinst->set_max_connections(_max_connections);
|
||||||
|
|
||||||
return inst;
|
return cinst;
|
||||||
}
|
}
|
||||||
|
|
||||||
DungeonCorridor::DungeonCorridor() {
|
DungeonCorridor::DungeonCorridor() {
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
|
|
||||||
int get_dungeon_room_count() const;
|
int get_dungeon_room_count() const;
|
||||||
|
|
||||||
Ref<DungeonRoom> _instance(const int seed, Ref<DungeonRoom> dungeon_room);
|
Ref<DungeonRoom> _instance(const int seed, Ref<DungeonRoom> inst);
|
||||||
|
|
||||||
DungeonCorridor();
|
DungeonCorridor();
|
||||||
~DungeonCorridor();
|
~DungeonCorridor();
|
||||||
|
@ -321,22 +321,18 @@ void DungeonRoom::set_entity_datas(const Vector<Variant> &entity_datas) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Ref<DungeonRoom> DungeonRoom::instance(const int seed) {
|
Ref<DungeonRoom> DungeonRoom::instance(const int seed) {
|
||||||
if (has_method("_instance")) {
|
Ref<DungeonRoom> inst;
|
||||||
return call("_instance", seed, Ref<DungeonRoom>());
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ref<DungeonRoom>();
|
inst = Ref<DungeonRoom>(Object::cast_to<DungeonRoom>(ClassDB::instance(get_class_name())));
|
||||||
}
|
ERR_FAIL_COND_V(!inst.is_valid(), inst);
|
||||||
|
|
||||||
Ref<DungeonRoom> DungeonRoom::_instance(const int seed, Ref<DungeonRoom> dungeon_room) {
|
if (!get_script().is_null())
|
||||||
Ref<DungeonRoom> inst = dungeon_room;
|
|
||||||
|
|
||||||
if (!inst.is_valid())
|
|
||||||
inst.instance();
|
|
||||||
|
|
||||||
if (inst->get_script().is_null() && !get_script().is_null())
|
|
||||||
inst->set_script(get_script());
|
inst->set_script(get_script());
|
||||||
|
|
||||||
|
return call("_instance", seed, inst);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<DungeonRoom> DungeonRoom::_instance(const int seed, Ref<DungeonRoom> inst) {
|
||||||
inst->set_current_seed(seed);
|
inst->set_current_seed(seed);
|
||||||
inst->set_level_range(_level_range);
|
inst->set_level_range(_level_range);
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Ref<DungeonRoom> instance(const int seed);
|
Ref<DungeonRoom> instance(const int seed);
|
||||||
virtual Ref<DungeonRoom> _instance(const int seed, Ref<DungeonRoom> dungeon_room);
|
virtual Ref<DungeonRoom> _instance(const int seed, Ref<DungeonRoom> inst);
|
||||||
|
|
||||||
void setup();
|
void setup();
|
||||||
|
|
||||||
|
@ -226,22 +226,18 @@ void Planet::set_voxel_surfaces(const Vector<Variant> &voxel_surfaces) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Ref<Planet> Planet::instance(const int seed) {
|
Ref<Planet> Planet::instance(const int seed) {
|
||||||
if (has_method("_instance")) {
|
Ref<Planet> inst;
|
||||||
return call("_instance", seed, Ref<Planet>());
|
|
||||||
}
|
|
||||||
|
|
||||||
return Ref<Planet>();
|
inst = Ref<Planet>(Object::cast_to<Planet>(ClassDB::instance(get_class_name())));
|
||||||
}
|
ERR_FAIL_COND_V(!inst.is_valid(), inst);
|
||||||
|
|
||||||
Ref<Planet> Planet::_instance(const int seed, Ref<Planet> planet) {
|
if (!get_script().is_null())
|
||||||
Ref<Planet> inst = planet;
|
|
||||||
|
|
||||||
if (!inst.is_valid())
|
|
||||||
inst.instance();
|
|
||||||
|
|
||||||
if (inst->get_script().is_null() && !get_script().is_null())
|
|
||||||
inst->set_script(get_script());
|
inst->set_script(get_script());
|
||||||
|
|
||||||
|
return call("_instance", seed, inst);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ref<Planet> Planet::_instance(const int seed, Ref<Planet> inst) {
|
||||||
inst->set_id(_id);
|
inst->set_id(_id);
|
||||||
inst->set_current_seed(seed);
|
inst->set_current_seed(seed);
|
||||||
inst->set_level_range(_level_range);
|
inst->set_level_range(_level_range);
|
||||||
|
@ -109,7 +109,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Ref<Planet> instance(const int seed);
|
Ref<Planet> instance(const int seed);
|
||||||
virtual Ref<Planet> _instance(const int seed, Ref<Planet> planet);
|
virtual Ref<Planet> _instance(const int seed, Ref<Planet> inst);
|
||||||
|
|
||||||
void setup();
|
void setup();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user