Exemplo n.º 1
0
        public void AddDanConstraints(BaseUnityPlugin plugin)
        {
            if (danEntryTarget == null || danEndTarget == null || collisionAgent == null)
            {
                return;
            }

            if (danEntryConstraint != null && danEntryConstraint.GetValue(1) != null)
            {
                var parentTransform = collisionAgent.GetComponentsInChildren <Transform>().Where(x => x.name == danEntryConstraint.GetValue(1) as string).FirstOrDefault();

                if (parentTransform != null)
                {
                    danEntryConstraint.SetValue(parentTransform, 1);
                    danEntryConstraint.SetValue(danEntryTarget, 2);
                    plugin.GetType().GetMethod("AddConstraint", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(plugin, danEntryConstraint);
                }
            }

            if (danEndConstraint != null && danEndConstraint.GetValue(1) != null)
            {
                var parentTransform = collisionAgent.GetComponentsInChildren <Transform>().Where(x => x.name == danEndConstraint.GetValue(1) as string).FirstOrDefault();

                if (parentTransform != null)
                {
                    danEndConstraint.SetValue(parentTransform, 1);
                    danEndConstraint.SetValue(danEndTarget, 2);
                    plugin.GetType().GetMethod("AddConstraint", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(plugin, danEndConstraint);
                }
            }
        }
Exemplo n.º 2
0
        List <PluginInfo> GetPluginInfos()
        {
            List <PluginInfo> infos = new List <PluginInfo>();

            foreach (var info in BepInEx.Bootstrap.Chainloader.PluginInfos)
            {
                if (info.Value == null)
                {
                    continue;
                }
                BaseUnityPlugin plugin = info.Value.Instance;
                if (plugin == null)
                {
                    continue;
                }
                Type type = plugin.GetType();

                IEnumerable <Gamemode> gamemodes = GetGamemodes(type);

                if (gamemodes.Count() > 0)
                {
                    infos.Add(new PluginInfo
                    {
                        Plugin          = plugin,
                        Gamemodes       = gamemodes.ToArray(),
                        OnGamemodeJoin  = CreateJoinLeaveAction(plugin, type, typeof(ModdedGamemodeJoinAttribute)),
                        OnGamemodeLeave = CreateJoinLeaveAction(plugin, type, typeof(ModdedGamemodeLeaveAttribute))
                    });
                }
            }

            return(infos);
        }
Exemplo n.º 3
0
        public RainWorldMod(BaseUnityPlugin plugin)
        {
            this.type = Type.BepInExPlugin;
            this.mod  = plugin;

            this.ModID       = plugin.Info.Metadata.Name;
            this.author      = authorNull;
            this.description = authorNull;
            this.Version     = plugin.Info.Metadata.Version.ToString();
            try
            {
                Assembly assm = Assembly.GetAssembly(plugin.GetType());
                if (assm.GetCustomAttributes(typeof(AssemblyTrademarkAttribute), false).FirstOrDefault() is AssemblyTrademarkAttribute trademarkAttr && !string.IsNullOrEmpty(trademarkAttr.Trademark))
                {
                    author = trademarkAttr.Trademark;
                }
                else if (assm.GetCustomAttributes(typeof(AssemblyCompanyAttribute), false).FirstOrDefault() is AssemblyCompanyAttribute companyAttr && !string.IsNullOrEmpty(companyAttr.Company))
                {
                    author = companyAttr.Company;
                }
                if (assm.GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false).FirstOrDefault() is AssemblyDescriptionAttribute descAttr && !string.IsNullOrEmpty(descAttr.Description))
                {
                    description = descAttr.Description;
                }
            }
Exemplo n.º 4
0
            internal static void Init()
            {
                BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue("madevil.kk.ass", out PluginInfo _pluginInfo);
                _instance = _pluginInfo?.Instance;

                if (_instance != null)
                {
                    _legacy = _pluginInfo.Metadata.Version.CompareTo(new Version("4.0.0.0")) < 0;
                    if (_legacy)
                    {
                        Logger.LogError($"AccStateSync version {_pluginInfo.Metadata.Version} found, minimun version 4 is reqired");
                        return;
                    }

                    _installed = true;
                    SupportList.Add("AccStateSync");

                    Assembly _assembly = _instance.GetType().Assembly;
                    _types["AccStateSyncController"] = _assembly.GetType("AccStateSync.AccStateSync+AccStateSyncController");
                    _types["TriggerProperty"]        = _assembly.GetType("AccStateSync.AccStateSync+TriggerProperty");
                    _types["TriggerGroup"]           = _assembly.GetType("AccStateSync.AccStateSync+TriggerGroup");

                    foreach (object _key in Enum.GetValues(typeof(ChaAccessoryDefine.AccessoryParentKey)))
                    {
                        _accParentNames[_key.ToString()] = ChaAccessoryDefine.dictAccessoryParent[(int)_key];
                    }
                }
            }
Exemplo n.º 5
0
        public void AddDanConstraints(BaseUnityPlugin plugin, Transform danEntryParent = null, Transform danEndParent = null)
        {
            if (!danTargetsValid || collisionAgent == null || collisionAgent.m_collisionCharacter == null)
            {
                return;
            }

            if (danEntryConstraint != null)
            {
                var parentTransform = danEntryParent;
                if (parentTransform == null && !danEntryParentName.IsNullOrEmpty())
                {
                    parentTransform = Tools.GetTransformOfChaControl(collisionAgent.m_collisionCharacter, danEntryParentName);
                }
                if (parentTransform == null && danEntryConstraint.GetValue(1) != null)
                {
                    parentTransform = Tools.GetTransformOfChaControl(collisionAgent.m_collisionCharacter, danEntryConstraint.GetValue(1) as string);
                }

                if (parentTransform != null)
                {
                    danEntryConstraint.SetValue(parentTransform, 1);
                    danEntryConstraint.SetValue(danEntryChild, 2);
                    plugin.GetType().GetMethod("AddConstraint", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(plugin, danEntryConstraint);
                }
            }

            if (danEndConstraint != null)
            {
                var parentTransform = danEndParent;
                if (parentTransform == null && !danEndParentName.IsNullOrEmpty())
                {
                    parentTransform = Tools.GetTransformOfChaControl(collisionAgent.m_collisionCharacter, danEndParentName);
                }
                if (parentTransform == null && danEndConstraint.GetValue(1) != null)
                {
                    parentTransform = Tools.GetTransformOfChaControl(collisionAgent.m_collisionCharacter, danEndConstraint.GetValue(1) as string);
                }

                if (parentTransform != null)
                {
                    danEndConstraint.SetValue(parentTransform, 1);
                    danEndConstraint.SetValue(danEndChild, 2);
                    plugin.GetType().GetMethod("AddConstraint", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(plugin, danEndConstraint);
                }
            }
        }
Exemplo n.º 6
0
 internal static void Init()
 {
     Instance = Toolbox.GetPluginInstance("com.deathweasel.bepinex.materialeditor");
     if (Instance == null)
     {
         return;
     }
     Installed   = true;
     MaterialAPI = Instance.GetType().Assembly.GetType("MaterialEditorAPI.MaterialAPI");
 }
Exemplo n.º 7
0
        /// <summary>
        /// Register a plugin with the plugin manager.
        /// </summary>
        /// <param name="plugin">Plugin to Register</param>
        public static void RegisterPlugin(BaseUnityPlugin plugin)
        {
            Plugins.Add(plugin.Info.Metadata.GUID, plugin);

            var assembly = plugin.GetType().Assembly;
            var uri      = new UriBuilder(assembly.CodeBase);
            var path     = Path.GetDirectoryName(Uri.UnescapeDataString(uri.Path));

            PluginGUIDToPath[plugin.Info.Metadata.GUID] = path;
            AssemblyNameToPluginGUID[assembly.FullName] = plugin.Info.Metadata.GUID;
        }
Exemplo n.º 8
0
            internal static void Init()
            {
                _instance = JetPack.MoreAccessories.Instance;
                if (_instance == null)
                {
                    return;
                }

                _installed = true;
                _type      = _instance.GetType();
                _newVer    = JetPack.MoreAccessories.NewVer;
            }
Exemplo n.º 9
0
            internal static void Init()
            {
                BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue("com.joan6694.illusionplugins.moreaccessories", out PluginInfo _pluginInfo);
                _instance = _pluginInfo.Instance;
                Assembly _assembly = _instance.GetType().Assembly;

                _legacy = _pluginInfo.Metadata.Version.CompareTo(new Version("1.1.0")) < 0;
#if DEBUG
                if (_legacy)
                {
                    Logger.LogWarning($"MoreAccessories version {_pluginInfo.Metadata.Version} found, running in legacy mode");
                }
#endif
                _accessoriesByChar = Traverse.Create(_instance).Field("_accessoriesByChar").GetValue();

                HooksInstance["General"].Patch(_instance.GetType().Assembly.GetType("MoreAccessoriesKOI.ChaControl_UpdateVisible_Patches").GetMethod("Postfix", AccessTools.all, null, new[] { typeof(ChaControl) }, null), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.ChaControl_UpdateVisible_Patches_Prefix)));

                if (CharaStudio.Running)
                {
                    HooksInstance["General"].Patch(_instance.GetType().GetMethod("UpdateStudioUI", AccessTools.all, null, new Type[0], null), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.MoreAccessories_UpdateStudioUI_Prefix)));
                }
            }
