public static void Importv1(Mobile mobile, string fileName, StreamReader r, ArrayList ArgsList) { ArrayList SpawnerList = new ArrayList(); int totalErrors = 0; string MessagesTitle = (string)ArgsList[2]; string Messages = (string)ArgsList[4]; ArrayList HideSpawnerList = (ArrayList)ArgsList[6]; ArrayList MSGCheckBoxesList = (ArrayList)ArgsList[13]; mobile.SendMessage("Importing spawners..."); DateTime beginTime = DateTime.Now; int amountOfSpawners = 0, amountOfEntries = 0, locX = 0, locY = 0, locZ = 0; string map = null; Map spawnerMap = null; try{ amountOfSpawners = Convert.ToInt32(r.ReadLine()); } catch { totalErrors++; } for (int i = 0; i < amountOfSpawners; i++) { int errors = 0; MegaSpawner megaSpawner = new MegaSpawner(); megaSpawner.Imported = CropDirectory(fileName.ToLower()); megaSpawner.ImportVersion = "1"; megaSpawner.Editor = null; megaSpawner.Workspace = false; try{ map = r.ReadLine().ToLower(); } catch { errors++; totalErrors++; } if (map == "felucca") { spawnerMap = Map.Felucca; } if (map == "trammel") { spawnerMap = Map.Trammel; } if (map == "ilshenar") { spawnerMap = Map.Ilshenar; } if (map == "malas") { spawnerMap = Map.Malas; } try{ locX = Convert.ToInt32(r.ReadLine()); } catch { errors++; totalErrors++; } try{ locY = Convert.ToInt32(r.ReadLine()); } catch { errors++; totalErrors++; } try{ locZ = Convert.ToInt32(r.ReadLine()); } catch { errors++; totalErrors++; } try{ amountOfEntries = Convert.ToInt32(r.ReadLine()); } catch { errors++; totalErrors++; } for (int cnt = 0; cnt < amountOfEntries; cnt++) { try{ megaSpawner.EntryList.Add(r.ReadLine()); } // Entry List catch { errors++; totalErrors++; } try{ megaSpawner.SpawnRangeList.Add(Convert.ToInt32(r.ReadLine())); } // Spawn Range List catch { errors++; totalErrors++; } try{ megaSpawner.WalkRangeList.Add(Convert.ToInt32(r.ReadLine())); } // Walk Range List catch { errors++; totalErrors++; } try{ megaSpawner.AmountList.Add(Convert.ToInt32(r.ReadLine())); } // Amount List catch { errors++; totalErrors++; } try{ megaSpawner.MinDelayList.Add(Convert.ToInt32(r.ReadLine())); } // Min Delay List catch { errors++; totalErrors++; } try{ megaSpawner.MaxDelayList.Add(Convert.ToInt32(r.ReadLine())); } // Max Delay List catch { errors++; totalErrors++; } megaSpawner.SpawnTypeList.Add(SpawnType.Regular); // Spawn Type List megaSpawner.ActivatedList.Add((bool)true); // Activated List megaSpawner.EventRangeList.Add(10); // EVent Range List megaSpawner.EventKeywordList.Add(""); // EVent Keyword List megaSpawner.KeywordCaseSensitiveList.Add((bool)false); megaSpawner.TriggerEventNowList.Add((bool)true); // Trigger Event Now List megaSpawner.EventAmbushList.Add((bool)true); // Event Ambush List megaSpawner.BeginTimeBasedList.Add(0); // Begin Time Based List megaSpawner.EndTimeBasedList.Add(0); // End Time Based List megaSpawner.GroupSpawnList.Add((bool)false); // Group Spawn List megaSpawner.MinStackAmountList.Add(0); megaSpawner.MaxStackAmountList.Add(0); megaSpawner.MovableList.Add((bool)true); megaSpawner.MinDespawnList.Add(1800); megaSpawner.MaxDespawnList.Add(3600); megaSpawner.DespawnList.Add((bool)false); megaSpawner.DespawnGroupList.Add((bool)false); megaSpawner.DespawnTimeExpireList.Add((bool)true); ArrayList respawnEntryList = new ArrayList(); ArrayList respawnTimeList = new ArrayList(); ArrayList spawnCounterList = new ArrayList(); ArrayList spawnTimeList = new ArrayList(); ArrayList respawnOnSaveList = new ArrayList(); ArrayList despawnTimeList = new ArrayList(); for (int j = 0; j < (int)megaSpawner.AmountList[cnt]; j++) { respawnEntryList.Add((string)megaSpawner.EntryList[cnt]); respawnTimeList.Add(0); spawnCounterList.Add(DateTime.Now); spawnTimeList.Add(0); respawnOnSaveList.Add((bool)false); despawnTimeList.Add(0); } megaSpawner.RespawnEntryList.Add(respawnEntryList); megaSpawner.RespawnTimeList.Add(respawnTimeList); megaSpawner.SpawnCounterList.Add(spawnCounterList); megaSpawner.SpawnTimeList.Add(spawnTimeList); megaSpawner.RespawnOnSaveList.Add(respawnOnSaveList); megaSpawner.DespawnTimeList.Add(despawnTimeList); megaSpawner.SpawnedEntries.Add(new ArrayList()); megaSpawner.LastMovedList.Add(new ArrayList()); } if (errors > 0) { megaSpawner.Delete(); amountOfSpawners--; } else { SpawnerList.Add(megaSpawner); megaSpawner.MoveToWorld(new Point3D(locX, locY, locZ), spawnerMap); if (megaSpawner.Active) { megaSpawner.Start(); megaSpawner.Respawn(); } HideSpawnerList.Add((bool)false); MSGCheckBoxesList.Add((bool)false); MC.FileImportAdd(megaSpawner.Imported, megaSpawner.ImportVersion); } } r.Close(); TimeSpan finishTime = DateTime.Now - beginTime; MessagesTitle = "Import Spawners"; if (amountOfSpawners > 0) { Messages = String.Format("File type identified as a Mega Spawner v1 file. {0} Mega Spawner{1} imported. The process took {2} second{3}.", amountOfSpawners, amountOfSpawners == 1 ? "" : "s", (int)finishTime.TotalSeconds, (int)finishTime.TotalSeconds == 1 ? "" : "s"); } else { Messages = String.Format("File type identified as a Mega Spawner v1 file. No Mega Spawners were imported due to errors in the file. The process took {0} second{1}.", (int)finishTime.TotalSeconds, (int)finishTime.TotalSeconds == 1 ? "" : "s"); MC.FileImportRemove(CropDirectory(fileName)); } DateTime beginDupeTime = DateTime.Now; Messages = DupeSpawnerCheck(SpawnerList, Messages); TimeSpan finishDupeTime = DateTime.Now - beginDupeTime; Messages = String.Format("{0} The duped spawner check process took {1} second{2}.", Messages, (int)finishDupeTime.TotalSeconds, (int)finishDupeTime.TotalSeconds == 1 ? "" : "s"); if (totalErrors > 0) { Messages = String.Format("{0} {1} error{2} been detected.", Messages, totalErrors, totalErrors == 1 ? " has" : "s have"); } MC.CheckFileImportList(fileName); ArgsList[2] = MessagesTitle; ArgsList[4] = Messages; ArgsList[6] = HideSpawnerList; ArgsList[13] = MSGCheckBoxesList; mobile.CloseGump(typeof(LoadFileGump)); mobile.SendGump(new FileMenuGump(mobile, ArgsList)); }
protected override void OnTick() { if (count == 0) { total = spawners.GetElementsByTagName("MegaSpawner").Count; beginTime = (DateTime)DateTime.Now; } XmlNode spawner = null; if (!fullForce) { spawner = spawners.GetElementsByTagName("MegaSpawner")[count]; ImportMegaSpawner(spawner, fileName); } else if (count == 0) { for (int i = 0; i < total; i++) { spawner = spawners.GetElementsByTagName("MegaSpawner")[i]; ImportMegaSpawner(spawner, fileName); } count = total; } count++; if (count >= total) { Stop(); finishTime = DateTime.Now - beginTime; gumpMobile.SendMessage("Spawner import complete."); gumpMobile.SendMessage("Checking for duplicate spawners..."); MessagesTitle = "Import Spawners"; if (amountOfSpawners > 0) { Messages = String.Format("File type identified as a Mega Spawner v{0} file. {1} Mega Spawner{2} imported. The import process took {3} second{4}.", version, amountOfSpawners, amountOfSpawners == 1 ? "" : "s", (int)finishTime.TotalSeconds, (int)finishTime.TotalSeconds == 1 ? "" : "s"); } else { Messages = String.Format("File type identified as a Mega Spawner v{0} file. No Mega Spawners were imported due to errors in the file. The import process took {1} second{2}.", version, (int)finishTime.TotalSeconds, (int)finishTime.TotalSeconds == 1 ? "" : "s"); MC.FileImportRemove(MC.CropDirectory(fileName)); } if (amountOfSpawners > 1) { DateTime beginDupeTime = DateTime.Now; DupeSpawnerCheck(); TimeSpan finishDupeTime = DateTime.Now - beginDupeTime; Messages = String.Format("{0} The duped spawner check process took {1} second{2}.", Messages, (int)finishDupeTime.TotalSeconds, (int)finishDupeTime.TotalSeconds == 1 ? "" : "s"); } if (totalErrors > 0) { Messages = String.Format("{0} {1} error{2} been detected.", Messages, totalErrors, totalErrors == 1 ? " has" : "s have"); } if (exceptions > 0) { Messages = String.Format("{0} {1} exception{2} been detected. This is a result of an older file export missing certain data. This is not a concern. Any missing data has been replaced by default data.", Messages, exceptions, exceptions == 1 ? " has" : "s have"); } if (autoFailures > 0) { Messages = String.Format("{0} {1} auto Z placement failure{2} been detected. The import file contains Mega Spawners configured for auto Z placement. There was a problem and placement has failed. Those Mega Spawners have been deleted.", Messages, autoFailures, autoFailures == 1 ? " has" : "s have"); } MC.CheckFileImportList(fileName); SetArgsList(); gumpMobile.SendGump(new FileMenuGump(gumpMobile, ArgsList)); } }