Skip to content

Commit

Permalink
Compat for Vanilla Recycling Expanded (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
SokyranTheDragon authored Feb 8, 2024
1 parent f6d2048 commit f310845
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Source/Mods/VanillaRecyclingExpanded.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using HarmonyLib;
using Multiplayer.API;
using RimWorld;
using Verse;

namespace Multiplayer.Compat;

/// <summary>Vanilla Recycling Expanded by OskarPotocki, Sarg Bjornson, xrushha</summary>
[MpCompatFor("VanillaExpanded.Recycling")]
public class VanillaRecyclingExpanded
{
public VanillaRecyclingExpanded(ModContentPack mod)
{
MpCompatPatchLoader.LoadPatch(this);

var type = AccessTools.TypeByName("VanillaRecyclingExpanded.CompBiopackDissolution");
// Dev: Single dissolution event (0), dissolution events until destroyed (1), +25% dissolution progress
MpCompat.RegisterLambdaMethod(type, nameof(ThingComp.CompGetGizmosExtra), 0, 1, 2).SetDebugOnly();
// Dev: Set next dissolve time
MP.RegisterSyncDelegateLambda(type, nameof(ThingComp.CompGetGizmosExtra), 4).SetDebugOnly();

type = AccessTools.TypeByName("VanillaRecyclingExpanded.CompSuperSimpleProcessor");
MP.RegisterSyncMethod(type, "EjectContents");
// In interface only called as dev mode command
MP.RegisterSyncMethod(type, "DoAtomize").SetDebugOnly();
// Toggle auto load
MP.RegisterSyncMethodLambda(type, nameof(ThingComp.CompGetGizmosExtra), 1);
// Dev: Set next processing time
MP.RegisterSyncDelegateLambda(type, nameof(ThingComp.CompGetGizmosExtra), 3).SetDebugOnly();
}

// Stop methods from running (most likely after syncing) when it would cause errors or other issues.
[MpCompatPrefix("VanillaRecyclingExpanded.CompBiopackDissolution", "TriggerDissolutionEvent")]
private static bool PreDoAtomize(CompThingContainer __instance) => __instance.ContainedThing is { stackCount: > 0 };
}

0 comments on commit f310845

Please sign in to comment.