示例#1
0
        private static void InitGameData()
        {
            using (var fs = new WzFileSystem {
                BaseDir = Constants.GameDataPath
            })
            {
                fs.Init(Constants.GameDataPath + @"img\Data");

                var sw = new Stopwatch();
                sw.Start();

                Task.WaitAll(Task.Run(() => { StringData = new StringProvider(fs); }),
                             Task.Run(() => { EquipTemplates = new EquipProvider(fs); }),
                             Task.Run(() => { ItemOptionTemplates = new ItemOptionProvider(fs); }),
                             Task.Run(() => { ItemTemplates = new ItemProvider(fs); }),
                             Task.Run(() => { QuestTemplates = new QuestProvider(fs); }),
                             Task.Run(() => { MobSkillTemplates = new MobSkillProvider(fs); }),
                             Task.Run(() => { SkillTemplates = new SkillProvider(fs); }),
                             Task.Run(() => { ItemMakeTemplates = new ItemMakeProvider(fs); }),
                             Task.Run(() => { CommodityProvider = new CashCommodityProvider(fs); }),
                             Task.Run(() => { PackageProvider = new CashPackageProvider(fs); }),
                             Task.Run(() => { NpcTemplates = new NpcProvider(fs); }),
                             Task.Run(() => { ReactorTemplates = new ReactorProvider(fs); }),
                             Task.Run(() => { MapTemplates = new MapProvider(fs); }),
                             Task.Run(() => { MobTemplates = new MobProvider(fs); })
                             );

                sw.Stop();

                Log.Info("Startup seconds elapsed: " + sw.ElapsedMilliseconds / 1000);
            }
        }
示例#2
0
        private void LoadContentsOfFolder(string folder)
        {
            if (!Directory.Exists(folder))
            {
                return;
            }
            var fs = new WzFileSystem();

            fs.Init(folder);
            BeginTreeUpdate();
            LoadContentsSmart(fs);

            EndTreeUpdate();

            AddLastDir(folder);
        }
示例#3
0
        private void LoadContentsOfFolder(string folder)
        {
            if (folder.EndsWith(".exe"))
            {
                LoadMapleInstall(folder);
                return;
            }

            if (!Directory.Exists(folder))
            {
                return;
            }
            var fs = new WzFileSystem();

            fs.Init(folder);
            BeginTreeUpdate();
            LoadContentsSmart(fs);

            EndTreeUpdate();

            AddLastDir(folder);
            LoadedFolderPath = folder;
            openFolderInExplorerToolStripMenuItem.Visible = true;
        }
示例#4
0
 public MobProvider(WzFileSystem baseFileSystem)
     : base(baseFileSystem)
 {
 }
示例#5
0
        protected override bool LoadFromJSON => false;         // doesnt work properly for some reason

        public MapProvider(WzFileSystem baseImgDir)
            : base(baseImgDir)
        {
        }
示例#6
0
 public ItemProvider(WzFileSystem baseFileSystem) : base(baseFileSystem)
 {
 }
 public QuestProvider(WzFileSystem baseFileSystem)
     : base(baseFileSystem)
 {
 }
示例#8
0
 public EquipProvider(WzFileSystem baseFileSystem) : base(baseFileSystem)
 {
 }
示例#9
0
        /// <summary>
        /// Calls LoadFromImg and then LockCollection. Outputs metrics to console.
        /// Requires an initialized WFileSystem object.
        /// </summary>
        /// <param name="baseFileSystem"></param>
        protected AbstractProvider(WzFileSystem baseFileSystem)
        {
            if (ProviderName is null || ProviderName.Length <= 0)
            {
                throw new ArgumentNullException(nameof(ProviderName));
            }
            if (baseFileSystem is null)
            {
                throw new ArgumentNullException(nameof(baseFileSystem));
            }
            if (baseFileSystem.SubDirectories.Count <= 0 && baseFileSystem.Files.Count <= 0)
            {
                throw new ArgumentException("No sub directories or files exist. Verify the file system has been initialized.");
            }

            var watch = new Stopwatch();

            watch.Start();

            _templates = new Dictionary <int, TItem>();

            var jsonFileName = baseFileSystem.BaseDir + @"json\" + ProviderName + ".json";
            var loadFromJson = LoadFromJSON && File.Exists(jsonFileName);

#if DEBUG
            if (loadFromJson)
            {
                RetrieveJsonCache(jsonFileName);
            }
            else
            {
#endif
            if (LoadFromJSON)
            {
                Log.Warn($"Unable to find {ProviderName} JSON. Fetching data from img instead.");
            }

            var dirs = ProviderName.Split('.');

            if (dirs.Length <= 0)
            {
                throw new NullReferenceException("ProviderName is empty.");
            }

            NameSpaceDirectory baseImgDir = baseFileSystem.SubDirectories
                                            .FirstOrDefault(item => item.Name.Equals(dirs[0]))
                                            ?? throw new NullReferenceException($"Unable to find '{dirs[0]}' sub directory.");

            LoadFromImg(baseImgDir);
            SaveToJson(jsonFileName);

            baseImgDir.Files.ForEach(item => item.Unload());
#if DEBUG
        }
#endif
            ProcessAdditionalData();
            LockCollection(_templates.Values.ToList());

            watch.Stop();

            var time      = $"{Math.Floor(watch.ElapsedMilliseconds * 0.001)}.{watch.ElapsedMilliseconds % 1000}";
            var type      = loadFromJson ? "json" : "img";
            var nameSplit = ProviderName.Split('.');

            Log.Info($"{nameSplit[nameSplit.Length - 1] + "Provider",-20} -> Loaded {Count,5} items from {type,4} in {time,5} seconds.");
        }
示例#10
0
 public SkillProvider(WzFileSystem baseFileSystem)
     : base(baseFileSystem)
 {
 }
示例#11
0
 public CashPackageProvider(WzFileSystem baseFileSystem)
     : base(baseFileSystem)
 {
 }
示例#12
0
 public StringProvider(WzFileSystem baseFileSystem)
     : base(baseFileSystem)
 {
 }
 public ReactorProvider(WzFileSystem baseImgDir)
     : base(baseImgDir)
 {
 }
 public CashCommodityProvider(WzFileSystem baseFileSystem)
     : base(baseFileSystem)
 {
 }