Exemplo n.º 10
0
            internal static void UpdateStudioUI(ChaControl _chaCtrl)
            {
                if (CharaStudio.CurOCIChar == null)
                {
                    return;
                }
                if (CharaStudio.CurOCIChar.charInfo != _chaCtrl)
                {
                    return;
                }

                AccessTools.Method(_instance.GetType(), "UpdateUI").Invoke(_instance, null);
            }
Exemplo n.º 11
0
 internal static void Init()
 {
     Instance = Toolbox.GetPluginInstance("com.joan6694.illusionplugins.moreaccessories");
     if (Instance == null)
     {
         return;
     }
     Installed = true;
     NewVer    = Toolbox.PluginVersionCompare(Instance, "1.1.0");
     Core.DebugLog($"MoreAccessories {Instance.Info.Metadata.Version} found, NewVer: {NewVer}");
     _type = Instance.GetType();
     _accessoriesByChar = Traverse.Create(Instance).Field("_accessoriesByChar").GetValue();
 }
Exemplo n.º 12
0
        public void RemoveDanConstraints(BaseUnityPlugin plugin)
        {
            if (danEntryChild == null || danEndChild == null || collisionAgent == null)
            {
                return;
            }

            danEntryParentName = null;
            danEndParentName   = null;
            isKokan            = false;
            isAna  = false;
            isOral = false;

            var pluginTraverse = Traverse.Create(plugin);

            if (pluginTraverse == null)
            {
                return;
            }

            IList constraintsList = pluginTraverse.Field <IList>("_constraints").Value;

            if (constraintsList == null)
            {
                return;
            }

            for (int constraintIndex = constraintsList.Count - 1; constraintIndex >= 0; constraintIndex--)
            {
                var constraint = constraintsList[constraintIndex];
                if (constraint == null)
                {
                    continue;
                }

                Traverse constraintTraverse = Traverse.Create(constraint);
                if (constraintTraverse == null)
                {
                    continue;
                }

                Transform childTransform = constraintTraverse.Field <Transform>("childTransform").Value;
                if (childTransform == null || childTransform.GetComponentInParent <ChaControl>() != danAgent.m_danCharacter || (childTransform.name != BoneNames.BPDanEntryTarget && childTransform.name != BoneNames.BPDanEndTarget))
                {
                    continue;
                }

                plugin.GetType().GetMethod("RemoveConstraintAt", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(plugin, new object[] { constraintIndex });
            }
        }
Exemplo n.º 13
0
            internal static void Init()
            {
                BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue("com.deathweasel.bepinex.dynamicboneeditor", out PluginInfo _pluginInfo);
                _instance = _pluginInfo?.Instance;

                if (_instance != null)
                {
                    _installed = true;
                    SupportList.Add("DynamicBoneEditor");

                    Assembly _assembly = _instance.GetType().Assembly;
                    _types["CharaController"] = _assembly.GetType("KK_Plugins.DynamicBoneEditor.CharaController");
                    _types["DynamicBoneData"] = _assembly.GetType("KK_Plugins.DynamicBoneEditor.DynamicBoneData");
                }
            }
Exemplo n.º 14
0
            internal static void Init()
            {
                BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue("madevil.kk.mr", out PluginInfo _pluginInfo);
                _instance = _pluginInfo?.Instance;

                if (_instance != null)
                {
                    _installed = true;
                    SupportList.Add("MaterialRouter");

                    Assembly _assembly = _instance.GetType().Assembly;
                    _types["MaterialRouterController"] = _assembly.GetType("MaterialRouter.MaterialRouter+MaterialRouterController");
                    _types["RouteRule"] = _assembly.GetType("MaterialRouter.MaterialRouter+RouteRule");

                    HooksInstance["General"].Patch(_types["MaterialRouterController"].GetMethod("BuildCheckList", AccessTools.all), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.DuringLoading_Prefix)));
                }
            }
            internal static void Init()
            {
                BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue("com.deathweasel.bepinex.hairaccessorycustomizer", out PluginInfo _pluginInfo);
                _instance = _pluginInfo?.Instance;

                if (_instance != null)
                {
                    _installed = true;
                    SupportList.Add("HairAccessoryCustomizer");

                    Assembly _assembly = _instance.GetType().Assembly;
                    _types["HairAccessoryController"] = _assembly.GetType("KK_Plugins.HairAccessoryCustomizer+HairAccessoryController");
                    _types["HairAccessoryInfo"]       = _assembly.GetType("KK_Plugins.HairAccessoryCustomizer+HairAccessoryController+HairAccessoryInfo");

                    HooksInstance["General"].Patch(_types["HairAccessoryController"].GetMethod("UpdateAccessories", AccessTools.all, null, new[] { typeof(bool) }, null), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.DuringLoading_Prefix)));
                }
            }
