Unravel Engine C++ Reference
Loading...
Searching...
No Matches
seq.cpp
Go to the documentation of this file.
1#include "seq.h"
3#include "seq_inspector.h"
4
5namespace seq
6{
7
8auto start(seq_action action, const seq_scope_policy& scope_policy, hpp::source_location location) -> seq_id_t
9{
10 inspector::add_location(action, location);
11 return detail::get_manager().start(std::move(action), scope_policy);
12}
13
14auto queue(seq_action action, const seq_scope_policy& scope_policy, hpp::source_location location) -> seq_id_t
15{
16 inspector::add_location(action, location);
17 return detail::get_manager().start(std::move(action), scope_policy, true); // Force queue
18}
19
20void stop(seq_id_t id)
21{
22 detail::get_manager().stop(id);
23}
24
25void pause(const seq_id_t id)
26{
27 detail::get_manager().pause(id);
28}
29
30void resume(const seq_id_t id)
31{
32 detail::get_manager().resume(id);
33}
34
36{
37 detail::get_manager().stop_when_finished(id);
38}
39
40void stop_and_finish(seq_id_t id, duration_t finish_after)
41{
42 detail::get_manager().stop_and_finish(id, finish_after);
43}
44
45auto is_stopping(seq_id_t id) -> bool
46{
47 return detail::get_manager().is_stopping(id);
48}
49
50auto is_running(seq_id_t id) -> bool
51{
52 return detail::get_manager().is_running(id);
53}
54
55auto is_paused(seq_id_t id) -> bool
56{
57 return detail::get_manager().is_paused(id);
58}
59
60auto is_finished(seq_id_t id) -> bool
61{
62 return detail::get_manager().is_finished(id);
63}
64
65auto has_action_with_scope(const std::string& scope_id) -> bool
66{
67 return detail::get_manager().has_action_with_scope(scope_id);
68}
69
70void set_speed_multiplier(seq_id_t id, float speed_multiplier)
71{
72 detail::get_manager().set_speed_multiplier(id, speed_multiplier);
73}
74
76{
77 return detail::get_manager().get_speed_multiplier(id);
78}
79
81{
82 return detail::get_manager().get_elapsed(id);
83}
84
86{
87 detail::get_manager().set_elapsed(id, duration);
88}
89
91{
92 return detail::get_manager().get_duration(id);
93}
94
96{
97 return detail::get_manager().get_overflow(id);
98}
99
101{
102 detail::get_manager().update(id, delta);
103}
104
105auto get_percent(seq_id_t id) -> float
106{
107 auto dur = get_duration(id);
108 if(dur == duration_t::zero())
109 {
110 return 0.0f;
111 }
112 float elapsed = float(get_elapsed(id).count());
113 float total_dur = float(dur.count());
114 return elapsed / total_dur;
115}
116
118{
119 detail::get_manager().update(delta);
120}
121
123{
124 update(std::chrono::duration_cast<seq::duration_t>(delta));
125}
126
127
129{
130 detail::get_manager() = {};
131}
132
133namespace scope
134{
135void push(const std::string& scope)
136{
137 detail::get_manager().push_scope(scope);
138}
139
140void pop()
141{
142 detail::get_manager().pop_scope();
143}
144
145void close(const std::string& scope)
146{
147 detail::get_manager().close_scope(scope);
148}
149
150void clear()
151{
152 detail::get_manager().clear_scopes();
153}
154
155auto get_current() -> const std::string&
156{
157 return detail::get_manager().get_current_scope();
158}
159
160void stop_all(const std::string& scope)
161{
162 detail::get_manager().stop_all(scope);
163}
164
165void pause_all(const std::string& scope)
166{
167 detail::get_manager().pause_all(scope);
168}
169
170void resume_all(const std::string& scope)
171{
172 detail::get_manager().resume_all(scope);
173}
174
175void pause_all(const std::string& scope, const std::string& key)
176{
177 detail::get_manager().pause_all(scope, key);
178}
179
180void resume_all(const std::string& scope, const std::string& key)
181{
182 detail::get_manager().resume_all(scope, key);
183}
184
185void stop_and_finish_all(const std::string& scope)
186{
187 detail::get_manager().stop_and_finish_all(scope);
188}
189
190void stop_when_finished_all(const std::string& scope)
191{
192 detail::get_manager().stop_when_finished_all(scope);
193}
194
195} // namespace scope
196
197namespace manager
198{
200{
201 detail::push(mgr);
202}
203void pop()
204{
205 detail::pop();
206}
207} // namespace manager
208} // namespace seq
float elapsed
auto get_manager() -> seq_manager &
void push(seq_manager &mgr)
void add_location(seq_action &action, const hpp::source_location &location)
void pop()
Pops the top sequence manager from the stack.
Definition seq.cpp:203
void push(seq_manager &mgr)
Pushes a sequence manager to the stack.
Definition seq.cpp:199
void pause_all(const std::string &scope)
Pauses all actions within the specified scope.
Definition seq.cpp:165
void stop_when_finished_all(const std::string &scope)
Marks all actions within the specified scope to stop when they finish.
Definition seq.cpp:190
void push(const std::string &scope)
Pushes a new scope to the stack.
Definition seq.cpp:135
void stop_all(const std::string &scope)
Stops all actions within the specified scope.
Definition seq.cpp:160
auto get_current() -> const std::string &
Gets the name of the current scope.
Definition seq.cpp:155
void pop()
Pops the current scope from the stack.
Definition seq.cpp:140
void close(const std::string &scope)
Closes the specified scope.
Definition seq.cpp:145
void clear()
Clears all scopes from the stack.
Definition seq.cpp:150
void resume_all(const std::string &scope)
Resumes all actions within the specified scope.
Definition seq.cpp:170
void stop_and_finish_all(const std::string &scope)
Stops and finishes all actions within the specified scope.
Definition seq.cpp:185
Provides a sequence-based action management system for controlling and scheduling actions.
size_t seq_id_t
Represents a unique identifier for sequence actions.
Definition seq_common.h:53
void update(seq_id_t id, duration_t delta)
Updates the elapsed duration of a specific action.
Definition seq.cpp:100
auto is_finished(seq_id_t id) -> bool
Checks if the action has finished.
Definition seq.cpp:60
std::chrono::duration< float > duraiton_secs_t
Represents a duration in seconds as a floating-point value.
Definition seq_common.h:35
void set_elapsed(seq_id_t id, duration_t duration)
Sets the elapsed duration of an action.
Definition seq.cpp:85
auto is_paused(seq_id_t id) -> bool
Checks if the action is paused.
Definition seq.cpp:55
void resume(const seq_id_t id)
Resumes the action associated with the given ID.
Definition seq.cpp:30
auto get_duration(seq_id_t id) -> duration_t
Gets the total duration of an action.
Definition seq.cpp:90
auto get_overflow(seq_id_t id) -> duration_t
Gets the overflow duration of an action.
Definition seq.cpp:95
void stop_and_finish(seq_id_t id, duration_t finish_after)
Stops the action after a specified duration.
Definition seq.cpp:40
auto is_running(seq_id_t id) -> bool
Checks if the action is running.
Definition seq.cpp:50
void shutdown()
Shuts down the action management system, stopping all actions.
Definition seq.cpp:128
void set_speed_multiplier(seq_id_t id, float speed_multiplier)
Sets the speed multiplier for an action.
Definition seq.cpp:70
auto queue(seq_action action, const seq_scope_policy &scope_policy, hpp::source_location location) -> seq_id_t
Queues a new action.
Definition seq.cpp:14
auto is_stopping(seq_id_t id) -> bool
Checks if the action is stopping.
Definition seq.cpp:45
auto get_speed_multiplier(seq_id_t id) -> float
Gets the speed multiplier of an action.
Definition seq.cpp:75
auto get_elapsed(seq_id_t id) -> duration_t
Gets the elapsed duration of an action.
Definition seq.cpp:80
void stop_when_finished(seq_id_t id)
Marks the action to stop when it finishes.
Definition seq.cpp:35
auto has_action_with_scope(const std::string &scope_id) -> bool
Checks if there is an action associated with the given scope ID.
Definition seq.cpp:65
auto get_percent(seq_id_t id) -> float
Gets the percentage completion of an action.
Definition seq.cpp:105
void stop(seq_id_t id)
Stops the action associated with the given ID.
Definition seq.cpp:20
std::chrono::nanoseconds duration_t
Represents a duration in nanoseconds.
Definition seq_common.h:41
void pause(const seq_id_t id)
Pauses the action associated with the given ID.
Definition seq.cpp:25
uint32_t count
std::vector< math::vec3 > start
Represents an action within the sequence management system. Contains lifecycle events and management ...
Definition seq_action.h:18
Manages and coordinates multiple sequence actions with scoping, pausing, and updating capabilities.
Definition seq_manager.h:18
Defines policies for scoping actions in a sequence.
Definition seq_common.h:92