public void GetComponentFromPawn() { Pawn pawn = new Pawn(); ComponentA a = pawn.AddComponent <ComponentA>(new ComponentA()); ComponentB b = pawn.AddComponent <ComponentB>(new ComponentB()); Assert.NotNull(pawn.GetComponent <ComponentA>()); Assert.AreNotEqual(a, b); }
public void CreateEntityWithTwoComponents() { EcsService service = EcsServiceFactory.CreateECSManager(); Entity entity = service.CreateEntityFromTemplate <TwoComponentsEntityTemplate>(); ComponentA componentA = entity.GetComponent <ComponentA>(); ComponentB componentB = entity.GetComponent <ComponentB>(); service.Update(new GameTime()); Assert.That(componentB.ComponentAReference, Is.EqualTo(componentA)); }
public void GetComponent_ShouldReturnOnly_ComponentA_WhenThereAreManyComponentsTypes() { // Arrange var entity = GetNewEntity(); var componentA = new ComponentA(); var componentB = new ComponentB(); entity.AddComponent(componentA); entity.AddComponent(componentB); // Act var component = entity.GetComponent <ComponentA>(); // Assert Assert.That(component, Is.EqualTo(componentA)); }
public void RemoveComponentBeforeUpdate() { EcsService service = EcsServiceFactory.CreateECSManager(); Entity entity = service.CreateEntityFromTemplate <TwoComponentsEntityTemplate>(); ComponentB componentB = entity.GetComponent <ComponentB>(); Assert.That(!componentB.IsEnabled); entity.RemoveComponent <ComponentB>(); service.Update(new GameTime()); Assert.That(!componentB.IsStarted); Assert.That(!componentB.IsUpdated); Assert.That(!componentB.IsEnabled); Assert.That(componentB.IsDestroyed); }
public void GetComponents_ShouldReturnEnumerableWithOnly_ComponentA_WhenThereAreManyComponentsTypes() { // Arrange var entity = GetNewEntity(); var componentA = new ComponentA(); var componentB = new ComponentB(); entity.AddComponent(componentA); entity.AddComponent(componentB); // Act var actual = entity.GetComponents <ComponentA>(); // Assert var components = actual.ToList(); Assert.That(components.Count, Is.EqualTo(1)); Assert.That(components.Single(), Is.EqualTo(componentA)); }
public void DestoryEntityBeforeAdding() { EcsService service = EcsServiceFactory.CreateECSManager(); Entity entity = service.CreateEntityFromTemplate <TwoComponentsEntityTemplate>(); ComponentB componentA = entity.GetComponent <ComponentB>(); ComponentB componentB = entity.GetComponent <ComponentB>(); entity.Destroy(); service.Update(new GameTime()); Assert.That(!componentA.IsStarted); Assert.That(!componentA.IsUpdated); Assert.That(!componentB.IsStarted); Assert.That(!componentB.IsUpdated); Assert.That(componentA.IsDestroyed); Assert.That(componentB.IsDestroyed); Assert.That(service.Tree.Count(), Is.EqualTo(0)); }
public static TestEntity ReplaceComponentB(this IEntity e, ComponentB component) { e.ReplaceComponent(CID.ComponentB, component); return((TestEntity)e); }
public void Visit(ComponentB component) { throw new System.NotImplementedException(); }
public ComponentA(ComponentB componentB) { this.componentB = componentB; }
public static Entity ReplaceComponentB(this Entity e, ComponentB component) { return e.ReplaceComponent(CID.ComponentB, component); }
public ComponentD(ComponentE e, ComponentB b) { Assert.IsNotNull(e); Assert.IsNotNull(b); }
public static MyTestEntity ReplaceComponentB(this IEntity e, ComponentB component) { e.ReplaceComponent(MyTestComponentsLookup.ComponentB, component); return((MyTestEntity)e); }
public static Entity ReplaceComponentB(this Entity e, ComponentB component) { return(e.ReplaceComponent(CID.ComponentB, component)); }
public void EntityManager_General() { // Arrange var m = new EntityManager(); var e1 = new Entity(); var e2 = new Entity(); var e3 = new Entity(); var e4 = new Entity(); var component_a = new ComponentA(); var component_b = new ComponentB(); var component_c = new ComponentC(); // Act #1 var node_ab = m.GetNodeList <NodeAB>(); var node_bc = m.GetNodeList <NodeBC>(); var node_abc = m.GetNodeList <NodeAbC>(); e1.Add(component_a); e1.Add(component_b); m.AddEntity(e1); e2.Add(component_b); e2.Add(component_c); m.AddEntity(e2); e3.Add(component_a); e3.Add(component_c); m.AddEntity(e3); e4.Add(component_a); e4.Add(component_b); e4.Add(component_c); m.AddEntity(e4); // Assert # Assert.AreEqual(node_ab.Nodes.Length, 2); Assert.AreEqual(node_ab.Nodes[0].Entity, e1); Assert.AreEqual(node_ab.Nodes[0].A, component_a); Assert.AreEqual(node_ab.Nodes[0].B, component_b); Assert.AreEqual(node_ab.Nodes[1].Entity, e4); Assert.AreEqual(node_ab.Nodes[1].A, component_a); Assert.AreEqual(node_ab.Nodes[1].B, component_b); Assert.AreEqual(node_bc.Nodes.Length, 2); Assert.AreEqual(node_bc.Nodes[0].Entity, e2); Assert.AreEqual(node_bc.Nodes[0].B, component_b); Assert.AreEqual(node_bc.Nodes[0].C, component_c); Assert.AreEqual(node_bc.Nodes[1].Entity, e4); Assert.AreEqual(node_bc.Nodes[1].B, component_b); Assert.AreEqual(node_bc.Nodes[1].C, component_c); Assert.AreEqual(node_abc.Nodes.Length, 2); Assert.AreEqual(node_abc.Nodes[0].Entity, e3); Assert.AreEqual(node_abc.Nodes[0].A, component_a); Assert.AreEqual(node_abc.Nodes[0].B, null); Assert.AreEqual(node_abc.Nodes[0].C, component_c); Assert.AreEqual(node_abc.Nodes[1].Entity, e4); Assert.AreEqual(node_abc.Nodes[1].A, component_a); Assert.AreEqual(node_abc.Nodes[1].B, component_b); Assert.AreEqual(node_abc.Nodes[1].C, component_c); // Act #2 e4.Remove(component_b); // Assert #2 Assert.AreEqual(node_ab.Nodes.Length, 1); Assert.AreEqual(node_ab.Nodes[0].Entity, e1); Assert.AreEqual(node_ab.Nodes[0].A, component_a); Assert.AreEqual(node_ab.Nodes[0].B, component_b); Assert.AreEqual(node_bc.Nodes.Length, 1); Assert.AreEqual(node_bc.Nodes[0].Entity, e2); Assert.AreEqual(node_bc.Nodes[0].B, component_b); Assert.AreEqual(node_bc.Nodes[0].C, component_c); Assert.AreEqual(node_abc.Nodes.Length, 2); Assert.AreEqual(node_abc.Nodes[0].Entity, e3); Assert.AreEqual(node_abc.Nodes[0].A, component_a); Assert.AreEqual(node_abc.Nodes[0].B, null); Assert.AreEqual(node_abc.Nodes[0].C, component_c); Assert.AreEqual(node_abc.Nodes[1].Entity, e4); Assert.AreEqual(node_abc.Nodes[1].A, component_a); Assert.AreEqual(node_abc.Nodes[1].B, null); Assert.AreEqual(node_abc.Nodes[1].C, component_c); }
public static void ReplaceComponentB(this Entity e, ComponentB component) { e.ReplaceComponent(CID.ComponentB, component); }
public ComponentA(ComponentB b, ComponentC c) { Assert.IsNotNull(b); Assert.IsNotNull(c); }