public AlphaBehavioursAndEvents(ModContentPack mod) { //RNG Fix { var rngFixConstructors = new[] { "AlphaBehavioursAndEvents.DeathActionWorker_ExplodeAndSpawnEggs", "AlphaBehavioursAndEvents.Hediff_Crushing", // Ocular plant conversion "AlphaBehavioursAndEvents.CompAbilityOcularConversion", "AlphaBehavioursAndEvents.Gas_Ocular", }; PatchingUtilities.PatchSystemRandCtor(rngFixConstructors, false); var rngFixMethods = new[] //System.Random fixes { "AlphaBehavioursAndEvents.Hediff_Crushing:RandomFilthGenerator", // Ocular plant conversion "AlphaBehavioursAndEvents.CompAbilityOcularConversion:Apply", "AlphaBehavioursAndEvents.Gas_Ocular:Tick", }; PatchingUtilities.PatchPushPopRand(rngFixMethods); } }
public AlphaBehavioursAndEvents(ModContentPack mod) { //RNG Fix { var rngFixConstructors = new[] { "AlphaBehavioursAndEvents.CompAnimalProduct", "AlphaBehavioursAndEvents.CompExploder", "AlphaBehavioursAndEvents.CompGasProducer", "AlphaBehavioursAndEvents.CompInitialHediff", "AlphaBehavioursAndEvents.Gas_Ocular", "AlphaBehavioursAndEvents.Hediff_Crushing", //"NewAlphaAnimalSubproducts.CompAnimalProduct ", // System.Random initialized, but not used }; PatchingUtilities.PatchSystemRandCtor(rngFixConstructors, false); var rngFixMethods = new[] //System.Random fixes { "AlphaBehavioursAndEvents.CompGasProducer:CompTick", "AlphaBehavioursAndEvents.CompAnimalProduct:InformGathered", "AlphaBehavioursAndEvents.CompInitialHediff:CompTickRare", "AlphaBehavioursAndEvents.Gas_Ocular:Tick", "AlphaBehavioursAndEvents.Hediff_Crushing:RandomFilthGenerator", "AlphaBehavioursAndEvents.CompExploder:wickInitializer", }; PatchingUtilities.PatchPushPopRand(rngFixMethods); PatchingUtilities.PatchSystemRand("AlphaBehavioursAndEvents.DamageWorker_ExtraInfecter:ApplySpecialEffectsToPart"); } }
public VanillaStorytellersWinstonWaves(ModContentPack mod) { // RNG { PatchingUtilities.PatchSystemRandCtor("VSEWW.Window_ChooseReward", false); } // Dialogs { var type = chooseRewardDialogType = AccessTools.TypeByName("VSEWW.Window_ChooseReward"); choosenRewardField = AccessTools.FieldRefAccess <Def>(type, "choosenReward"); type = AccessTools.TypeByName("VSEWW.RewardDef"); MpCompat.harmony.Patch(AccessTools.Method(type, "DrawCard"), transpiler: new HarmonyMethod(typeof(VanillaStorytellersWinstonWaves), nameof(ReplaceButton))); MP.RegisterSyncMethod(typeof(VanillaStorytellersWinstonWaves), nameof(SyncedChooseReward)); // The window is always visible and its default position covers MP chat button // This patch will move it under the button (if MP is on), // especially considering that it'll move up on autosave/joinstate creation type = AccessTools.TypeByName("VSEWW.Window_WaveCounter"); MpCompat.harmony.Patch(AccessTools.Method(type, "SetInitialSizeAndPosition"), postfix: new HarmonyMethod(typeof(VanillaStorytellersWinstonWaves), nameof(PostSetInitialSizeAndPosition))); MP.RegisterPauseLock(PauseIfDialogOpen); } LongEventHandler.ExecuteWhenFinished(LatePatch); }
public VanillaIdeologyDryads(ModContentPack mod) { // RNG PatchingUtilities.PatchSystemRandCtor("VanillaIdeologyExpanded_Dryads.HediffComp_PeriodicWounds"); // Gizmos MP.RegisterSyncMethod(AccessTools.TypeByName("VanillaIdeologyExpanded_Dryads.CompPawnMerge"), "SetDryadAwakenPod"); MpCompat.RegisterLambdaMethod("VanillaIdeologyExpanded_Dryads.CompSpawnAwakened", "CompGetGizmosExtra", 0).SetDebugOnly(); }
public VanillaGeneticsExpanded(ModContentPack mod) { // Sync worker { var type = AccessTools.TypeByName("GeneticRim.Command_SetGenomeList"); setGenomeListMap = AccessTools.FieldRefAccess <Map>(type, "map"); setGenomeListBuilding = AccessTools.FieldRefAccess <Building>(type, "building"); MP.RegisterSyncWorker <Command>(SyncCommand, type, shouldConstruct: true); } // RNG { var constructors = new[] { "GeneticRim.CompExploder", "GeneticRim.HediffComp_PeriodicWounds", }; PatchingUtilities.PatchSystemRandCtor(constructors, false); } // Gizmos { // Archocentipide former - start and (dev) finish gizmos MpCompat.RegisterLambdaMethod("GeneticRim.Building_ArchocentipedeFormer", "GetGizmos", 0, 1)[1].SetDebugOnly(); // Archowomb - awaken confirmation and (dev) finish gizmo MpCompat.RegisterLambdaMethod("GeneticRim.Building_ArchoWomb", "GetGizmos", 1, 2)[1].SetDebugOnly(); // Mechahybridizer - (dev) finish gizmo MpCompat.RegisterLambdaMethod("GeneticRim.Building_Mechahybridizer", "GetGizmos", 0).SetDebugOnly(); // Age related disease dev gizmo MpCompat.RegisterLambdaMethod("GeneticRim.CompApplyAgeDiseases", "GetGizmos", 0).SetDebugOnly(); // DNA storage bank and mechahybridizer gizmos var type = AccessTools.TypeByName("GeneticRim.ArchotechExtractableAnimals_MapComponent"); MP.RegisterSyncMethod(type, "AddAnimalToCarry"); MP.RegisterSyncMethod(type, "AddParagonToCarry"); // DNA storage bank gizmo MpCompat.RegisterLambdaDelegate("GeneticRim.Command_SetGenomeList", "ProcessInput", 2); } // Float menu { MpCompat.RegisterLambdaDelegate("GeneticRim.CompArchotechGrowthCell", "CompFloatMenuOptions", 0); } LongEventHandler.ExecuteWhenFinished(LatePatch); }
public VanillaFishingExpanded(ModContentPack mod) { // RNG fix { PatchingUtilities.PatchSystemRandCtor("VCE_Fishing.JobDriver_Fish", false); PatchingUtilities.PatchPushPopRand("VCE_Fishing.JobDriver_Fish:SelectFishToCatch"); } // Gizmo (select fish size to catch) { commandType = AccessTools.TypeByName("VCE_Fishing.Command_SetFishList"); mapField = AccessTools.Field(commandType, "map"); fishingZoneField = AccessTools.Field(commandType, "zone"); MpCompat.RegisterSyncMethodsByIndex(commandType, "<ProcessInput>", Enumerable.Range(0, 3).ToArray()); MP.RegisterSyncWorker <Command>(SyncFishingZoneChange, commandType, shouldConstruct: false); } }
public VanillaAnimalsCaves(ModContentPack mod) { // RNG { var methods = new[] { "VAECaves.Building_SpiderEggs:Tick", "VAECaves.DamageWorker_TwoArmSlam:Apply", "VAECaves.IncidentWorker_Hulk:CanFireNowSub", "VAECaves.JobDriver_CreateEggs:<MakeNewToils>b__1_0", }; PatchingUtilities.PatchSystemRand(methods, false); PatchingUtilities.PatchSystemRandCtor("VAECaves.Hediff_WallBreaker", false); } // Gizmos { MpCompat.RegisterLambdaMethod("VAECaves.Building_Cocoon", "GetGizmos", 0); MpCompat.RegisterLambdaMethod("VAECaves.CompConditionalSpawner", "CompGetGizmosExtra", 0).SetDebugOnly(); } }
public VanillaFactionsInsectoid(ModContentPack mod) { // Gizmos { // These two methods aren't patched, but supposedly the teleporter isn't included in the mod right now due to being bugged // Working on them could be problematic, as it seems that they reimplement (or at least used to reimplement) vanilla caravan forming screen completely from scratch // VFEI.Comps.ItemComps.CompArchotechTeleporter // VFEI.Comps.ItemComps.CompCustomTransporter var type = AccessTools.TypeByName("InsectoidBioengineering.Building_BioengineeringIncubator"); MpCompat.RegisterSyncMethodsByIndex(type, "<GetGizmos>", 0, 1, 2, 3); // Keep an eye on this in the future, seems like something the devs might combine into a single class at some point foreach (var geneNumber in new[] { "First", "Second", "Third" }) { type = AccessTools.TypeByName($"InsectoidBioengineering.Command_Set{geneNumber}GenomeList"); MP.RegisterSyncWorker <Command>(SyncSetGenomeCommand, type, shouldConstruct: true); MP.RegisterSyncMethod(AccessTools.Method(type, $"TryInsert{geneNumber}Genome")); } } // RNG { var constructors = new[] { "InsectoidBioengineering.Building_BioengineeringIncubator", //"VFEI.CompFilthProducer", }; PatchingUtilities.PatchSystemRandCtor(constructors, false); var methods = new[] { "VFEI.CompTargetEffect_Tame:RandomNumber", }; PatchingUtilities.PatchSystemRand(methods); } }
public GeneticRimCompat(ModContentPack mod) { Type type; // Several Gizmos { type = AccessTools.TypeByName("DraftingPatcher.Pawn_GetGizmos_Patch"); string[] methods = { "<AddGizmo>b__0", "<AddGizmo>b__1", "<AddGizmo>b__10", "<AddGizmo>b__11", "<AddGizmo>b__12", "<AddGizmo>b__13", "<AddGizmo>b__14", "<AddGizmo>b__15", "<AddGizmo>b__16", "<AddGizmo>b__17", "<AddGizmo>b__3", "<AddGizmo>b__5", "<AddGizmo>b__7", "<AddGizmo>b__8", "<AddGizmo>b__9", }; foreach (string method in methods) { MP.RegisterSyncDelegate(type, "<>c__DisplayClass0_0", method); } } // ArchotechShip startup { MP.RegisterSyncMethod(AccessTools.Method("NewMachinery.ArchotechUtility:StartupHibernatingParts")); MP.RegisterSyncMethod(AccessTools.Method("NewMachinery.ArchotechCountdown:InitiateCountdown")); } { type = AccessTools.TypeByName("NewMachinery.ArchotechCountdown"); string[] methods = { "InitiateCountdown", "CancelCountdown", "CountdownEnded" }; foreach (string method in methods) { MP.RegisterSyncMethod(AccessTools.Method(type, method)); } } // Genepod { type = AccessTools.TypeByName("NewMachinery.Building_NewGenePod"); MP.RegisterSyncMethod(type, "<GetGizmos>b__20_0"); MP.RegisterSyncMethod(type, "<GetGizmos>b__20_1"); } // Commands { MP.RegisterSyncMethod(AccessTools.Method("NewMachinery.Command_SetGene2List:ProcessInput")); MP.RegisterSyncMethod(AccessTools.Method("NewMachinery.Command_SetGeneList:ProcessInput")); } // RNG patching { string[] constructorsToPatch = { "NewHatcher.CompHatcherRandomizer", "NewHatcher.CompIncubator", "NewHatcher.CompRecombinator", "NewHatcher.CompRecombinatorSerum", }; PatchingUtilities.PatchSystemRandCtor(constructorsToPatch, false); string[] methodsWithRand = { "NewHatcher.CompHatcherRandomizer:Hatch", "NewHatcher.CompIncubator:Hatch", "NewHatcher.CompRecombinator:Hatch", "NewHatcher.CompRecombinator:RecombinateAgain", "NewHatcher.CompRecombinatorSerum:Hatch", }; PatchingUtilities.PatchPushPopRand(methodsWithRand); } }
public VanillaExpandedFramework(ModContentPack mod) { // ItemProcessor { var type = AccessTools.TypeByName("ItemProcessor.Building_ItemProcessor"); // _1, _5 and _7 are used to check if gizmo should be enabled, so we don't sync them MpCompat.RegisterSyncMethodsByIndex(type, "<GetGizmos>", 0, 2, 3, 4, 6, 8, 9, 10); type = AccessTools.TypeByName("ItemProcessor.Command_SetQualityList"); MP.RegisterSyncWorker <Command>(SyncCommandWithBuilding, type, shouldConstruct: true); MpCompat.RegisterSyncMethodsByIndex(type, "<ProcessInput>", Enumerable.Range(0, 8).ToArray()); type = AccessTools.TypeByName("ItemProcessor.Command_SetOutputList"); MP.RegisterSyncWorker <Command>(SyncCommandWithBuilding, type, shouldConstruct: true); MP.RegisterSyncMethod(type, "TryConfigureIngredientsByOutput"); // Keep an eye on this in the future, seems like something the devs could combine into a single class at some point foreach (var ingredientNumber in new[] { "First", "Second", "Third", "Fourth" }) { type = AccessTools.TypeByName($"ItemProcessor.Command_Set{ingredientNumber}ItemList"); MP.RegisterSyncWorker <Command>(SyncSetIngredientCommand, type, shouldConstruct: true); MP.RegisterSyncMethod(type, $"TryInsert{ingredientNumber}Thing"); MpCompat.RegisterSyncMethodsByIndex(type, "<ProcessInput>", 0); } } // Vanilla Cooking Expanded { // AddHediff desyncs with Arbiter, but seems fine without it PatchingUtilities.PatchPushPopRand("VanillaCookingExpanded.Thought_Hediff:MoodOffset"); } // VFE Core { var type = AccessTools.TypeByName("VFECore.CompPawnDependsOn"); MpCompat.RegisterSyncMethodByIndex(type, "<CompGetGizmosExtra>", 0).SetDebugOnly(); } // Vanilla Furniture Expanded { var type = AccessTools.TypeByName("VanillaFurnitureExpanded.CompConfigurableSpawner"); MpCompat.RegisterSyncMethodByIndex(type, "<CompGetGizmosExtra>", 0).SetDebugOnly(); type = AccessTools.TypeByName("VanillaFurnitureExpanded.Command_SetItemsToSpawn"); MP.RegisterSyncDelegate(type, "<>c__DisplayClass2_0", "<ProcessInput>b__1"); type = AccessTools.TypeByName("VanillaFurnitureExpanded.CompRockSpawner"); MpCompat.RegisterSyncMethodByIndex(type, "<CompGetGizmosExtra>", 0); type = AccessTools.TypeByName("VanillaFurnitureExpanded.Command_SetStoneType"); setStoneBuildingField = AccessTools.Field(type, "building"); MpCompat.RegisterSyncMethodByIndex(type, "<ProcessInput>", 0); MP.RegisterSyncWorker <Command>(SyncSetStoneTypeCommand, type, shouldConstruct: true); MP.RegisterSyncDelegate(type, "<>c__DisplayClass2_0", "<ProcessInput>b__1"); } // Vanilla Faction Mechanoids { var type = AccessTools.TypeByName("VFE.Mechanoids.CompMachineChargingStation"); MP.RegisterSyncDelegate(type, "<>c", "<CompGetGizmosExtra>b__21_1", Array.Empty <string>()).SetContext(SyncContext.MapSelected); MP.RegisterSyncDelegate(type, "<>c", "<CompGetGizmosExtra>b__21_6", Array.Empty <string>()).SetContext(SyncContext.MapSelected); MP.RegisterSyncDelegate(type, "<>c__DisplayClass21_0", "<CompGetGizmosExtra>b__4"); } // AnimalBehaviours { // RNG PatchingUtilities.PatchSystemRand("AnimalBehaviours.DamageWorker_ExtraInfecter:ApplySpecialEffectsToPart", false); PatchingUtilities.PatchSystemRandCtor(new[] { "AnimalBehaviours.CompAnimalProduct", "AnimalBehaviours.CompGasProducer" }, false); // Gizmos // Might not work, as I could not find a mod that uses this to test this var type = AccessTools.TypeByName("AnimalBehaviours.CompDestroyThisItem"); MP.RegisterSyncMethod(type, "SetObjectForDestruction"); MP.RegisterSyncMethod(type, "CancelObjectForDestruction"); } // MVCF (Multi Verb Combat Framework) { var type = AccessTools.TypeByName("MVCF.WorldComponent_MVCF"); mvcfGetWorldCompMethod = AccessTools.Method(type, "GetComp"); mvcfAllManagersListField = AccessTools.Field(type, "allManagers"); mvcfManagersTableField = AccessTools.Field(type, "managers"); MP.RegisterSyncMethod(typeof(VanillaExpandedFramework), nameof(SyncedInitVerbManager)); MpCompat.harmony.Patch(AccessTools.Method(type, "GetManagerFor"), prefix: new HarmonyMethod(typeof(VanillaExpandedFramework), nameof(GetManagerForPrefix))); type = AccessTools.TypeByName("MVCF.VerbManager"); MP.RegisterSyncWorker <object>(SyncVerbManager, type, isImplicit: true); mvcfVerbManagerCtor = AccessTools.Constructor(type); mvcfInitializeManagerMethod = AccessTools.Method(type, "Initialize"); mvcfPawnGetter = AccessTools.PropertyGetter(type, "Pawn"); mvcfVerbsField = AccessTools.Field(type, "verbs"); var weakReferenceType = typeof(System.WeakReference <>).MakeGenericType(new[] { type }); weakReferenceCtor = AccessTools.FirstConstructor(weakReferenceType, ctor => ctor.GetParameters().Count() == 1); var conditionalWeakTableType = typeof(System.Runtime.CompilerServices.ConditionalWeakTable <,>).MakeGenericType(new[] { typeof(Pawn), type }); conditionalWeakTableAddMethod = AccessTools.Method(conditionalWeakTableType, "Add"); conditionalWeakTableTryGetValueMethod = AccessTools.Method(conditionalWeakTableType, "TryGetValue"); type = AccessTools.TypeByName("MVCF.ManagedVerb"); mvcfManagerVerbManagerField = AccessTools.Field(type, "man"); MP.RegisterSyncWorker <object>(SyncManagedVerb, type, isImplicit: true); // Seems like selecting the Thing that holds the verb inits some stuff, so we need to set the context MP.RegisterSyncMethod(type, "Toggle"); type = AccessTools.TypeByName("MVCF.Harmony.Gizmos"); MP.RegisterSyncDelegate(type, "<>c__DisplayClass5_0", "<GetGizmos_Postfix>b__1"); // Fire at will MP.RegisterSyncDelegate(type, "<>c__DisplayClass6_0", "<GetAttackGizmos_Postfix>b__4"); // Interrupt Attack MP.RegisterSyncDelegate(type, "<>c__DisplayClass7_0", "<Pawn_GetGizmos_Postfix>b__0"); // Also interrupt Attack } }
public GeneticRimCompat(ModContentPack mod) { Type type; // Several Gizmos { type = AccessTools.TypeByName("GeneticRim.GeneticRim_Pawn_GetGizmos_Patch"); string[] methods = { "<AddGizmo>b__0", "<AddGizmo>b__1", "<AddGizmo>b__10", "<AddGizmo>b__11", "<AddGizmo>b__12", "<AddGizmo>b__13", "<AddGizmo>b__14", "<AddGizmo>b__15", "<AddGizmo>b__16", "<AddGizmo>b__17", "<AddGizmo>b__3", "<AddGizmo>b__5", "<AddGizmo>b__7", "<AddGizmo>b__8", "<AddGizmo>b__9", }; foreach (string method in methods) { MP.RegisterSyncDelegate(type, "<>c__DisplayClass0_0", method); } } // ArchotechShip startup { MP.RegisterSyncMethod(AccessTools.Method("GeneticRim.ArchotechUtility:StartupHibernatingParts")); MP.RegisterSyncMethod(AccessTools.Method("GeneticRim.ArchotechCountdown:InitiateCountdown")); } { type = AccessTools.TypeByName("GeneticRim.ArchotechCountdown"); string[] methods = { "InitiateCountdown", "CancelCountdown", "CountdownEnded" }; foreach (string method in methods) { MP.RegisterSyncMethod(AccessTools.Method(type, method)); } } // RNG patching { string[] constructorsToPatch = { "GeneticRim.CompHatcherRandomizer", "GeneticRim.CompIncubator", "GeneticRim.CompRecombinator", "GeneticRim.CompRecombinatorSerum", "GeneticRim.DeathActionWorker_Eggxplosion", "GeneticRim.CompExploder", }; PatchingUtilities.PatchSystemRandCtor(constructorsToPatch, false); string[] methodsWithRand = { "GeneticRim.CompHatcherRandomizer:Hatch", "GeneticRim.CompIncubator:Hatch", "GeneticRim.CompRecombinator:Hatch", "GeneticRim.CompRecombinator:RecombinateAgain", "GeneticRim.CompRecombinatorSerum:Hatch", "GeneticRim.DeathActionWorker_Eggxplosion:PawnDied", "GeneticRim.CompExploder:wickInitializer", }; PatchingUtilities.PatchPushPopRand(methodsWithRand); } }
public VanillaExpandedFramework(ModContentPack mod) { // ItemProcessor { var type = AccessTools.TypeByName("ItemProcessor.Building_ItemProcessor"); // _1, _5 and _7 are used to check if gizmo should be enabled, so we don't sync them MpCompat.RegisterLambdaMethod(type, "GetGizmos", 0, 2, 3, 4, 6, 8, 9, 10); type = AccessTools.TypeByName("ItemProcessor.Command_SetQualityList"); MP.RegisterSyncWorker <Command>(SyncCommandWithBuilding, type, shouldConstruct: true); MpCompat.RegisterLambdaMethod(type, "ProcessInput", Enumerable.Range(0, 8).ToArray()); type = AccessTools.TypeByName("ItemProcessor.Command_SetOutputList"); MP.RegisterSyncWorker <Command>(SyncCommandWithBuilding, type, shouldConstruct: true); MP.RegisterSyncMethod(type, "TryConfigureIngredientsByOutput"); // Keep an eye on this in the future, seems like something the devs could combine into a single class at some point foreach (var ingredientNumber in new[] { "First", "Second", "Third", "Fourth" }) { type = AccessTools.TypeByName($"ItemProcessor.Command_Set{ingredientNumber}ItemList"); MP.RegisterSyncWorker <Command>(SyncSetIngredientCommand, type, shouldConstruct: true); MP.RegisterSyncMethod(type, $"TryInsert{ingredientNumber}Thing"); MpCompat.RegisterLambdaMethod(type, "ProcessInput", 0); } } // Vanilla Cooking Expanded { // AddHediff desyncs with Arbiter, but seems fine without it PatchingUtilities.PatchPushPopRand("VanillaCookingExpanded.Thought_Hediff:MoodOffset"); } // VFE Core { MpCompat.RegisterLambdaMethod("VFECore.CompPawnDependsOn", "CompGetGizmosExtra", 0).SetDebugOnly(); learnedAbilitiesField = AccessTools.Field(AccessTools.TypeByName("VFECore.Abilities.CompAbilities"), "learnedAbilities"); MP.RegisterSyncWorker <ITargetingSource>(SyncVEFAbility, AccessTools.TypeByName("VFECore.Abilities.Ability")); } // Vanilla Furniture Expanded { MpCompat.RegisterLambdaMethod("VanillaFurnitureExpanded.CompConfigurableSpawner", "CompGetGizmosExtra", 0).SetDebugOnly(); var type = AccessTools.TypeByName("VanillaFurnitureExpanded.Command_SetItemsToSpawn"); MpCompat.RegisterLambdaDelegate(type, "ProcessInput", 1); MP.RegisterSyncWorker <Command>(SyncCommandWithBuilding, type, shouldConstruct: true); MpCompat.RegisterLambdaMethod("VanillaFurnitureExpanded.CompRockSpawner", "CompGetGizmosExtra", 0); type = AccessTools.TypeByName("VanillaFurnitureExpanded.Command_SetStoneType"); setStoneBuildingField = AccessTools.Field(type, "building"); MpCompat.RegisterLambdaMethod(type, "ProcessInput", 0); MP.RegisterSyncWorker <Command>(SyncSetStoneTypeCommand, type, shouldConstruct: true); MpCompat.RegisterLambdaDelegate(type, "ProcessInput", 1); type = AccessTools.TypeByName("VanillaFurnitureExpanded.CompRandomBuildingGraphic"); MpCompat.RegisterLambdaMethod(type, "CompGetGizmosExtra", 0); } // Vanilla Faction Mechanoids { var type = AccessTools.TypeByName("VFE.Mechanoids.CompMachineChargingStation"); MpCompat.RegisterLambdaDelegate(type, "CompGetGizmosExtra", 1, 6).SetContext(SyncContext.MapSelected); MpCompat.RegisterLambdaDelegate(type, "CompGetGizmosExtra", 4); } // AnimalBehaviours { // RNG PatchingUtilities.PatchSystemRand("AnimalBehaviours.DamageWorker_ExtraInfecter:ApplySpecialEffectsToPart", false); var rngFixConstructors = new[] { "AnimalBehaviours.CompAnimalProduct", "AnimalBehaviours.CompFilthProducer", "AnimalBehaviours.CompGasProducer", "AnimalBehaviours.CompInitialHediff", "AnimalBehaviours.DeathActionWorker_DropOnDeath", }; PatchingUtilities.PatchSystemRandCtor(rngFixConstructors, false); // Gizmos var type = AccessTools.TypeByName("AnimalBehaviours.CompDestroyThisItem"); MP.RegisterSyncMethod(type, "SetObjectForDestruction"); MP.RegisterSyncMethod(type, "CancelObjectForDestruction"); } // MVCF (Multi Verb Combat Framework) { var type = AccessTools.TypeByName("MVCF.WorldComponent_MVCF"); mvcfGetWorldCompMethod = AccessTools.Method(type, "GetComp"); mvcfAllManagersListField = AccessTools.Field(type, "allManagers"); mvcfManagersTableField = AccessTools.Field(type, "managers"); MP.RegisterSyncMethod(typeof(VanillaExpandedFramework), nameof(SyncedInitVerbManager)); MpCompat.harmony.Patch(AccessTools.Method(type, "GetManagerFor"), prefix: new HarmonyMethod(typeof(VanillaExpandedFramework), nameof(GetManagerForPrefix))); type = AccessTools.TypeByName("MVCF.VerbManager"); MP.RegisterSyncWorker <object>(SyncVerbManager, type, isImplicit: true); mvcfVerbManagerCtor = AccessTools.Constructor(type); mvcfInitializeManagerMethod = AccessTools.Method(type, "Initialize"); mvcfPawnGetter = AccessTools.PropertyGetter(type, "Pawn"); mvcfVerbsField = AccessTools.Field(type, "verbs"); var weakReferenceType = typeof(System.WeakReference <>).MakeGenericType(new[] { type }); weakReferenceCtor = AccessTools.FirstConstructor(weakReferenceType, ctor => ctor.GetParameters().Count() == 1); var conditionalWeakTableType = typeof(System.Runtime.CompilerServices.ConditionalWeakTable <,>).MakeGenericType(new[] { typeof(Pawn), type }); conditionalWeakTableAddMethod = AccessTools.Method(conditionalWeakTableType, "Add"); conditionalWeakTableTryGetValueMethod = AccessTools.Method(conditionalWeakTableType, "TryGetValue"); type = AccessTools.TypeByName("MVCF.ManagedVerb"); mvcfManagerVerbManagerField = AccessTools.Field(type, "man"); MP.RegisterSyncWorker <object>(SyncManagedVerb, type, isImplicit: true); // Seems like selecting the Thing that holds the verb inits some stuff, so we need to set the context MP.RegisterSyncMethod(type, "Toggle"); type = AccessTools.TypeByName("MVCF.Harmony.Gizmos"); MpCompat.RegisterLambdaDelegate(type, "GetGizmos_Postfix", 1); // Fire at will MpCompat.RegisterLambdaDelegate(type, "GetAttackGizmos_Postfix", 4); // Interrupt Attack MpCompat.RegisterLambdaDelegate(type, "Pawn_GetGizmos_Postfix", 0); // Also interrupt Attack } // Explosive Trails Effect { // RNG PatchingUtilities.PatchPushPopRand("ExplosiveTrailsEffect.SmokeThrowher:ThrowSmokeTrail"); } // KCSG (Custom Structure Generation) { // RNG var methods = new[] { "KCSG.SymbolResolver_AddFields:Resolve", "KCSG.SymbolResolver_Settlement:GenerateRooms", }; PatchingUtilities.PatchSystemRand(methods, false); } }
public VanillaBrewingExpanded(ModContentPack mod) { PatchingUtilities.PatchSystemRand("VanillaBrewingExpanded.Plant_AutoProduce:TickLong"); PatchingUtilities.PatchSystemRandCtor("VanillaBrewingExpanded.Hediff_ConsumedCocktail"); }