Toast Engine
Loading...
Searching...
No Matches
toast::PlayWorkspace Class Reference

A Workspace that actually runs game logic. More...

#include <play_workspace.hpp>

Inheritance diagram for toast::PlayWorkspace:
Collaboration diagram for toast::PlayWorkspace:

Public Member Functions

 PlayWorkspace (UID handle, assets::Prefab &prefab)
auto name () -> std::string override
void registerDependency (Node &from, Node &to) override
void unregisterDependency (Node &from, Node &to) override
void registerInteraction (Node &first, Node &second) override
void tick () override
auto participatesIn (NodeOwnerParticipation use) const noexcept -> bool override
 Determines if this owner is elegible for runtime systems.
auto receivesEvents () const noexcept -> bool override
auto paused () const noexcept -> bool
Public Member Functions inherited from toast::Workspace
 Workspace (std::string_view type, UID handle)
 Creates a new workspace rooted at a single fresh node of the given type.
 Workspace (UID uid)
 Opens an existing workspace by loading the prefab at the given UID.
 Workspace (UID uid, std::string_view source_uri)
 Opens a workspace bound to the given asset UID but loading its content from another file.
auto name () -> std::string override
auto asWorkspace () -> Workspace *override
 Downcast helper for owners that need Workspace-specific state.
void registerDependency (Node &from, Node &to) override
 No-op; Workspace has no tick scheduler and never registers dependencies.
void unregisterDependency (Node &from, Node &to) override
void nodeEnabledChanged (Node &node) noexcept override
auto participatesIn (NodeOwnerParticipation use) const noexcept -> bool override
 Determines if this owner is elegible for runtime systems.
auto receivesEvents () const noexcept -> bool override
auto findFrom (const Node &origin, std::string_view query) -> Box< Node > override
 Name lookup over origin's subtree.
auto findFrom (const Node &origin, const UID &uid) -> Box< Node > override
 UID lookup over origin's subtree.
auto searchFrom (const Node &origin, std::string_view query) -> std::vector< Box< Node > > override
 Same query grammar as World::searchFrom(); searches only within m_root_node.
auto usesGameCamera () const noexcept -> bool
void inheritEditorCamera (const Workspace &source)
void preparePrefabReload (UID uid)
void finishPrefabReload ()
void tick () override
 Editor-only per-frame work: camera preview, animation preview, editorTick lifecycle, inspector streaming.
auto rootNode () const -> const Node &
auto isValid () const -> bool
auto findPrefabInstance (UID prefab, UID instance) -> Box< Node >
auto gizmoRenderState () const -> GizmoRenderState
 snapshot of the active gizmo's transform/highlight state, resolved on the main thread for Engine::tick() to hand to VulkanRenderer
Public Member Functions inherited from toast::INodeOwner
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 &
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 auto exists () noexcept -> bool
Static Public Member Functions inherited from toast::INodeOwner
static void reapOrphanedControlBoxes () noexcept

Protected Member Functions

auto isPlaying () const -> bool override
 Playmode state.
Protected Member Functions inherited from toast::Workspace
auto owningPrefabUid () const -> UID override
 Workspace (UID handle, EmptyTag)
 Sets only the handle and subscribes to editor events; used by PlayWorkspace.
void sendEnabledChanges ()
auto isActiveWorkspace () const noexcept -> bool
auto gizmoOrigin () const -> glm::vec3
auto gizmoOrientation () const -> glm::quat
auto gizmoScale () const -> float
auto gizmoInteractionAllowed () const -> bool
auto collectSizeHandles () const -> std::pair< std::array< SizeHandlePoint, k_max_size_handles >, uint32_t >
void gizmoApplySizeDrag (float delta)
void gizmoUpdateHover ()
void gizmoBeginDrag (GizmoHandle handle)
void gizmoUpdateDrag ()
void gizmoEndDrag ()
void eventSubscriptions ()
void initializeHistory (bool available, bool initially_saved)
auto restoreHistorySnapshot (const assets::Prefab &snapshot) -> bool
void destroyOwnedTree (Box< Node > &root)
auto duplicateNode (Box< Node > src, Box< Node > par, bool after_source) -> Box< Node >
void subscribeVoxelEditing ()
void voxelUpdatePreview (uint8_t kind)
void voxelReparent (Box< Node > node, Box< Node > parent, size_t index)
auto voxelWrapInGroup (Box< Node > node, std::string_view name) -> Box< Node >
auto voxelToolShape () -> ProceduralVoxel *
void voxelToolMouseMove ()
auto voxelToolMouseButton (uint32_t button, bool pressed, int mods) -> bool
void voxelToolCancel ()
auto pickNodeUnderMouse () -> Box< Node >
auto retypeNode (Box< Node > &target, std::string_view type, bool keep_fields) -> Box< Node >
void promoteNode (Box< Node > &target, std::string_view path)
template<typename F>
void recordHistory (WorkspaceHistory::Context context, F &&mutation)
void initFromPrefab (const assets::Handle< assets::Prefab > &file)
 instantiates the prefab and sets up the root node
