public void CopiesOfAllComponentsAddedToTargetEntity() { _originalEntity.AddComponentA(); _originalEntity.AddComponent(MyTestComponentsLookup.NameAge, _nameAge); _originalEntity.CopyTo(_targetEntity); Assert.AreEqual(2, _targetEntity.GetComponents().Length); Assert.IsTrue(_targetEntity.HasComponentA()); Assert.IsTrue(_targetEntity.HasNameAge); Assert.AreNotEqual(Component.A, _targetEntity.GetComponentA()); Assert.AreNotEqual(_nameAge, _targetEntity.NameAge); var clonedComponent = (NameAgeComponent)_targetEntity.GetComponent(MyTestComponentsLookup.NameAge); Assert.AreEqual(_nameAge.name, clonedComponent.name); Assert.AreEqual(_nameAge.age, clonedComponent.age); }
private void SetupGroupEntities() { eAB1 = _defaultContext.CreateEntity(); eAB1.AddComponentA(); eAB1.AddComponentB(); eAB2 = _defaultContext.CreateEntity(); eAB2.AddComponentA(); eAB2.AddComponentB(); eA = _defaultContext.CreateEntity(); eA.AddComponentA(); }
public void CopiesOfAllComponentsAddedToTargetEntity() { _entity.AddComponentA(); _entity.AddComponent(CID.ComponentB, _nameAge); #pragma warning disable CS0618 // Type or member is obsolete #pragma warning disable HAA0101 // Array allocation for params parameter _entity.CopyTo(_target); #pragma warning restore HAA0101 // Array allocation for params parameter #pragma warning restore CS0618 // Type or member is obsolete Assert.AreEqual(2, _target.GetComponents().Length); Assert.IsTrue(_target.HasComponentA()); Assert.IsTrue(_target.HasComponentB()); Assert.AreNotEqual(Component.A, _target.GetComponentA()); Assert.AreNotEqual(_nameAge, _target.GetComponent(CID.ComponentB)); var clonedComponent = (NameAgeComponent)_target.GetComponent(CID.ComponentB); Assert.AreEqual(_nameAge.name, clonedComponent.name); Assert.AreEqual(_nameAge.age, clonedComponent.age); }
public void SetupMultipleKeyEntityIndex() { _context = new MyTestContext(); _group = _context.GetGroup(Matcher <MyTestEntity> .AllOf(CID.ComponentA)); _index = new EntityIndex <MyTestEntity, string>("TestIndex", _group, (e, c) => { return(e == _entity1 ? new[] { "1", "2" } : new[] { "2", "3" }); }); _entity1 = _context.CreateEntity(); _entity1.AddComponentA(); _entity2 = _context.CreateEntity(); _entity2.AddComponentA(); }
public void AllEventHandlersAreRemovedFromGroup() { _groupA.OnEntityAdded += delegate { Assert.Fail(); }; _groupA.OnEntityRemoved += delegate { Assert.Fail(); }; _groupA.OnEntityUpdated += delegate { Assert.Fail(); }; _groupA.RemoveAllEventHandlers(); HandleAddEntityWithAComponent(_entityWithAComponent1); var cA = _entityWithAComponent1.GetComponentA(); _entityWithAComponent1.RemoveComponentA(); HandleRemoveEntityWithAComponent(_entityWithAComponent1, cA); _entityWithAComponent1.AddComponentA(); HandleAddEntityWithAComponent(_entityWithAComponent1); HandleUpdateEntityWithAComponent(_entityWithAComponent1, Component.A); }
public void Setup() { _eA = TestTools.CreateEntity(); _eA.AddComponentA(); _eB = TestTools.CreateEntity(); _eB.AddComponentB(); _eC = TestTools.CreateEntity(); _eC.AddComponentC(); _eAb = TestTools.CreateEntity(); _eAb.AddComponentA(); _eAb.AddComponentB(); _eAbc = TestTools.CreateEntity(); _eAbc.AddComponentA(); _eAbc.AddComponentB(); _eAbc.AddComponentC(); }
public void ValidateInitializedComponentIsPresent() { _defaultEntity.AddComponentA(); AssertHasComponentA(_defaultEntity); }