コード例 #1
0
 void IHook.OnRegister(BaseUnityPlugin plugin)
 {
     elementPos     = plugin.Config.Bind("界面改进", "五行位置", new Vector3(-80, 15, 0), "调整五行位置");
     elementTextPos = plugin.Config.Bind("界面改进", "名字位置", new Vector3(8, 18, 0), "调整名字位置");
     elementKey     = plugin.Config.Bind("界面改进", "五行与名字显示热键", KeyCode.F3, "战斗时显示五行与名字。调整位置后需开关一次生效");
     showThreshold  = plugin.Config.Bind("界面改进", "显示练满所需点数", true, "是否提示n次练满所需相应数值");
 }
コード例 #2
0
        public void OnRegister(BaseUnityPlugin plugin)
        {
            var adv1 = new ConfigDescription("", null, new ConfigurationManagerAttributes {
                IsAdvanced = true, Order = 3
            });

            DebugOn     = plugin.Config.Bind("Debug功能", "调试开关", false, adv1);
            DebugOutDir = plugin.Config.Bind("Debug功能", "调试路径", "export/", adv1);

            var adv = new ConfigDescription("", null, new ConfigurationManagerAttributes {
                IsAdvanced = true
            });

            NodeDocKey     = plugin.Config.Bind("Debug功能", "Mod文档导出", KeyCode.P, adv);
            NodeContent    = plugin.Config.Bind("Debug功能", "OutputNode内容(原始格式)", "", adv);
            NodeFileKey    = plugin.Config.Bind("Debug功能", "OutputNode输出(Json格式)", KeyCode.O, adv);
            NodeFilePath   = plugin.Config.Bind("Debug功能", "OutputNode输出路径", "OutputNode.json", adv);
            JsonFormat     = plugin.Config.Bind("Debug功能", "导出时使用json格式", true, adv);
            JsonPritty     = plugin.Config.Bind("Debug功能", "导出json是否格式化", true, adv);
            BattleFileId   = plugin.Config.Bind("Debug功能", "战斗文件Id", "", adv);
            BattleFileKey  = plugin.Config.Bind("Debug功能", "战斗文件保存键", KeyCode.B, adv);
            BattleFilePath = plugin.Config.Bind("Debug功能", "战斗文件保存路径", "battle/{0}.json", adv);
            BuffFileId     = plugin.Config.Bind("Debug功能", "Buff文件Id", "", adv);
            BuffFileKey    = plugin.Config.Bind("Debug功能", "Buff文件保存键", KeyCode.N, adv);
            BuffFilePath   = plugin.Config.Bind("Debug功能", "Buff文件保存路径", "buff/{0}.json", adv);
            MovieFileType  = plugin.Config.Bind("Debug功能", "过场文件类型", MovieType.Cinematic, adv);
            MovieFileId    = plugin.Config.Bind("Debug功能", "过场文件Id", "", adv);
            MovieFileKey   = plugin.Config.Bind("Debug功能", "过场文件保存键", KeyCode.M, adv);
            MovieFilePath  = plugin.Config.Bind("Debug功能", "过场文件保存路径", "movie/{0}.json", adv);
            SortSchedule   = plugin.Config.Bind("Debug功能", "过场是否重新排序", false, adv);
            SortSchedule.SettingChanged += (o, e) => { ScheduleGraphConverter.WriteSorted = SortSchedule.Value; };
        }
