Added gas grid optimization, various despawn optimizations, new hauling optimizations utilizing events and regions, bugfixes for old patches and for vanilla functions too, as well as smaller additions. 1.3 files removed.

This commit is contained in:
bbradson
2024-01-27 10:24:24 +01:00
parent 0247ad59a1
commit c8b764de68
151 changed files with 7318 additions and 2145 deletions
@@ -3,18 +3,17 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
using System.Linq;
using static System.Reflection.Emit.OpCodes;
namespace PerformanceFish.Hediffs;
public class HediffComp_PsychicHarmonizer_Bugfix : ClassWithFishPatches
public sealed class HediffComp_PsychicHarmonizer_Bugfix : ClassWithFishPatches
{
public class CompPostTick_Patch : FishPatch
public sealed class CompPostTick_Patch : FishPatch
{
public override string Description { get; }
= "Fixes a bug in the psychic harmonizer tick method that was causing it to recalculate results on 149 "
+ "out of 150 ticks instead of once every 150 ticks. Large impact.";
+ "out of 150 ticks instead of once every 150 ticks. Large impact.";
public override MethodBase TargetMethodInfo { get; }
= AccessTools.Method(typeof(HediffComp_PsychicHarmonizer),
@@ -22,29 +21,19 @@ public class HediffComp_PsychicHarmonizer_Bugfix : ClassWithFishPatches
public static CodeInstructions Transpiler(CodeInstructions codeInstructions)
{
var codes = codeInstructions.ToList();
var codes = codeInstructions.AsOrToList();
var pawn_int_IsHashIntervalTick = FishTranspiler.Call<Func<Thing, int, bool>>(Gen.IsHashIntervalTick);
var success = false;
for (var i = 0; i < codes.Count; i++)
{
if (i + 2 < codes.Count
&& codes[i].opcode == Ldc_I4
&& codes[i + 1] == pawn_int_IsHashIntervalTick
&& codes[i + 2].opcode == Brfalse_S)
if (i - 2 >= 0
&& codes[i - 2].opcode == Ldc_I4
&& codes[i - 1] == pawn_int_IsHashIntervalTick
&& codes[i].opcode == Brfalse_S)
{
//codes[i].operand = 128;
yield return codes[i];
yield return codes[i + 1];
codes[i + 2].opcode = Brtrue_S;
yield return codes[i + 2];
codes[i].opcode = Brtrue_S;
success = true;
i += 2;
}
else
{
yield return codes[i];
}
}
@@ -55,6 +44,8 @@ public class HediffComp_PsychicHarmonizer_Bugfix : ClassWithFishPatches
+ "an actual failure to patch if settings were not toggled however, which would mean some other "
+ "patch or a vanilla change either messes with this or implements the same thing");
}
return codes;
}
}
}