public static void ExpireSchool(Map map, SchoolEntry entry) { if (Schools.ContainsKey(map) && Schools[map].Contains(entry)) { Schools[map].Remove(entry); Point3D p; int failsafe = 0; do { p = SOS.FindLocation(map); failsafe++; }while (p == Point3D.Zero && failsafe < 10); Schools[map].Add(new SchoolEntry(map, new Point2D(p.X, p.Y))); } }
public static void Initialize() { Schools = new Dictionary <Map, List <SchoolEntry> >(); Schools[Map.Trammel] = new List <SchoolEntry>(); Schools[Map.Felucca] = new List <SchoolEntry>(); Schools[Map.Ilshenar] = new List <SchoolEntry>(); Schools[Map.Tokuno] = new List <SchoolEntry>(); foreach (KeyValuePair <Map, List <SchoolEntry> > kvp in Schools) { int amount = 150; if (kvp.Key == Map.Ilshenar || kvp.Key == Map.Tokuno) { amount = 50; } for (int i = 0; i < amount; i++) { Point3D p; int failsafe = 0; do { p = SOS.FindLocation(kvp.Key); failsafe++; }while (p == Point3D.Zero && failsafe < 10); kvp.Value.Add(new SchoolEntry(kvp.Key, new Point2D(p.X, p.Y))); } if (kvp.Value.Count == 0) { Console.WriteLine("Warning: {0} has 0 School entries!", kvp.Key); } } CommandSystem.Register("MoveToSchool", AccessLevel.GameMaster, e => { Mobile m = e.Mobile; if (Schools.ContainsKey(m.Map)) { SchoolEntry entry = Schools[m.Map][Utility.Random(Schools[m.Map].Count)]; if (entry != null) { m.MoveToWorld(new Point3D(entry.Location.X, entry.Location.Y, m.Map.GetAverageZ(entry.Location.X, entry.Location.Y)), m.Map); } else { m.SendMessage("Bad entry"); } } else { m.SendMessage("Bad map"); } }); }