Example #1
0
        internal static void Awake()
        {
            //MoreAcc相關
            string path = KoikatuHelper.TryGetPluginInstance("com.joan6694.illusionplugins.moreaccessories", new Version(2, 0, 10))?.Info.Location;

            if (null != path && path.Length != 0)
            {
                Assembly ass = Assembly.LoadFrom(path);
                MoreAccessories = ass.GetType("MoreAccessoriesKOI.MoreAccessories");
            }
        }
Example #2
0
        public static void InitCharaListPostfix(CharaList __instance)
        {
            bool flag = string.Equals(__instance.name, "00_Female") == (SampleChara.chaFile.parameter.sex == 1);

            if (KoikatuHelper.TryGetPluginInstance("com.jim60105.kk.studioallgirlsplugin"))
            {
                flag = true;
            }
            if (flag && null == UnityEngine.GameObject.Find($"StudioScene/Canvas Main Menu/01_Add/{__instance.name}/redBagBtn"))
            {
                FBIOpenUp.nowGameMode = FBIOpenUp.GameMode.Studio;
                UnityStuff.DrawRedBagBtn(FBIOpenUp.GameMode.Studio, __instance);
            }
        }
Example #3
0
 internal bool LoadAssembly(out string path, Version version = null)
 {
     try {
         path = KoikatuHelper.TryGetPluginInstance(GUID, version)?.Info.Location;
         if (!File.Exists(path))
         {
             throw new Exception($"Load assembly FAILED: {CCFCName}");
         }
         Logger.LogDebug($"{CCFCName} found");
         isExist = true;
     } catch (Exception ex) {
         Logger.LogDebug(ex.Message);
         path    = "";
         isExist = false;
     }
     return(isExist);
 }
Example #4
0
 public static bool LoadAssembly()
 {
     try {
         string   path = KoikatuHelper.TryGetPluginInstance("com.joan6694.illusionplugins.moreaccessories", new Version(2, 0, 10))?.Info.Location;
         Assembly ass  = Assembly.LoadFrom(path);
         MoreAccObj = ass.GetType("MoreAccessoriesKOI.MoreAccessories")?.GetFieldStatic("_self");
         if (null == MoreAccObj)
         {
             throw new Exception("Load assembly FAILED: MoreAccessories");
         }
         Extension.Logger.LogDebug("MoreAccessories found");
         return(true);
     } catch (Exception ex) {
         Extension.Logger.LogDebug(ex.Message);
         return(false);
     }
 }
Example #5
0
        public void Start()
        {
            //讀取config
            Enable     = Config.Bind <bool>("Config", "Enable", false);
            _isenabled = Enable.Value;
            SetEnabled(false);

            Effect_on_ABMX = Config.Bind <bool>("Config", "Effect on ABMX", false, "In most cases, it is not recommended to enable.");
            _isABMXExist   = null != KoikatuHelper.TryGetPluginInstance("KKABMX.Core", new Version(3, 5, 1));

            Sample_chara = Config.Bind <string>("Config", "Sample chara", "", "Leave blank to use my default loli, or use paths like UserData/chara/female/*.png");
            Sample_chara.SettingChanged += SetCharaPath;
            SetCharaPath(null, null);

            Change_rate = Config.Bind <float>("Config", "Change rate", 0.77f, "Proportion of change from original character to sample character, 1 is completely changed");
            Change_rate.SettingChanged += ChangeRate;
            ChangeRate(null, null);
            void ChangeRate(object sender, EventArgs e)
            {
                Patches.ChangeRate = Change_rate.Value;
                Logger.LogDebug("Change Rate: " + Change_rate.Value);
            }

            Video_related_path = Config.Bind <string>("Config", "Video path", "UserData/Custom/FBI.mp4", "Path where FBI Open Up video is located");
            try {
                string tempVideoPath = Uri.UnescapeDataString(new Uri(Path.GetFullPath(Video_related_path.Value)).ToString());
                if (File.Exists(new Uri(tempVideoPath).LocalPath))
                {
                    videoPath = tempVideoPath;
                }
                else
                {
                    throw new Exception();
                }
            } catch (Exception) {
                Logger.LogError($@"Video Not Found: {Video_related_path.Value}");
                videoPath = null;
            }

            Video_volume = Config.Bind <float>("Config", "Video volume", 0.04f);
            videoVolume  = Video_volume.Value;
            Logger.LogDebug($"Set video volume to {videoVolume}");
        }
