Added stat caching, fixed all the bugs
Added RitualObligationTriggers analyzer category, Fixed defs from other mods with broken market value breaking fish's storage patches, Fixed storage caches not updating for quality, rotting and similar changes to stored things, Fixed storage caches not updating capacity when reinstalling storage, Fixed prison labor compatibility, Improved multiplayer compatibility, Fixed ideology style dominance and altar sharing patches throwing errors instead of defaulting to disabled when not having ideology, Fixed compatibility with RIMMSqol's world pawn GC patch by disabling that patch, Fixed rare threading issues throwing errors on startup
This commit is contained in:
@@ -16,6 +16,8 @@ public static class ActiveMods
|
||||
Multiplayer = Contains(PackageIDs.MULTIPLAYER),
|
||||
PerformanceOptimizer = Contains(PackageIDs.PERFORMANCE_OPTIMIZER),
|
||||
Prepatcher = Contains(PackageIDs.PREPATCHER),
|
||||
PrisonLabor = Contains(PackageIDs.PRISON_LABOR),
|
||||
RIMMSqol = Contains(PackageIDs.RIMMSQOL),
|
||||
UseBestMaterials = Contains(PackageIDs.USE_BEST_MATERIALS),
|
||||
VanillaExpandedFramework = Contains(PackageIDs.VANILLA_EXPANDED_FRAMEWORK);
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ public static class PackageIDs
|
||||
PERFORMANCE_FISH = "bs.performance",
|
||||
PERFORMANCE_OPTIMIZER = "Taranchuk.PerformanceOptimizer",
|
||||
PREPATCHER = "zetrith.prepatcher",
|
||||
PRISON_LABOR = "avius.prisonlabor",
|
||||
RIMMSQOL = "MalteSchulze.RIMMSqol",
|
||||
USE_BEST_MATERIALS = "kathanon.UseBestMaterials",
|
||||
VANILLA_EXPANDED_FRAMEWORK = "OskarPotocki.VanillaFactionsExpanded.Core";
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
// Copyright (c) 2023 bradson
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// 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/.
|
||||
|
||||
namespace PerformanceFish.ModCompatibility;
|
||||
|
||||
public static class RIMMSqol
|
||||
{
|
||||
private const string ASSEMBLY_NAME = "RIMMSqol";
|
||||
|
||||
public static bool Active => ActiveMods.RIMMSqol;
|
||||
|
||||
public static string[] BlockedPatchNamespaces { get; } = ["WorldPawnGC"];
|
||||
|
||||
public static ModContentPack? ModContentPack { get; }
|
||||
= ActiveMods.TryGetModContentPack(PackageIDs.RIMMSQOL);
|
||||
|
||||
public static Type? HarmonyPatchNamespaceType { get; }
|
||||
|
||||
public static MethodInfo? RegisterAllMethod { get; }
|
||||
|
||||
static RIMMSqol()
|
||||
{
|
||||
if (ModContentPack is null)
|
||||
return;
|
||||
|
||||
if (ModContentPack.TryGetAssembly(ASSEMBLY_NAME) is not { } assembly)
|
||||
{
|
||||
LogFailureToFind("assembly");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((HarmonyPatchNamespaceType = assembly.GetType("RIMMSqol.HarmonyPatchNamespace")) is null)
|
||||
{
|
||||
LogFailureToFind("harmony patch namespace type");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((RegisterAllMethod = AccessTools.DeclaredMethod(HarmonyPatchNamespaceType, "registerAll")) is null)
|
||||
LogFailureToFind("registerAll method");
|
||||
}
|
||||
|
||||
private static void LogFailureToFind(string text)
|
||||
=> Log.Error($"Performance Fish failed to find RIMMSqol's {
|
||||
text}. This is likely to cause issues.");
|
||||
|
||||
public static bool TryPatch()
|
||||
=> RegisterAllMethod is { } registerAllMethod
|
||||
&& PerformanceFishMod.Harmony.Patch(registerAllMethod, postfix: new(methodof(RegisterAllPostfix))) != null;
|
||||
|
||||
public static void RegisterAllPostfix()
|
||||
{
|
||||
if (AccessTools.Field(HarmonyPatchNamespaceType, "namespaces").GetValue(null) is not IDictionary namespaces)
|
||||
{
|
||||
LogFailureToFind("harmony patch namespaces field");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var blockedPatchNamespace in BlockedPatchNamespaces)
|
||||
{
|
||||
if (!namespaces.Contains(blockedPatchNamespace))
|
||||
{
|
||||
LogFailureToFind(blockedPatchNamespace);
|
||||
continue;
|
||||
}
|
||||
|
||||
var properties = namespaces[blockedPatchNamespace];
|
||||
if (AccessTools.Field(properties.GetType(), "active") is not { } activeField)
|
||||
{
|
||||
LogFailureToFind("harmony patch active field");
|
||||
return;
|
||||
}
|
||||
|
||||
activeField.SetValue(properties, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user