Esempio n. 1
0
        public static bool Deserialize(GenericReader reader)
        {
            bool success = false;

            Map     map      = null;
            Point3D location = new Point3D();

            MegaSpawner megaSpawner = new MegaSpawner(true);

            try
            {
                int version = reader.ReadInt();

                if (version >= 1)
                {
                    location           = reader.ReadPoint3D();
                    map                = reader.ReadMap();
                    megaSpawner.Active = reader.ReadBool();

                    megaSpawner.Imported       = reader.ReadString();
                    megaSpawner.ImportVersion  = reader.ReadString();
                    megaSpawner.ContainerSpawn = (Container)reader.ReadItem();
                    megaSpawner.Workspace      = reader.ReadBool();

                    int count = reader.ReadInt();

                    for (int i = 0; i < count; i++)
                    {
                        megaSpawner.EntryList.Add(reader.ReadString());
                    }

                    for (int i = 0; i < count; i++)
                    {
                        megaSpawner.SpawnRangeList.Add(reader.ReadInt());
                    }

                    for (int i = 0; i < count; i++)
                    {
                        megaSpawner.WalkRangeList.Add(reader.ReadInt());
                    }

                    for (int i = 0; i < count; i++)
                    {
                        int amount = reader.ReadInt();

                        if (amount == 0)
                        {
                            amount = 1;
                        }

                        megaSpawner.AmountList.Add(amount);
                    }

                    for (int i = 0; i < count; i++)
                    {
                        megaSpawner.MinDelayList.Add(reader.ReadInt());
                    }

                    for (int i = 0; i < count; i++)
                    {
                        megaSpawner.MaxDelayList.Add(reader.ReadInt());
                    }

                    for (int i = 0; i < count; i++)
                    {
                        megaSpawner.SpawnTypeList.Add(reader.ReadInt());
                    }

                    for (int i = 0; i < count; i++)
                    {
                        megaSpawner.ActivatedList.Add(reader.ReadBool());
                    }

                    for (int i = 0; i < count; i++)
                    {
                        megaSpawner.EventRangeList.Add(reader.ReadInt());
                    }

                    for (int i = 0; i < count; i++)
                    {
                        megaSpawner.EventKeywordList.Add(reader.ReadString());
                    }

                    for (int i = 0; i < count; i++)
                    {
                        megaSpawner.KeywordCaseSensitiveList.Add(reader.ReadBool());
                    }

                    for (int i = 0; i < count; i++)
                    {
                        megaSpawner.TriggerEventNowList.Add(reader.ReadBool());
                    }

                    for (int i = 0; i < count; i++)
                    {
                        megaSpawner.EventAmbushList.Add(reader.ReadBool());
                    }

                    for (int i = 0; i < count; i++)
                    {
                        megaSpawner.BeginTimeBasedList.Add(reader.ReadInt());
                    }

                    for (int i = 0; i < count; i++)
                    {
                        megaSpawner.EndTimeBasedList.Add(reader.ReadInt());
                    }

                    for (int i = 0; i < count; i++)
                    {
                        megaSpawner.GroupSpawnList.Add(reader.ReadBool());
                    }

                    for (int i = 0; i < count; i++)
                    {
                        megaSpawner.MinStackAmountList.Add(reader.ReadInt());
                    }

                    for (int i = 0; i < count; i++)
                    {
                        megaSpawner.MaxStackAmountList.Add(reader.ReadInt());
                    }

                    for (int i = 0; i < count; i++)
                    {
                        megaSpawner.MovableList.Add(reader.ReadBool());
                    }

                    if (version >= 2)
                    {
                        for (int i = 0; i < count; i++)
                        {
                            megaSpawner.MinDespawnList.Add(reader.ReadInt());
                        }

                        for (int i = 0; i < count; i++)
                        {
                            megaSpawner.MaxDespawnList.Add(reader.ReadInt());
                        }

                        for (int i = 0; i < count; i++)
                        {
                            megaSpawner.DespawnList.Add(reader.ReadBool());
                        }

                        for (int i = 0; i < count; i++)
                        {
                            megaSpawner.DespawnGroupList.Add(reader.ReadBool());
                        }

                        for (int i = 0; i < count; i++)
                        {
                            megaSpawner.DespawnTimeExpireList.Add(reader.ReadBool());
                        }
                    }
                    else
                    {
                        for (int i = 0; i < count; i++)
                        {
                            megaSpawner.MinDespawnList.Add(1800);
                        }

                        for (int i = 0; i < count; i++)
                        {
                            megaSpawner.MaxDespawnList.Add(3600);
                        }

                        for (int i = 0; i < count; i++)
                        {
                            megaSpawner.DespawnList.Add((bool)false);
                        }

                        for (int i = 0; i < count; i++)
                        {
                            megaSpawner.DespawnGroupList.Add((bool)false);
                        }

                        for (int i = 0; i < count; i++)
                        {
                            megaSpawner.DespawnTimeExpireList.Add((bool)true);
                        }
                    }

                    int settingsCount = reader.ReadInt();

                    if (version >= 3)
                    {
                        for (int i = 0; i < settingsCount; i++)
                        {
                            ArrayList List = new ArrayList();

                            Setting setting = (Setting)reader.ReadInt();

                            List.Add(setting);

                            switch (setting)
                            {
                            case Setting.OverrideIndividualEntries:
                            {
                                List.Add(reader.ReadInt());
                                List.Add(reader.ReadInt());
                                List.Add(reader.ReadInt());
                                List.Add(reader.ReadInt());
                                List.Add(reader.ReadInt());
                                List.Add(reader.ReadBool());
                                List.Add(reader.ReadBool());
                                List.Add((SpawnType)reader.ReadInt());
                                List.Add(reader.ReadString());
                                List.Add(reader.ReadBool());
                                List.Add(reader.ReadInt());
                                List.Add(reader.ReadInt());
                                List.Add(reader.ReadInt());
                                List.Add(reader.ReadInt());
                                List.Add(reader.ReadInt());
                                List.Add(reader.ReadInt());
                                List.Add(reader.ReadInt());
                                List.Add(reader.ReadBool());
                                List.Add(reader.ReadBool());
                                List.Add(reader.ReadBool());

                                break;
                            }

                            case Setting.AddItem:
                            {
                                List.Add(reader.ReadString());
                                List.Add(reader.ReadInt());
                                List.Add(reader.ReadString());
                                List.Add(reader.ReadInt());
                                List.Add(reader.ReadInt());

                                break;
                            }

                            case Setting.AddContainer:
                            {
                                List.Add(reader.ReadString());
                                List.Add(reader.ReadInt());
                                List.Add(reader.ReadString());
                                List.Add(reader.ReadInt());
                                List.Add(reader.ReadInt());

                                int settingCount = reader.ReadInt();

                                for (int j = 6; j < settingCount; j++)
                                {
                                    ArrayList ItemsList = new ArrayList();

                                    ItemsList.Add(reader.ReadString());
                                    ItemsList.Add(reader.ReadInt());
                                    ItemsList.Add(reader.ReadInt());

                                    List.Add(ItemsList);
                                }

                                break;
                            }
                            }

                            megaSpawner.SettingsList.Add(List);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < settingsCount; i++)
                        {
                            megaSpawner.SettingsList.Add(reader.ReadString());
                        }

                        megaSpawner.ConvertOldSettings();
                    }
                }

                if (megaSpawner.Workspace)
                {
                    megaSpawner.Delete();
                }
                else
                {
                    megaSpawner.MoveToWorld(location, map);
                    megaSpawner.Start();

                    if (megaSpawner.Imported != "")
                    {
                        MC.FileImportAdd(megaSpawner.Imported, megaSpawner.ImportVersion);
                    }

                    megaSpawner.CompileSettings();
                    megaSpawner.CheckEntryErrors();

                    megaSpawner.SettingsList.Sort(new MC.SettingsSorter());

                    if (megaSpawner.OverrideIndividualEntries)
                    {
                        for (int i = 0; i < megaSpawner.OverrideAmount; i++)
                        {
                            megaSpawner.OverrideRespawnEntryList.Add("");
                            megaSpawner.OverrideRespawnTimeList.Add(0);
                            megaSpawner.OverrideSpawnCounterList.Add(DateTime.Now);
                            megaSpawner.OverrideSpawnTimeList.Add(0);
                            megaSpawner.OverrideDespawnTimeList.Add(0);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < megaSpawner.EntryList.Count; i++)
                        {
                            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[i]; j++)
                            {
                                respawnEntryList.Add((string)megaSpawner.EntryList[i]);
                                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());
                        }
                    }

                    megaSpawner.Respawn();
                }

                success = true;
            }
            catch
            {
                if (megaSpawner != null)
                {
                    megaSpawner.Delete();
                }
            }

            return(success);
        }