Exemplo n.º 16
0
        public void Awake()
        {
            if (!RoR2Application.isModded)
            {
                RoR2Application.isModded = true;
            }

            if (Chainloader.PluginInfos.ContainsKey("com.funkfrog_sipondo.sharesuite"))
            {
                ShareSuite = Chainloader.PluginInfos["com.funkfrog_sipondo.sharesuite"].Instance;
                AddMoney   = ShareSuite.GetType().GetMethod("AddMoneyExternal", BindingFlags.Instance | BindingFlags.Public);
            }

            const string moneySection = "Money";

            var conUtil = new ConditionalUtil(this.Config);

            LatestStageToReceiveMoney = conUtil.AddConditionalConfig <uint>(
                moneySection,
                nameof(LatestStageToReceiveMoney),
                4,
                false,
                new ConfigDescription("Enable to set a latest stage you wish to receive a bonus on. E.g. set this to 4 and you will receive bonus for first 4 rounds and then none after.")
                );

            StageFlatMoney = Config.Bind <uint>(
                moneySection,
                nameof(StageFlatMoney),
                0,
                new ConfigDescription(
                    "The flat amount of extra money the player should receive at beginning of each stage"
                    )
                );

            StageWeightedMoney = Config.Bind <float>(
                moneySection,
                nameof(StageWeightedMoney),
                1.0f,
                new ConfigDescription(
                    "The equivalent number of small chest worth of money you get at start of each stage"
                    )
                );

            RoR2.SceneDirector.onPostPopulateSceneServer += SceneDirector_onPostPopulateSceneServer;
        }