コード例 #3
0
        public void OnRegister(BaseUnityPlugin plugin)
        {
            speedValue = plugin.Config.Bind("游戏设定", "速度值", 1.5f, "调整速度值");
            speedKey   = plugin.Config.Bind("游戏设定", "速度热键", KeyCode.F2, "开关速度调节");
            saveCount  = plugin.Config.Bind("游戏设定", "存档数量", 20,
                                            new ConfigDescription("存档数量上限", new AcceptableValueRange <int>(20, 100)));
            playerScale = plugin.Config.Bind("游戏设定", "主角模型尺寸", 1f,
                                             new ConfigDescription("修改主角在自由活动和战斗中的模型尺寸", new AcceptableValueRange <float>(0.75f, 1.5f)));
            moveSpeed = plugin.Config.Bind("游戏设定", "移动速度", 2.6f, "修改玩家在大地图的移动速度。如果太快可能会穿模");
            moveSpeed.SettingChanged += (o, e) =>
            {
                if (moveSpeed.Value > 0f)
                {
                    Game.EntityManager.GetComponent <PlayerStateMachine>(GameConfig.Player).forwardRate = moveSpeed.Value;
                }
            };
            difficulty = plugin.Config.Bind("游戏设定", "难度值", GameLevel.Normal, "调节游戏难度");
            difficulty.SettingChanged += OnGameLevelChange;
            probablyMode   = plugin.Config.Bind("游戏设定", "随机事件方式", ProbablyMode.None, "None-原版 SmallChance-小概率事件必发生 FixedRandomValue-设定产生的随机数");
            probablyValue  = plugin.Config.Bind("游戏设定", "随机事件值", 50, "SmallChance:多少被界定为小概率 FixedRandomValue:1~100对应必发生/必不发生");
            changeAnim     = plugin.Config.Bind("游戏设定", "切换姿势(特殊)", KeyCode.F7, "切换特化战斗姿势(随机选择)");
            changeAnimBack = plugin.Config.Bind("游戏设定", "切换姿势(还原)", KeyCode.F8, "切换回默认战斗姿势");

            cameraFocusMode   = plugin.Config.Bind("相机设置", "战斗相机跟随方式", CameraFocusMode.Attacker, "战斗时相机如何跟随,游戏默认跟随攻击者");
            cameraFree        = plugin.Config.Bind("相机设置", "场景自由视角", false, "是否开启自由视角");
            cameraFree_Battle = plugin.Config.Bind("相机设置", "战斗自由视角", false, "是否开启战斗自由视角,重启战斗生效");
        }
コード例 #4
0
        public void OnRegister(BaseUnityPlugin plugin)
        {
            newGameAttributePoint   = plugin.Config.Bind("开局设定", "增加属性点", 0, "设置开局增加多少属性点");
            newGameTraitPoint       = plugin.Config.Bind("开局设定", "增加特性点", 0, "设置开局增加多少特性点");
            newGameExteriorId       = plugin.Config.Bind("角色设定", "主角建模", string.Empty, "设定主角建模数据源,请通过CharacterExterior表格查找,使用第一列ID");
            newGamePortraitOverride = plugin.Config.Bind("角色设定", "主角头像", string.Empty, "若已设置建模,则可为空,使用建模的头像,否则用此头像代替");
            newGameSurNameOverride  = plugin.Config.Bind("角色设定", "主角姓", string.Empty, "可修改主角的姓");
            newGameNameOverride     = plugin.Config.Bind("角色设定", "主角名", string.Empty, "可修改主角的名");



            newGameExteriorId.SettingChanged += (o, e) =>
            {
                ReplacePlayerExteriorData();
            };
            newGamePortraitOverride.SettingChanged += (o, e) =>
            {
                ReplacePlayerExteriorData();
            };
            newGameSurNameOverride.SettingChanged += (o, e) =>
            {
                ReplacePlayerExteriorData();
            };
            newGameNameOverride.SettingChanged += (o, e) =>
            {
                ReplacePlayerExteriorData();
            };
        }
コード例 #5
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);
                }
            }
        }
コード例 #6
0
        Action <string> CreateJoinLeaveAction(BaseUnityPlugin plugin, Type baseType, Type attribute)
        {
            ParameterExpression param = Expression.Parameter(typeof(string));

            ParameterExpression[] paramExpression = new ParameterExpression[] { param };
            ConstantExpression    instance        = Expression.Constant(plugin);
            BindingFlags          bindingFlags    = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

            Action <string> action = null;

            foreach (var method in baseType.GetMethods(bindingFlags).Where(m => m.GetCustomAttribute(attribute) != null))
            {
                var parameters = method.GetParameters();
                MethodCallExpression methodCall;
                if (parameters.Length == 0)
                {
                    methodCall = Expression.Call(instance, method);
                }
                else if (parameters.Length == 1 && parameters[0].ParameterType == typeof(string))
                {
                    methodCall = Expression.Call(instance, method, param);
                }
                else
                {
                    continue;
                }

                action += Expression.Lambda <Action <string> >(methodCall, paramExpression).Compile();
            }

            return(action);
        }
