Toast Engine
Toggle main menu visibility
Loading...
Searching...
No Matches
play_workspace.hpp
Go to the documentation of this file.
1
8
9
#pragma once
10
11
#include "
tick_scheduler.hpp
"
12
#include "workspace.hpp"
13
14
#include <atomic>
15
16
namespace
toast {
25
class
PlayWorkspace :
public
Workspace
{
26
public
:
27
PlayWorkspace(
UID
handle,
assets::Prefab
& prefab);
28
29
~PlayWorkspace()
override
;
30
31
auto
name() -> std::string
override
;
32
33
void
registerDependency(
Node
& from,
Node
& to)
override
;
34
void
unregisterDependency(
Node
& from,
Node
& to)
override
;
35
void
registerInteraction(
Node
& first,
Node
& second)
override
;
36
37
void
tick
()
override
;
38
39
[[nodiscard]]
40
auto
participatesIn
(NodeOwnerParticipation use)
const
noexcept
->
bool
override
;
41
42
[[nodiscard]]
43
auto
receivesEvents
() const noexcept ->
bool
override
{
44
// The play workspace is the one running so it always receives events
45
return
true
;
46
}
47
48
[[nodiscard]]
49
auto
paused() const noexcept ->
bool
{
50
return
m_paused.load(std::memory_order_acquire);
51
}
52
53
[[nodiscard]]
54
static
auto
exists() noexcept ->
bool
{
55
// True while any PlayWorkspace exists
56
return
s_instances.load(std::memory_order_acquire) > 0;
57
}
58
59
protected
:
61
[[nodiscard]]
62
auto
isPlaying
() const ->
bool
override
{
63
return
true
;
64
}
65
66
private
:
67
static
inline
std::atomic<int> s_instances = 0;
68
69
TickScheduler
m_scheduler;
70
std::atomic<bool> m_paused =
false
;
71
bool
m_started =
false
;
72
std::atomic<bool> m_schedule_dirty =
true
;
// scripts register dependencies from init(), possibly on a loader thread
73
void
computeSchedule();
74
};
75
}
assets::Prefab
Definition
prefab.hpp:54
toast::Node
Definition
node.hpp:81
toast::PlayWorkspace::receivesEvents
auto receivesEvents() const noexcept -> bool override
Definition
play_workspace.hpp:43
toast::PlayWorkspace::isPlaying
auto isPlaying() const -> bool override
Playmode state.
Definition
play_workspace.hpp:62
toast::PlayWorkspace::participatesIn
auto participatesIn(NodeOwnerParticipation use) const noexcept -> bool override
Determines if this owner is elegible for runtime systems.
Definition
play_workspace.cpp:129
toast::TickScheduler
Definition
tick_scheduler.hpp:74
toast::Workspace::tick
void tick() override
Editor-only per-frame work: camera preview, animation preview, editorTick lifecycle,...
Definition
workspace.cpp:2601
toast::Workspace::Workspace
Workspace(std::string_view type, UID handle)
Creates a new workspace rooted at a single fresh node of the given type.
Definition
workspace.cpp:352
toast::UID
Definition
uid.hpp:20
tick_scheduler.hpp
Dependency-graph tick scheduling shared by World and PlayWorkspace.
engine
src
toast
world
play_workspace.hpp
Generated by
1.17.0