Exemplo n.º 17
0
		internal static void Init()
		{
			if (!Chainloader.PluginInfos.ContainsKey(GUID)) return;

			Plugin = Chainloader.PluginInfos[GUID].Instance;
			PluginAssembly = Assembly.GetAssembly(Plugin.GetType());

			if (PluginAssembly != null)
			{
				GatherInfos();
			}
			else
			{
				Logger.Warn("[AetheriumCompat] - Could Not Find Aetherium Assembly");
			}

			HookMethods();
		}
Exemplo n.º 18
0
        /// <summary>
        ///     Window display state changed event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        internal void ConfigurationManager_DisplayingWindowChanged(object sender, object e)
        {
            // Read configuration manager's DisplayingWindow property
            var pi = configurationManager.GetType().GetProperty("DisplayingWindow");

            configurationManagerWindowShown = (bool)pi.GetValue(configurationManager, null);

            // Did window open or close?
            if (configurationManagerWindowShown)
            {
                // If window just opened, cache the config values for comparison later
                CacheConfigurationValues();
            }
            else
            {
                SynchronizeToServer();
            }
        }
Exemplo n.º 19
0
        private static void Postfix()
        {
            // trigger events
            bool isPrivate = false;

            if (PhotonNetwork.CurrentRoom != null)
            {
                var currentRoom = PhotonNetwork.NetworkingClient.CurrentRoom;
                isPrivate = !currentRoom.IsVisible ||
                            currentRoom.CustomProperties.ContainsKey("Description"); // Room Browser rooms
            }
            Debug.Log("IS PRIVATE?");
            Debug.Log(isPrivate);
            Events.RoomJoinedArgs args = new Events.RoomJoinedArgs();
            args.isPrivate = isPrivate;
            events.TriggerRoomJoin(args);

            // handle forcing private lobbies
            bool forcePrivateLobbies = false;
            var  infos = BepInEx.Bootstrap.Chainloader.PluginInfos;

            foreach (var info in infos)
            {
                if (info.Value == null)
                {
                    continue;
                }
                BaseUnityPlugin plugin = info.Value.Instance;
                if (plugin == null)
                {
                    continue;
                }
                var attribute = plugin.GetType().GetCustomAttribute <ForcePrivateLobbyAttribute>();
                if (attribute != null)
                {
                    forcePrivateLobbies = true;
                }
            }

            if (forcePrivateLobbies)
            {
                RoomUtils.JoinPrivateLobby();
            }
        }