コード例 #7
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);
        }
コード例 #8
0
 public void OnRegister(BaseUnityPlugin plugin)
 {
     newGameAttributePoint   = plugin.Config.Bind("开局设定", "属性点", 50, "设置开局属性点");
     newGameTraitPoint       = plugin.Config.Bind("开局设定", "特性点", 1, "设置开局特性点");
     newGameExteriorId       = plugin.Config.Bind("开局设定", "主角建模", string.Empty, "设定新开局时的主角建模数据源,请通过CharacterExterior表格查找,使用第一列ID");
     newGamePortraitOverride = plugin.Config.Bind("开局设定", "主角头像", string.Empty, "若已设置建模,则可为空,使用建模的头像,否则用此头像代替");
 }
コード例 #9
0
 public CustomHero(Type bepinPluginType, BaseUnityPlugin bepinPlugin)
 {
     name = GetRealName();
     BepinExPluginType    = bepinPluginType;
     BepinPluginReference = bepinPlugin;
     SetupPluginData();
 }
コード例 #10
0
ファイル: Configs.cs プロジェクト: Zinal001/ValheimMods
        public static void Init(BaseUnityPlugin plugin)
        {
            MaxCharactersPerPlayer = plugin.Config.Bind("Server", "Max Characters Per Player", 1, "How many characters can the player use on the server?");


            ShowDebugMessages = plugin.Config.Bind("Common", "Debug Messages", false, "Show debug messages in console?");
        }
コード例 #11
0
		/// <summary>
		///   <para>Patches an original method so that the given patch method will be called right after the original.</para>
		///   <para>Automatically catches and logs all errors. Returns true if the patch was successful, returns false if an error occured.</para>
		/// </summary>
		public static bool PatchPostfix(this BaseUnityPlugin me, Type type, string methodName, Type patchType, string patchMethodName, Type[] types = null)
		{
			MethodInfo original, patch;
			try
			{
				original = AccessTools.Method(type, methodName, types);
			}
			catch (Exception e)
			{
				me.LogError("Could not find original method " + type.Name + "." + methodName + "(..)!", e);
				return false;
			}
			try
			{
				patch = AccessTools.Method(patchType, patchMethodName);
			}
			catch (Exception e)
			{
				me.LogError("Could not find postfix-method " + patchType.Name + "." + patchMethodName + "(..)!", e);
				return false;
			}
			try
			{
				new Harmony(me.Info.Metadata.GUID).Patch(original, null, new HarmonyMethod(patch));
			}
			catch (Exception e)
			{
				me.LogError("Failed to postfix-patch " + type.Name + "." + methodName + "(..) with " + patchType.Name + "." + patchMethodName + "(..)!", e);
				return false;
			}
			return true;
		}
コード例 #12
0
 public void OnRegister(BaseUnityPlugin plugin)
 {
     Plugin      = plugin;
     modBasePath = plugin.Config.Bind("Mod设置", "Mod总路径", "Mods\\", new ConfigDescription("Mod主目录", null, new ConfigurationManagerAttributes {
         IsAdvanced = true, Order = 3
     }));
     modBattleVoicePath = Plugin.Config.Bind("Mod设置", "Mod战斗语音路径", "audio/voice/um_{0}_{1}.ogg", new ConfigDescription("可更改相对路径和扩展名", null, new ConfigurationManagerAttributes {
         IsAdvanced = true
     }));
     modTalkVoicePath = Plugin.Config.Bind("Mod设置", "Mod对话语音路径", "audio/voice/talk_{0}.ogg", new ConfigDescription("可更改相对路径和扩展名", null, new ConfigurationManagerAttributes {
         IsAdvanced = true
     }));
     string[] dirs = null;
     if (Directory.Exists(modBasePath.Value))
     {
         dirs = Directory.GetDirectories(modBasePath.Value);
     }
     modList = plugin.Config.Bind(
         "Mod设置", "Mod集合",
         dirs != null ? string.Join(",", from dir in dirs select(dir.Replace(modBasePath.Value, ""))) : "",
         new ConfigDescription("多Mod以逗号分隔按顺序加载,设为空或有错则不加载Mod。须重启游戏生效", null, new ConfigurationManagerAttributes {
         Order = 2
     })
         );
 }
