bugfix 21/09/26
This commit is contained in:
parent
834d6647fd
commit
64d8869f98
3 changed files with 70 additions and 3 deletions
|
|
@ -199,4 +199,46 @@ namespace RacesOfValheim
|
|||
return PieceDensityLimit.Allow(__instance, Utils.GetPrefabName(__0.gameObject), __1);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// What makes "a prefix returning false spends nothing" TRUE, which on its own it is not.
|
||||
///
|
||||
/// Read off the 1.0 IL: nothing is paid inside PlacePiece. TryPlacePiece calls it and then does an
|
||||
/// unconditional `ldc.i4.1; ret`, and it is UpdatePlacement that, on that true, runs
|
||||
/// ConsumeResources and UseStamina. So every race lock in the mod - this class's gates, the Trol
|
||||
/// totem, the Dvergar bank and barrel, the Trenta Root - stopped the building and still took the
|
||||
/// wood: "Only the Sverm can raise a hive", and 40 wood and 20 resin gone.
|
||||
///
|
||||
/// Fixed here once rather than in each lock: a last-priority prefix on the same PlacePiece
|
||||
/// overload sees __runOriginal after every other prefix has had its say, and if any of them said
|
||||
/// no, TryPlacePiece reports false - the path vanilla already takes for a blocked placement, which
|
||||
/// charges nothing. Any lock added later is covered without knowing this exists.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Player), "PlacePiece",
|
||||
new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool), typeof(bool) })]
|
||||
public static class PlacementRefusalWatch
|
||||
{
|
||||
internal static bool Refused;
|
||||
|
||||
[HarmonyPriority(Priority.Last)]
|
||||
public static void Prefix(bool __runOriginal)
|
||||
{
|
||||
if (!__runOriginal) Refused = true;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Player), "TryPlacePiece")]
|
||||
public static class PlacementRefusalCharge
|
||||
{
|
||||
public static void Prefix()
|
||||
{
|
||||
PlacementRefusalWatch.Refused = false;
|
||||
}
|
||||
|
||||
public static void Postfix(ref bool __result)
|
||||
{
|
||||
if (PlacementRefusalWatch.Refused) __result = false;
|
||||
PlacementRefusalWatch.Refused = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue