Unravel Engine C++ Reference
Loading...
Searching...
No Matches
seq_action.h
Go to the documentation of this file.
1#pragma once
2#include "seq_common.h"
3#include <hpp/event.hpp>
4
9namespace seq
10{
11
18{
19 friend struct seq_private;
20
27 using updater_t = std::function<state_t(duration_t, seq_action&)>;
28
33 using creator_t = std::function<updater_t()>;
34
35 seq_action() = default;
36 ~seq_action() = default;
37
44 seq_action(creator_t&& creator, duration_t duration, sentinel_t sentinel);
45
46 seq_action(const seq_action&) = default;
47 seq_action(seq_action&&) = default;
48
49 auto operator=(const seq_action&) -> seq_action& = default;
50 auto operator=(seq_action&&) -> seq_action& = default;
51
52 //---------------------------------------------------------------------------------------
54 //---------------------------------------------------------------------------------------
55 hpp::event<void()> on_begin;
56
57 //---------------------------------------------------------------------------------------
59 //---------------------------------------------------------------------------------------
60 hpp::event<void()> on_step;
61
62 //---------------------------------------------------------------------------------------
64 //---------------------------------------------------------------------------------------
65 hpp::event<void()> on_update;
66
67 //---------------------------------------------------------------------------------------
69 //---------------------------------------------------------------------------------------
70 hpp::event<void()> on_end;
71
76
81 auto get_id() const -> seq_id_t;
82
87 operator seq_id_t() const;
88
93 auto is_valid() const noexcept -> bool;
94
95private:
100 void update_elapsed(duration_t update_time);
101
106 void set_elapsed(duration_t elapsed);
107
111 void clamp_elapsed();
112
116 void start();
117
121 void stop();
122
128 void resume(const std::string& key = {}, bool force = false);
129
134 void pause(const std::string& key = {});
135
140 void pause_forced(const std::string& key);
141
145 void pause_forced();
146
152 auto update(duration_t delta) -> state_t;
153
155 seq_id_t id_{};
156
158 creator_t creator_;
159
161 updater_t updater_;
162
164 std::string pause_key_;
165
167 state_t state_ = state_t::finished;
168
170 duration_t elapsed_{};
171
173 duration_t elapsed_not_clamped_{};
174
176 duration_t duration_{};
177
179 sentinel_t sentinel_;
180
182 bool stop_and_finished_ = false;
183
185 bool stop_when_finished_ = false;
186
188 float speed_multiplier_ = 1.0f;
189};
190
191} // namespace seq
float elapsed
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
hpp::sentinel sentinel_t
Alias for a sentinel object used for lifecycle management.
Definition seq_common.h:47
state_t
Represents the state of a sequence action.
Definition seq_common.h:81
@ finished
The action has finished.
seq::seq_action creator(const std::string &type, values_t< T > &values, T &begin, const T &end, seq::duration_t duration)
Definition tests.cpp:195
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
hpp::event< void()> on_update
Event emitted every frame while the action is running.
Definition seq_action.h:65
std::function< state_t(duration_t, seq_action &)> updater_t
Type alias for an updater function that defines the action's behavior.
Definition seq_action.h:27
auto operator=(seq_action &&) -> seq_action &=default
std::function< updater_t()> creator_t
Type alias for a creator function that generates an updater function for the action.
Definition seq_action.h:33
hpp::event< void()> on_step
Event emitted every time the action value is updated.
Definition seq_action.h:60
auto is_valid() const noexcept -> bool
Checks if the action is valid.
auto get_id() const -> seq_id_t
Gets the unique ID of the action.
auto operator=(const seq_action &) -> seq_action &=default
seq_inspect_info::ptr info
Gets a pointer to the action's inspection information.
Definition seq_action.h:75
seq_action()=default
seq_action(const seq_action &)=default
hpp::event< void()> on_end
Event emitted when the action is finished. Not emitted if the action is stopped prematurely.
Definition seq_action.h:70
hpp::event< void()> on_begin
Event emitted when the action is started.
Definition seq_action.h:55
seq_action(seq_action &&)=default
~seq_action()=default
std::shared_ptr< seq_inspect_info > ptr
Shared pointer type.
Definition seq_common.h:142
Provides internal utilities for managing seq_action objects. These methods allow for direct control o...
Definition seq_private.h:17