50 lines
1.1 KiB
C++
50 lines
1.1 KiB
C++
/*
|
|
* ©2023 Batty Bovine Productions, LLC. All Rights Reserved.
|
|
*
|
|
* If this source code makes it to the public internet, this software can be
|
|
* considered to be protected by the MIT licence. Have fun with it.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "orng_macros.h"
|
|
|
|
#include <godot_cpp/classes/node3d.hpp>
|
|
#include <godot_cpp/classes/packed_scene.hpp>
|
|
using namespace godot;
|
|
|
|
|
|
// Scene that loads a subscene immediately in editor, but only on command
|
|
// during gameplay.
|
|
class SublevelScene : public Node3D
|
|
{
|
|
GDCLASS(SublevelScene, Node3D);
|
|
|
|
public:
|
|
virtual void _ready() override;
|
|
|
|
void set_sublevel(StringName s);
|
|
StringName get_sublevel() const { return this->sublevel; }
|
|
|
|
void load_sublevel();
|
|
void unload_sublevel();
|
|
|
|
protected:
|
|
StringName sublevel;
|
|
|
|
private:
|
|
void _threaded_load_callback(Ref<PackedScene> loaded_scene);
|
|
|
|
Node3D *sublevel_node = nullptr;
|
|
|
|
// Godot boilerplate below
|
|
protected:
|
|
static void _bind_methods()
|
|
{
|
|
ADD_GETTER_SETTER_HINTED(SublevelScene, sublevel, Variant::STRING, PROPERTY_HINT_FILE, "*.scn,*.tscn");
|
|
|
|
BIND_METHOD(SublevelScene, load_sublevel);
|
|
BIND_METHOD(SublevelScene, unload_sublevel);
|
|
}
|
|
};
|