public void NoErrorIfThereAreNoVertices() { var entity = new Entity2D(Rectangle.One); entity.Add(new OutlineColor(Color.Red)); Assert.DoesNotThrow(entity.OnDraw <DrawPolygon2DOutlines>); }
public void AddNewComponent() { var entity = new Entity2D(Rectangle.Zero); Assert.AreEqual(Rectangle.Zero, entity.DrawArea); Assert.AreEqual(Color.White, entity.Color); Assert.AreEqual(0, entity.NumberOfComponents); entity.Add(Size.Zero); Assert.AreEqual(1, entity.NumberOfComponents); }
public void ApplyUpdateWithVelocity() { var entity2D = new Entity2D(new Rectangle(0, 0, 1, 1)); entity2D.Add(velocity); entity2D.Start<Velocity2D.PositionUpdate>(); var originalPosition = entity2D.Center; entity2D.Get<Velocity2D.Data>().Accelerate(2.0f, 90.0f); AdvanceTimeAndUpdateEntities(); Assert.AreNotEqual(originalPosition, entity2D.Center); }
public void ApplyUpdateWithVelocity() { var entity2D = new Entity2D(new Rectangle(0, 0, 1, 1)); entity2D.Add(velocity); entity2D.Start <Velocity2D.PositionUpdate>(); var originalPosition = entity2D.Center; entity2D.Get <Velocity2D.Data>().Accelerate(2.0f, 90.0f); AdvanceTimeAndUpdateEntities(); Assert.AreNotEqual(originalPosition, entity2D.Center); }
public static void AffixToPhysics(this Entity2D entity, PhysicsBody body) { entity.Add(body); entity.Start <AffixToPhysics2D>(); }
private static void AddSimplePhysicsDataIfNeeded(Entity2D entity) { if (!entity.Contains<SimplePhysics.Data>()) entity.Add(new SimplePhysics.Data()); }
public void CannotAddTheSameTypeOfComponentTwice() { var entity = new Entity2D(Rectangle.Zero); Assert.Throws <Entity.ComponentOfTheSameTypeAddedMoreThanOnce>(() => entity.Add(Rectangle.One)); }
public void NoErrorIfThereAreNoVertices() { var entity = new Entity2D(Rectangle.One); entity.Add(new OutlineColor(Color.Red)); Assert.DoesNotThrow(entity.OnDraw<DrawPolygon2DOutlines>); }