Exemplo n.º 20
0
            internal static void HookInit()
            {
                if (!Installed)
                {
                    return;
                }

                Type AccStateSyncController = PluginInstance.GetType().Assembly.GetType("AccStateSync.AccStateSync+AccStateSyncController");

                if (Legacy)
                {
                    HooksInstance.Patch(AccStateSyncController.GetMethod("AccSlotChangedHandler", AccessTools.all, null, new[] { typeof(int) }, null), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.DuringLoading_Prefix)));
                    HooksInstance.Patch(AccStateSyncController.GetMethod("SyncOutfitVirtualGroupInfo", AccessTools.all, null, new[] { typeof(int) }, null), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.DuringLoading_Prefix)));
                }
                else
                {
                    HooksInstance.Patch(AccStateSyncController.GetMethod("AccSlotChangedHandler", AccessTools.all), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.DuringLoading_Prefix)));
                    HooksInstance.Patch(AccStateSyncController.GetMethod("RefreshCache", AccessTools.all), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.DuringLoading_Prefix)));
                }
            }
Exemplo n.º 21
0
        internal static void LateSetup()
        {
            if (!Chainloader.PluginInfos.ContainsKey(GUID))
            {
                return;
            }

            Plugin         = Chainloader.PluginInfos[GUID].Instance;
            PluginAssembly = Assembly.GetAssembly(Plugin.GetType());

            if (PluginAssembly != null)
            {
                GatherInfos();
            }
            else
            {
                Logger.Warn("[EliteReworksCompat] - Could Not Find EliteReworks Assembly");
            }

            ReadValues();
            HookMethods();
        }
Exemplo n.º 22
0
        /// <summary>
        ///     Hook ConfigurationManager's DisplayingWindowChanged to be able to react on window open/close.
        /// </summary>
        private void HookConfigurationManager()
        {
            Logger.LogDebug("Trying to hook config manager");

            var result = new Dictionary <string, BaseUnityPlugin>();

            configurationManager = GameObject.FindObjectsOfType(typeof(BaseUnityPlugin)).Cast <BaseUnityPlugin>().ToArray()
                                   .FirstOrDefault(x => x.Info.Metadata.GUID == "com.bepis.bepinex.configurationmanager");

            if (configurationManager)
            {
                Logger.LogDebug("Configuration manager found, trying to hook DisplayingWindowChanged");
                var eventinfo = configurationManager.GetType().GetEvent("DisplayingWindowChanged");
                if (eventinfo != null)
                {
                    Action <object, object> local = ConfigurationManager_DisplayingWindowChanged;
                    var converted = Delegate.CreateDelegate(eventinfo.EventHandlerType, local.Target, local.Method);

                    eventinfo.AddEventHandler(configurationManager, converted);
                }
            }
        }
Exemplo n.º 23
0
            internal static void Init()
            {
                BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue("com.deathweasel.bepinex.materialeditor", out PluginInfo _pluginInfo);
                _instance = _pluginInfo.Instance;
                SupportList.Add("MaterialEditor");

                Assembly _assembly = _instance.GetType().Assembly;

                _types["MaterialAPI"] = _assembly.GetType("MaterialEditorAPI.MaterialAPI");
                _types["MaterialEditorCharaController"] = _assembly.GetType("KK_Plugins.MaterialEditor.MaterialEditorCharaController");
                _types["ObjectType"] = _assembly.GetType("KK_Plugins.MaterialEditor.MaterialEditorCharaController+ObjectType");

                _legacy = _pluginInfo.Metadata.Version.CompareTo(new Version("3.0")) < 0;

                if (_legacy)
                {
                    Logger.LogWarning($"Material Editor version {_pluginInfo.Metadata.Version} found, running in legacy mode");
                }
                else
                {
                    _containerKeys.Add("MaterialCopyList");
                }
            }