Esempio n. 2
0
            private void ImportMegaSpawner(XmlNode node, string fileName)
            {
                int errors = 0;

                amountOfSpawners++;

                Map     map      = null;
                Point3D location = new Point3D();

                MegaSpawner megaSpawner = new MegaSpawner();

                megaSpawner.Imported      = MC.CropDirectory(fileName.ToLower());
                megaSpawner.ImportVersion = version;
                megaSpawner.Editor        = null;
                megaSpawner.Workspace     = false;

                double ver;

                try{ ver = Convert.ToDouble(version); }
                catch { ver = 0.0; }

                try{ megaSpawner.Name = GetInnerText(node["Name"]); }
                catch { errors++; totalErrors++; }

                try{ megaSpawner.Active = bool.Parse(GetInnerText(node["Active"])); }
                catch { errors++; totalErrors++; }

                try{ map = Map.Parse(GetInnerText(node["Map"])); }
                catch { errors++; totalErrors++; }

                try{ location = Point3D.Parse(GetInnerText(node["Location"])); }
                catch { errors++; totalErrors++; }

                XmlElement entryLists = null;

                try{ entryLists = node["EntryLists"]; }
                catch { errors++; totalErrors++; }

                if (entryLists != null)
                {
                    int cnt = 0;

                    try
                    {
                        foreach (XmlElement entry in entryLists.GetElementsByTagName("EntryList"))
                        {
                            string entryCompare = null;

                            try{ entryCompare = GetInnerText(entry["EntryType"]); }
                            catch { errors++; totalErrors++; }

                            int entryCount = 0;

                            for (int i = 0; i < megaSpawner.EntryList.Count; i++)
                            {
                                string entryType = (string)megaSpawner.EntryList[i];

                                if (entryType.ToLower() == entryCompare.ToLower())
                                {
                                    entryCount++;
                                }
                            }

                            if (entryCount == 0)
                            {
                                megaSpawner.EntryList.Add(entryCompare);
                            }

                            try{ megaSpawner.SpawnRangeList.Add(int.Parse(GetInnerText(entry["SpawnRange"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.WalkRangeList.Add(int.Parse(GetInnerText(entry["WalkRange"]))); }
                            catch { errors++; totalErrors++; }

                            try
                            {
                                int amount = int.Parse(GetInnerText(entry["Amount"]));

                                if (amount == 0)
                                {
                                    amount = 1;
                                }

                                megaSpawner.AmountList.Add(amount);
                            }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.MinDelayList.Add(int.Parse(GetInnerText(entry["MinDelay"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.MaxDelayList.Add(int.Parse(GetInnerText(entry["MaxDelay"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.SpawnTypeList.Add(int.Parse(GetInnerText(entry["SpawnType"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.ActivatedList.Add(bool.Parse(GetInnerText(entry["Activated"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.EventRangeList.Add(int.Parse(GetInnerText(entry["EventRange"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.EventKeywordList.Add(GetInnerText(entry["EventKeyword"])); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.KeywordCaseSensitiveList.Add(bool.Parse(GetInnerText(entry["KeywordCaseSensitive"]))); }
                            catch { megaSpawner.KeywordCaseSensitiveList.Add((bool)false); exceptions++; }

                            megaSpawner.TriggerEventNowList.Add((bool)true);

                            try{ megaSpawner.EventAmbushList.Add(bool.Parse(GetInnerText(entry["EventAmbush"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.BeginTimeBasedList.Add(int.Parse(GetInnerText(entry["BeginTimeBased"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.EndTimeBasedList.Add(int.Parse(GetInnerText(entry["EndTimeBased"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.GroupSpawnList.Add(bool.Parse(GetInnerText(entry["GroupSpawn"]))); }
                            catch { errors++; totalErrors++; }

                            try{ megaSpawner.MinStackAmountList.Add(int.Parse(GetInnerText(entry["MinStackAmount"]))); }
                            catch { megaSpawner.MinStackAmountList.Add(1); exceptions++; }

                            try{ megaSpawner.MaxStackAmountList.Add(int.Parse(GetInnerText(entry["MaxStackAmount"]))); }
                            catch { megaSpawner.MaxStackAmountList.Add(1); exceptions++; }

                            if (ver < 3.2)
                            {
                                try{ megaSpawner.MovableList.Add(bool.Parse(GetInnerText(entry["ItemMovable"]))); }
                                catch { megaSpawner.MovableList.Add((bool)true); exceptions++; }
                            }
                            else
                            {
                                try{ megaSpawner.MovableList.Add(bool.Parse(GetInnerText(entry["Movable"]))); }
                                catch { megaSpawner.MovableList.Add((bool)true); exceptions++; }
                            }

                            if (ver >= 3.5)
                            {
                                try{ megaSpawner.MinDespawnList.Add(int.Parse(GetInnerText(entry["MinDespawn"]))); }
                                catch { errors++; totalErrors++; }

                                try{ megaSpawner.MaxDespawnList.Add(int.Parse(GetInnerText(entry["MaxDespawn"]))); }
                                catch { errors++; totalErrors++; }

                                try{ megaSpawner.DespawnList.Add(bool.Parse(GetInnerText(entry["Despawn"]))); }
                                catch { errors++; totalErrors++; }

                                try{ megaSpawner.DespawnGroupList.Add(bool.Parse(GetInnerText(entry["DespawnGroup"]))); }
                                catch { errors++; totalErrors++; }

                                try{ megaSpawner.DespawnTimeExpireList.Add(bool.Parse(GetInnerText(entry["DespawnTimeExpire"]))); }
                                catch { errors++; totalErrors++; }
                            }
                            else
                            {
                                megaSpawner.MinDespawnList.Add(1800);
                                megaSpawner.MaxDespawnList.Add(3600);
                                megaSpawner.DespawnList.Add((bool)false);
                                megaSpawner.DespawnGroupList.Add((bool)false);
                                megaSpawner.DespawnTimeExpireList.Add((bool)true);
                            }

                            cnt++;
                        }
                    }
                    catch { errors++; totalErrors++; }
                }

                XmlElement settingsList = null;

                try{ settingsList = node["SettingsList"]; }
                catch { errors++; totalErrors++; }

                if (settingsList != null)
                {
                    if (ver >= 3.6)
                    {
                        try
                        {
                            foreach (XmlElement setting in settingsList.GetElementsByTagName("OverrideIndividualEntries"))
                            {
                                int err = errors;

                                ArrayList List = new ArrayList();

                                List.Add(Setting.OverrideIndividualEntries);

                                try{ List.Add(int.Parse(GetInnerText(setting["SpawnRange"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["WalkRange"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["Amount"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["MinDelay"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["MaxDelay"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(bool.Parse(GetInnerText(setting["GroupSpawn"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(bool.Parse(GetInnerText(setting["EventAmbush"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add((SpawnType)int.Parse(GetInnerText(setting["SpawnType"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(GetInnerText(setting["EventKeyword"])); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(bool.Parse(GetInnerText(setting["CaseSensitive"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["EventRange"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["BeginTimeBasedHour"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["BeginTimeBasedMinute"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["EndTimeBasedHour"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["EndTimeBasedMinute"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["MinDespawn"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["MaxDespawn"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(bool.Parse(GetInnerText(setting["Despawn"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(bool.Parse(GetInnerText(setting["DespawnGroup"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(bool.Parse(GetInnerText(setting["DespawnTimeExpire"]))); }
                                catch { errors++; totalErrors++; }

                                if (err == errors)
                                {
                                    megaSpawner.SettingsList.Add(List);
                                }
                            }
                        }
                        catch {}

                        try
                        {
                            foreach (XmlElement setting in settingsList.GetElementsByTagName("AddItemSetting"))
                            {
                                int err = errors;

                                ArrayList List = new ArrayList();

                                List.Add(Setting.AddItem);

                                try{ List.Add(GetInnerText(setting["EntryName"])); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["EntryIndex"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(GetInnerText(setting["AddItem"])); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["MinStackAmount"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["MaxStackAmount"]))); }
                                catch { errors++; totalErrors++; }

                                if (err == errors)
                                {
                                    megaSpawner.SettingsList.Add(List);
                                }
                            }
                        }
                        catch {}

                        try
                        {
                            foreach (XmlElement setting in settingsList.GetElementsByTagName("AddContainerSetting"))
                            {
                                int err = errors;

                                ArrayList List = new ArrayList();

                                List.Add(Setting.AddContainer);

                                try{ List.Add(GetInnerText(setting["EntryName"])); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["EntryIndex"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(GetInnerText(setting["AddItem"])); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["MinStackAmount"]))); }
                                catch { errors++; totalErrors++; }

                                try{ List.Add(int.Parse(GetInnerText(setting["MaxStackAmount"]))); }
                                catch { errors++; totalErrors++; }

                                XmlElement contList = null;

                                try{ contList = setting["ContainerItems"]; }
                                catch { errors++; totalErrors++; }

                                try
                                {
                                    foreach (XmlElement contItem in contList.GetElementsByTagName("ContainerItem"))
                                    {
                                        ArrayList ItemsList = new ArrayList();

                                        try{ ItemsList.Add(GetInnerText(contItem["AddItem"])); }
                                        catch { errors++; totalErrors++; }

                                        try{ ItemsList.Add(int.Parse(GetInnerText(contItem["MinStackAmount"]))); }
                                        catch { errors++; totalErrors++; }

                                        try{ ItemsList.Add(int.Parse(GetInnerText(contItem["MaxStackAmount"]))); }
                                        catch { errors++; totalErrors++; }

                                        List.Add(ItemsList);
                                    }
                                }
                                catch {}

                                if (err == errors)
                                {
                                    megaSpawner.SettingsList.Add(List);
                                }
                            }
                        }
                        catch {}
                    }
                    else
                    {
                        foreach (XmlElement setting in settingsList.GetElementsByTagName("Setting"))
                        {
                            try{ megaSpawner.SettingsList.Add(setting.InnerText); }
                            catch { errors++; totalErrors++; }
                        }

                        megaSpawner.ConvertOldSettings();
                    }
                }

                if (errors > 0)
                {
                    megaSpawner.Delete();

                    amountOfSpawners--;
                }
                else
                {
                    megaSpawner.MoveToWorld(location, map);

                    if (location.Z == -999)
                    {
                        megaSpawner.Location = GetLocation(megaSpawner, location);
                    }

                    if (megaSpawner.Location.Z == -999)
                    {
                        megaSpawner.Delete();

                        amountOfSpawners--;
                        autoFailures++;

                        return;
                    }

                    megaSpawner.CheckDupedSettings();
                    megaSpawner.CompileSettings();

                    megaSpawner.SettingsList.Sort(new MC.SettingsSorter());

                    if (megaSpawner.OverrideIndividualEntries)
                    {
                        for (int i = 0; i < megaSpawner.OverrideAmount; i++)
                        {
                            megaSpawner.OverrideRespawnEntryList.Add("");
                            megaSpawner.OverrideRespawnTimeList.Add(0);
                            megaSpawner.OverrideSpawnCounterList.Add(DateTime.Now);
                            megaSpawner.OverrideSpawnTimeList.Add(0);
                            megaSpawner.OverrideDespawnTimeList.Add(0);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < megaSpawner.EntryList.Count; i++)
                        {
                            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[i]; j++)
                            {
                                respawnEntryList.Add((string)megaSpawner.EntryList[i]);
                                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());
                        }
                    }

                    SpawnerList.Add(megaSpawner);

                    if (megaSpawner.Active)
                    {
                        megaSpawner.Respawn();
                    }

                    HideSpawnerList.Add((bool)false);
                    MSGCheckBoxesList.Add((bool)false);

                    MC.FileImportAdd(megaSpawner.Imported, megaSpawner.ImportVersion);
                }
            }
Esempio n. 3
0
            private void ConvertDistroSpawner(Item item)
            {
                MegaSpawner megaSpawner = new MegaSpawner();
                Spawner     spawner     = (Spawner)item;
                Type        type        = spawner.GetType();

                PropertyInfo[] props = type.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);

                int count     = spawner.CreaturesName.Count;
                int walkRange = spawner.HomeRange;

                foreach (PropertyInfo prop in props)
                {
                    if (prop.Name == "WalkingRange")
                    {
                        walkRange = Convert.ToInt32(prop.GetValue(spawner, null));

                        break;
                    }
                }

                if (spawner.Name != "Spawner")
                {
                    megaSpawner.Name = spawner.Name;
                }

                int calcMinDelay = 0, calcMaxDelay = 0;

                for (int i = 0; i < count; i++)
                {
                    int entryCount = 0;

                    for (int j = 0; j < megaSpawner.EntryList.Count; j++)
                    {
                        string entryType = (string)megaSpawner.EntryList[j];

                        if (entryType.ToLower() == ((string)spawner.CreaturesName[i]).ToLower())
                        {
                            entryCount++;
                        }
                    }

                    if (entryCount == 0)
                    {
                        bool movable = true;

                        megaSpawner.EntryList.Add((string)spawner.CreaturesName[i]);

                        megaSpawner.SpawnRangeList.Add(spawner.HomeRange);
                        megaSpawner.WalkRangeList.Add(walkRange);

                        if (count == 1)
                        {
                            megaSpawner.AmountList.Add((int)(spawner.Count));
                        }
                        else if (((int)spawner.Count / count) == (int)((double)spawner.Count / (double)count))
                        {
                            megaSpawner.AmountList.Add((int)(spawner.Count / count));
                        }
                        else
                        {
                            megaSpawner.AmountList.Add((int)(spawner.Count / count) + 1);
                        }

                        calcMinDelay = (spawner.MinDelay.Hours * 3600) + (spawner.MinDelay.Minutes * 60) + spawner.MinDelay.Seconds;
                        calcMaxDelay = (spawner.MaxDelay.Hours * 3600) + (spawner.MaxDelay.Minutes * 60) + spawner.MaxDelay.Seconds;

                        Type entryType = ScriptCompiler.FindTypeByName((string)spawner.CreaturesName[i]);

                        if (entryType != null)
                        {
                            Item toAdd = null;

                            try
                            {
                                toAdd   = (Item)Activator.CreateInstance(entryType);
                                movable = toAdd.Movable;
                            }
                            catch {}

                            if (toAdd != null)
                            {
                                toAdd.Delete();
                            }
                        }

                        megaSpawner.MinDelayList.Add(calcMinDelay);
                        megaSpawner.MaxDelayList.Add(calcMaxDelay);
                        megaSpawner.SpawnTypeList.Add(SpawnType.Regular);
                        megaSpawner.ActivatedList.Add((bool)true);
                        megaSpawner.EventRangeList.Add(10);
                        megaSpawner.EventKeywordList.Add("");
                        megaSpawner.KeywordCaseSensitiveList.Add((bool)false);
                        megaSpawner.TriggerEventNowList.Add((bool)true);
                        megaSpawner.EventAmbushList.Add((bool)true);
                        megaSpawner.BeginTimeBasedList.Add(0);
                        megaSpawner.EndTimeBasedList.Add(0);
                        megaSpawner.GroupSpawnList.Add(spawner.Group);
                        megaSpawner.MinStackAmountList.Add(1);
                        megaSpawner.MaxStackAmountList.Add(1);
                        megaSpawner.MovableList.Add(movable);
                        megaSpawner.MinDespawnList.Add(1800);
                        megaSpawner.MaxDespawnList.Add(3600);
                        megaSpawner.DespawnList.Add((bool)false);
                        megaSpawner.DespawnGroupList.Add((bool)false);
                        megaSpawner.DespawnTimeExpireList.Add((bool)true);
                    }
                }

                ArrayList settingList = new ArrayList();

                settingList.Add(Setting.OverrideIndividualEntries);
                settingList.Add(spawner.HomeRange);
                settingList.Add(walkRange);
                settingList.Add(spawner.Count);
                settingList.Add(calcMinDelay);
                settingList.Add(calcMaxDelay);
                settingList.Add(spawner.Group);
                settingList.Add((bool)true);
                settingList.Add(SpawnType.Regular);
                settingList.Add("");
                settingList.Add((bool)false);
                settingList.Add(10);
                settingList.Add(0);
                settingList.Add(0);
                settingList.Add(0);
                settingList.Add(0);
                settingList.Add(1800);
                settingList.Add(3600);
                settingList.Add((bool)false);
                settingList.Add((bool)false);
                settingList.Add((bool)true);

                megaSpawner.SettingsList.Add(settingList);

                megaSpawner.CompileSettings();

                megaSpawner.SettingsList.Sort(new MC.SettingsSorter());

                for (int j = 0; j < megaSpawner.OverrideAmount; j++)
                {
                    megaSpawner.OverrideRespawnEntryList.Add("");
                    megaSpawner.OverrideRespawnTimeList.Add(0);
                    megaSpawner.OverrideSpawnCounterList.Add(DateTime.Now);
                    megaSpawner.OverrideSpawnTimeList.Add(0);
                    megaSpawner.OverrideDespawnTimeList.Add(0);
                }

                megaSpawner.MoveToWorld(spawner.Location, spawner.Map);

                if (megaSpawner.Active)
                {
                    MegaSpawnerOverride.CheckDupedEntries(megaSpawner);

                    megaSpawner.Start();
                    megaSpawner.Respawn();
                }

                HideSpawnerList.Add((bool)false);
                MSGCheckBoxesList.Add((bool)false);

                spawner.Delete();
            }