public void ActiveEntityRunsBehavior() { var entity = new MockEntity(); entity.Start<IncrementCounter>().Add(0); entities.RunEntities(); Assert.AreEqual(1, entity.Get<int>()); }
public void AddingAndRemovingTheSameHandlerDoesNothing() { var entity = new MockEntity().Add(0); entity.Start<IncrementCounter>(); entity.Stop<IncrementCounter>(); entities.RunEntities(); Assert.AreEqual(0, entity.Get<int>()); }
public void AddingBehaviorTwiceIsIgnored() { var entity = new MockEntity().Start<IncrementCounter>().Add(0); var behavior = EntitiesRunner.Current.GetUpdateBehavior<IncrementCounter>(); entities.RunEntities(); Assert.AreEqual(1, entity.Get<int>()); entity.Start<IncrementCounter>(); Assert.AreEqual(behavior, EntitiesRunner.Current.GetUpdateBehavior<IncrementCounter>()); entities.RunEntities(); Assert.AreEqual(2, entity.Get<int>()); Assert.AreEqual(1, EntitiesRunner.Current.NumberOfEntities); }
public void AddEntityAndAttachHandlerLater() { var entity = new MockEntity().Add(0); entities.RunEntities(); Assert.AreEqual(0, entity.Get<int>()); entity.Start<IncrementCounter>(); entities.RunEntities(); Assert.AreEqual(1, entity.Get<int>()); entity.Stop<IncrementCounter>(); entities.RunEntities(); Assert.AreEqual(1, entity.Get<int>()); }
public override void Update(IEnumerable<Entity> entities) { foreach (Entity entity in entities) { var child = new MockEntity(); child.Start<MockUpdateBehavior>(); child.Stop<MockUpdateBehavior>(); entity.Add(child); } }
public void ReactivatedEntityRunsBehavior() { var entity = new MockEntity(); entity.Start<IncrementCounter>().Add(0); entity.IsActive = false; entity.IsActive = true; entities.RunEntities(); Assert.AreEqual(1, entity.Get<int>()); }
public void InactiveEntityDoesntRunBehavior() { var entity = new MockEntity(); entity.Start<IncrementCounter>().Add(0); entity.IsActive = false; entities.RunEntities(); Assert.AreEqual(0, entity.Get<int>()); }