边缘世界 RimWorld

边缘世界 RimWorld

Trade Price Fix
Spürgelwürg 2023 年 8 月 13 日 下午 2:43
Fixed a little icompatability with 1-2-3 Perosnalites M2
Your transpiler was a little too crude and not compatible with other mods changing that method, so I went over it a little and changed it to this:

using System.Collections.Generic; using System.Linq; using System.Reflection.Emit; using HarmonyLib; using RimWorld; using Verse; namespace TradePriceFix { [HarmonyPatch(typeof(Tradeable), "InitPriceDataIfNeeded")] public static partial class Tradeable_InitPriceDataIfNeededPatch { [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> codes = new List<CodeInstruction>(instructions); bool foundEnd = false; bool foundStart = false; int idxEnd = 0; int idxStart = 0; for (int i = codes.Count<CodeInstruction>() - 1; i > 0; i--) { if (!foundStart && codes.opcode == OpCodes.Stfld && codes.opcode == OpCodes.Ldfld && codes.LoadsField(AccessTools.Field(typeof(Tradeable), "pricePlayerBuy")) && codes.opcode == OpCodes.Ldarg_0)
{
foundStart = true;
idxStart = i;
}
if (!foundEnd && codes.opcode == OpCodes.Ldarg_0 && codes.opcode == OpCodes.Ldfld && codes.LoadsField(AccessTools.Field(typeof(Tradeable), "pricePlayerSell")) && codes.opcode == OpCodes.Ldarg_0)
{
foundEnd = true;
idxEnd = i - 2;
break;
}
}
//Log.Message($"idxEnd = {idxEnd},idxStart = {idxStart}, count = {idxStart + 1 - idxEnd}");
codes.RemoveRange(idxEnd, idxStart + 1 - idxEnd);
return codes.AsEnumerable<CodeInstruction>();
}
}
}
最后由 Spürgelwürg 编辑于; 2023 年 8 月 13 日 下午 2:59
< >
正在显示第 1 - 1 条,共 1 条留言
Spürgelwürg 2023 年 8 月 14 日 上午 2:03 
From what I've seen, UnCap TradePriceImprovement should also be now compatible with this change.
< >
正在显示第 1 - 1 条,共 1 条留言
每页显示数: 1530 50