Skip to content

Clone EntityStore #59

Answered by friflo
DruidOwl asked this question in Q&A
Feb 17, 2025 · 2 comments · 13 replies
Discussion options

You must be logged in to vote

Example

  • Source store: entities with id: 1, 2, 3, 4, 5.
  • Copy (clone) only tagged entities [2,4] to target store.

Here a code snippet which preserves the ids [2,4] in the target store.

    var store       = new EntityStore();
    var targetStore = new EntityStore();
    
    store.CreateEntity(new Position(1,1,1));                        // 1
    store.CreateEntity(new Position(2,2,2), Tags.Get<TestTag>());   // 2
    store.CreateEntity(new Position(3,3,3));                        // 3
    store.CreateEntity(new Position(4,4,4), Tags.Get<TestTag>());   // 4
    store.CreateEntity(new Position(5,5,5));                        // 5
    
    // Query will copy only entities [2, 4]
    var query 

Replies: 2 comments 13 replies

Comment options

You must be logged in to vote
13 replies
@friflo
Comment options

@DruidOwl
Comment options

@DruidOwl
Comment options

@friflo
Comment options

Answer selected by friflo
@friflo
Comment options

@friflo
Comment options

@DruidOwl
Comment options

@friflo
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants