Rh里有个Harmony动态链接库,看描述挺有意思的就反汇编了一下,代码也很简单
using System;
using System.Reflection;
using DMT;
using Harmony;
using UnityEngine;
[HarmonyPatch(“IsBroken”)]
[HarmonyPatch(typeof(VehiclePart))]
public class NovehicleBM : IHarmony
{
public void Start()
{
Debug.Log(” Loading Patch: ” + base.GetType().ToString());
HarmonyInstance harmonyInstance = HarmonyInstance.Create(base.GetType().ToString());
harmonyInstance.PatchAll(Assembly.GetExecutingAssembly());
}
private static bool Postfix(bool __result, VehiclePart __instance)
{
bool flag = SkyManager.BloodMoon();
bool result;
if (__instance is VPEngine && flag)
{
try
{
foreach (EntityPlayerLocal entityPlayerLocal in GameManager.Instance.World.GetLocalPlayers())
{
if (entityPlayerLocal.AttachedToEntity && entityPlayerLocal.AttachedToEntity.GetType() != typeof(EntityBicycle))
{
GameManager.ShowTooltip(entityPlayerLocal, Localization.Get(“BMEngineWarning”, “”));
}
}
}
catch (Exception arg)
{
Debug.LogWarning(“Caught exception: ” + arg);
}
result = true;
}
else
{
result = __result;
}
return result;
}
}
前面的Start()还有HarmonyPatch()不用管,固定格式意思是加载到游戏中。
然后Postfix函数的意思是遍历所有玩家然后判断他们是不是在载具上,如果载具不是自行车,就显示BMEngineWarning对应的翻译(这个翻译可以自己加,比如血月来了你车炸了之类的)。
知道大概意思Mods作者们就可以看着改了,比如自行车都别想开了安心等死(跑), 也可以直接用。