12 , sentinel_(
std::move(sentinel))
14 if(duration_ < duration_t::zero())
16 duration_ = duration_t::zero();
35void seq_action::update_elapsed(
duration_t update_time)
37 elapsed_ += update_time;
39 elapsed_not_clamped_ += update_time;
52void seq_action::clamp_elapsed()
54 elapsed_ = std::max(elapsed_, duration_t::zero());
55 elapsed_ = std::min(elapsed_, duration_);
57 elapsed_not_clamped_ = std::max(elapsed_not_clamped_, duration_t::zero());
60void seq_action::start()
62 if(creator_ ==
nullptr)
68 elapsed_ = duration_t::zero();
69 elapsed_not_clamped_ = duration_t::zero();
71 updater_ = creator_();
72 state_ = updater_(0ms, *
this);
77 if(!sentinel_.expired())
84void seq_action::stop()
90void seq_action::resume(
const std::string& key,
bool force)
94 if(force || pause_key_ == key)
103void seq_action::pause(
const std::string& key)
111void seq_action::pause_forced(
const std::string& key)
118void seq_action::pause_forced()
131 auto update_time = (delta.count() * int64_t(speed_multiplier_ * 1000.0f)) / int64_t(1000);
134 state_ = updater_(
duration_t(update_time), *
this);
144 if(!sentinel_.expired())
void update_action_state(seq_action &action, state_t state)
Provides a sequence-based action management system for controlling and scheduling actions.
size_t seq_id_t
Represents a unique identifier for sequence actions.
hpp::sentinel sentinel_t
Alias for a sentinel object used for lifecycle management.
state_t
Represents the state of a sequence action.
@ running
The action is running.
@ finished
The action has finished.
@ paused
The action is paused.
seq::seq_action creator(const std::string &type, values_t< T > &values, T &begin, const T &end, seq::duration_t duration)
void stop(seq_id_t id)
Stops the action associated with the given ID.
std::chrono::nanoseconds duration_t
Represents a duration in nanoseconds.
std::function< updater_t()> creator_t
Type alias for a creator function that generates an updater function for the action.
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.
hpp::event< void()> on_end
Event emitted when the action is finished. Not emitted if the action is stopped prematurely.
hpp::event< void()> on_begin
Event emitted when the action is started.