/// <summary> /// <para>Loads the embedded base files.</para> /// </summary> public void LoadBaseResources() { _resources.Initialize(); _resources.MountContentDirectory(""); _resources.MountContentPack(@"./EngineContentPack.zip"); }
/// <summary> /// 预下载初始AssetBundle资源 /// </summary> /// <returns></returns> public IEnumerator PreDownloadInitBundle() { IEnumerator e = m_ResourceManager.Initialize(); while (e.MoveNext()) { yield return(null); } }
private void initializeResourceManager() { // Which resource manager? IResourceManager rmInstance = (IResourceManager) applicationAttributes[RuntimeConstants.RESOURCE_MANAGER_CLASS]; String rm = GetString(RuntimeConstants.RESOURCE_MANAGER_CLASS); if (rmInstance == null && rm != null && rm.Length > 0) { // if something was specified, then make one. // if that isn't a ResourceManager, consider // this a huge error and throw Object o; try { Type rmType = Type.GetType(rm); o = Activator.CreateInstance(rmType); } catch (System.Exception) { String err = string.Format("The specified class for ResourceManager ({0}) does not exist.", rm); Error(err); throw new System.Exception(err); } if (!(o is IResourceManager)) { String err = string.Format( "The specified class for ResourceManager ({0}) does not implement ResourceManager. NVelocity not initialized correctly.", rm); Error(err); throw new System.Exception(err); } resourceManager = (IResourceManager)o; resourceManager.Initialize(this); } else if (rmInstance != null) { resourceManager = rmInstance; resourceManager.Initialize(this); } else { // someone screwed up. Lets not fool around... String err = "It appears that no class was specified as the ResourceManager. Please ensure that all configuration information is correct."; Error(err); throw new System.Exception(err); } }
/// <inheritdoc /> public bool Start() { //Sets up the configMgr _config.LoadFromFile(_commandLine.ConfigFile); //Sets up Logging _config.RegisterCVar("log.path", "logs", CVar.ARCHIVE); _config.RegisterCVar("log.format", "log_%(date)s-%(time)s.txt", CVar.ARCHIVE); _config.RegisterCVar("log.level", LogLevel.Info, CVar.ARCHIVE); var logPath = _config.GetCVar <string>("log.path"); var logFormat = _config.GetCVar <string>("log.format"); var logFilename = logFormat.Replace("%(date)s", DateTime.Now.ToString("yyyyMMdd")).Replace("%(time)s", DateTime.Now.ToString("hhmmss")); var fullPath = Path.Combine(logPath, logFilename); if (!Path.IsPathRooted(fullPath)) { logPath = PathHelpers.ExecutableRelativeFile(fullPath); } fileLogHandler = new FileLogHandler(logPath); _log.RootSawmill.Level = _config.GetCVar <LogLevel>("log.level"); _log.RootSawmill.AddHandler(fileLogHandler); // Has to be done early because this guy's in charge of the main thread Synchronization Context. _taskManager.Initialize(); LoadSettings(); var netMan = IoCManager.Resolve <IServerNetManager>(); try { netMan.Initialize(true); netMan.StartServer(); } catch (Exception e) { var port = netMan.Port; Logger.Fatal("Unable to setup networking manager. Check port {0} is not already in use and that all binding addresses are correct!\n{1}", port, e); return(true); } // Set up the VFS _resources.Initialize(); #if RELEASE _resources.MountContentDirectory(@"./Resources/"); #else // Load from the resources dir in the repo root instead. // It's a debug build so this is fine. _resources.MountContentDirectory(@"../../Resources/"); _resources.MountContentDirectory(@"../../../bin/Content.Server/", new ResourcePath("/Assemblies/")); #endif //mount the engine content pack // _resources.MountContentPack(@"EngineContentPack.zip"); //mount the default game ContentPack defined in config // _resources.MountDefaultContentPack(); //identical code in game controller for client if (!AssemblyLoader.TryLoadAssembly <GameShared>(_resources, $"Content.Shared")) { Logger.Warning($"[ENG] Could not load any Shared DLL."); } if (!AssemblyLoader.TryLoadAssembly <GameServer>(_resources, $"Content.Server")) { Logger.Warning($"[ENG] Could not load any Server DLL."); } // HAS to happen after content gets loaded. // Else the content types won't be included. // TODO: solve this properly. _serializer.Initialize(); // Initialize Tier 2 services _stateManager.Initialize(); _entities.Initialize(); IoCManager.Resolve <IChatManager>().Initialize(); IoCManager.Resolve <IPlayerManager>().Initialize(MaxPlayers); _mapManager.Initialize(); IoCManager.Resolve <IPlacementManager>().Initialize(); IoCManager.Resolve <IViewVariablesHost>().Initialize(); // Call Init in game assemblies. AssemblyLoader.BroadcastRunLevel(AssemblyLoader.RunLevel.Init); // because of 'reasons' this has to be called after the last assembly is loaded // otherwise the prototypes will be cleared var prototypeManager = IoCManager.Resolve <IPrototypeManager>(); prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes")); prototypeManager.Resync(); IoCManager.Resolve <ITileDefinitionManager>().Initialize(); IoCManager.Resolve <IConsoleShell>().Initialize(); IoCManager.Resolve <IConGroupController>().Initialize(); AssemblyLoader.BroadcastRunLevel(AssemblyLoader.RunLevel.PostInit); _entities.Startup(); IoCManager.Resolve <IStatusHost>().Start(); return(false); }
private void initializeResourceManager() { // Which resource manager? IResourceManager rmInstance = (IResourceManager) applicationAttributes[RuntimeConstants.RESOURCE_MANAGER_CLASS]; String rm = GetString(RuntimeConstants.RESOURCE_MANAGER_CLASS); if (rmInstance == null && rm != null && rm.Length > 0) { // if something was specified, then make one. // if that isn't a ResourceManager, consider // this a huge error and throw Object o; try { Type rmType = Type.GetType(rm); o = Activator.CreateInstance(rmType); } catch(System.Exception) { String err = string.Format("The specified class for ResourceManager ({0}) does not exist.", rm); Error(err); throw new System.Exception(err); } if (!(o is IResourceManager)) { String err = string.Format( "The specified class for ResourceManager ({0}) does not implement ResourceManager. NVelocity not initialized correctly.", rm); Error(err); throw new System.Exception(err); } resourceManager = (IResourceManager) o; resourceManager.Initialize(this); } else if (rmInstance != null) { resourceManager = rmInstance; resourceManager.Initialize(this); } else { // someone screwed up. Lets not fool around... String err = "It appears that no class was specified as the ResourceManager. Please ensure that all configuration information is correct."; Error(err); throw new System.Exception(err); } }