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

Undoable create for entity subtrees: invokes a user-supplied factory on first execution, snapshots the newly-created roots, and restores them with identical UUIDs on redo. More...

#include <entity_actions.h>

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

Public Member Functions

 create_entities_action_t (std::function< std::vector< entt::handle >()> factory)
 Multi-root constructor. The factory returns the set of newly-created roots.
 
 create_entities_action_t (std::function< entt::handle()> factory)
 Single-root convenience overload.
 
void do_action () override
 
void undo_action () override
 
auto is_mergeable (const editing_action_t &previous) const -> bool override
 
auto is_valid () const -> bool override
 
- Public Member Functions inherited from crtp_meta_type< create_entities_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::function< std::vector< entt::handle >()> factory {}
 
std::vector< std::string > serialized_roots {}
 Serialized bytes of each root, captured after the first factory execution.
 
std::vector< entt::uhandleroot_entities {}
 Handles of each created root; the registry pointer persists even after the entity is destroyed.
 
std::vector< entt::uhandleparent_entities {}
 Parent of each root (may hold a nil uuid for root-level entities). Refreshed on every undo.
 
std::vector< std::vector< hpp::uuid > > subtree_uuids {}
 Preorder UUIDs per root subtree (same ordering as save_to_stream / flatten_hierarchy).
 
bool captured {false}
 True once the initial factory-driven creation has run and the snapshot is populated.
 

Additional Inherited Members

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

Detailed Description

Undoable create for entity subtrees: invokes a user-supplied factory on first execution, snapshots the newly-created roots, and restores them with identical UUIDs on redo.

This action is intentionally narrow: it only owns the creation/destruction lifecycle. Selection changes and any parent re-wiring that happens outside the factory are expected to be driven by separate actions. Any parent assigned by the factory itself (e.g. scene::create_entity(name, parent)) is captured as part of the snapshot and re-applied on redo.

Definition at line 28 of file entity_actions.h.

Constructor & Destructor Documentation

◆ create_entities_action_t() [1/2]

unravel::create_entities_action_t::create_entities_action_t ( std::function< std::vector< entt::handle >()> factory)

Multi-root constructor. The factory returns the set of newly-created roots.

Definition at line 90 of file entity_actions.cpp.

◆ create_entities_action_t() [2/2]

unravel::create_entities_action_t::create_entities_action_t ( std::function< entt::handle()> factory)

Single-root convenience overload.

Definition at line 96 of file entity_actions.cpp.

Member Function Documentation

◆ do_action()

void unravel::create_entities_action_t::do_action ( )
override

Definition at line 111 of file entity_actions.cpp.

◆ is_mergeable()

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

Definition at line 265 of file entity_actions.cpp.

◆ is_valid()

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

Definition at line 270 of file entity_actions.cpp.

◆ undo_action()

void unravel::create_entities_action_t::undo_action ( )
override

Definition at line 213 of file entity_actions.cpp.

Member Data Documentation

◆ captured

bool unravel::create_entities_action_t::captured {false}

True once the initial factory-driven creation has run and the snapshot is populated.

Definition at line 44 of file entity_actions.h.

◆ factory

std::function<std::vector<entt::handle>()> unravel::create_entities_action_t::factory {}

Factory invoked on the first execution. Returns the newly-created root entities (may be empty). Cleared after the first execution; subsequent redos use the captured snapshot.

Definition at line 32 of file entity_actions.h.

◆ parent_entities

std::vector<entt::uhandle> unravel::create_entities_action_t::parent_entities {}

Parent of each root (may hold a nil uuid for root-level entities). Refreshed on every undo.

Definition at line 39 of file entity_actions.h.

◆ root_entities

std::vector<entt::uhandle> unravel::create_entities_action_t::root_entities {}

Handles of each created root; the registry pointer persists even after the entity is destroyed.

Definition at line 37 of file entity_actions.h.

◆ serialized_roots

std::vector<std::string> unravel::create_entities_action_t::serialized_roots {}

Serialized bytes of each root, captured after the first factory execution.

Definition at line 35 of file entity_actions.h.

◆ subtree_uuids

std::vector<std::vector<hpp::uuid> > unravel::create_entities_action_t::subtree_uuids {}

Preorder UUIDs per root subtree (same ordering as save_to_stream / flatten_hierarchy).

Definition at line 41 of file entity_actions.h.


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