Exemplo n.º 24
0
        /// <summary>
        ///     Manager's main init
        /// </summary>
        public void Init()
        {
            // Register RPCs and the admin watchdog
            ConfigRPC = NetworkManager.Instance.AddRPC(
                Main.Instance.Info.Metadata, "ConfigSync", ConfigRPC_OnServerReceive, ConfigRPC_OnClientReceive);

            AdminRPC = NetworkManager.Instance.AddRPC(
                Main.Instance.Info.Metadata, "AdminStatus", null, AdminRPC_OnClientReceive);

            Main.Harmony.PatchAll(typeof(Patches));

            // Hook start scene to reset config
            SceneManager.sceneLoaded += SceneManager_sceneLoaded;

            // Find Configuration manager plugin and add to DisplayingWindowChanged event
            if (!ConfigurationManager)
            {
                Logger.LogDebug("Trying to hook config manager");

                ConfigurationManager = Object.FindObjectsOfType(typeof(BaseUnityPlugin)).Cast <BaseUnityPlugin>().ToArray()
                                       .FirstOrDefault(x => x.Info?.Metadata?.GUID == "com.bepis.bepinex.configurationmanager");

                if (ConfigurationManager)
                {
                    Logger.LogDebug("Configuration manager found, trying to hook DisplayingWindowChanged");
                    var eventinfo = ConfigurationManager.GetType().GetEvent("DisplayingWindowChanged");
                    if (eventinfo != null)
                    {
                        Action <object, object> local = ConfigurationManager_DisplayingWindowChanged;
                        var converted = Delegate.CreateDelegate(eventinfo.EventHandlerType, local.Target, local.Method);

                        eventinfo.AddEventHandler(ConfigurationManager, converted);
                    }
                }
            }
        }
        internal void Main()
        {
            CharacterApi.RegisterExtraBehaviour <BetterPenetrationController>(BEHAVIOR);

            harmony = new Harmony("HS2_Studio_BetterPenetration");
            harmony.PatchAll(GetType());

            Chainloader.PluginInfos.TryGetValue("com.deathweasel.bepinex.uncensorselector", out PluginInfo pluginInfo);
            if (pluginInfo == null || pluginInfo.Instance == null)
            {
                return;
            }

            Type nestedType = pluginInfo.Instance.GetType().GetNestedType("UncensorSelectorController", AccessTools.all);

            if (nestedType == null)
            {
                return;
            }

            MethodInfo methodInfo = AccessTools.Method(nestedType, "ReloadCharacterBody", null, null);

            if (methodInfo == null)
            {
                return;
            }

            harmony.Patch(methodInfo, prefix: new HarmonyMethod(GetType(), "BeforeCharacterReload"));
            UnityEngine.Debug.Log("Studio_BetterPenetration: patched UncensorSelector::ReloadCharacterBody correctly");

            methodInfo = AccessTools.Method(nestedType, "ReloadCharacterBalls", null, null);
            if (methodInfo == null)
            {
                return;
            }

            harmony.Patch(methodInfo, postfix: new HarmonyMethod(GetType(), "AfterTamaCharacterReload"));
            UnityEngine.Debug.Log("Studio_BetterPenetration: patched UncensorSelectorController::ReloadCharacterBalls correctly");

            Chainloader.PluginInfos.TryGetValue("com.joan6694.illusionplugins.nodesconstraints", out pluginInfo);
            if (pluginInfo == null || pluginInfo.Instance == null)
            {
                return;
            }

            nodeConstraintPlugin = pluginInfo.Instance;
            Type nodeConstraintType = nodeConstraintPlugin.GetType();

            if (nodeConstraintType == null)
            {
                return;
            }

            methodInfo = AccessTools.Method(nodeConstraintType, "AddConstraint", null, null);
            if (methodInfo == null)
            {
                return;
            }

            harmony.Patch(methodInfo, postfix: new HarmonyMethod(GetType(), nameof(AfterAddConstraint)));
            UnityEngine.Debug.Log("Studio_BetterPenetration: patched NodeConstraints::AddConstraint correctly");

            methodInfo = AccessTools.Method(nodeConstraintType, "ApplyNodesConstraints", null, null);
            if (methodInfo == null)
            {
                return;
            }

            harmony.Patch(methodInfo, postfix: new HarmonyMethod(GetType(), nameof(AfterApplyNodesConstraints)));
            UnityEngine.Debug.Log("Studio_BetterPenetration: patched NodeConstraints::ApplyNodesConstraints correctly");

            methodInfo = AccessTools.Method(nodeConstraintType, "ApplyConstraints", null, null);
            if (methodInfo == null)
            {
                return;
            }

            harmony.Patch(methodInfo, postfix: new HarmonyMethod(GetType(), nameof(AfterApplyConstraints)));
            UnityEngine.Debug.Log("Studio_BetterPenetration: patched NodeConstraints::ApplyConstraints correctly");

            RegisterStudioControllerBasic();
        }
Exemplo n.º 26
0
            internal static void HookInit()
            {
                Type MaterialEditorCharaController = PluginInstance.GetType().Assembly.GetType("KK_Plugins.MaterialEditor.MaterialEditorCharaController");

                HooksInstance.Patch(MaterialEditorCharaController.GetMethod("LoadData", AccessTools.all, null, new[] { typeof(bool), typeof(bool), typeof(bool) }, null), prefix: new HarmonyMethod(typeof(Hooks), nameof(Hooks.DuringLoading_Co_Prefix)));
            }
