mirror of
https://github.com/Relintai/world_generator.git
synced 2024-11-08 10:02:10 +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
|
||||
|
||||
Ref<Biome> Biome::instance(const int seed) {
|
||||
if (has_method("_instance")) {
|
||||
return call("_instance", seed, Ref<Biome>());
|
||||
}
|
||||
Ref<Biome> inst;
|
||||
|
||||
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) {
|
||||
Ref<Biome> inst = biome;
|
||||
|
||||
if (!inst.is_valid())
|
||||
inst.instance();
|
||||
|
||||
if (inst->get_script().is_null() && !get_script().is_null())
|
||||
if (!get_script().is_null())
|
||||
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_level_range(_level_range);
|
||||
|
||||
|
@ -119,7 +119,7 @@ public:
|
||||
#endif
|
||||
|
||||
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();
|
||||
|
||||
|
@ -463,22 +463,18 @@ void Dungeon::set_environment_datas(const Vector<Variant> &environment_datas) {
|
||||
#endif
|
||||
|
||||
Ref<Dungeon> Dungeon::instance(const int seed) {
|
||||
if (has_method("_instance")) {
|
||||
return call("_instance", seed, Ref<Dungeon>());
|
||||
}
|
||||
Ref<Dungeon> inst;
|
||||
|
||||
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) {
|
||||
Ref<Dungeon> inst = dungeon;
|
||||
|
||||
if (!inst.is_valid())
|
||||
inst.instance();
|
||||
|
||||
if (inst->get_script().is_null() && !get_script().is_null())
|
||||
if (!get_script().is_null())
|
||||
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_level_range(_level_range);
|
||||
|
||||
|
@ -187,7 +187,7 @@ public:
|
||||
#endif
|
||||
|
||||
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();
|
||||
|
||||
|
@ -53,17 +53,13 @@ int DungeonCorridor::get_dungeon_room_count() const {
|
||||
return _dungeon_rooms.size();
|
||||
}
|
||||
|
||||
Ref<DungeonRoom> DungeonCorridor::_instance(const int seed, Ref<DungeonRoom> dungeon_room) {
|
||||
Ref<DungeonCorridor> inst = dungeon_room;
|
||||
|
||||
if (!inst.is_valid())
|
||||
inst.instance();
|
||||
|
||||
Ref<DungeonRoom> DungeonCorridor::_instance(const int seed, Ref<DungeonRoom> 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() {
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
|
||||
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();
|
||||
|
@ -321,22 +321,18 @@ void DungeonRoom::set_entity_datas(const Vector<Variant> &entity_datas) {
|
||||
#endif
|
||||
|
||||
Ref<DungeonRoom> DungeonRoom::instance(const int seed) {
|
||||
if (has_method("_instance")) {
|
||||
return call("_instance", seed, Ref<DungeonRoom>());
|
||||
}
|
||||
Ref<DungeonRoom> inst;
|
||||
|
||||
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) {
|
||||
Ref<DungeonRoom> inst = dungeon_room;
|
||||
|
||||
if (!inst.is_valid())
|
||||
inst.instance();
|
||||
|
||||
if (inst->get_script().is_null() && !get_script().is_null())
|
||||
if (!get_script().is_null())
|
||||
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_level_range(_level_range);
|
||||
|
||||
|
@ -156,7 +156,7 @@ public:
|
||||
#endif
|
||||
|
||||
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();
|
||||
|
||||
|
@ -226,22 +226,18 @@ void Planet::set_voxel_surfaces(const Vector<Variant> &voxel_surfaces) {
|
||||
#endif
|
||||
|
||||
Ref<Planet> Planet::instance(const int seed) {
|
||||
if (has_method("_instance")) {
|
||||
return call("_instance", seed, Ref<Planet>());
|
||||
}
|
||||
Ref<Planet> inst;
|
||||
|
||||
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) {
|
||||
Ref<Planet> inst = planet;
|
||||
|
||||
if (!inst.is_valid())
|
||||
inst.instance();
|
||||
|
||||
if (inst->get_script().is_null() && !get_script().is_null())
|
||||
if (!get_script().is_null())
|
||||
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_current_seed(seed);
|
||||
inst->set_level_range(_level_range);
|
||||
|
@ -109,7 +109,7 @@ public:
|
||||
#endif
|
||||
|
||||
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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user