mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-11 13:21:10 +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_2d.h"
|
||||||
#include "scene/resources/world_3d.h"
|
#include "scene/resources/world_3d.h"
|
||||||
|
|
||||||
void World::set_use_own_world_3d(bool p_use_own_world_3d) {
|
Ref<World2D> World::get_world_2d() const {
|
||||||
if (p_use_own_world_3d == own_world_3d.is_valid()) {
|
return world_2d;
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::set_world_2d(const Ref<World2D> &p_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) {
|
void World::set_world_3d(const Ref<World3D> &p_world_3d) {
|
||||||
if (world_3d == p_world_3d) {
|
if (world_3d == p_world_3d) {
|
||||||
return;
|
return;
|
||||||
@ -109,14 +83,6 @@ void World::set_world_3d(const Ref<World3D> &p_world_3d) {
|
|||||||
_on_set_world_3d(old_world);
|
_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 {
|
Ref<World3D> World::find_world_3d() const {
|
||||||
if (own_world_3d.is_valid()) {
|
if (own_world_3d.is_valid()) {
|
||||||
return own_world_3d;
|
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) {
|
void World::_propagate_enter_world(Node *p_node) {
|
||||||
if (p_node != this) {
|
if (p_node != this) {
|
||||||
if (!p_node->is_inside_tree()) { //may not have entered scene yet
|
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) {
|
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) {
|
void World::_notification(int p_what) {
|
||||||
switch (p_what) {
|
switch (p_what) {
|
||||||
case NOTIFICATION_ENTER_TREE: {
|
case NOTIFICATION_ENTER_TREE: {
|
||||||
|
@ -12,15 +12,16 @@ class World : public Node {
|
|||||||
GDCLASS(World, Node);
|
GDCLASS(World, Node);
|
||||||
|
|
||||||
public:
|
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);
|
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<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);
|
void set_use_own_world_3d(bool p_use_own_world_3d);
|
||||||
bool is_using_own_world_3d() const;
|
bool is_using_own_world_3d() const;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user