Exemplo n.º 27
0
        private static IEnumerable <LegacySettingEntry> GetLegacyPluginConfig(BaseUnityPlugin plugin)
        {
            if (_bepin4BaseSettingType == null)
            {
                return(Enumerable.Empty <LegacySettingEntry>());
            }

            var type       = plugin.GetType();
            var pluginInfo = plugin.Info.Metadata;

            // Config wrappers ------

            var settingProps = type
                               .GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
                               .FilterBrowsable(true, true);

            var settingFields = type.GetFields(BindingFlags.Instance | BindingFlags.Public)
                                .Where(f => !f.IsSpecialName)
                                .FilterBrowsable(true, true)
                                .Select(f => new FieldToPropertyInfoWrapper(f));

            var settingEntries = settingProps.Concat(settingFields.Cast <PropertyInfo>())
                                 .Where(x => x.PropertyType.IsSubclassOfRawGeneric(_bepin4BaseSettingType));

            var results = settingEntries.Select(x => LegacySettingEntry.FromConfigWrapper(plugin, x, pluginInfo, plugin)).Where(x => x != null);

            // Config wrappers static ------

            var settingStaticProps = type
                                     .GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)
                                     .FilterBrowsable(true, true);

            var settingStaticFields = type.GetFields(BindingFlags.Static | BindingFlags.Public)
                                      .Where(f => !f.IsSpecialName)
                                      .FilterBrowsable(true, true)
                                      .Select(f => new FieldToPropertyInfoWrapper(f));

            var settingStaticEntries = settingStaticProps.Concat(settingStaticFields.Cast <PropertyInfo>())
                                       .Where(x => x.PropertyType.IsSubclassOfRawGeneric(_bepin4BaseSettingType));

            results = results.Concat(settingStaticEntries.Select(x => LegacySettingEntry.FromConfigWrapper(null, x, pluginInfo, plugin)).Where(x => x != null));

            // Normal properties ------

            bool IsPropSafeToShow(PropertyInfo p) => p.GetSetMethod()?.IsPublic == true && (p.PropertyType.IsValueType || p.PropertyType == typeof(string));

            var normalPropsSafeToShow = type
                                        .GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly)
                                        .Where(IsPropSafeToShow)
                                        .FilterBrowsable(true, true)
                                        .Where(x => !x.PropertyType.IsSubclassOfRawGeneric(_bepin4BaseSettingType));

            var normalPropsWithBrowsable = type.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public)
                                           .FilterBrowsable(true, false)
                                           .Where(x => !x.PropertyType.IsSubclassOfRawGeneric(_bepin4BaseSettingType));

            var normalProps = normalPropsSafeToShow.Concat(normalPropsWithBrowsable).Distinct();

            results = results.Concat(normalProps.Select(x => LegacySettingEntry.FromNormalProperty(plugin, x, pluginInfo, plugin)).Where(x => x != null));

            // Normal static properties ------

            var normalStaticPropsSafeToShow = type
                                              .GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.DeclaredOnly)
                                              .Where(IsPropSafeToShow)
                                              .FilterBrowsable(true, true)
                                              .Where(x => !x.PropertyType.IsSubclassOfRawGeneric(_bepin4BaseSettingType));

            var normalStaticPropsWithBrowsable = type.GetProperties(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public)
                                                 .FilterBrowsable(true, false)
                                                 .Where(x => !x.PropertyType.IsSubclassOfRawGeneric(_bepin4BaseSettingType));

            var normalStaticProps = normalStaticPropsSafeToShow.Concat(normalStaticPropsWithBrowsable).Distinct();

            results = results.Concat(normalStaticProps.Select(x => LegacySettingEntry.FromNormalProperty(null, x, pluginInfo, plugin)).Where(x => x != null));

            return(results);
        }
Exemplo n.º 28
0
 internal static void Init()
 {
     _instance = Toolbox.GetPluginInstance("marco.kkapi");
     _makerAPI = _instance.GetType().Assembly.GetType("KKAPI.Maker.MakerAPI");
     Hooks.Init();
 }
