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
@@ -12,14 +12,38 @@ public static class ActiveMods
// GradientHair = Contains(PackageIDs.GRADIENT_HAIR),
GraphicsSetter = Contains(PackageIDs.GRAPHICS_SETTINGS),
Harmony = Contains(PackageIDs.HARMONY),
HumanResources = Contains(PackageIDs.HUMAN_RESOURCES),
Multiplayer = Contains(PackageIDs.MULTIPLAYER),
PerformanceOptimizer = Contains(PackageIDs.PERFORMANCE_OPTIMIZER),
Prepatcher = Contains(PackageIDs.PREPATCHER),
UseBestMaterials = Contains(PackageIDs.USE_BEST_MATERIALS),
VanillaExpandedFramework = Contains(PackageIDs.VANILLA_EXPANDED_FRAMEWORK);
// ModsConfig.IsActive does not ignore _steam postfixes, causing it to fail when local copies were made
public static bool Contains(string packageID) => TryGetModMetaData(packageID) != null;
public static bool ContainsAnyOf<T>(T packageIDs) where T : IEnumerable<string>
{
foreach (var id in packageIDs)
{
if (Contains(id))
return true;
}
return false;
}
public static bool ContainsAllOf<T>(T packageIDs) where T : IEnumerable<string>
{
foreach (var id in packageIDs)
{
if (!Contains(id))
return false;
}
return true;
}
public static ModMetaData? TryGetModMetaData(string packageID)
=> ModLister.GetActiveModWithIdentifier(packageID, true);
@@ -55,7 +79,7 @@ public static class ActiveMods
ThrowForMissingModDependency(nameof(Fishery));
if (!Harmony)
ThrowForMissingModDependency(nameof(Harmony));
WarnForMissingModDependency(nameof(Harmony));
VerifyLoadOrder(nameof(Fishery), PackageIDs.FISHERY, PackageIDs.PERFORMANCE_FISH, PackageIDs.BETTER_LOG);
VerifyLoadOrder(nameof(Harmony), PackageIDs.HARMONY, PackageIDs.PERFORMANCE_FISH);
@@ -70,14 +94,14 @@ public static class ActiveMods
if (activeModsInLoadOrder.FindIndex(mod => mod.PackageId == dependencyID)
> activeModsInLoadOrder.FindIndex(mod => dependingModIDs.Contains(mod.PackageId)))
{
ThrowForIncorrectLoadOrder(dependencyName);
ErrorForIncorrectLoadOrder(dependencyName);
}
}
private static void CheckFisheryVersion()
{
if (FisheryLib.FisheryLib.VERSION > FisheryLib.FisheryLib.CurrentlyLoadedVersion)
ThrowForOutdatedModDependency(nameof(Fishery));
ErrorForOutdatedModDependency(nameof(Fishery));
}
private static void CheckHarmonyVersion()
@@ -86,23 +110,27 @@ public static class ActiveMods
private static void CheckDependencyVersion(string dependencyName, Type dependencyType,
string dependencyAssemblyName)
{
if (typeof(PerformanceFishMod).Assembly.GetReferencedAssemblies().First(assembly
=> assembly.FullName.StartsWith($"{dependencyAssemblyName}, Version", StringComparison.Ordinal)).Version
> dependencyType.Assembly.GetName().Version)
if (typeof(PerformanceFishMod).Assembly.GetReferencedAssemblyVersion(dependencyAssemblyName)
> dependencyType.Assembly.GetLoadedVersion())
{
ThrowForOutdatedModDependency(dependencyName);
ErrorForOutdatedModDependency(dependencyName);
}
}
private static void ThrowForIncorrectLoadOrder(string dependencyName)
=> ThrowHelper.ThrowOperationCanceledException($"Incorrect load order detected. {
dependencyName} must be loaded before any mod depending on it.");
private static void ErrorForIncorrectLoadOrder(string dependencyName)
=> Log.Error($"Incorrect load order detected. {dependencyName} must be loaded before any mod depending on it.");
private static void ThrowForOutdatedModDependency(string modName)
=> ThrowHelper.ThrowOperationCanceledException($"Outdated {modName} mod detected. {
private static void ErrorForOutdatedModDependency(string modName)
=> Log.Error($"Outdated {modName} mod detected. {
modName} must be updated for Performance Fish to work correctly");
private static void ThrowForMissingModDependency(string modName)
=> ThrowHelper.ThrowOperationCanceledException(
$"{modName} mod is missing. Performance Fish requires this mod in order to function.");
{
Log.Error($"{modName} mod is missing. Performance Fish requires this mod in order to function.");
ThrowHelper.ThrowOperationCanceledException();
}
private static void WarnForMissingModDependency(string modName)
=> Log.Warning(
$"{modName} mod is missing. Performance Fish may not work correctly without this dependency.");
}
@@ -13,9 +13,11 @@ public static class PackageIDs
// GRADIENT_HAIR = "automatic.gradienthair",
GRAPHICS_SETTINGS = "Telefonmast.GraphicsSettings",
HARMONY = "brrainz.harmony",
HUMAN_RESOURCES = "JPT.HumanResources",
MULTIPLAYER = "rwmt.Multiplayer",
PERFORMANCE_FISH = "bs.performance",
PERFORMANCE_OPTIMIZER = "Taranchuk.PerformanceOptimizer",
PREPATCHER = "zetrith.prepatcher",
USE_BEST_MATERIALS = "kathanon.UseBestMaterials",
VANILLA_EXPANDED_FRAMEWORK = "OskarPotocki.VanillaFactionsExpanded.Core";
}
@@ -20,10 +20,10 @@ public static class PerformanceOptimizer
public static string[] BlockedPatchNames { get; }
=
{
[
"PerformanceOptimizer.Optimization_FasterGetCompReplacement",
"PerformanceOptimizer.Optimization_IdeoUtility_GetStyleDominance"
};
];
static PerformanceOptimizer()
{
@@ -0,0 +1,32 @@
// 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 Types
{
public static class RealRuins
{
public static Type? POIWorldObject = Reflection.Type("RealRuins", "RealRuins.RealRuinsPOIWorldObject");
}
public static class VFEAncients
{
public static Type? RecipeExtensionMend = Reflection.Type("VFEAncients", "VFEAncients.RecipeExtension_Mend");
}
public static class PerformanceAnalyzer
{
public static Type?
ModBase = Reflection.Type("PerformanceAnalyzer", "Analyzer.Modbase"),
ProfilingEntry = Reflection.Type("PerformanceAnalyzer", "Analyzer.Profiling.Entry"),
Window_Analyzer = Reflection.Type("PerformanceAnalyzer", "Analyzer.Window_Analyzer");
}
public static class LWM
{
public static Type? CompProperties = Reflection.Type("LWM.DeepStorage.Properties");
}
}
@@ -3,18 +3,20 @@
// 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/.
#if fixed // with commit from Jul 3, 2023
namespace PerformanceFish.ModCompatibility;
public class VanillaExpandedFixes : ClassWithFishPatches
public sealed class VanillaExpandedFixes : ClassWithFishPatches
{
public class ExpandableGraphicData : FishPatch
public sealed class ExpandableGraphicData : FishPatch
{
public override string? Description { get; }
= "Fixes the LoadAllFiles method in Vanilla Expanded Framework's ExpandableGraphicData to not scan through "
+ "all texture folders of all mods for every graphic and instead just use cached files the game already "
+ "loaded. Improves load times and prevents dds related errors.";
public override bool Enabled => ActiveMods.VanillaExpandedFramework;
public override bool Enabled => ActiveMods.VanillaExpandedFramework && base.Enabled;
public override MethodBase TargetMethodInfo { get; }
= AccessTools.Method("VFECore.ExpandableGraphicData:LoadAllFiles");
@@ -27,20 +29,20 @@ public class VanillaExpandedFixes : ClassWithFishPatches
var paths = new List<string>();
var mods = LoadedModManager.RunningModsListForReading;
var count = mods.Count;
var prefix = !folderPath.NullOrEmpty() && folderPath![^1] == '/'
? folderPath
: folderPath + '/';
for (var i = 0; i < count; i++)
{
var contentListTrie = mods[i].GetContentHolder<Texture2D>().contentListTrie;
var prefix = !folderPath.NullOrEmpty() && folderPath![^1] == '/'
? folderPath
: folderPath + '/';
foreach (var path in contentListTrie.GetByPrefix(prefix))
foreach (var path in mods[i].GetContentHolder<Texture2D>().contentListTrie.GetByPrefix(prefix))
paths.Add(path);
}
return paths;
}
}
}
}
#endif