Toast Engine
Loading...
Searching...
No Matches
toast::INodeOwner Class Referenceabstract
Inheritance diagram for toast::INodeOwner:
Collaboration diagram for toast::INodeOwner:

Classes

struct  InstantiateContext

Public Member Functions

virtual auto name () -> std::string=0
virtual void tick ()=0
virtual auto asWorkspace () -> Workspace *
 Downcast helper for owners that need Workspace-specific state.
virtual auto participatesIn (NodeOwnerParticipation use) const noexcept -> bool=0
 Determines if this owner is elegible for runtime systems.
virtual auto receivesEvents () const noexcept -> bool
void syncListenerState () noexcept
auto isEditing () noexcept -> bool
 True for a Workspace open for editing: lifecycle callbacks still run there, but the game is not running.
auto treeMutex () const noexcept -> std::shared_mutex &
virtual void registerDependency (Node &from, Node &to)=0
virtual void unregisterDependency (Node &from, Node &to)=0
virtual void registerInteraction (Node &, Node &)
virtual void nodeEnabledChanged (Node &node) noexcept
virtual auto findFrom (const Node &origin, std::string_view query) -> Box< Node >=0
virtual auto findFrom (const Node &origin, const UID &uid) -> Box< Node >=0
virtual auto searchFrom (const Node &origin, std::string_view query) -> std::vector< Box< Node > >=0
void activateCamera (Camera &camera)
void setMainCamera (Camera &camera)
 Like activateCamera(), but replaces whatever camera is currently active.
void deactivateCamera (Camera &camera)
void activateCameraController (CameraController &controller)
void deactivateCameraController (CameraController &controller)
auto requestRuntimeCreate (Node &parent, std::string_view type) -> Box< Node >
auto requestRuntimeSpawn (Node &parent, UID uid) -> Box< Node >
auto requestRuntimeSpawn (Node &parent, std::string_view) -> Box< Node >
void reloadScriptsUsing (UID script_uid) noexcept
void refreshNodeInfos () noexcept
void rebindAssetHandles (UID asset_uid) noexcept

Static Public Member Functions

static void reapOrphanedControlBoxes () noexcept

Protected Member Functions

virtual auto owningPrefabUid () const -> UID
void seedPrefabContext (InstantiateContext &context, const Node *parent=nullptr) const
auto nodeAllocation (std::string_view type="toast::Node") noexcept -> Box< Node >
 Allocates a Node and its ControlBox in one contiguous block.
auto nodeAllocation (const assets::Prefab::BasicNode &node_data, uint64_t script_group=0, bool build_scripts=true) noexcept -> Box< Node >
 Allocates a Node and initializes its name and type from a prefab data record.
void buildLeaves (const assets::Handle< assets::Prefab > &file, uint64_t group, const std::vector< size_t > &leaf_slots, std::vector< Box< Node > > &slots)
auto buildTree (std::vector< Box< Node > > &&nodes, const assets::Handle< assets::Prefab > &file) -> Box< Node >
 Assembles a flat list of allocated nodes into a parent/child tree.
auto instantiate (const assets::Handle< assets::Prefab > &file, InstantiateContext &ctx) -> Box< Node >
 Allocates and initializes a full node tree from a prefab asset.
void applyFields (Node &node, const assets::Prefab::BasicNode &data)
 Copies reflected field values from the serialized BasicNode onto the live node; skips fields absent from NodeInfo.
void applyLuaOverrides (Node &node, const assets::Prefab::BasicNode &data, const scripting::NodeResolver &find_node)
 Restores edited Lua script variables saved in the prefab.
void releaseNode (_detail::ControlBox &control) noexcept
 Marks the ControlBox as dead and increments tombstones; does not free memory.
void reapTombstones () noexcept
 Sweeps the nodes set and erases any ControlBox whose ref count is zero; short-circuits if tombstones == 0.
void findCamera ()
void findCameraController ()
void tickActiveCameraController ()
void beginCameraShutdown () noexcept
auto activeCamera () noexcept -> Box< Camera > &
auto activeRenderCamera () noexcept -> Camera *
virtual void applyActiveCamera ()=0
template<typename Fn>
void forEachNode (Fn &&fn) const

Static Protected Member Functions

static void updateTransforms (Node &root)
static void generateUid (Node &node)
 Assigns a fresh UID to the node; called on every spawned instance to avoid UID collisions.
