コード例 #1
0
ファイル: EntryPoint.cs プロジェクト: DaEgi01/PatchLoader
        /// <summary>
        ///  Entry point called from Doorstop
        /// </summary>
        /// <param name="args">First argument is the path of the currently executing process.</param>
        public static void Main(string[] args)
        {
            _paths  = Paths.Create();
            _logger = new Logger(PathExtensions.Combine(_paths.LogsPath, "PatchLoader.log"));
            _paths.WorkshopModsPath = GetWorkshopModsPath(_paths.WorkingPath, _logger);

            _logger.Info("Detected paths:\n" + _paths);

            if (_paths.DisableMods)
            {
                _logger.Info("******** Mods loading disabled via --disableMods commandline argument. Further execution aborted ********");
                return;
            }

            if (_paths.SkipWorkshop)
            {
                _logger.Info("******** Workshop mods loading disabled via --noWorkshop commandline argument. Processing workshop mods directories will be skipped ********");
            }

            try {
                AppDomain.CurrentDomain.TypeResolve     += AssemblyResolver;
                AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolver;

                new InternalLoader(_logger, _paths)
                .Run();
            } catch (Exception e) {
                _logger.Exception(e);
            } finally {
                AppDomain.CurrentDomain.AssemblyResolve -= AssemblyResolver;
                AppDomain.CurrentDomain.TypeResolve     -= AssemblyResolver;
            }
        }
コード例 #2
0
        public void OnDisabled()
        {
            if (Application.platform == RuntimePlatform.OSXPlayer)
            {
                Debug.Log("PatchLoader disabled");
                return;
            }

            if (_doorstopManager.IsInstalled() && !_pluginInfo.isEnabled)
            {
                _doorstopManager.Disable();
            }

            if (_doorstopManager.RequiresRestart)
            {
                ShowRestartGameModal($"The '{Name}' was uninstalled.\n{_doorstopManager.UninstallMessage}");
            }

            _doorstopManager           = null;
            _pluginInfo                = null;
            _logger                    = null;
            _patchLoaderConfigFilePath = null;
            _configManager             = null;

            Debug.Log("PatchLoader disabled");
        }
コード例 #3
0
ファイル: EntryPoint.cs プロジェクト: DaEgi01/PatchLoader
        private static string GetWorkshopModsPath(string workingPath, Logger logger)
        {
            var configFilePath = Path.Combine(workingPath, "PatchLoader.Config.xml");

            if (File.Exists(configFilePath))
            {
                return(new ConfigManager <Config>(configFilePath, logger).Load().WorkshopPath);
            }
            else
            {
                logger.Info($"File '{configFilePath}' does not exist.");
                return(null);
            }
        }
コード例 #4
0
        private static string GetWorkshopModsPath(string workingPath, Logger logger)
        {
            var configFilePath = Path.Combine(workingPath, "PatchLoader.Config.xml");

            if (File.Exists(configFilePath))
            {
                return(new ConfigManager <Config>(configFilePath, logger).Load().WorkshopPath);
            }
            else
            {
                logger.Info($"File '{configFilePath}' does not exist.");
                PatchLoaderStatusInfo.Statuses.Add("PatchLoader.Config.xml", new PatchStatus("PatchLoader.Config.xml", workingPath, "Not found! Workshop mods may cause problems"));
                return(null);
            }
        }
コード例 #5
0
        public void OnEnabled()
        {
            _pluginInfo = PluginManager.instance.FindPluginInfo(Assembly.GetExecutingAssembly());
            EnsureLogsDirectoryCreated();
            _logger = new Utils.Logger(Path.Combine(Path.Combine(Application.dataPath, "Logs"), "PatchLoaderMod.log"));
            _patchLoaderConfigFilePath = Path.Combine(DataLocation.applicationBase, "PatchLoader.Config.xml");
            _configManager             = new ConfigManager <Config>(_patchLoaderConfigFilePath, _logger);

            var expectedTargetAssemblyPath = PathExtensions.Combine(
                _pluginInfo.modPath,
                "PatchLoader",
                "PatchLoader.dll"
                );

            _doorstopManager = DoorstopManager.Create(expectedTargetAssemblyPath, _logger);

            if (Application.platform == RuntimePlatform.OSXPlayer)
            {
                ShowExceptionModal($"The '{Name}'\nMacOS platform is not supported yet.\n\n" +
                                   "Mod will disable itself.\n" +
                                   "Follow FPS Booster and PatchLoader mod development to stay informed about changes.\n" +
                                   "MacOS support will be added in one of the next major updates for PatchLoader mod.",
                                   () => {
                    _pluginInfo.isEnabled = false;
                });
                return;
            }

            if (!_doorstopManager.IsInstalled())
            {
                _doorstopManager.Install();
                SaveOrUpdateWorkshopPath();
            }

            if (_doorstopManager.CanEnable && !_doorstopManager.IsEnabled())
            {
                _doorstopManager.Enable();
            }

            if (_doorstopManager.RequiresRestart)
            {
                ShowRestartGameModal($"The '{Name}' was installed.\n{_doorstopManager.InstallMessage}");
            }

            Debug.Log("PatchLoader enabled");
        }
