From bd81790456dfe75e4186c8cd63264c4eefc0612e Mon Sep 17 00:00:00 2001 From: Ullrich Praetz Date: Thu, 25 Jul 2024 17:03:12 +0200 Subject: [PATCH] reduced line length for wiki examples --- src/Tests/ECS/Examples/Component_Types.cs | 56 +++++++++++------------ 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/src/Tests/ECS/Examples/Component_Types.cs b/src/Tests/ECS/Examples/Component_Types.cs index 299ac405..6b11ba41 100644 --- a/src/Tests/ECS/Examples/Component_Types.cs +++ b/src/Tests/ECS/Examples/Component_Types.cs @@ -35,23 +35,23 @@ public static void LinkComponents() { var store = new EntityStore(); - var entity1 = store.CreateEntity(1); // link components - var entity2 = store.CreateEntity(2); // symbolized as → - var entity3 = store.CreateEntity(3); // 1 2 3 + var entity1 = store.CreateEntity(1); // link components + var entity2 = store.CreateEntity(2); // symbolized as → + var entity3 = store.CreateEntity(3); // 1 2 3 // add a link component to entity (2) referencing entity (1) - entity2.AddComponent(new AttackComponent { target = entity1 }); // 1 ← 2 3 - // get all incoming links of given type. O(1) // - entity1.GetIncomingLinks(); // { 2 } + entity2.AddComponent(new AttackComponent { target = entity1 }); // 1 ← 2 3 + // get all incoming links of given type. O(1) + entity1.GetIncomingLinks(); // { 2 } // update link component of entity (2). It links now entity (3) - entity2.AddComponent(new AttackComponent { target = entity3 }); // 1 2 → 3 - entity1.GetIncomingLinks(); // { } - entity3.GetIncomingLinks(); // { 2 } + entity2.AddComponent(new AttackComponent { target = entity3 }); // 1 2 → 3 + entity1.GetIncomingLinks(); // { } + entity3.GetIncomingLinks(); // { 2 } // deleting a linked entity (3) removes all link components referencing it - entity3.DeleteEntity(); // 1 2 - entity2.HasComponent (); // false + entity3.DeleteEntity(); // 1 2 + entity2.HasComponent (); // false } #endregion @@ -83,29 +83,29 @@ public static void LinkRelations() { var store = new EntityStore(); - var entity1 = store.CreateEntity(1); // link relations - var entity2 = store.CreateEntity(2); // symbolized as → - var entity3 = store.CreateEntity(3); // 1 2 3 + var entity1 = store.CreateEntity(1); // link relations + var entity2 = store.CreateEntity(2); // symbolized as → + var entity3 = store.CreateEntity(3); // 1 2 3 // add a link relation to entity (2) referencing entity (1) - entity2.AddRelation(new AttackRelation { target = entity1 }); // 1 ← 2 3 - // get all links added to the entity. O(1) // - entity2.GetRelations (); // { 1 } - // get all incoming links. O(1) // - entity1.GetIncomingLinks(); // { 2 } + entity2.AddRelation(new AttackRelation { target = entity1 }); // 1 ← 2 3 + // get all links added to the entity. O(1) + entity2.GetRelations (); // { 1 } + // get all incoming links. O(1) + entity1.GetIncomingLinks(); // { 2 } // add another one. An entity can have multiple link relations - entity2.AddRelation(new AttackRelation { target = entity3 }); // 1 ← 2 → 3 - entity2.GetRelations (); // { 1, 3 } - entity3.GetIncomingLinks(); // { 2 } + entity2.AddRelation(new AttackRelation { target = entity3 }); // 1 ← 2 → 3 + entity2.GetRelations (); // { 1, 3 } + entity3.GetIncomingLinks(); // { 2 } // deleting a linked entity (1) removes all link relations referencing it - entity1.DeleteEntity(); // 2 → 3 - entity2.GetRelations (); // { 3 } + entity1.DeleteEntity(); // 2 → 3 + entity2.GetRelations (); // { 3 } // deleting entity (2) is reflected by incoming links query - entity2.DeleteEntity(); // 3 - entity3.GetIncomingLinks(); // { } + entity2.DeleteEntity(); // 3 + entity3.GetIncomingLinks(); // { } } #endregion @@ -130,10 +130,10 @@ enum ItemType { Axe = 2, } -struct InventoryItem : IRelationComponent { // relation key type: ItemType +struct InventoryItem : IRelationComponent { // relation key type: ItemType public ItemType type; public int count; - public ItemType GetRelationKey() => type; // unique relation key + public ItemType GetRelationKey() => type; // unique relation key } [Test]