Lots of new optimizations utilizing prepatcher
To start, this mod now requires Prepatcher and Fishery. New optimizations include: gene ticking improvements, world object improvements, hediff optimizations, world pawn gc optimizations, better mothballing, dds support, ContentFinder caching, additions and changes to reflection caching, as well as various other additions. Multiplayer support has been improved too, but should be considered highly experimental. The WorkGiver_DoBill bug is fixed in this build. Multiple patches aiming to improve RimWorld's load time have been added too.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2022 bradson
|
||||
// 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/.
|
||||
@@ -8,7 +8,8 @@ public class GenDrawPatches : ClassWithFishPatches
|
||||
{
|
||||
public class DrawMeshNowOrLater_Patch : FishPatch
|
||||
{
|
||||
public override Delegate TargetMethodGroup => (Action<Mesh, Vector3, Quaternion, Material, bool>)GenDraw.DrawMeshNowOrLater;
|
||||
public override Delegate TargetMethodGroup { get; }
|
||||
= (Action<Mesh, Vector3, Quaternion, Material, bool>)GenDraw.DrawMeshNowOrLater;
|
||||
|
||||
public static void Replacement(Mesh mesh, Vector3 loc, Quaternion quat, Material mat, bool drawNow)
|
||||
{
|
||||
@@ -27,7 +28,8 @@ public class GenDrawPatches : ClassWithFishPatches
|
||||
|
||||
public class DrawMeshNowOrLaterWithMatrix_Patch : FishPatch
|
||||
{
|
||||
public override Delegate TargetMethodGroup => (Action<Mesh, Matrix4x4, Material, bool>)GenDraw.DrawMeshNowOrLater;
|
||||
public override Delegate TargetMethodGroup { get; }
|
||||
= (Action<Mesh, Matrix4x4, Material, bool>)GenDraw.DrawMeshNowOrLater;
|
||||
|
||||
public static void Replacement(Mesh mesh, Matrix4x4 matrix, Material mat, bool drawNow)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2022 bradson
|
||||
// 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/.
|
||||
@@ -8,7 +8,8 @@ public class GraphicPatches : ClassWithFishPatches
|
||||
{
|
||||
public class DrawMeshInt_Patch : FishPatch
|
||||
{
|
||||
public override MethodBase TargetMethodInfo => AccessTools.DeclaredMethod(typeof(Graphic), nameof(Graphic.DrawMeshInt));
|
||||
public override MethodBase TargetMethodInfo { get; }
|
||||
= AccessTools.DeclaredMethod(typeof(Graphic), nameof(Graphic.DrawMeshInt));
|
||||
|
||||
public static void Replacement(Graphic __instance, Mesh mesh, Vector3 loc, Quaternion quat, Material mat)
|
||||
{
|
||||
@@ -18,9 +19,11 @@ public class GraphicPatches : ClassWithFishPatches
|
||||
|
||||
public class Shadow_DrawWorker_Patch : FishPatch
|
||||
{
|
||||
public override MethodBase TargetMethodInfo => AccessTools.DeclaredMethod(typeof(Graphic_Shadow), nameof(Graphic_Shadow.DrawWorker));
|
||||
public override MethodBase TargetMethodInfo { get; }
|
||||
= AccessTools.DeclaredMethod(typeof(Graphic_Shadow), nameof(Graphic_Shadow.DrawWorker));
|
||||
|
||||
public static void Replacement(Graphic_Shadow __instance, Vector3 loc, Rot4 rot, ThingDef thingDef, Thing thing, float extraRotation)
|
||||
public static void Replacement(Graphic_Shadow __instance, Vector3 loc, Rot4 rot, ThingDef? thingDef, Thing thing,
|
||||
float extraRotation)
|
||||
{
|
||||
if (__instance.shadowMesh is null
|
||||
|| thingDef is null
|
||||
|
||||
@@ -1,16 +1,20 @@
|
||||
// Copyright (c) 2022 bradson
|
||||
// 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.Rendering;
|
||||
public class PawnCacheRendererPatches : ClassWithFishPatches // The PawnCacheRenderer's Camera.Render() call has a considerable performance impact despite only being used for rendering of single pawns. These are failed attempts at lowering its impact.
|
||||
|
||||
public class PawnCacheRendererPatches : ClassWithFishPatches
|
||||
// The PawnCacheRenderer's Camera.Render() call has a considerable performance impact despite only being used for
|
||||
// rendering of single pawns. These are failed attempts at lowering its impact.
|
||||
{
|
||||
private static bool _optimizeCameraEnabled;
|
||||
|
||||
public class OnPostRender_Patch : FishPatch
|
||||
{
|
||||
public override MethodBase TargetMethodInfo => AccessTools.DeclaredMethod(typeof(PawnCacheRenderer), nameof(PawnCacheRenderer.OnPostRender));
|
||||
public override MethodBase TargetMethodInfo
|
||||
=> AccessTools.DeclaredMethod(typeof(PawnCacheRenderer), nameof(PawnCacheRenderer.OnPostRender));
|
||||
|
||||
public static CodeInstructions Transpiler(CodeInstructions codes)
|
||||
=> Reflection.MakeReplacementCall(OnPostRender);
|
||||
@@ -18,7 +22,10 @@ public class PawnCacheRendererPatches : ClassWithFishPatches // The PawnCacheR
|
||||
public static void OnPostRender(PawnCacheRenderer __instance)
|
||||
{
|
||||
Find.PawnCacheCamera.cullingMask = DefaultCullingMask;
|
||||
__instance.pawn.Drawer.renderer.RenderCache(__instance.rotation, __instance.angle, __instance.positionOffset, __instance.renderHead, __instance.renderBody, __instance.portrait, __instance.renderHeadgear, __instance.renderClothes, __instance.overrideApparelColor, __instance.overrideHairColor, __instance.stylingStation);
|
||||
__instance.pawn.Drawer.renderer.RenderCache(__instance.rotation, __instance.angle,
|
||||
__instance.positionOffset, __instance.renderHead, __instance.renderBody, __instance.portrait,
|
||||
__instance.renderHeadgear, __instance.renderClothes, __instance.overrideApparelColor,
|
||||
__instance.overrideHairColor, __instance.stylingStation);
|
||||
Find.PawnCacheCamera.cullingMask = 16; // random
|
||||
}
|
||||
|
||||
@@ -28,7 +35,8 @@ public class PawnCacheRendererPatches : ClassWithFishPatches // The PawnCacheR
|
||||
|
||||
public class RenderPawn_Patch : FishPatch
|
||||
{
|
||||
public override MethodBase TargetMethodInfo => AccessTools.DeclaredMethod(typeof(PawnCacheRenderer), nameof(PawnCacheRenderer.RenderPawn));
|
||||
public override MethodBase TargetMethodInfo
|
||||
=> AccessTools.DeclaredMethod(typeof(PawnCacheRenderer), nameof(PawnCacheRenderer.RenderPawn));
|
||||
|
||||
public static void Prefix(ref Vector3 cameraOffset, ref Vector3 positionOffset)
|
||||
{
|
||||
@@ -58,8 +66,12 @@ public class PawnCacheRendererPatches : ClassWithFishPatches // The PawnCacheR
|
||||
cacheCamera.renderingPath = _optimizeCameraEnabled ? RenderingPath.VertexLit : DefaultCacheCameraRenderingPath;
|
||||
}
|
||||
|
||||
private static RenderingPath DefaultCameraRenderingPath => _defaultCameraRenderingPath ??= Find.Camera.renderingPath;
|
||||
private static RenderingPath DefaultCacheCameraRenderingPath => _defaultCacheCameraRenderingPath ??= Find.PawnCacheCamera.renderingPath;
|
||||
private static RenderingPath DefaultCameraRenderingPath
|
||||
=> _defaultCameraRenderingPath ??= Find.Camera.renderingPath;
|
||||
|
||||
private static RenderingPath DefaultCacheCameraRenderingPath
|
||||
=> _defaultCacheCameraRenderingPath ??= Find.PawnCacheCamera.renderingPath;
|
||||
|
||||
private static RenderingPath? _defaultCameraRenderingPath;
|
||||
private static RenderingPath? _defaultCacheCameraRenderingPath;
|
||||
}*/
|
||||
Reference in New Issue
Block a user