diff --git a/SinZational Scrutinizing Spousal Speech/ModEntry.cs b/SinZational Scrutinizing Spousal Speech/ModEntry.cs new file mode 100644 index 0000000..c44c7fb --- /dev/null +++ b/SinZational Scrutinizing Spousal Speech/ModEntry.cs @@ -0,0 +1,112 @@ +using HarmonyLib; +using StardewModdingAPI; +using StardewValley.Buildings; +using StardewValley; +using System.Reflection.Emit; + +namespace SinZ.ScrutinizingSpousalSpeech; + +public class ModEntry : Mod +{ + public override void Entry(IModHelper helper) + { + var harmony = new Harmony(this.ModManifest.UniqueID); + HarmonyPatches.Setup(Monitor, harmony); + + // helper.Events.Content.AssetRequested += Content_AssetRequested; + } + + /*private void Content_AssetRequested(object? sender, StardewModdingAPI.Events.AssetRequestedEventArgs e) + { + if (e.NameWithoutLocale.IsEquivalentTo("Characters/Dialogue/MarriageDialogueAbigail")) + { + e.Edit(data => + { + var dict = data.AsDictionary(); + dict.Data.Clear(); + }, StardewModdingAPI.Events.AssetEditPriority.Late); + } + if (e.NameWithoutLocale.IsEquivalentTo("Characters/Dialogue/MarriageDialogue")) + { + e.Edit(data => + { + var dict = data.AsDictionary(); + dict.Data.Clear(); + }, StardewModdingAPI.Events.AssetEditPriority.Late); + } + }*/ +} + +public static class HarmonyPatches +{ + private static IMonitor monitor; + public static void Setup(IMonitor monitor, Harmony harmony) + { + HarmonyPatches.monitor = monitor; + var tryToGetMarriageSpecificDialogue = typeof(NPC).GetMethod(nameof(NPC.tryToGetMarriageSpecificDialogue)); + if (tryToGetMarriageSpecificDialogue != null) + { + harmony.Patch(tryToGetMarriageSpecificDialogue, transpiler: new HarmonyMethod(typeof(HarmonyPatches).GetMethod(nameof(tryToGetMarriageSpecificDialogue__transpiler)))); + } + } + public static IEnumerable tryToGetMarriageSpecificDialogue__transpiler(ILGenerator generator, IEnumerable instructions) + { + var output = new List(); + foreach (var instruction in instructions) + { + if (instruction.opcode == OpCodes.Ldloc_2) + { + var loadThis = new CodeInstruction(OpCodes.Ldarg_0) + { + labels = instruction.labels + }; + instruction.labels = new List