Adjusting Transport Pod Range, Harmony Patch Not Working

Started by Mersid, March 28, 2018, 04:09:47 PM

Previous topic - Next topic

Mersid

So the first HarmonyPatch method (MaxLaunchDistanceAtFuelLevel) is working fine, but (FuelNeededToLaunchAtDist) is never accessed when it needs to be. How would I fix this?


using System.Reflection;

using UnityEngine;

using RimWorld;
using RimWorld.Planet;
using Verse;
using Harmony;

namespace TransportPodsExtended
{

[StaticConstructorOnStartup]
public static class TPE_HarmonyPatch
{
static TPE_HarmonyPatch()
{
HarmonyInstance harmony = HarmonyInstance.Create("TransportPod");
harmony.PatchAll(Assembly.GetExecutingAssembly());
var methods = harmony.GetPatchedMethods();
foreach (var method in methods)
{
Log.Warning(method.ToString());
}

}
}

[HarmonyPatch(typeof(CompLaunchable))]
[HarmonyPatch("MaxLaunchDistanceAtFuelLevel")]
static class MaxDistancePatch
{
static void Postfix(ref int __result, float fuelLevel)
{
__result = Mathf.FloorToInt(fuelLevel / 10f);
}
}



#region FuelNeededToLaunchAtDist
[HarmonyPatch(typeof(CompLaunchable))]
[HarmonyPatch("FuelNeededToLaunchAtDist")]
static class FuelNeededPatch
{
static FuelNeededPatch()
{
Log.Error("Hello!");
}

static void Postfix(ref float __result, float dist)
{
__result = 10 * dist;
}
}
#endregion

}


Here are the methods they patch


public static int MaxLaunchDistanceAtFuelLevel(float fuelLevel)
{
return Mathf.FloorToInt(fuelLevel / 2.25f);
}

public static float FuelNeededToLaunchAtDist(float dist)
{
return 2.25f * dist;
}