void applyActiveCamera () override
Protected Member Functions inherited from toast::INodeOwner
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 *
template<typename Fn>
void forEachNode (Fn &&fn) const

Additional Inherited Members

Static Public Attributes inherited from toast::Workspace
static constexpr size_t k_max_size_handles = 6
Static Protected Member Functions inherited from toast::INodeOwner
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 inherited from toast::Workspace
UID m_handle
std::unique_ptr< assets::Prefab > m_owned_source_prefab
Box< Node > m_root_node
Box< Node > m_focused_node
event::Listener m_listener
GizmoTool m_gizmo_tool = GizmoTool::select
bool m_world_space = false
 false = local coordinates
SnapSetting m_translate_snap {true, 0.10f}
SnapSetting m_rotate_snap {true, 30.0f}
SnapSetting m_scale_snap {true, 0.10f}
bool m_game_camera = false
 false = editor camera
std::unique_ptr< Camera > m_editor_camera
EditorCameraController m_editor_camera_controller
 drives m_editor_camera; ticked from tick() below
std::unique_ptr< WorkspaceHistory > m_history
std::mutex m_enabled_changes_mutex
std::vector< Box< Node > > m_enabled_changes
glm::vec2 m_gizmo_mouse_pos {0.0f, 0.0f}
 The gizmo's current state.
GizmoHandle m_gizmo_hover = GizmoHandle::none
GizmoHandle m_gizmo_drag = GizmoHandle::none
glm::vec3 m_gizmo_drag_start_world_pos {0.0f}
glm::quat m_gizmo_drag_start_rotation {1.0f, 0.0f, 0.0f, 0.0f}
glm::vec3 m_gizmo_drag_start_scale {1.0f}
glm::vec3 m_gizmo_drag_anchor {0.0f}
 closest-point-on-axis or ray-plane hit at drag start
glm::vec3 m_gizmo_drag_axis {0.0f}
 world-space axis direction, for axis/ring drags
glm::vec3 m_gizmo_drag_plane_normal {0.0f}
 world-space plane normal, for plane/center/ring drags
float m_gizmo_drag_start_angle = 0.0f
 radians, for rotate drags
float m_gizmo_drag_current_factor = 1.0f
 live scale factor, for the scale feedback stretch
glm::vec3 m_gizmo_drag_start_size {0.0f}
glm::vec3 m_gizmo_drag_start_local_pos {0.0f}
glm::quat m_gizmo_drag_start_local_rot {1.0f, 0.0f, 0.0f, 0.0f}
std::optional< std::string > m_gizmo_history_start
 dragged field's value at drag start, set while the drag owns the open history transaction
VoxelToolState m_voxel_tool
Box< Node > m_voxel_preview
std::optional< glm::vec2 > m_pick_press
Protected Attributes inherited from toast::INodeOwner
std::mutex nodes_mutex
size_t tombstones = 0
 short-circuits the reap sweep when there's nothing to clean
physics::Accumulator m_accumulator

Detailed Description

A Workspace that actually runs game logic.

Created when the editor presses play, reruns the tick lifecycle (all nodes created from scratch again)

See also
Workspace, TickScheduler, World

Member Function Documentation

◆ isPlaying()

auto toast::PlayWorkspace::isPlaying ( ) const -> bool
inlinenodiscardoverrideprotectedvirtual

Playmode state.

Reimplemented from toast::Workspace.

◆ name()

auto toast::PlayWorkspace::name ( ) -> std::string
overridevirtual

Implements toast::INodeOwner.

◆ participatesIn()

auto toast::PlayWorkspace::participatesIn ( NodeOwnerParticipation use) const -> bool
nodiscardoverridevirtualnoexcept

Determines if this owner is elegible for runtime systems.

Implements toast::INodeOwner.

Here is the caller graph for this function:

◆ receivesEvents()

auto toast::PlayWorkspace::receivesEvents ( ) const -> bool
inlinenodiscardoverridevirtualnoexcept
Returns
false when silenced

Reimplemented from toast::INodeOwner.

◆ registerDependency()

void toast::PlayWorkspace::registerDependency ( Node & from,
Node & to )
overridevirtual

Implements toast::INodeOwner.

◆ registerInteraction()

void toast::PlayWorkspace::registerInteraction ( Node & first,
Node & second )
overridevirtual

Reimplemented from toast::INodeOwner.

◆ tick()

void toast::PlayWorkspace::tick ( )
overridevirtual

Implements toast::INodeOwner.

◆ unregisterDependency()

void toast::PlayWorkspace::unregisterDependency ( Node & from,
Node & to )
overridevirtual

Implements toast::INodeOwner.


The documentation for this class was generated from the following files: