Beispiel #1
0
 public World()
 {
     NPCs.Clear();
     Signs.Clear();
     Chests.Clear();
     CharacterNames.Clear();
 }
Beispiel #2
0
 public World()
 {
     NPCs.Clear();
     Signs.Clear();
     Chests.Clear();
     CharacterNames.Clear();
     TileFrameImportant = SettingsTileFrameImportant.ToArray(); // clone for "new" world. Loaded worlds will replace this with file data
 }
Beispiel #3
0
        public static bool Load(string path, string key)
        {
            SilkroadPath = GetSetting("SilkroadPath", path);
            MediaPk2Key  = GetSetting("MediaPk2Key", key);
            if (string.IsNullOrEmpty(SilkroadPath) || string.IsNullOrEmpty(MediaPk2Key))
            {
                if (!string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(key))
                {
                    SilkroadPath = GetSetting("SilkroadPath", path, true);
                    MediaPk2Key  = GetSetting("MediaPk2Key", key, true);
                }
                else
                {
                    return(false);
                }
            }
            _reader = new Pk2Reader(SilkroadPath + @"\Media.pk2", MediaPk2Key);

            var isUpdate   = GetSetting("GameVersion", 0);
            var needUpdate = isUpdate == 0 || isUpdate < Version();

            GameVerison     = GetSetting("GameVersion", Version(), needUpdate);
            GatewayPort     = ushort.Parse(GetSetting("GatewayPort", GatePort(), needUpdate).ToString());
            DivisionServers = DivisionInfo().ToList();

            if (!needUpdate)
            {
                return(true);
            }
            LiteDatabase.DropCollection(Skills.Name);
            LiteDatabase.DropCollection(Items.Name);
            LoadTextData();
            Skills.Insert(LoadSkillsData().GroupBy(x => x.Id).Select(x => x.OrderBy(y => y.Id).First()));
            Items.Insert(LoadItemsData().GroupBy(x => x.Id).Select(x => x.OrderBy(y => y.Id).First()));
            Characters.Insert(LoadCharacterData().GroupBy(x => x.Id).Select(x => x.OrderBy(y => y.Id).First()));
            ItemNames.Clear();
            SkillNames.Clear();
            CharacterNames.Clear();
            RegionNames.Clear();
            GC.Collect();
            GC.WaitForPendingFinalizers();
            return(true);
        }