Exemplo n.º 1
0
        public static void LoadData()
        {
            var    ass      = Assembly.GetExecutingAssembly();
            string dataPath = Path.Combine(Path.GetDirectoryName(ass.Location), dataFileName);

            if (File.Exists(dataPath))
            {
                try
                {
                    var json = File.ReadAllText(dataPath);
                    data = JSONSerializer.Deserialize <TargetData>(json);
                    LockOnPlugin.Logger.Log(LogLevel.Info, "Loading custom target data.");
                }
                catch (Exception)
                {
                    LockOnPlugin.Logger.Log(LogLevel.Info, "Failed to deserialize custom target data. Loading default target data.");
                    LoadResourceData();
                }
            }
            else
            {
                LockOnPlugin.Logger.Log(LogLevel.Debug, "Loading default target data.");
                LoadResourceData();
            }
        }
Exemplo n.º 2
0
        private void Awake()
        {
            TargetData.LoadData();

            bepinex = gameObject;
            harmony = new Harmony($"{GUID}.harmony");
            HarmonyWrapper.PatchAll(typeof(Hooks), harmony);
        }
Exemplo n.º 3
0
        private static void LoadResourceData()
        {
            string resourceName = $"{nameof(LockOnPluginKK)}.{dataFileName}";

            using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName))
            {
                using (var reader = new StreamReader(stream))
                {
                    string json = reader.ReadToEnd();
                    data = JSONSerializer.Deserialize <TargetData>(json);
                }
            }
        }
Exemplo n.º 4
0
 void Awake()
 {
     TargetData.LoadData();
     SceneLoaded();
     SceneManager.sceneLoaded += SceneLoaded;
 }