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 void LatePatch() { // Facepaint changeFacepaintDialogType = AccessTools.TypeByName("VFEV.Facepaint.Dialog_ChangeFacepaint"); orderedFacepaintDefs = (IList)AccessTools.Field(changeFacepaintDialogType, "orderedFacepaintDefs").GetValue(null); newFacepaintComboSync = MP.RegisterSyncField(AccessTools.Field(changeFacepaintDialogType, "newFacepaintCombo")); coloursTiedSync = MP.RegisterSyncField(AccessTools.Field(changeFacepaintDialogType, "coloursTied")); MP.RegisterSyncMethod(changeFacepaintDialogType, "SetHairstyle"); MP.RegisterSyncWorker <Window>(SyncDialog, changeFacepaintDialogType); MP.RegisterSyncMethod(typeof(VanillaFactionsVikings), nameof(SyncedTryRemoveWindow)); MpCompat.harmony.Patch(AccessTools.Method(changeFacepaintDialogType, "DoWindowContents"), prefix: new HarmonyMethod(typeof(VanillaFactionsVikings), nameof(PreDoWindowContents)), postfix: new HarmonyMethod(typeof(VanillaFactionsVikings), nameof(PostDoWindowContents))); var type = AccessTools.Inner(changeFacepaintDialogType, "FacepaintCombination"); MP.RegisterSyncWorker <object>(SyncFacepaintCombination, type); facepaintDefOneField = AccessTools.Field(type, "facepaintDefOne"); facepaintDefTwoField = AccessTools.Field(type, "facepaintDefTwo"); facepaintColourOneField = AccessTools.Field(type, "colourOne"); facepaintColourTwoField = AccessTools.Field(type, "colourTwo"); MpCompat.harmony.Patch(AccessTools.Method(typeof(WindowStack), nameof(WindowStack.TryRemove), new[] { typeof(Window), typeof(bool) }), prefix: new HarmonyMethod(typeof(VanillaFactionsVikings), nameof(PreTryRemoveWindow))); MP.RegisterPauseLock(PauseIfDialogOpen); }
public VanillaFactionsAncients(ModContentPack mod) { // Supply slingshot launch gizmo (after 2 possible confirmation) MP.RegisterSyncMethod(AccessTools.TypeByName("VFEAncients.CompSupplySlingshot"), "TryLaunch"); // VFEAncients.CompGeneTailoringPod:StartOperation requires SyncWorker for Operation // (Method inside of LatePatch) var type = AccessTools.TypeByName("VFEAncients.Operation"); operationPodField = AccessTools.FieldRefAccess <ThingComp>(type, "Pod"); MP.RegisterSyncWorker <object>(SyncOperation, type, true); MP.RegisterPauseLock(ShouldPause); LongEventHandler.ExecuteWhenFinished(LatePatch); }
public HealerMechSerumChoice(ModContentPack mod) { MP.RegisterSyncMethod(typeof(HealerMechSerumChoice), nameof(SyncedSetHediff)); // Dialog hediffSelectionDialogType = AccessTools.TypeByName("HMSChoice.Dialog_HediffSelection"); dialogSelectedHediffField = AccessTools.FieldRefAccess <Hediff>(hediffSelectionDialogType, "SelectedHediff"); MP.RegisterSyncMethod(AccessTools.Method(hediffSelectionDialogType, "Close", new[] { typeof(Hediff) })); MP.RegisterSyncWorker <Window>(SyncHediffDialog, hediffSelectionDialogType); MpCompat.harmony.Patch(AccessTools.Method(hediffSelectionDialogType, nameof(Window.DoWindowContents)), prefix: new HarmonyMethod(typeof(HealerMechSerumChoice), nameof(PreDoWindowContents)), postfix: new HarmonyMethod(typeof(HealerMechSerumChoice), nameof(PostDoWindowContents))); MpCompat.harmony.Patch(AccessTools.Constructor(hediffSelectionDialogType, new[] { typeof(string), typeof(List <Hediff>), typeof(Action <Hediff>) }), postfix: new HarmonyMethod(typeof(HealerMechSerumChoice), nameof(PostDialogConstructor))); MP.RegisterPauseLock(PauseWhenDialogOpen); }
public VanillaFactionsPirates(ModContentPack mod) { // Gizmos { // Enable/disable siege mode MpCompat.RegisterLambdaMethod("VFEPirates.Ability_SiegeMode", "GetGizmo", 0, 2); // Trigger flight towards tile (right now, the TransportPodsArrivalAction parameter is always null) MP.RegisterSyncMethod(AccessTools.TypeByName("VFEPirates.Ability_BlastOff"), "TryLaunch").ExposeParameter(1); } // Warcasket dialog { // Dialog_WarcasketCustomization warcasketDialogType = AccessTools.TypeByName("VFEPirates.Buildings.Dialog_WarcasketCustomization"); notifySettingsChangedMethod = AccessTools.Method(warcasketDialogType, "Notify_SettingsChanged"); warcasketProjectField = AccessTools.FieldRefAccess <object>(warcasketDialogType, "project"); MP.RegisterSyncWorker <Window>(SyncWarcasketCustomizationDialog, warcasketDialogType); MP.RegisterSyncMethod(warcasketDialogType, "OnAcceptKeyPressed"); MP.RegisterSyncMethod(warcasketDialogType, "OnCancelKeyPressed"); MpCompat.RegisterLambdaMethod(warcasketDialogType, "DoWindowContents", 0, 1, 2); MpCompat.harmony.Patch(AccessTools.Method(warcasketDialogType, "DoWindowContents"), prefix: new HarmonyMethod(typeof(VanillaFactionsPirates), nameof(PreDoWindowContents)), postfix: new HarmonyMethod(typeof(VanillaFactionsPirates), nameof(PostDoWindowContents))); // WarcasketProject var type = AccessTools.TypeByName("VFEPirates.WarcasketProject"); helmetColorField = AccessTools.FieldRefAccess <Color>(type, "colorHelmet"); shoulderPadsColorField = AccessTools.FieldRefAccess <Color>(type, "colorShoulderPads"); armorColorField = AccessTools.FieldRefAccess <Color>(type, "colorArmor"); MP.RegisterSyncMethod(typeof(VanillaFactionsPirates), nameof(SyncedSetColors)); MP.RegisterPauseLock(PauseIfDialogOpen); } // Curse window { // Page_ChooseCurses MP.RegisterSyncMethod(typeof(VanillaFactionsPirates), nameof(SyncedSetCurse)); MpCompat.harmony.Patch(AccessTools.Method("VFEPirates.Page_ChooseCurses:DoCurse"), transpiler: new HarmonyMethod(typeof(VanillaFactionsPirates), nameof(ReplaceButton))); // GameComponent_CurseManager var type = AccessTools.TypeByName("VFEPirates.GameComponent_CurseManager"); curseManagerInstanceField = AccessTools.StaticFieldRefAccess <GameComponent>(AccessTools.Field(type, "Instance")); activeCurseDefsField = AccessTools.FieldRefAccess <IEnumerable>(type, "activeCurseDefs"); removeCurseMethod = AccessTools.Method(type, "Remove"); addCurseMethod = AccessTools.Method(type, "Add"); // CurseDef curseDefWorkerGetter = AccessTools.PropertyGetter(AccessTools.TypeByName("VFEPirates.CurseDef"), "Worker"); // CurseWorker type = AccessTools.TypeByName("VFEPirates.CurseWorker"); curseWorkerDisactivateMethod = AccessTools.Method(type, "Disactivate"); curseWorkerStartMethod = AccessTools.Method(type, "Start"); } }