コード例 #6
0
        protected void Awake()
        {
            if (assetLibrary == null)
            {
                Debug.LogError($"[{nameof(DemoController)}] No '{nameof(GraphicAssetLibrary)}' provided!");
                return;
            }

            //Create utilities
            logger          = new Utils.Logger(UnityEngine.Debug.Log);
            subtaskRunner   = new SubtaskRunner(executorCount);
            entityContext   = new EntityContext();
            deltaTime       = new DeltaTimeHandle();
            random          = new ShiftRandomProvider();
            renderManager   = new RenderManager(executorCount, assetLibrary);
            colliderManager = new ColliderManager(new AABox(minCollisionArea, maxCollisionArea));

            //Create systems
            systemManager = new TaskManager(subtaskRunner, new ECS.Tasks.ITask[]
            {
                new ApplyVelocitySystem(deltaTime, entityContext),
                new RegisterColliderSystem(colliderManager, entityContext),
                new TestCollisionSystem(deltaTime, colliderManager, entityContext),
                new ApplyGravitySystem(deltaTime, entityContext),

                new SpawnProjectilesSystem(colliderManager, deltaTime, entityContext),
                new SpawnTurretSystem(new AABox(minTurretSpawnArea, maxTurretSpawnArea), turretCount, random, entityContext),
                new SpawnSpaceshipSystem(new AABox(minSpaceshipSpawnArea, maxSpaceshipSpawnArea), spaceshipCount, random, entityContext),

                new ExplodeSpaceshipWhenCrashSystem(entityContext),
                new DisableSpaceshipWhenHitSystem(entityContext),

                new AgeSystem(deltaTime, entityContext),
                new LifetimeSystem(entityContext),

                new RegisterRenderObjectsSystem(renderManager, entityContext),
            }, logger, timeline);

            timeline?.StartTimers();
        }
コード例 #7
0
        public static DoorstopManager Create(string expectedTargetAssemblyPath, Logger logger, ConfigManager <Config> configManager)
        {
            DoorstopManager manager  = null;
            RuntimePlatform platform = Application.platform;

            if (platform == RuntimePlatform.WindowsPlayer || platform == RuntimePlatform.WindowsEditor)
            {
                manager = new WindowsDoorstopManager(expectedTargetAssemblyPath, logger);
            }

            if (platform == RuntimePlatform.OSXPlayer || platform == RuntimePlatform.OSXEditor)
            {
                manager = new MacOSDoorstopManager(expectedTargetAssemblyPath, logger);
            }

            if (platform == RuntimePlatform.LinuxPlayer)
            {
                manager = new LinuxDoorstopManager(expectedTargetAssemblyPath, logger);
            }

            if (manager == null)
            {
                throw new PlatformNotSupportedException($"Platform {platform} is not supported!");
            }
            manager.UpgradeManager.SetLogger(logger);
            manager.UpgradeManager.SetDoorstopManager(manager);
            manager.UpgradeManager.SetConfigManager(configManager);
            manager.UpgradeManager.UpdateState();

            if (manager.IsInstalled())
            {
                manager.LoadConfig();
                manager.RestoreTargetAssemblyPathIfNecessary();
            }

            return(manager);
        }
コード例 #8
0
 internal static void ShowRestartGameModal(string message, string title = "PatchLoaderMod", Logger logger = null)
 {
     logger?.Info($"[ShowRestartGameModal - {title}] {message}");
     CoroutineHelper.WaitFor(
         () => UIView.library != null,
         success: () =>
     {
         UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel", (comp, result) =>
         {
             Debug.Log("[PatchLoaderMod] Trying to quit the game");
             // LoadingManager.instance.QuitApplication(); doesn't work sometimes
             Application.Quit();
         }).SetMessage(title, message, false);
     },
         failure: () =>
     {
         Debug.Log("[PatchLoaderMod] Fail");
         throw new Exception("PatchLoader could not open an important dialog. Something seems to be seriously broken. Please contact the author.");
     },
         stopPollingAfterInSec: 30f
         );
 }
コード例 #9
0
 //Use static factory method 'Create()' for construction.
 protected DoorstopManager(string expectedTargetAssemblyPath, Logger logger)
 {
     _expectedTargetAssemblyPath = expectedTargetAssemblyPath ?? throw new ArgumentNullException(nameof(expectedTargetAssemblyPath));
     _logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }