38class TOAST_API INodeOwner {
41 virtual ~INodeOwner();
42 virtual auto name() -> std::string = 0;
44 virtual void tick() = 0;
51 virtual auto participatesIn(NodeOwnerParticipation use)
const noexcept ->
bool = 0;
59 void syncListenerState() noexcept;
63 auto isEditing() noexcept ->
bool;
66 auto treeMutex() const noexcept -> std::shared_mutex& {
70 virtual void registerDependency(Node& from, Node& to) = 0;
71 virtual void unregisterDependency(Node& from, Node& to) = 0;
73 virtual void registerInteraction(Node& , Node& ) { }
75 virtual void nodeEnabledChanged(Node& node)
noexcept { (void)node; }
77 virtual auto findFrom(
const Node& origin, std::string_view query) -> Box<Node> = 0;
78 virtual auto findFrom(
const Node& origin,
const UID& uid) -> Box<Node> = 0;
79 virtual auto searchFrom(
const Node& origin, std::string_view query) -> std::vector<Box<Node>> = 0;
81 void activateCamera(Camera& camera);
83 void setMainCamera(Camera& camera);
84 void deactivateCamera(Camera& camera);
85 void activateCameraController(CameraController& controller);
86 void deactivateCameraController(CameraController& controller);
88 auto requestRuntimeCreate(Node& parent, std::string_view type) -> Box<Node>;
89 auto requestRuntimeSpawn(Node& parent, UID uid) -> Box<Node>;
90 auto requestRuntimeSpawn(Node& parent, std::string_view) -> Box<Node>;
92 void reloadScriptsUsing(UID script_uid)
noexcept;
93 void refreshNodeInfos() noexcept;
94 void rebindAssetHandles(UID asset_uid) noexcept;
95 static
void reapOrphanedControlBoxes() noexcept;
100 uint64_t script_group = 0;
106 virtual auto owningPrefabUid() const ->
UID {
110 void seedPrefabContext(InstantiateContext& context,
const Node* parent =
nullptr)
const;
111 static void updateTransforms(Node& root);
114 static void generateUid(Node& node);
117 static auto stripNamespace(std::string_view type) -> std::string_view;
120 static auto uniqueChildName(
const Node& parent, std::string_view base) -> std::string;
128 auto nodeAllocation(std::string_view type =
"toast::Node") noexcept -> Box<Node>;
135 auto nodeAllocation(const assets::Prefab::BasicNode& node_data, uint64_t script_group = 0,
bool build_scripts = true) noexcept
139 const assets::Handle<assets::Prefab>& file, uint64_t group, const std::vector<
size_t>& leaf_slots,
140 std::vector<Box<Node>>& slots
149 auto buildTree(std::vector<Box<Node>>&& nodes, const assets::Handle<assets::Prefab>& file) -> Box<Node>;
162 auto instantiate(const assets::Handle<assets::Prefab>& file, InstantiateContext& ctx) -> Box<Node>;
165 void applyFields(Node& node, const assets::Prefab::BasicNode& data);
170 void applyLuaOverrides(Node& node, const assets::Prefab::BasicNode& data, const scripting::NodeResolver& find_node);
173 void releaseNode(_detail::ControlBox& control) noexcept;
176 void reapTombstones() noexcept;
179 void findCameraController();
180 void tickActiveCameraController();
181 void beginCameraShutdown() noexcept;
184 auto activeCamera() noexcept -> Box<Camera>&;
187 auto activeRenderCamera() noexcept -> Camera*;
188 virtual
void applyActiveCamera() = 0;
190 template<typename Fn>
191 void forEachNode(Fn&& fn)
const {
192 for (
const auto& cb : nodes) {
197 std::mutex nodes_mutex;
203 friend class CameraController;
205 mutable std::shared_mutex m_tree_mutex;
206 std::unordered_set<_detail::ControlBox> nodes;
208 std::unique_ptr<Camera> m_fallback_camera;
211 bool m_has_camera_controller =
false;
212 bool m_is_shutting_down =
false;
std::vector< uint64_t > asset_chain
UIDs of prefabs currently being instantiated; prevents infinite recursion.
Definition node_owner.hpp:98
std::function< assets::Handle< assets::Prefab >(toast::UID)> resolver
injected loader so tests can swap in a fake
Definition node_owner.hpp:99