Unravel Engine C++ Reference
Loading...
Searching...
No Matches
seq_private.h
Go to the documentation of this file.
1#pragma once
2#include "seq_action.h"
3
8namespace seq
9{
10
17{
22 static void start(seq_action& action)
23 {
24 action.start();
25 }
26
31 static void stop(seq_action& action)
32 {
33 action.stop();
34 }
35
40 static void stop_and_finished(seq_action& action)
41 {
42 action.stop_and_finished_ = true;
43 }
44
49 static void stop_when_finished(seq_action& action)
50 {
51 action.stop_when_finished_ = true;
52 }
53
59 static void resume(seq_action& action, bool force = false)
60 {
61 action.resume({}, force);
62 }
63
69 static void resume(seq_action& action, const std::string& key)
70 {
71 action.resume(key);
72 }
73
78 static void pause(seq_action& action)
79 {
80 action.pause();
81 }
82
88 static void pause(seq_action& action, const std::string& key)
89 {
90 action.pause(key);
91 }
92
97 static void pause_forced(seq_action& action)
98 {
99 action.pause_forced();
100 }
101
107 static void pause_forced(seq_action& action, const std::string& key)
108 {
109 action.pause_forced(key);
110 }
111
117 static void set_speed_multiplier(seq_action& action, float speed_multiplier)
118 {
119 speed_multiplier = std::min<float>(100.0f, speed_multiplier);
120 speed_multiplier = std::max<float>(0.0f, speed_multiplier);
121 action.speed_multiplier_ = speed_multiplier;
122 }
123
129 static auto get_speed_multiplier(const seq_action& action) -> float
130 {
131 return action.speed_multiplier_;
132 }
133
139 static auto get_state(const seq_action& action) -> state_t
140 {
141 return action.state_;
142 }
143
149 static auto is_stop_when_finished_requested(const seq_action& action) -> bool
150 {
151 return action.stop_when_finished_;
152 }
153
159 static auto is_stop_and_finished_requested(const seq_action& action) -> bool
160 {
161 return action.stop_and_finished_;
162 }
163
169 static auto is_running(const seq_action& action) -> bool
170 {
171 return action.state_ == state_t::running;
172 }
173
179 static auto is_paused(const seq_action& action) -> bool
180 {
181 return action.state_ == state_t::paused;
182 }
183
189 static auto is_finished(const seq_action& action) -> bool
190 {
191 return action.state_ == state_t::finished;
192 }
193
200 static auto update(seq_action& action, duration_t delta) -> state_t
201 {
202 return action.update(delta);
203 }
204
211 {
212 self.set_elapsed(elapsed);
213 }
214
220 static void update_elapsed(seq_action& self, duration_t update_time)
221 {
222 self.update_elapsed(update_time);
223 }
224
230 static auto get_elapsed(const seq_action& self) -> duration_t
231 {
232 return self.elapsed_;
233 }
234
240 static auto get_duration(const seq_action& self) -> duration_t
241 {
242 return self.duration_;
243 }
244
250 static auto get_overflow(const seq_action& self) -> duration_t
251 {
252 auto duration = get_duration(self);
253 auto elapsed_not_clamped = self.elapsed_not_clamped_;
254
255 if(duration > duration_t::zero() && duration <= elapsed_not_clamped)
256 {
257 return elapsed_not_clamped - duration;
258 }
259
260 return {};
261 }
262};
263
264} // namespace seq
float elapsed
Provides a sequence-based action management system for controlling and scheduling actions.
state_t
Represents the state of a sequence action.
Definition seq_common.h:81
@ running
The action is running.
@ finished
The action has finished.
@ paused
The action is paused.
std::chrono::nanoseconds duration_t
Represents a duration in nanoseconds.
Definition seq_common.h:41
Represents an action within the sequence management system. Contains lifecycle events and management ...
Definition seq_action.h:18
Provides internal utilities for managing seq_action objects. These methods allow for direct control o...
Definition seq_private.h:17
static void pause_forced(seq_action &action)
Forcibly pauses a given action.
Definition seq_private.h:97
static auto get_duration(const seq_action &self) -> duration_t
Gets the total duration of a given action.
static void pause(seq_action &action)
Pauses a given action.
Definition seq_private.h:78
static void start(seq_action &action)
Starts a given action.
Definition seq_private.h:22
static void stop(seq_action &action)
Stops a given action.
Definition seq_private.h:31
static auto update(seq_action &action, duration_t delta) -> state_t
Updates a given action with a time delta.
static auto is_running(const seq_action &action) -> bool
Checks if the action is currently running.
static void set_elapsed(seq_action &self, duration_t elapsed)
Sets the elapsed time of a given action.
static void stop_and_finished(seq_action &action)
Marks a given action as stopped and finished.
Definition seq_private.h:40
static void pause_forced(seq_action &action, const std::string &key)
Forcibly pauses a given action with a specific key.
static void resume(seq_action &action, const std::string &key)
Resumes a given action with a specific key.
Definition seq_private.h:69
static void update_elapsed(seq_action &self, duration_t update_time)
Updates the elapsed time of a given action.
static void stop_when_finished(seq_action &action)
Marks a given action to stop when finished.
Definition seq_private.h:49
static void set_speed_multiplier(seq_action &action, float speed_multiplier)
Sets the speed multiplier for a given action.
static auto get_speed_multiplier(const seq_action &action) -> float
Gets the speed multiplier of a given action.
static void pause(seq_action &action, const std::string &key)
Pauses a given action with a specific key.
Definition seq_private.h:88
static auto is_finished(const seq_action &action) -> bool
Checks if the action is finished.
static auto is_paused(const seq_action &action) -> bool
Checks if the action is currently paused.
static auto get_overflow(const seq_action &self) -> duration_t
Computes the overflow duration of a given action if it exceeds its total duration.
static auto get_state(const seq_action &action) -> state_t
Gets the current state of a given action.
static auto is_stop_and_finished_requested(const seq_action &action) -> bool
Checks if the action is requested to stop and finish.
static auto is_stop_when_finished_requested(const seq_action &action) -> bool
Checks if the action is requested to stop when finished.
static void resume(seq_action &action, bool force=false)
Resumes a given action, optionally forcing the resume.
Definition seq_private.h:59
static auto get_elapsed(const seq_action &self) -> duration_t
Gets the elapsed time of a given action.