Exemplo n.º 29
0
        private static void GatherInfos()
        {
            Type type;

            type = Plugin.GetType();
            if (type != null)
            {
                PluginType = type;

                AffixBlueEnabledField = type.GetField("affixBlueEnabled", Flags);
                if (AffixBlueEnabledField == null)
                {
                    Logger.Warn("[EliteReworksCompat] - Could Not Find Field : EliteReworksPlugin.affixBlueEnabled");
                }

                AffixBlueRemoveShieldField = type.GetField("affixBlueRemoveShield", Flags);
                if (AffixBlueRemoveShieldField == null)
                {
                    Logger.Warn("[EliteReworksCompat] - Could Not Find Field : EliteReworksPlugin.affixBlueRemoveShield");
                }

                AffixHauntedEnabledField = type.GetField("affixHauntedEnabled", Flags);
                if (AffixHauntedEnabledField == null)
                {
                    Logger.Warn("[EliteReworksCompat] - Could Not Find Field : EliteReworksPlugin.affixHauntedEnabled");
                }

                AffixPoisonEnabledField = type.GetField("affixPoisonEnabled", Flags);
                if (AffixPoisonEnabledField == null)
                {
                    Logger.Warn("[EliteReworksCompat] - Could Not Find Field : EliteReworksPlugin.affixPoisonEnabled");
                }

                EliteVoidEnabledField = type.GetField("eliteVoidEnabled", Flags);
                if (EliteVoidEnabledField == null)
                {
                    Logger.Warn("[EliteReworksCompat] - Could Not Find Field : EliteReworksPlugin.eliteVoidEnabled");
                }
            }
            else
            {
                Logger.Warn("[EliteReworksCompat] - Could Not Find Type : EliteReworksPlugin");
            }

            type = Type.GetType("EliteReworks.Tweaks.T1.AffixBlue, " + PluginAssembly.FullName, false);
            if (type != null)
            {
                TweakAffixBlueType = type;

                AffixBluePassiveField = type.GetField("enablePassiveLightning", Flags);
                if (AffixBluePassiveField == null)
                {
                    Logger.Warn("[EliteReworksCompat] - Could Not Find Field : AffixBlue.enablePassiveLightning");
                }

                AffixBlueOnHitReworkField = type.GetField("enableOnHitRework", Flags);
                if (AffixBlueOnHitReworkField == null)
                {
                    Logger.Warn("[EliteReworksCompat] - Could Not Find Field : AffixBlue.enableOnHitRework");
                }

                AffixBlueDamageCoeffField = type.GetField("lightningDamageCoefficient", Flags);
                if (AffixBlueDamageCoeffField == null)
                {
                    Logger.Warn("[EliteReworksCompat] - Could Not Find Field : AffixBlue.lightningDamageCoefficient");
                }
            }
            else
            {
                Logger.Warn("[EliteReworksCompat] - Could Not Find Type : EliteReworks.Tweaks.T1.AffixBlue");
            }

            type = Type.GetType("EliteReworks.Tweaks.T1.Components.AffixBluePassiveLightning, " + PluginAssembly.FullName, false);
            if (type != null)
            {
                ComponentPassiveAffixBlueType = type;

                AffixBlueScatterBombField = type.GetField("scatterBombs", Flags);
                if (AffixBlueScatterBombField == null)
                {
                    Logger.Warn("[EliteReworksCompat] - Could Not Find Field : AffixBluePassiveLightning.scatterBombs");
                }
            }
            else
            {
                Logger.Warn("[EliteReworksCompat] - Could Not Find Type : EliteReworks.Tweaks.T1.Components.AffixBluePassiveLightning");
            }

            type = Type.GetType("EliteReworks.Tweaks.DLC1.EliteVoid, " + PluginAssembly.FullName, false);
            if (type != null)
            {
                TweakEliteVoidType = type;

                EliteVoidDamageBonusField = type.GetField("damageBonus", Flags);
                if (EliteVoidDamageBonusField == null)
                {
                    Logger.Warn("[EliteReworksCompat] - Could Not Find Field : EliteVoid.damageBonus");
                }
            }
            else
            {
                Logger.Warn("[EliteReworksCompat] - Could Not Find Type : EliteReworks.Tweaks.DLC1.EliteVoid");
            }

            type = Type.GetType("EliteReworks.Tweaks.T2.AffixHaunted, " + PluginAssembly.FullName, false);
            if (type != null)
            {
                TweakAffixHauntedType = type;

                AffixHauntedReplaceOnHitField = type.GetField("replaceOnHitEffect", Flags);
                if (AffixHauntedReplaceOnHitField == null)
                {
                    Logger.Warn("[EliteReworksCompat] - Could Not Find Field : AffixHaunted.replaceOnHitEffect");
                }
            }
            else
            {
                Logger.Warn("[EliteReworksCompat] - Could Not Find Type : EliteReworks.Tweaks.T2.AffixHaunted");
            }

            type = Type.GetType("EliteReworks.SharedHooks.OnHitAll, " + PluginAssembly.FullName, false);
            if (type != null)
            {
                OnHitAllMethod = type.GetMethod("TriggerOnHitAllEffects", Flags);
                if (OnHitAllMethod == null)
                {
                    Logger.Warn("[EliteReworksCompat] - Could Not Find Method : OnHitAll.TriggerOnHitAllEffects");
                }
            }
            else
            {
                Logger.Warn("[EliteReworksCompat] - Could Not Find Type : EliteReworks.SharedHooks.OnHitAll");
            }
        }
Exemplo n.º 30
0
 /// <summary>
 ///   <para>Initializes a new instance of the <see cref="RoguePatcher"/> class with the specified <paramref name="callerPlugin"/>.</para>
 /// </summary>
 /// <param name="callerPlugin">The instance of <see cref="BaseUnityPlugin"/> responsible for the patches.</param>
 public RoguePatcher(BaseUnityPlugin callerPlugin) : this(callerPlugin, callerPlugin?.GetType())
 {
 }