public void SupportsIrregularSizedMapChunks() { var map = new Map2D <float>(16, 32); var oldBoot = new Entity { Name = "Old Boot" }; var newBoot = new Entity { Name = "New Boot" }; map.PutEntity(1, 1, oldBoot); // W:{1,1}, C:{0,0} map.PutEntity(16, 33, newBoot); // w:{33,33}, C:{0,2} Assert.That(map.GetEntitiesInChunk(new ChunkSpace(0, 0, 0)).Count(), Is.EqualTo(1)); Assert.That(map.GetEntitiesInChunk(new ChunkSpace(0, 2, 0)).Count(), Is.EqualTo(1)); Assert.That(map.GetEntitiesInChunk(new ChunkSpace(0, 0, 0)).Single(), Is.EqualTo(oldBoot)); Assert.That(map.GetEntitiesInChunk(new ChunkSpace(0, 2, 0)).Single(), Is.EqualTo(newBoot)); Assert.That(map.GetEntitiesAt(1, 1).Single() == oldBoot); Assert.That(map.GetEntitiesAt(16, 33).Single() == newBoot); Assert.That(map.ChunksWithin(0, 0, 33, 33, createIfNull: false).Count(), Is.EqualTo(2)); }
public void SupportsGettingEntitiesInLocalArea() { var map = new Map2D <float>(16, 16); var oldBoot = new Entity { Name = "Old Boot" }; var oldCan = new Entity { Name = "Old Boot" }; var oldBucket = new Entity { Name = "Old Boot" }; map.PutEntity(1, 1, oldBoot); map.PutEntity(1, 1, oldBucket); map.PutEntity(1, 1, oldCan); Assert.That(map.GetEntitiesAt(1, 1).Any()); Assert.That(oldBoot.X == 1 && oldBoot.Y == 1); Assert.That(map.GetEntitiesInChunk(1, 1).Count() == 3); }