コード例 #13
0
		/// <summary>
		///   <para>It's just a shortcut for: <c>Logger.LogError(<paramref name="message"/>); Logger.LogError(<paramref name="e"/>);</c>.</para>
		/// </summary>
		public static void LogError(this BaseUnityPlugin me, string message, Exception e)
		{
			PropertyInfo property = AccessTools.Property(typeof(BaseUnityPlugin), "Logger");
			ManualLogSource logger = (ManualLogSource)property.GetValue(me, new object[0]);
			logger.LogError(message);
			logger.LogError(e);
		}
コード例 #14
0
ファイル: KoikatuAPIBase.cs プロジェクト: Kokaiinum/KKAPI
        /// <summary>
        /// Check if a plugin is loaded and has at least the minimum version.
        /// If the plugin is missing or older than minimumVersion, user is shown an error message on screen and false is returned.
        /// Warning: Run only from Start, not from constructor or Awake because some plugins might not be loaded yet!
        /// </summary>
        /// <param name="origin">Your plugin</param>
        /// <param name="guid">Guid of the plugin your plugin is dependant on</param>
        /// <param name="minimumVersion">Minimum version of the required plugin</param>
        /// <param name="level">Level of the issue - <code>Error</code> if plugin can't work, <code>Warning</code> if there might be issues, or <code>None</code> to not show any message.</param>
        /// <returns>True if plugin exists and it's version equals or is newer than minimumVersion, otherwise false</returns>
        public static bool CheckRequiredPlugin(BaseUnityPlugin origin, string guid, Version minimumVersion, LogLevel level = LogLevel.Error)
        {
            var target = BepInEx.Bootstrap.Chainloader.Plugins
                         .Select(MetadataHelper.GetMetadata)
                         .FirstOrDefault(x => x.GUID == guid);

            if (target == null)
            {
                if (level != LogLevel.None)
                {
                    KoikatuAPI.Log(LogLevel.Message | level,
                                   $"{level.ToString().ToUpper()}: Plugin \"{guid}\" required by \"{MetadataHelper.GetMetadata(origin).GUID}\" was not found!");
                }

                return(false);
            }
            if (minimumVersion > target.Version)
            {
                if (level != LogLevel.None)
                {
                    KoikatuAPI.Log(LogLevel.Message | level,
                                   $"{level.ToString().ToUpper()}: Plugin \"{guid}\" required by \"{MetadataHelper.GetMetadata(origin).GUID}\" is outdated! At least v{minimumVersion} is needed!");
                }

                return(false);
            }
            return(true);
        }
コード例 #15
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;
                }
            }
コード例 #16
0
        /// <summary>
        /// Create a new custom control. Create and register it in <see cref="MakerAPI.RegisterCustomSubCategories"/>.
        /// </summary>
        /// <param name="text">Text displayed on the button</param>
        /// <param name="category">Category the control will be created under</param>
        /// <param name="owner">Plugin that owns the control</param>
        public MakerButton(string text, MakerCategory category, BaseUnityPlugin owner) : base(category, owner)
        {
            Text    = text;
            OnClick = new Button.ButtonClickedEvent();

            TextColor = new Color(0.090f, 0.118f, 0.141f);
        }
コード例 #17
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];
                    }
                }
            }
