Skip to content

Commit

Permalink
update example: EntityBatchOperations()
Browse files Browse the repository at this point in the history
  • Loading branch information
friflo committed Aug 2, 2024
1 parent a1dc6b1 commit c5ceaf1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/Tests/ECS/Examples/Optimization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,20 @@ public static void EntityBatchOperations()
new Scale3(4, 5, 6),
new EntityName("test"),
Tags.Get<MyTag1>());
Console.WriteLine(entity); // id: 1 "test" [EntityName, Position, Scale3, #MyTag1]
Console.WriteLine(entity); // id: 1 "test" [EntityName, Position, Scale3, #MyTag1]

// batch: get operations
var data = entity.Data; // introduced in 3.0.0-preview.7
var data = entity.Data; // introduced in 3.0.0-preview.7
var pos = data.Get<Position>();
var scale = data.Get<Scale3>();
var name = data.Get<EntityName>();
var tags = data.Tags;
Console.WriteLine($"({pos}), ({scale}), ({name})"); // (1, 2, 3), (4, 5, 6), ('test')
Console.WriteLine(tags); // Tags: [#MyTag1]
Console.WriteLine($"({pos}),({scale}),({name})"); // (1, 2, 3), (4, 5, 6), ('test')
Console.WriteLine(tags); // Tags: [#MyTag1]

// batch: remove operations
entity.Remove<Position, EntityName>(Tags.Get<MyTag1>());
Console.WriteLine(entity); // id: 1 []
entity.Remove<Position, Scale3, EntityName>(Tags.Get<MyTag1>());
Console.WriteLine(entity); // id: 1 []
}

/// An EntityBatch should only be used when adding <b>AND</b> removing components / tags to the same entity.<br/>
Expand Down

0 comments on commit c5ceaf1

Please sign in to comment.