コード例 #1
0
 public void ActiveEntityRunsBehavior()
 {
     var entity = new MockEntity();
     entity.Start<IncrementCounter>().Add(0);
     entities.RunEntities();
     Assert.AreEqual(1, entity.Get<int>());
 }
コード例 #2
0
 public void AddingAndRemovingTheSameHandlerDoesNothing()
 {
     var entity = new MockEntity().Add(0);
     entity.Start<IncrementCounter>();
     entity.Stop<IncrementCounter>();
     entities.RunEntities();
     Assert.AreEqual(0, entity.Get<int>());
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 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>());
 }
コード例 #5
0
ファイル: EntityTests.cs プロジェクト: whztt07/DeltaEngine
			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);
				}
			}
コード例 #6
0
 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>());
 }
コード例 #7
0
 public void InactiveEntityDoesntRunBehavior()
 {
     var entity = new MockEntity();
     entity.Start<IncrementCounter>().Add(0);
     entity.IsActive = false;
     entities.RunEntities();
     Assert.AreEqual(0, entity.Get<int>());
 }