// count adds // count deletes // count moves // moves too far away // adds too far away // deletes too far away static bool RunEventCallbacksTest(int centerX, int centerZ, int range, Asteroid[] ast, SpatialPartitionPattern.VisibilityGrid partition) { partition.ClearAll(); partition.Tick();// must tick float testRange = 200; Observer ob = new Observer(); ob.Range = testRange; ob.SetPosition(centerX, centerZ); ob.Register(partition); if (ob.CountAdded != 0 || ob.CountDeleted != 0) { Console.WriteLine("RunEventCallbacksTest:: invalid setup ****"); } Asteroid as1 = new Asteroid(); as1.spaceObject.position.x = ob.GetPosition().x + testRange; as1.spaceObject.position.z = ob.GetPosition().z + testRange; partition.Add(as1.spaceObject); partition.Tick(); if (ob.CountAdded != 0 || ob.CountDeleted != 0) { Console.WriteLine("RunEventCallbacksTest:: invalid add or delete ****"); } return(true); }
static bool RunDeleteTest1(int centerX, int centerZ, int range, Asteroid[] ast, SpatialPartitionPattern.VisibilityGrid partition) { partition.ClearAll(); partition.Add(ast[0].spaceObject); Asteroid astDup = ast[0].Duplicate(); partition.Add(astDup.spaceObject); Vector3 center = ast[0].spaceObject.position; int dist = 500; List <SpaceObject> myList = partition.GetAll((int)center.x, (int)center.z, dist); int countToFind = 2; foreach (var obj in myList) { if (obj == ast[0].spaceObject) { countToFind--; } else if (obj == astDup.spaceObject) { countToFind--; } } if (countToFind != 0) { Console.WriteLine("RunDeleteTest1:: invalid storage of vectors ****"); } partition.Remove(astDup.spaceObject); List <SpaceObject> myList2 = partition.GetAll((int)center.x, (int)center.z, dist); if (myList2.Count != myList.Count - 1) { Console.WriteLine("RunDeleteTest1:: wrong number of items deleted"); } else { Console.WriteLine("RunDeleteTest1:: SUCCESS"); return(true); } return(false); }