static auto stripNamespace (std::string_view type) -> std::string_view
 Removes the "toast::" namespace prefix from a type name; used to derive default display names.
static auto uniqueChildName (const Node &parent, std::string_view base) -> std::string
 Appends " 2", " 3", etc. to base until the name is unique among the parent's existing children.

Protected Attributes

std::mutex nodes_mutex
size_t tombstones = 0
 short-circuits the reap sweep when there's nothing to clean
physics::Accumulator m_accumulator

Friends

class CameraController

Member Function Documentation

◆ asWorkspace()

virtual auto toast::INodeOwner::asWorkspace ( ) -> Workspace *
inlinevirtual

Downcast helper for owners that need Workspace-specific state.

Reimplemented in toast::Workspace.

Here is the caller graph for this function:

◆ buildTree()

auto toast::INodeOwner::buildTree ( std::vector< Box< Node > > && nodes,
const assets::Handle< assets::Prefab > & file ) -> Box< Node >
protected

Assembles a flat list of allocated nodes into a parent/child tree.

Parameters
nodesFlat list in prefab file order; index 0 becomes the tree root
fileThe source prefab, kept alive until all Handle fields are resolved
Returns
The root Box<Node>
Here is the caller graph for this function:

◆ findFrom() [1/2]

virtual auto toast::INodeOwner::findFrom ( const Node & origin,
const UID & uid ) -> Box< Node >
pure virtual

Implemented in toast::Workspace.

◆ findFrom() [2/2]

virtual auto toast::INodeOwner::findFrom ( const Node & origin,
std::string_view query ) -> Box< Node >
pure virtual

Implemented in toast::Workspace.

◆ instantiate()

auto toast::INodeOwner::instantiate ( const assets::Handle< assets::Prefab > & file,
InstantiateContext & ctx ) -> Box< Node >
protected

Allocates and initializes a full node tree from a prefab asset.

Allocates every node, resolves embedded child prefabs recursively via ctx.resolver, and calls load on each node before returning

Parameters
fileThe prefab to instantiate
ctxResolver for child prefabs and the asset chain used for cycle detection; asset_chain is mutated during the call and restored on return
Returns
The root of the new tree, or an empty box if instantiation fails
Here is the caller graph for this function:

◆ nodeAllocation() [1/2]

auto toast::INodeOwner::nodeAllocation ( const assets::Prefab::BasicNode & node_data,
uint64_t script_group = 0,
bool build_scripts = true ) -> Box< Node >
protectednoexcept

Allocates a Node and initializes its name and type from a prefab data record.

Parameters
node_dataThe BasicNode entry from the prefab file
Returns
Owning Box<Node>; the node is in NodeState::null until explicitly placed in a tree

◆ nodeAllocation() [2/2]

auto toast::INodeOwner::nodeAllocation ( std::string_view type = "toast::Node") -> Box< Node >
protectednoexcept

Allocates a Node and its ControlBox in one contiguous block.

Parameters
typeFully-qualified C++ class name looked up in NodeRegistry to find the factory; defaults to "toast::Node"
Returns
Owning Box<Node>; the node is in NodeState::null until explicitly placed in a tree
Here is the caller graph for this function:

◆ participatesIn()

virtual auto toast::INodeOwner::participatesIn ( NodeOwnerParticipation use) const -> bool
nodiscardpure virtualnoexcept

Determines if this owner is elegible for runtime systems.

Implemented in toast::PlayWorkspace, toast::Workspace, and toast::World.

◆ receivesEvents()

virtual auto toast::INodeOwner::receivesEvents ( ) const -> bool
inlinenodiscardvirtualnoexcept
Returns
false when silenced

Reimplemented in toast::PlayWorkspace, and toast::Workspace.

Here is the caller graph for this function:

◆ registerDependency()

virtual void toast::INodeOwner::registerDependency ( Node & from,
Node & to )
pure virtual

Implemented in toast::Workspace, and toast::World.

◆ searchFrom()

virtual auto toast::INodeOwner::searchFrom ( const Node & origin,
std::string_view query ) -> std::vector< Box< Node > >
pure virtual

Implemented in toast::Workspace.

◆ tick()

virtual void toast::INodeOwner::tick ( )
pure virtual

Implemented in toast::Workspace.


The documentation for this class was generated from the following files:
  • engine/src/toast/world/node_owner.hpp
  • engine/src/toast/world/node_owner.cpp