コード例 #18
0
        public ConfigSettingEntry(ConfigEntryBase entry, BaseUnityPlugin owner)
        {
            Entry = entry;

            DispName    = entry.Definition.Key;
            Category    = entry.Definition.Section;
            Description = entry.Description?.Description;

            var converter = TomlTypeConverter.GetConverter(entry.SettingType);

            if (converter != null)
            {
                ObjToStr = o => converter.ConvertToString(o, entry.SettingType);
                StrToObj = s => converter.ConvertToObject(s, entry.SettingType);
            }

            var values = entry.Description?.AcceptableValues;

            if (values != null)
            {
                GetAcceptableValues(values);
            }

            DefaultValue = entry.DefaultValue;

            SetFromAttributes(entry.Description?.Tags, owner);
        }
コード例 #19
0
 static void BindConfig(BaseUnityPlugin plugin)
 {
     teamMemberAdd       = plugin.Config.Bind("自由组队", "队伍加入当前角色", KeyCode.F3, "加入队伍");
     teamMemberRemove    = plugin.Config.Bind("自由组队", "队伍移除当前角色", KeyCode.F4, "移出队伍");
     teamMemberRemoveAll = plugin.Config.Bind("自由组队", "队伍移除全部队友", KeyCode.F5, "清空队伍");
     communityRemove     = plugin.Config.Bind("自由组队", "队伍从社群移除", KeyCode.F6, "删除社群,之后可于行囊->任务->人物加入道具重新加回");
 }
コード例 #20
0
        public void OnRegister(BaseUnityPlugin plugin)
        {
            teamManageOn = plugin.Config.Bind("自由组队", "开启自由组队模式", false,
                                              new ConfigDescription("开启自由组队模式,用来调整队伍、通过剧情等,剑击江湖mod请打开", null, new ConfigurationManagerAttributes {
                Order = 2
            }));
            teamMemberMax = plugin.Config.Bind("自由组队", "最大队伍人数", 4,
                                               new ConfigDescription("最大队伍人数", new AcceptableValueRange <int>(4, 9), new ConfigurationManagerAttributes {
                Order = 1
            }));
            if (teamManageOn.Value)
            {
                BindConfig(plugin);
            }

            teamManageOn.SettingChanged += (o, e) =>
            {
                if (teamManageOn.Value)
                {
                    BindConfig(plugin);
                }
                else
                {
                    plugin.Config.Remove(teamMemberAdd.Definition);
                    plugin.Config.Remove(teamMemberRemove.Definition);
                    plugin.Config.Remove(teamMemberRemoveAll.Definition);
                    plugin.Config.Remove(communityRemove.Definition);
                }
                UpdateTeamDisplay();
            };
        }
コード例 #21
0
ファイル: HookGeneral.cs プロジェクト: Binarizer/Plugin_J2
        public void OnRegister(BaseUnityPlugin plugin)
        {
            // configs
            speedValue   = plugin.Config.Bind("游戏设定", "速度值", 1.5f, "调整速度值");
            speedKey     = plugin.Config.Bind("游戏设定", "速度热键", KeyCode.F2, "开关速度调节");
            alwaysAmbush = plugin.Config.Bind("游戏设定", "全难度开启切磋", false, "全难度开启切磋(需重启游戏生效)");
            sharePoints  = plugin.Config.Bind("游戏设定", "共享成就感悟点", false, "全队成员可享受成就感悟点");
            jumpTalent   = plugin.Config.Bind("游戏设定", "跳点天赋", false, "花费5点跳点不连接的天赋");

            alwaysFullMember  = plugin.Config.Bind("队伍调整", "开放队伍人数上限", false, "开启全难度固定队友数量(不受原版4-5-6限制)");
            alwaysMemberCount = plugin.Config.Bind("队伍调整", "队伍人数上限", 6, "全难度队友数量, 用队伍调整键调整可看到后备队友");
            headKey           = plugin.Config.Bind("队伍调整", "队伍调整-提到前面", KeyCode.F4, "将选中队友放到队伍前面,主角后面");
            tailKey           = plugin.Config.Bind("队伍调整", "队伍调整-放到队尾", KeyCode.F3, "将选中队友放到队伍末端");
            alwaysBattleCount = plugin.Config.Bind("队伍调整", "队伍战斗可上场数", 6, "上场战斗队友人数, 最小1,最大6(超过6需要dll支持),从主角开始算起");

            // specific patches
            {
                //var harmony = new Harmony("Generals");
                //var assembly = Assembly.GetAssembly(typeof(BattleFactory));
                //var listTypes = assembly.GetTypes().ToList();
                //var realType = listTypes.FindAll(t => t.Name.Contains("GenerateBattleCreateInfo")).First();    // <GenerateBattleCreateInfo>d__7
                //var source = realType.GetMethod("MoveNext", BindingFlags.Instance | BindingFlags.NonPublic);
                //var il = source.GetMethodBody().GetILAsByteArray();
                //int size = il.Length;
                //MethodRental.SwapMethodBody(realType, source.MetadataToken, il, il.Length, MethodRental.JitImmediate);
                //Console.WriteLine("source=" + source);
                //var transpiler = typeof(HookGenerals).GetMethod("TeammateCountBattle1");
                //Console.WriteLine("transpiler=" + transpiler);
                //harmony.Patch(source, transpiler: new HarmonyMethod(transpiler));
            }
        }
