public void MultiSpatialMapCreate()
        {
            var mySpatialMap = new MultiSpatialMap <MyIDImpl>();

            Assert.AreEqual(0, mySpatialMap.Count);
            bool retVal = mySpatialMap.Remove(new MyIDImpl(0));

            Assert.AreEqual(false, retVal);

            retVal = false;
            foreach (var item in mySpatialMap.Remove(Coord.Get(1, 2)))
            {
                retVal = true;
            }
            Assert.AreEqual(false, retVal);

            retVal = false;
            foreach (var item in mySpatialMap.Items)
            {
                retVal = true;
            }
            Assert.AreEqual(false, retVal);

            retVal = mySpatialMap.Move(new MyIDImpl(0), Coord.Get(5, 6));
            Assert.AreEqual(false, retVal);

            retVal = false;
            foreach (var item in mySpatialMap.Move(Coord.Get(1, 2), Coord.Get(5, 6)))
            {
                retVal = true;
            }
            Assert.AreEqual(false, retVal);
        }
Beispiel #2
0
        // Removes an Entity from the MultiSpatialMap
        public void Remove(Entity entity)
        {
            // Remove from spatial map
            Entities.Remove(entity);

            // Link up the entity's Moved event to a new handler
            entity.Moved -= OnEntityMoved;
        }
Beispiel #3
0
        public void MultiSpatialMapRemove()
        {
            var mySpatialMap = new MultiSpatialMap <MyIDImpl>();

            var myId1 = new MyIDImpl(0);
            var myId2 = new MyIDImpl(1);
            var myId3 = new MyIDImpl(2);
            var myId4 = new MyIDImpl(3);

            mySpatialMap.Add(myId1, (1, 2));
            mySpatialMap.Add(myId2, (2, 3));
            mySpatialMap.Add(myId3, (3, 4));
            mySpatialMap.Add(myId4, (1, 2));

            bool retVal = mySpatialMap.Remove(myId1);

            Assert.AreEqual(true, retVal);

            retVal = mySpatialMap.Contains(myId1);
            Assert.AreEqual(false, retVal);

            retVal = mySpatialMap.Contains((1, 2));
            Assert.AreEqual(true, retVal);

            int count = 0;

            foreach (var i in mySpatialMap.Remove((2, 3)))
            {
                count++;
            }

            Assert.AreEqual(1, count);

            Assert.AreEqual(false, mySpatialMap.Contains((2, 3)));
            Assert.AreEqual(false, mySpatialMap.Contains(myId2));

            retVal = mySpatialMap.Remove(myId1);
            Assert.AreEqual(false, retVal);

            count = 0;
            foreach (var i in mySpatialMap.Remove((5, 6)))
            {
                count++;
            }
            Assert.AreEqual(0, count);
        }
Beispiel #4
0
        public void MultiSpatialMapRemove()
        {
            var mySpatialMap = new MultiSpatialMap <MyIDImpl>();

            var myId1 = new MyIDImpl(0);
            var myId2 = new MyIDImpl(1);
            var myId3 = new MyIDImpl(2);
            var myId4 = new MyIDImpl(3);

            mySpatialMap.Add(myId1, (1, 2));
            mySpatialMap.Add(myId2, (2, 3));
            mySpatialMap.Add(myId3, (3, 4));
            mySpatialMap.Add(myId4, (1, 2));

            mySpatialMap.Remove(myId1);


            var retVal = mySpatialMap.Contains(myId1);

            Assert.False(retVal);

            retVal = mySpatialMap.Contains((1, 2));
            Assert.True(retVal);



            Assert.Single(mySpatialMap.Remove((2, 3)));

            Assert.False(mySpatialMap.Contains((2, 3)));
            Assert.False(mySpatialMap.Contains(myId2));

            Assert.Throws <ArgumentException>(() => mySpatialMap.Remove(myId1));


            Assert.Empty(mySpatialMap.Remove((5, 6)));
        }