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
@@ -13,12 +13,33 @@ namespace PerformanceFish.Patching;
[UsedImplicitly(ImplicitUseTargetFlags.WithInheritors)]
public class FishPatchHolder : IExposable, IEnumerable<FishPatch>
{
private volatile int _completedPatchingOnce;
public ConcurrentDictionary<Type, FishPatch> All { get; } = new();
public T Get<T>() where T : FishPatch => (T)All[typeof(T)];
public void Add(FishPatch patch) => All[patch.GetType()] = patch;
public void PatchAll() => All.Values.PatchAll();
public void UnpatchAll() => All.Values.UnpatchAll();
public void PatchAll()
{
using var patches = new PooledArray<FishPatch>(All.Values);
for (var i = 0; i < patches.Length; i++)
patches[i].TryPatch();
if (Interlocked.Exchange(ref _completedPatchingOnce, 1) == 0)
{
for (var i = 0; i < patches.Length; i++)
patches[i].OnPatchingCompleted();
}
}
public void UnpatchAll()
{
foreach (var patch in All.Values)
patch.TryUnpatch();
}
public FishPatch this[Type type] => All[type];
public FishPatchHolder(Type type)
@@ -62,8 +83,8 @@ public class FishPatchHolder : IExposable, IEnumerable<FishPatch>
patchClass.Patches[type].Enabled = false;
patchClass.Patches.All.TryRemove(type, out _);
Log.Warning($"Performance Fish removed a duplicate patch from {patchClass.GetType().FullName
}. This is likely caused by no longer valid mod configs");
Log.Warning($"Performance Fish removed a duplicate patch from {
patchClass.GetType().FullName}. This is likely caused by no longer valid mod configs");
}
}