コード例 #22
0
        private static void CreateCustomControlsInSubCategory(Transform subCategoryTransform, ICollection <BaseGuiEntry> entriesToAdd)
        {
            if (entriesToAdd.Count == 0)
            {
                return;
            }

            var contentParent = FindSubcategoryContentParent(subCategoryTransform);

            BaseUnityPlugin lastOwner = contentParent.childCount > 1 ? KoikatuAPI.Instance : null;

            foreach (var customControl in entriesToAdd)
            {
                if (lastOwner != customControl.Owner && lastOwner != null)
                {
                    new MakerSeparator(new MakerCategory(null, null), KoikatuAPI.Instance).CreateControl(contentParent);
                }

                customControl.CreateControl(contentParent);
                lastOwner = customControl.Owner;
            }

            var category = entriesToAdd.First().Category;

            KoikatuAPI.Logger.LogDebug(
                $"Added {entriesToAdd.Count} custom controls " +
                $"to {category.CategoryName}/{category.SubCategoryName}");
        }
コード例 #23
0
        void IHook.OnRegister(BaseUnityPlugin plugin)
        {
            elementPos     = plugin.Config.Bind("五行显示", "五行位置", new Vector3(-80, 15, 0), "调整五行位置");
            elementTextPos = plugin.Config.Bind("五行显示", "名字位置", new Vector3(8, 18, 0), "调整名字位置");
            elementKey     = plugin.Config.Bind("五行显示", "五行显示热键", KeyCode.F3, "战斗时显示五行。调整位置后需开关一次生效");

            thresholdDisplay = plugin.Config.Bind("游戏设定", "显示一次练满点数", true, "是否提示一次练满所需相应数值");
        }
コード例 #24
0
 private void Awake()
 {
     instance             = this;
     _exploreFullMap      = Config.Bind("General", "Explore full map", true, "explore the full map");
     _toggleHotkey        = Config.Bind("Hotkeys", "Toggle explore full map hotkey", "F6", "The hotkey that toggles showing the full map, for a full list of available keys visit https://docs.unity3d.com/ScriptReference/KeyCode.html");
     _toggleHotkeyKeyCode = (KeyCode)Enum.Parse(typeof(KeyCode), _toggleHotkey.Value);
     Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), null);
 }
コード例 #25
0
ファイル: HookSave.cs プロジェクト: findsky6544/Plugin-Pow
 public void OnRegister(BaseUnityPlugin plugin)
 {
     saveCount            = plugin.Config.Bind("存档设定", "存档数量", 20, "扩充存档数量");
     remindBlankSaveCount = plugin.Config.Bind("存档设定", "自动存档剩余数量提示", false, "在自动存档剩余空白存档数量不足5个时弹窗提示");
     jumpToLatestSave     = plugin.Config.Bind("存档设定", "自动跳转到最新存档位置", false, "在存档数量太多的时候会有点作用");
     pagination           = plugin.Config.Bind("存档设定", "存档分页", false, "在存档数量太多的时候会有点作用");
     countPerPage         = plugin.Config.Bind("存档设定", "存档分页-每页存档数", 20, "每页多少条存档,存档分页启用后才有用");
 }
