Esempio n. 1
0
        public object LoadAsset(AssetKey key, string name, Func <AssetKey, object> loaderFunc)
        {
            var generalConfig = (IGeneralConfig)loaderFunc(new AssetKey(AssetType.GeneralConfig));
            var filename      = Path.Combine(generalConfig.BasePath, generalConfig.SavePath, $"SAVE.{key.Id:D3}");

            var loader = AssetLoaderRegistry.GetLoader <SavedGame>(FileFormat.SavedGame);

            using var stream = File.Open(filename, FileMode.Open);
            using var br     = new BinaryReader(stream);
            return(loader.Serdes(
                       null,
                       new AlbionReader(br, stream.Length), key, null));
        }
Esempio n. 2
0
        static (ModApplier, EventExchange, AssetLoaderRegistry) BuildModApplier(string baseDir, string mod, IFileSystem disk, IJsonUtil jsonUtil)
        {
            var config              = GeneralConfig.Load(Path.Combine(baseDir, "data", "config.json"), baseDir, disk, jsonUtil);
            var applier             = new ModApplier();
            var exchange            = new EventExchange(new LogExchange());
            var assetLoaderRegistry = new AssetLoaderRegistry();

            exchange
            .Register(disk)
            .Register(jsonUtil)
            .Register <IGeneralConfig>(config)
            .Attach(new StdioConsoleLogger())
            .Attach(assetLoaderRegistry)
            .Attach(new ContainerRegistry())
            .Attach(new PostProcessorRegistry())
            .Attach(new AssetLocator())
            .Attach(new SpellManager())
            .Attach(new SettingsManager(new GeneralSettings()))     // Used for event comments
            .Attach(applier)
            ;
            applier.LoadMods(config, new[] { mod });
            return(applier, exchange, assetLoaderRegistry);
        }