SirW_CustomHints

创作者: SirWintour
已更新:2026-06-11 21:27:04
16KB

前置 MOD

使用 SirW_CustomHints 时将自动安装

关于此 MOD

用于向游戏添加自定义提示的模组工具。其本身不执行任何功能。
这是一款模组工具,允许其他模组添加自定义提示。
提示是屏幕左侧的物品,显示一个输入框以及一些文字。

该工具使用起来相当简单,但也为模组作者可能遇到的特定使用场景提供了一些额外功能。

额外奖励是,这也修复了游戏中的一个错误,即如果用户在不移开视线的情况下,将光标在不同可交互对象之间移动,提示会叠加在一起。  
例如,先看货架,再看标签,然后再看回货架,标签的提示仍然会显示。

安装:
  • 安装 Tobey的超市模拟器BepInEx整合包 或基础BepInEx模组加载器
  • 从下载页面下载zip文件
  • 打开/解压zip文件,并将.dll文件放入\Supermarket Simulator\BepInEx\plugin中


模组/实现:
我在Files/Optional下包含了一个带有xml文档的版本。
我还放了一个Markdown格式的REDAME 这里 以帮助实施此MOD。


警告:
此模组覆盖了“PlayerInteraction.Raycast”函数,使得即使玩家没有看向可交互物品时,也能显示提示。
这可能会与其他也修改此功能的模组产生冲突。
如果这会导致任何问题,那么已添加一项名为“DisablePermanentHints”的设置,启用此项将禁用该覆盖。


基本用法
这里是使用该模组的一段示例代码:
using BepInEx;
using HarmonyLib;
using SirW_CustomHints;

namespace MyMod
{
    [BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
    [BepInDependency("SirW_CustomHints", BepInDependency.DependencyFlags.HardDependency)]
    public class Plugin : BasePlugin
    {
        // 用于已翻译的提示。这些是可选的。
        private static CustomTranslatedHints customTranslatedHints = new CustomTranslatedHints();

        public override void Load()
        {
            // 将自定义函数附加到短信代码。
            Harmony.CreateAndPatchAll(typeof(Plugin));
        }

        // 与电脑互动时添加提示。
        [HarmonyPatch(typeof(ComputerInteraction), nameof(ComputerInteraction.DefaultHint))]
        [HarmonyPostfix]
        static void ComputerExample(ComputerInteraction __instance, bool show)
        {
            // 仅当 ComputerInteraction.DefaultHint 设置为显示时,才添加提示。 
            if (show)
            {
                // 基础提示。
                CustomHints.AddHint(HintIcons.R, "基础提示");
                // 包含多个按键的提示。
                自定义提示.添加提示([提示图标.右键, 提示图标.暂停], "多键操作");
                // 提示使用 UnityEngine.KeyCode。
                CustomHints.AddHint(HintIcons.GetKeyFromCode(KeyCode.R), "按键提示");
                // 增加提示窗口宽度。
                CustomHints.AddHint(HintIcons.W, "更宽的提示", 350f);
                // 永久提示。
                CustomHints.AddHint(HintIcons.P, "永久提示", null, true);

                // 显示翻译后的提示。
                customTranslatedHints.AddHint(HintIcons.T, "translated_hint")
            }
        }

        // 创建翻译的方法。
        private static void CreateTranslation()
        {
            translated_hint
            LocalizedStrings localizedStrings = new LocalizedStrings();
            localizedStrings["en"] = "翻译提示";
            localizedStrings["de"] = "翻译后的提示";
            localizedStrings["es-ES"] = "翻译后的曲目";
            localizedStrings["da-DK"] = "翻译提示";

            // 如果列表已存在,则直接更新它。
            TranslationEntry existingKey = customTranslatedHints.Translations.FirstOrDefault(x => x.TranslationKey == translationKey);
            if (existingKey != null)
            {
                existingKey.LocalizedStrings.Merge(localizedStrings);
            }
            否则
            {
                TranslationEntry translationEntry = new TranslationEntry(translationKey, localizedStrings);
                customTranslatedHints.Translations.Add(translationEntry);
            }
        }
    }
}

额外:
示例中还展示了一个名为“HintIcons”的类,它包含了所有可能的图标。


计划中/待办事项:
  • 添加增加提示宽度的功能,以便显示更长的提示。
  • 添加一个功能,让一条提示可以显示多个按钮。
  • 添加一项功能,当玩家未注视任何可交互对象时,显示提示。
  • 添加一个将Unity KeyCode转换为HintIcon的功能。
  • 为自定义键盘快捷键添加额外的图标。
  • 分离发布版和调试版构建。
请我喝杯咖啡吧

使用 Xmod 解锁 超市模拟器 的全部潜力 — 今天就探索这些顶级 MOD!