Unravel Engine C++ Reference
Loading...
Searching...
No Matches
unravel::sequence_action_t Struct Reference

Single-undo container for a chain of DEPENDENT actions. More...

#include <composite_action.h>

Inheritance diagram for unravel::sequence_action_t:
crtp_meta_type< sequence_action_t, editing_action_t >

Public Member Functions

void add_step (std::function< std::shared_ptr< editing_action_t >()> factory)
 Append a step to the sequence. Factory is invoked only on the first execution.
 
void do_action () override
 
void undo_action () override
 
auto is_valid () const -> bool override
 
auto is_mergeable (const editing_action_t &previous) const -> bool override
 
void draw_in_inspector (rtti::context &ctx) override
 
- Public Member Functions inherited from crtp_meta_type< sequence_action_t, editing_action_t >
virtual auto get_meta_type () const -> entt::meta_type
 
auto is () const -> bool
 
auto is (const entt::meta_type &type) const -> bool
 
virtual auto as_derived () -> entt::meta_any
 

Public Attributes

std::vector< std::function< std::shared_ptr< editing_action_t >()> > step_factories
 Factories evaluated lazily on the first execution. Cleared once consumed.
 
std::vector< std::shared_ptr< editing_action_t > > sub_actions
 Captured sub-actions after first execution, replayed on redo and reversed on undo.
 
bool first_run_done {false}
 

Additional Inherited Members

- Static Public Member Functions inherited from crtp_meta_type< sequence_action_t, editing_action_t >
static auto get_static_meta_type () -> entt::meta_type
 

Detailed Description

Single-undo container for a chain of DEPENDENT actions.

Where composite_action_t requires every sub-action to be fully constructed up-front, sequence_action_t accepts "step factories" so later steps can reference values produced by earlier ones (e.g. an entity handle that only exists after the preceding create step has run).

Lifecycle:

  • First do_action: each factory is invoked in order; the returned sub-action is executed immediately before moving to the next factory, then retained for redos.
  • Subsequent do_action (redo): replays retained sub-actions in order.
  • undo_action: walks retained sub-actions in reverse and undoes each, matching composite_action_t semantics.

Factories returning nullptr are silently skipped, allowing conditional steps.

Definition at line 44 of file composite_action.h.

Member Function Documentation

◆ add_step()

void unravel::sequence_action_t::add_step ( std::function< std::shared_ptr< editing_action_t >()> factory)

Append a step to the sequence. Factory is invoked only on the first execution.

Definition at line 109 of file composite_action.cpp.

◆ do_action()

void unravel::sequence_action_t::do_action ( )
override

Definition at line 117 of file composite_action.cpp.

◆ draw_in_inspector()

void unravel::sequence_action_t::draw_in_inspector ( rtti::context & ctx)
override

Definition at line 190 of file composite_action.cpp.

◆ is_mergeable()

auto unravel::sequence_action_t::is_mergeable ( const editing_action_t & previous) const -> bool
override

Definition at line 185 of file composite_action.cpp.

◆ is_valid()

auto unravel::sequence_action_t::is_valid ( ) const -> bool
override

Definition at line 165 of file composite_action.cpp.

◆ undo_action()

void unravel::sequence_action_t::undo_action ( )
override

Definition at line 153 of file composite_action.cpp.

Member Data Documentation

◆ first_run_done

bool unravel::sequence_action_t::first_run_done {false}

Definition at line 51 of file composite_action.h.

◆ step_factories

std::vector<std::function<std::shared_ptr<editing_action_t>()> > unravel::sequence_action_t::step_factories

Factories evaluated lazily on the first execution. Cleared once consumed.

Definition at line 47 of file composite_action.h.

◆ sub_actions

std::vector<std::shared_ptr<editing_action_t> > unravel::sequence_action_t::sub_actions

Captured sub-actions after first execution, replayed on redo and reversed on undo.

Definition at line 49 of file composite_action.h.


The documentation for this struct was generated from the following files: