#include "prop_2d_data_scene.h" #include "../prop_2d_scene_instance.h" #include "prop_2d_data.h" Ref Prop2DDataScene::get_scene() { return _scene; } void Prop2DDataScene::set_scene(const Ref &value) { _scene = value; } bool Prop2DDataScene::_processor_handles(Node *node) { Prop2DSceneInstance *i = Object::cast_to(node); return i; } void Prop2DDataScene::_processor_process(Ref prop_data, Node *node, const Transform2D &transform, Ref entry) { Prop2DSceneInstance *i = Object::cast_to(node); ERR_FAIL_COND(!i); Ref l; if (entry.is_valid()) { l = entry; } else { l.instance(); } l->set_scene(i->get_scene()); Prop2DDataEntry::_processor_process(prop_data, node, transform, l); } Node *Prop2DDataScene::_processor_get_node_for(const Transform2D &transform, Node *node) { Prop2DSceneInstance *i = nullptr; if (!node) { i = memnew(Prop2DSceneInstance); } else { i = Object::cast_to(node); } i->set_scene(get_scene()); return Prop2DDataEntry::_processor_get_node_for(transform, i); } Prop2DDataScene::Prop2DDataScene() { _snap_to_mesh = true; _snap_axis = Vector3(0, 1, 0); } Prop2DDataScene::~Prop2DDataScene() { if (_scene.is_valid()) _scene.unref(); } void Prop2DDataScene::_bind_methods() { ClassDB::bind_method(D_METHOD("get_scene"), &Prop2DDataScene::get_scene); ClassDB::bind_method(D_METHOD("set_scene", "value"), &Prop2DDataScene::set_scene); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene", "get_scene"); }