Example #6
0
        public void LateUpdate()
        {
            //只觸發一次
            if (!_isInited)
            {
                _isInited = true;
                Logger.LogDebug($"--Start listing loaded plugin infos--");
                Logger.LogDebug($"--These are listed in order of loading--");

                #region GetPlugins
                //IPA
                Logger.LogDebug($">>Try load IPA plugin infos");
                string IPAAssPath = KoikatuHelper.TryGetPluginInstance("BepInEx.IPALoader", new Version(1, 2))?.Info.Location;
                //Logger.LogDebug($"Path: {IPAAssPath}");
                if (null != IPAAssPath && File.Exists(IPAAssPath))
                {
                    Type IPlugin       = Assembly.LoadFrom(IPAAssPath).GetType("IllusionPlugin.IPlugin");
                    Type PluginManager = Assembly.LoadFrom(IPAAssPath).GetType("IllusionInjector.PluginManager");

                    //呼叫 KK_PluginListTool.GetIPA<IPlugin>(Plugins);
                    MethodInfo method = typeof(PluginListTool).GetMethod(nameof(GetIPA), BindingFlags.Public | BindingFlags.Static);
                    method = method.MakeGenericMethod(IPlugin);
                    method.Invoke(null, new object[] { PluginManager.GetProperties()[0].GetValue(null, null) });
                }
                else
                {
                    Logger.LogDebug($">>No IPALoader found.");
                }

                //BepPlugin
                Logger.LogDebug($">>Get {BepInEx.Bootstrap.Chainloader.PluginInfos.Count} BepInEx Plugins.");
                foreach (KeyValuePair <string, PluginInfo> kv in BepInEx.Bootstrap.Chainloader.PluginInfos)
                {
                    pluginList.Add(new Plugin(
                                       kv.Value.Metadata.GUID,
                                       kv.Value.Metadata.Name,
                                       kv.Value.Metadata.Version.ToString(),
                                       kv.Value.Location.Replace(Paths.GameRootPath + "\\", "")
                                       ));
                }
                #endregion

                #region WriteFile
                _ = Directory.CreateDirectory(fullSavePath);

                try
                {
                    File.WriteAllText(Path.Combine(fullSavePath, Path.GetFileNameWithoutExtension(Paths.ExecutablePath)) + "_LoadedPluginList.json",
                                      JsonHelper.FormatJson($"[{pluginList.Select(x => MakeJsonString(x.GUID, x.Name, x.Version, x.Location)).Join(delimiter: ",")}]"));
                }
                catch (Exception e)
                {
                    Logger.LogError($">>Logged JSON FAILED");
                    Logger.LogError(e.Message);
                    Logger.LogError(e.StackTrace);
                }

                try
                {
                    File.WriteAllText(Path.Combine(fullSavePath, Path.GetFileNameWithoutExtension(Paths.ExecutablePath)) + "_LoadedPluginList.csv",
                                      $"GUID, Name, Version, Location\n{pluginList.Select(x => MakeCsvString(x.GUID, x.Name, x.Version, x.Location)).Join(delimiter: "\n")}");
                }
                catch (Exception e)
                {
                    Logger.LogError($">>Logged CSV FAILED");
                    Logger.LogError(e.Message);
                    Logger.LogError(e.StackTrace);
                }
                #endregion
                Logger.LogDebug($"--List Finish--");
            }
        }