Ejemplo n.º 1
0
        public void Init(IPALogger logger)
        {
            Logger.log = logger;
            Logger.Log("Logger prepared", LogLevel.Debug);
            string path = Path.Combine(UnityGame.UserDataPath, Plugin.Name + ".ini");

            _rootConfig = new RootConfig(path);
            if (_rootConfig.ForceDisableSmoothCamera)
            {
                try
                {
                    string gameCfgPath = Path.Combine(Application.persistentDataPath, "settings.cfg");
                    var    settings    = JsonConvert.DeserializeObject <ConfigEntity>(File.ReadAllText(gameCfgPath));
                    if (settings.smoothCameraEnabled == 1)
                    {
                        settings.smoothCameraEnabled = 0;
                        File.WriteAllText(gameCfgPath, JsonConvert.SerializeObject(settings));
                    }
                }
                catch (Exception e)
                {
                    Logger.Log($"Fail SmoothCamera off {e.Message}", LogLevel.Error);
                }
            }
        }
Ejemplo n.º 2
0
        private void Awake()
        {
            if (instance != null)
            {
                Logger.log?.Warn($"Instance of {this.GetType().Name} already exists, destroying.");
                GameObject.DestroyImmediate(this);
                return;
            }
            GameObject.DontDestroyOnLoad(this);
            instance = this;

            string path       = Path.Combine(UnityGame.UserDataPath, $"{Plugin.Name}.ini");
            string backupPath = backupPath = Path.Combine(UnityGame.UserDataPath, Plugin.Name, "OldProfiles");

            if (File.Exists(path))
            {
                RootConfig rootConfig = new RootConfig(path);
                if (!Directory.Exists(backupPath))
                {
                    Directory.CreateDirectory(backupPath);
                }
                File.Copy(path, Path.Combine(backupPath, $"{Plugin.Name}.ini"), true);
                File.Delete(path);
            }

            ConfigConverter.ProfileConverter();

            SceneManager.activeSceneChanged += this.OnActiveSceneChanged;
            CameraUtilities.CreateMainDirectory();
            CameraUtilities.CreateExampleScript();

            ConfigConverter.DefaultConfigConverter();
        }
Ejemplo n.º 3
0
        public void Init(IPALogger logger)
        {
            Logger.log = logger;
            Logger.Log("Logger prepared", LogLevel.Debug);
            string path = Path.Combine(UnityGame.UserDataPath, $"{Plugin.Name}.ini");

            _rootConfig = new RootConfig(path);
        }
Ejemplo n.º 4
0
        public void Init(IPALogger logger)
        {
            Logger.log = logger;
            Logger.Log("Logger prepared", LogLevel.Debug);
            string path = Path.Combine(UnityGame.UserDataPath, $"{Plugin.Name}.ini");

            _rootConfig = new RootConfig(path);
            if (_rootConfig.ForceDisableSmoothCamera)
            {
                try {
                    string gameCfgPath = Path.Combine(Application.persistentDataPath, "settings.cfg");
                    var    settings    = JsonConvert.DeserializeObject <ConfigEntity>(File.ReadAllText(gameCfgPath));
                    if (settings.version == "1.6.0")
                    {
                        if (settings.smoothCameraEnabled == 1)
                        {
                            settings.smoothCameraEnabled = 0;
                            File.WriteAllText(gameCfgPath, JsonConvert.SerializeObject(settings));
                        }
                    }
                } catch (Exception e) {
                    Logger.Log($"Fail SmoothCamera off {e.Message}", LogLevel.Error);
                }
            }

            //var x = AccessTools.PropertySetter(typeof(Camera), "cullingMask");

            //var d = x.MethodHandle;

            //RuntimeHelpers.PrepareMethod(d);

            //var y = d.GetFunctionPointer();
            //maskSetterAddr = (byte*)y.ToPointer();
            //cullingMask_ogOp = *maskSetterAddr;

            //Console.WriteLine(">> {0} {1}", y, (int)maskSetterAddr);
        }