public VEE(ModContentPack mod) { var methodsForAll = new[] { "VEE.HeddifComp_MightJoin:CompPostTick", "VEE.HuntingParty:TryExecuteWorker", // These 4 methods initialize System.Random, but don't use them in any way whatsoever. //"VEE.PurpleEvents.GlobalWarming:ChangeBiomes", //"VEE.PurpleEvents.GlobalWarming:ChangeTileTemp", //"VEE.PurpleEvents.IceAge:ChangeBiomes", //"VEE.PurpleEvents.IceAge:ChangeTileTemp", "VEE.PurpleEvents.PsychicBloom:Init", "VEE.RegularEvents.ApparelPod:TryExecuteWorker", "VEE.RegularEvents.CaravanAnimalWI:GenerateGroup", "VEE.RegularEvents.MeteoriteShower:TryExecuteWorker", "VEE.RegularEvents.WeaponPod:TryExecuteWorker", }; PatchingUtilities.PatchSystemRand(methodsForAll, false); // This method only calls other methods that use RNG calls PatchingUtilities.PatchPushPopRand("VEE.RegularEvents.EarthQuake:TryExecuteWorker"); // Only patch System.Random out, as this methods is only called by other ones PatchingUtilities.PatchSystemRand("VEE.RegularEvents.EarthQuake:DamageInRadius", false); // Unity RNG PatchingUtilities.PatchUnityRand("VEE.Shuttle:Tick"); LongEventHandler.ExecuteWhenFinished(LatePatch); }
public AnimaObelisk(ModContentPack mod) { var type = AccessTools.TypeByName("PsyObelisk.Things.ThingComp_PsyObelisk"); PatchingUtilities.PatchUnityRand(AccessTools.Method(type, "GlowAround"), false); var syncMethods = MpCompat.RegisterLambdaMethod(type, "CompGetGizmosExtra", Enumerable.Range(0, 8).ToArray()); // 0 to 7 syncMethods.Skip(2).SetDebugOnly(); }
public Reunion(ModContentPack mod) { var methods = new[] { "Kyrun.Reunion.GameComponent:GetRandomAllyForSpawning", "Kyrun.Reunion.GameComponent:TryScheduleNextEvent", "Kyrun.Reunion.GameComponent:DecideAndDoEvent", }; PatchingUtilities.PatchUnityRand(methods); }
public VanillaFactionsSettlers(ModContentPack mod) { var type = AccessTools.TypeByName("VFE_Settlers.Utilities.UtilityEvent"); // Protection fee event MP.RegisterSyncDialogNodeTree(type, "ProtectionFee"); // Caravan gizmo - turn in wanted criminal to settlement MP.RegisterSyncDelegate(type, "<>c__DisplayClass8_0", "<CommandTurnInWanted>b__0"); // Toggle mode MpCompat.RegisterSyncMethodByIndex(AccessTools.TypeByName("Warmup.CompWarmUpReduction"), "<CompGetGizmosExtra>", 1); // Five fingers fillet table PatchingUtilities.PatchUnityRand("VFE_Settlers.JobGivers.JobDriver_PlayFiveFingerFillet:WatchTickAction", false); }
public VanillaFactionsSettlers(ModContentPack mod) { var type = AccessTools.TypeByName("VFE_Settlers.Utilities.UtilityEvent"); // Protection fee event NodeTreeDialogSync.EnableNodeTreeDialogSync(); MpCompat.harmony.Patch(AccessTools.Method(type, "ProtectionFee"), prefix: NodeTreeDialogSync.HarmonyMethodMarkDialogAsOpen); // Caravan gizmo - turn in wanted criminal to settlement MP.RegisterSyncDelegate(type, "<>c__DisplayClass8_0", "<CommandTurnInWanted>b__0"); // Dev mode set progress to 1 MpCompat.RegisterSyncMethodByIndex(AccessTools.TypeByName("VFE_Settlers.Buildings.Building_ChemshineBarrel"), "<GetGizmos>", 0); // Toggle mode MpCompat.RegisterSyncMethodByIndex(AccessTools.TypeByName("VanillaFactionsExpandedSettlers.CompWarmUpReduction"), "<CompGetGizmosExtra>", 1); // Five fingers fillet table PatchingUtilities.PatchUnityRand("VFE_Settlers.JobGivers.JobDriver_PlayFiveFingerFillet:WatchTickAction", false); }
public CommonSense(ModContentPack mod) { var type = AccessTools.TypeByName("CommonSense.CompUnloadChecker"); // We need to make a sync worker for this Comp, as it is initialized dynamically and might not exists at the time MP.RegisterSyncWorker <ThingComp>(SyncComp, type); shouldUnloadSyncField = MP.RegisterSyncField(AccessTools.Field(type, "ShouldUnload")); // The GetChecker method either gets an existing, or creates a new comp getCompUnlockerCheckerMethod = AccessTools.Method(type, "GetChecker"); // Watch unload bool changes MpCompat.harmony.Patch(AccessTools.Method("CommonSense.Utility:DrawThingRow"), prefix: new HarmonyMethod(typeof(CommonSense), nameof(CommonSensePatchPrefix)), postfix: new HarmonyMethod(typeof(CommonSense), nameof(CommonSensePatchPostix))); // RNG Patch PatchingUtilities.PatchUnityRand("CommonSense.JobGiver_Wander_TryGiveJob_CommonSensePatch:Postfix", false); }
public VanillaPowerExpanded(ModContentPack mod) { Type type; // Gizmos // Debug fill/empty { type = AccessTools.TypeByName("GasNetwork.CompGasStorage"); // Both these methods are calling (basically) the same method, // but that method also has other callers that don't need syncing MpCompat.RegisterSyncMethodsByIndex(type, "<CompGetGizmosExtra>", 0, 1).Do(m => m.SetDebugOnly()); } // Order to or cancel plugging the hole (method names shared by both types) { var types = new[] { "VanillaPowerExpanded.Building_ChemfuelPond", "VanillaPowerExpanded.Building_GasGeyser", }; foreach (var typeName in types) { type = AccessTools.TypeByName(typeName); MP.RegisterSyncMethod(type, "SetHoleForPlugging"); MP.RegisterSyncMethod(type, "CancelHoleForPlugging"); } } // RNG Fix { var methods = new[] { "VanillaPowerExpanded.Building_SmallBattery:Tick", "VanillaPowerExpanded.Building_SmallBattery:PostApplyDamage", "VanillaPowerExpanded.WeatherEvent_CustomLightningStrike:FireEvent", "VanillaPowerExpanded.MapComponentExtender:doMapSpawns", "VanillaPowerExpanded.CompPlantHarmRadiusIfBroken:CompTick", // HarmRandomPlantInRadius is only called by CompPlantHarmRadiusIfBroken:CompTick, no need for patching // CompPowerPlantNuclear:AffectCell is only calling a seeded random "VanillaPowerExpanded.IntermittentGasSprayer:SteamSprayerTick", // IntermittentGasSprayer - NewBaseAirPuff is only called by ThrowAirPuffUp which is called by SteamSprayerTick, no need for patching // Building_GasGeyser:StartSpray is assigned to IntermittentGasSprayer:startSprayCallback, which is called from SteamSprayerTick "GasNetwork.GasNet:GasNetTick", // PipeNetGrid pushes and pops all Rand calls, no need to patch // CompPowerAdvancedWater:RebuildCache is only calling a seeded random }; // These methods are loading resources in their .ctor, must be patched later var methodsForLater = new[] { "VanillaPowerExpanded.CompPowerAdvancedWater:PostSpawnSetup", "VanillaPowerExpanded.CompPowerAdvancedWind:PostSpawnSetup", }; PatchingUtilities.PatchPushPopRand(methods); LongEventHandler.ExecuteWhenFinished(() => PatchingUtilities.PatchPushPopRand(methodsForLater)); // Wind map comp windDirectionField = AccessTools.Field(AccessTools.TypeByName("GasNetwork.MapComponent_WindDirection"), "windDirection"); PatchingUtilities.PatchUnityRand("GasNetwork.MapComponent_WindDirection:MapGenerated"); MpCompat.harmony.Patch(AccessTools.Method("GasNetwork.MapComponent_WindDirection:MapComponentTick"), prefix: new HarmonyMethod(typeof(VanillaPowerExpanded), nameof(ReplaceWindMapComponentTick))); } }