コード例 #26
0
 void IHook.OnRegister(BaseUnityPlugin plugin)
 {
     elementPos     = plugin.Config.Bind("界面改进", "五行位置", new Vector3(-80, 15, 0), "调整五行位置");
     elementTextPos = plugin.Config.Bind("界面改进", "名字位置", new Vector3(8, 18, 0), "调整名字位置");
     elementKey     = plugin.Config.Bind("界面改进", "五行显示热键", KeyCode.F3, "战斗时显示五行。调整位置后需开关一次生效");
     showThreshold  = plugin.Config.Bind("界面改进", "显示练满所需点数", true, "是否提示n次练满所需相应数值");
     showFavExp     = plugin.Config.Bind("界面改进", "显示好感度", true, "在好友界面显示当前好感度 / 总需好感度 在送礼界面显示礼物可提高的好感度");
 }
コード例 #27
0
        public static void Start(MonoBehaviour mb, BaseUnityPlugin thisPlugin)
        {
            if (_running)
            {
                return;
            }
            _running = true;

            if (_harmonyInstance == null)
            {
                _harmonyInstance = new Harmony(FrameCounter.GUID);
            }

            var hookCount = 0;

            // Hook unity event methods on all plugins
            var baseType     = typeof(MonoBehaviour);
            var unityMethods = new[] { "FixedUpdate", "Update", "LateUpdate", "OnGUI" };

            foreach (var baseUnityPlugin in Chainloader.Plugins.Where(x => x != null && x != thisPlugin))
            {
                var timer = new Stopwatch();

                var pluginBehaviours = SafeGetTypes(baseUnityPlugin.GetType().Assembly).Where(x => baseType.IsAssignableFrom(x) && !x.IsAbstract).ToList();
                foreach (var pluginBehaviour in pluginBehaviours)
                {
                    foreach (var unityMethod in unityMethods)
                    {
                        var methodInfo = pluginBehaviour.GetMethod(unityMethod, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly);
                        if (methodInfo == null)
                        {
                            continue;
                        }

                        if (!_timers.ContainsKey(pluginBehaviour))
                        {
                            _timers[pluginBehaviour] = new KeyValuePair <BepInPlugin, Stopwatch>(baseUnityPlugin.Info.Metadata, timer);
                        }

                        try
                        {
                            _harmonyInstance.Patch(methodInfo, new HarmonyMethod(AccessTools.Method(typeof(PluginCounter), nameof(Pre))), new HarmonyMethod(AccessTools.Method(typeof(PluginCounter), nameof(Post))));
                            hookCount += 1;
                        }
                        catch (Exception ex)
                        {
                            FrameCounter.Logger.LogError(ex);
                        }
                    }
                }
            }

            var co = mb.StartCoroutine(CollectLoop());

            _stopAction = () => mb.StopCoroutine(co);

            FrameCounter.Logger.LogDebug($"Attached timers to {hookCount} unity methods in {Chainloader.Plugins.Count} plugins");
        }
コード例 #28
0
 internal static void InitSupport()
 {
     BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue("com.deathweasel.bepinex.hairaccessorycustomizer", out PluginInfo PluginInfo);
     PluginInstance = PluginInfo?.Instance;
     if (PluginInstance != null)
     {
         Installed = true;
     }
 }
コード例 #29
0
 public static void Initialize(BaseUnityPlugin parentPlugin, ManualLogSource logger)
 {
     AppStateManager.UsingCodeInjection = true;
     ModdingUtils.parentPlugin          = parentPlugin;
     ModdingUtils.parentLogger          = logger;
     parentLogger.LogInfo("Inside initialize");
     SceneManager.sceneLoaded += OnSceneLoaded;
     // By default do not start the socket server. It requires the caller to also call OnUpdate in the plugin update method.
 }
コード例 #30
0
 internal static void InitSupport()
 {
     BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue("madevil.kk.mr", out PluginInfo PluginInfo);
     PluginInstance = PluginInfo?.Instance;
     if (PluginInstance != null)
     {
         Installed = true;
     }
 }