mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-23 20:36:53 +01:00
Reordered World.
This commit is contained in:
parent
68b21dc61f
commit
3894452760
@ -6,38 +6,8 @@
|
||||
#include "scene/resources/world_2d.h"
|
||||
#include "scene/resources/world_3d.h"
|
||||
|
||||
void World::set_use_own_world_3d(bool p_use_own_world_3d) {
|
||||
if (p_use_own_world_3d == own_world_3d.is_valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_inside_tree()) {
|
||||
_propagate_exit_world(this);
|
||||
}
|
||||
|
||||
if (p_use_own_world_3d) {
|
||||
if (world_3d.is_valid()) {
|
||||
own_world_3d = world_3d->duplicate();
|
||||
world_3d->connect(CoreStringNames::get_singleton()->changed, this, "_own_world_3d_changed");
|
||||
} else {
|
||||
own_world_3d = Ref<World3D>(memnew(World3D));
|
||||
}
|
||||
} else {
|
||||
own_world_3d = Ref<World3D>();
|
||||
if (world_3d.is_valid()) {
|
||||
world_3d->disconnect(CoreStringNames::get_singleton()->changed, this, "_own_world_3d_changed");
|
||||
}
|
||||
}
|
||||
|
||||
if (is_inside_tree()) {
|
||||
_propagate_enter_world(this);
|
||||
}
|
||||
|
||||
_on_set_use_own_world_3d(p_use_own_world_3d);
|
||||
}
|
||||
|
||||
bool World::is_using_own_world_3d() const {
|
||||
return own_world_3d.is_valid();
|
||||
Ref<World2D> World::get_world_2d() const {
|
||||
return world_2d;
|
||||
}
|
||||
|
||||
void World::set_world_2d(const Ref<World2D> &p_world_2d) {
|
||||
@ -76,6 +46,10 @@ Ref<World2D> World::find_world_2d() const {
|
||||
}
|
||||
}
|
||||
|
||||
Ref<World3D> World::get_world_3d() const {
|
||||
return world_3d;
|
||||
}
|
||||
|
||||
void World::set_world_3d(const Ref<World3D> &p_world_3d) {
|
||||
if (world_3d == p_world_3d) {
|
||||
return;
|
||||
@ -109,14 +83,6 @@ void World::set_world_3d(const Ref<World3D> &p_world_3d) {
|
||||
_on_set_world_3d(old_world);
|
||||
}
|
||||
|
||||
Ref<World3D> World::get_world_3d() const {
|
||||
return world_3d;
|
||||
}
|
||||
|
||||
Ref<World2D> World::get_world_2d() const {
|
||||
return world_2d;
|
||||
}
|
||||
|
||||
Ref<World3D> World::find_world_3d() const {
|
||||
if (own_world_3d.is_valid()) {
|
||||
return own_world_3d;
|
||||
@ -129,6 +95,46 @@ Ref<World3D> World::find_world_3d() const {
|
||||
}
|
||||
}
|
||||
|
||||
bool World::is_using_own_world_3d() const {
|
||||
return own_world_3d.is_valid();
|
||||
}
|
||||
|
||||
void World::set_use_own_world_3d(bool p_use_own_world_3d) {
|
||||
if (p_use_own_world_3d == own_world_3d.is_valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_inside_tree()) {
|
||||
_propagate_exit_world(this);
|
||||
}
|
||||
|
||||
if (p_use_own_world_3d) {
|
||||
if (world_3d.is_valid()) {
|
||||
own_world_3d = world_3d->duplicate();
|
||||
world_3d->connect(CoreStringNames::get_singleton()->changed, this, "_own_world_3d_changed");
|
||||
} else {
|
||||
own_world_3d = Ref<World3D>(memnew(World3D));
|
||||
}
|
||||
} else {
|
||||
own_world_3d = Ref<World3D>();
|
||||
if (world_3d.is_valid()) {
|
||||
world_3d->disconnect(CoreStringNames::get_singleton()->changed, this, "_own_world_3d_changed");
|
||||
}
|
||||
}
|
||||
|
||||
if (is_inside_tree()) {
|
||||
_propagate_enter_world(this);
|
||||
}
|
||||
|
||||
_on_set_use_own_world_3d(p_use_own_world_3d);
|
||||
}
|
||||
|
||||
World::World() {
|
||||
world_2d = Ref<World2D>(memnew(World2D));
|
||||
}
|
||||
World::~World() {
|
||||
}
|
||||
|
||||
void World::_propagate_enter_world(Node *p_node) {
|
||||
if (p_node != this) {
|
||||
if (!p_node->is_inside_tree()) { //may not have entered scene yet
|
||||
@ -198,12 +204,6 @@ void World::_on_set_world_3d(const Ref<World3D> &p_old_world) {
|
||||
void World::_on_set_world_2d(const Ref<World2D> &p_old_world_2d) {
|
||||
}
|
||||
|
||||
World::World() {
|
||||
world_2d = Ref<World2D>(memnew(World2D));
|
||||
}
|
||||
World::~World() {
|
||||
}
|
||||
|
||||
void World::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
case NOTIFICATION_ENTER_TREE: {
|
||||
@ -233,4 +233,4 @@ void World::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("find_world_3d"), &World::find_world_3d);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("_own_world_3d_changed"), &World::_own_world_3d_changed);
|
||||
}
|
||||
}
|
||||
|
@ -12,15 +12,16 @@ class World : public Node {
|
||||
GDCLASS(World, Node);
|
||||
|
||||
public:
|
||||
void set_world_3d(const Ref<World3D> &p_world);
|
||||
Ref<World2D> get_world_2d() const;
|
||||
void set_world_2d(const Ref<World2D> &p_world_2d);
|
||||
|
||||
Ref<World3D> get_world_3d() const;
|
||||
Ref<World3D> find_world_3d() const;
|
||||
|
||||
Ref<World2D> get_world_2d() const;
|
||||
Ref<World2D> find_world_2d() const;
|
||||
|
||||
Ref<World3D> get_world_3d() const;
|
||||
void set_world_3d(const Ref<World3D> &p_world);
|
||||
|
||||
Ref<World3D> find_world_3d() const;
|
||||
|
||||
void set_use_own_world_3d(bool p_use_own_world_3d);
|
||||
bool is_using_own_world_3d() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user