public void AddPage(AbstractPage newPage, Vector3 pageLocation) { if (newPage.Size.Equals(this.pageSize) == false) { throw new ArgumentException("All pages must be the size specified to the Map object."); } if (Pages.ContainsKey(pageLocation)) { throw new ArgumentException("Page already exists at " + pageLocation.ToString() + "."); } /* * Vector3 n = new Vector3(here.x, here.y - 1, here.z); * Vector3 s = new Vector3(here.x, here.y + 1, here.z); * Vector3 e = new Vector3(here.x + 1, here.y, here.z); * Vector3 w = new Vector3(here.x - 1, here.y, here.z); * Vector3 u = new Vector3(here.x, here.y, here.z - 1); * Vector3 d = new Vector3(here.x, here.y, here.z + 1); * bool valid = pages.Count == 0 || * (false && * (pages.ContainsKey(n) || * pages.ContainsKey(s) || * pages.ContainsKey(e) || * pages.ContainsKey(w) || * pages.ContainsKey(u) || * pages.ContainsKey(d))); * if (!valid) * { * throw new ArgumentException("Provided coordinates for new page are not contiguous with existing pages."); * } */ newPage.parentMap = this; newPage.address = pageLocation; Game.Scheduler.AddTask(newPage); Pages.Add(pageLocation, newPage); newPage.Build(); }
/// <summary> /// Adds the passed in page to this map, at the specified map slot. /// </summary> /// <param name="newPage">The page to add to this map.</param> /// <param name="pageLocation">The map slot to place this page.</param> public void AddPage(AbstractPage newPage, Vector3 pageLocation) { if (newPage.Size.Equals(this.PageSize) == false) { throw new ArgumentException("All pages must be the size specified to the Map object."); } if (Pages.ContainsKey(pageLocation)) { throw new ArgumentException("Page already exists at " + pageLocation.ToString() + "."); } // Let's allow them to make disjointed space -- maybe they have infinite terrain, as well as teleportation //bool Found = false; //for (int dx = -1; dx <= 1; dx++) { // for (int dy = -1; dy <= 1; dy++) { // for (int dz = -1; dz <= 1; dz++){ // if (Pages.ContainsKey(pageLocation + new Vector3(dx, dy, dz))) { // Found = true; // break; // } // } // if (Found) break; // } // if (Found) break; //} //if (!Found) //{ // throw new ArgumentException("Provided coordinates for new page are not contiguous with existing pages."); //} newPage.ParentMap = this; newPage.address = pageLocation; Game.Scheduler.AddTask(newPage); Pages.Add(pageLocation, newPage); newPage.Build(); }