/// <summary>The mod entry point, called after the mod is first loaded.</summary> /// <param name="helper">Provides simplified APIs for writing mods.</param> public override void Entry(IModHelper helper) { config = Helper.ReadConfig <ModConfig>(); if (!config.EnableMod) { return; } PMonitor = Monitor; PHelper = helper; mp = helper.Reflection.GetField <Multiplayer>(typeof(Game1), "multiplayer").GetValue(); myRand = new Random(); helper.Events.GameLoop.GameLaunched += HelperEvents.GameLoop_GameLaunched; helper.Events.GameLoop.SaveLoaded += HelperEvents.GameLoop_SaveLoaded; helper.Events.Input.ButtonPressed += HelperEvents.Input_ButtonPressed; helper.Events.GameLoop.DayStarted += HelperEvents.GameLoop_DayStarted; helper.Events.GameLoop.DayEnding += HelperEvents.GameLoop_DayEnding; helper.Events.GameLoop.ReturnedToTitle += HelperEvents.GameLoop_ReturnedToTitle; NPCPatches.Initialize(Monitor); LocationPatches.Initialize(Monitor); FarmerPatches.Initialize(Monitor, Helper); Maps.Initialize(Monitor); Kissing.Initialize(Monitor); UIPatches.Initialize(Monitor); EventPatches.Initialize(Monitor, Helper); HelperEvents.Initialize(Monitor, Helper); FileIO.Initialize(Monitor, Helper); Misc.Initialize(Monitor, Helper); var harmony = HarmonyInstance.Create(this.ModManifest.UniqueID); // npc patches harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.setUpForOutdoorPatioActivity)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_setUpForOutdoorPatioActivity_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.marriageDuties)), postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_marriageDuties_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.getSpouse)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_getSpouse_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.isRoommate)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_isRoommate_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.isMarried)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_isMarried_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.isMarriedOrEngaged)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_isMarriedOrEngaged_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.tryToReceiveActiveObject)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_tryToReceiveActiveObject_Prefix)), transpiler: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_tryToReceiveActiveObject_Transpiler)), postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_tryToReceiveActiveObject_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.checkAction)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_checkAction_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.spouseObstacleCheck)), postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_spouseObstacleCheck_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), "doPlaySpousePatioAnimation"), postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_doPlaySpousePatioAnimation_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), "engagementResponse"), postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_engagementResponse_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.playSleepingAnimation)), postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_playSleepingAnimation_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(Child), nameof(Child.reloadSprite)), postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.Child_reloadSprite_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(Child), nameof(Child.resetForPlayerEntry)), postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.Child_resetForPlayerEntry_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(Child), nameof(Child.dayUpdate)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.Child_dayUpdate_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(Child), nameof(Child.tenMinuteUpdate)), postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.Child_tenMinuteUpdate_Postfix)) ); // location patches harmony.Patch( original: AccessTools.Method(typeof(Farm), "addSpouseOutdoorArea"), prefix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.Farm_addSpouseOutdoorArea_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(Beach), nameof(Beach.checkAction)), prefix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.Beach_checkAction_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(ManorHouse), nameof(ManorHouse.performAction)), prefix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.ManorHouse_performAction_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(FarmHouse), nameof(FarmHouse.getWalls)), postfix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.FarmHouse_getWalls_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(FarmHouse), nameof(FarmHouse.getFloors)), postfix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.FarmHouse_getFloors_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(GameLocation), nameof(GameLocation.performAction)), prefix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.GameLocation_performAction_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(Beach), "resetLocalState"), postfix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.Beach_resetLocalState_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(FarmHouse), "resetLocalState"), postfix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.FarmHouse_resetLocalState_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(GameLocation), "checkEventPrecondition"), prefix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.GameLocation_checkEventPrecondition_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(FarmHouse), nameof(FarmHouse.performTenMinuteUpdate)), postfix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.FarmHouse_performTenMinuteUpdate_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(Desert), nameof(Desert.getDesertMerchantTradeStock)), postfix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.Desert_getDesertMerchantTradeStock_Postfix)) ); // pregnancy patches harmony.Patch( original: AccessTools.Method(typeof(Utility), nameof(Utility.pickPersonalFarmEvent)), prefix: new HarmonyMethod(typeof(Pregnancy), nameof(Pregnancy.Utility_pickPersonalFarmEvent_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(QuestionEvent), nameof(QuestionEvent.setUp)), prefix: new HarmonyMethod(typeof(Pregnancy), nameof(Pregnancy.QuestionEvent_setUp_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(BirthingEvent), nameof(BirthingEvent.setUp)), prefix: new HarmonyMethod(typeof(Pregnancy), nameof(Pregnancy.BirthingEvent_setUp_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(BirthingEvent), nameof(BirthingEvent.tickUpdate)), prefix: new HarmonyMethod(typeof(Pregnancy), nameof(Pregnancy.BirthingEvent_tickUpdate_Prefix)) ); // Farmer patches harmony.Patch( original: AccessTools.Method(typeof(Farmer), nameof(Farmer.doDivorce)), prefix: new HarmonyMethod(typeof(FarmerPatches), nameof(FarmerPatches.Farmer_doDivorce_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(Farmer), nameof(Farmer.isMarried)), prefix: new HarmonyMethod(typeof(FarmerPatches), nameof(FarmerPatches.Farmer_isMarried_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(Farmer), nameof(Farmer.checkAction)), prefix: new HarmonyMethod(typeof(FarmerPatches), nameof(FarmerPatches.Farmer_checkAction_Prefix)) ); // UI patches harmony.Patch( original: AccessTools.Method(typeof(SocialPage), "drawNPCSlot"), prefix: new HarmonyMethod(typeof(UIPatches), nameof(UIPatches.SocialPage_drawNPCSlot)) ); harmony.Patch( original: typeof(DialogueBox).GetConstructor(new Type[] { typeof(List <string>) }), prefix: new HarmonyMethod(typeof(UIPatches), nameof(UIPatches.DialogueBox_Prefix)) ); // Event patches harmony.Patch( original: AccessTools.Method(typeof(Event), nameof(Event.answerDialogueQuestion)), prefix: new HarmonyMethod(typeof(EventPatches), nameof(EventPatches.Event_answerDialogueQuestion_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(Event), "setUpCharacters"), postfix: new HarmonyMethod(typeof(EventPatches), nameof(EventPatches.Event_setUpCharacters_Postfix)) ); // HelperEvent patches harmony.Patch( original: AccessTools.Method(typeof(SaveGame), nameof(SaveGame.Load)), prefix: new HarmonyMethod(typeof(HelperEvents), nameof(HelperEvents.SaveGame_Load_prefix)) ); }
/// <summary>The mod entry point, called after the mod is first loaded.</summary> /// <param name="helper">Provides simplified APIs for writing mods.</param> public override void Entry(IModHelper helper) { config = Helper.ReadConfig <ModConfig>(); if (!config.EnableMod) { return; } PMonitor = Monitor; PHelper = helper; mp = helper.Reflection.GetField <Multiplayer>(typeof(Game1), "multiplayer").GetValue(); myRand = new Random(); helper.Events.GameLoop.GameLaunched += HelperEvents.GameLoop_GameLaunched; helper.Events.GameLoop.SaveLoaded += HelperEvents.GameLoop_SaveLoaded; helper.Events.Input.ButtonPressed += HelperEvents.Input_ButtonPressed; helper.Events.GameLoop.DayStarted += HelperEvents.GameLoop_DayStarted; helper.Events.GameLoop.DayEnding += HelperEvents.GameLoop_DayEnding; helper.Events.GameLoop.ReturnedToTitle += HelperEvents.GameLoop_ReturnedToTitle; NPCPatches.Initialize(Monitor, config); LocationPatches.Initialize(Monitor); FarmerPatches.Initialize(Monitor, Helper); Maps.Initialize(Monitor); Kissing.Initialize(Monitor); UIPatches.Initialize(Monitor, Helper); EventPatches.Initialize(Monitor, Helper); HelperEvents.Initialize(Monitor, Helper); FileIO.Initialize(Monitor, Helper); Misc.Initialize(Monitor, Helper, config); Divorce.Initialize(Monitor, Helper); FurniturePatches.Initialize(Monitor, Helper, config); ObjectPatches.Initialize(Monitor, Helper, config); NetWorldStatePatches.Initialize(Monitor, Helper, config); var harmony = new Harmony(ModManifest.UniqueID); // npc patches harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.marriageDuties)), postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_marriageDuties_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.getSpouse)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_getSpouse_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.isRoommate)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_isRoommate_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.isMarried)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_isMarried_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.isMarriedOrEngaged)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_isMarriedOrEngaged_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.tryToReceiveActiveObject)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_tryToReceiveActiveObject_Prefix)), transpiler: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_tryToReceiveActiveObject_Transpiler)), postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_tryToReceiveActiveObject_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.checkAction)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_checkAction_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.spouseObstacleCheck)), postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_spouseObstacleCheck_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), "engagementResponse"), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_engagementResponse_Prefix)), postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_engagementResponse_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.playSleepingAnimation)), postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_playSleepingAnimation_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.GetDispositionModifiedString)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_GetDispositionModifiedString_Prefix)), postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_GetDispositionModifiedString_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), "loadCurrentDialogue"), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_loadCurrentDialogue_Prefix)), postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_loadCurrentDialogue_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.tryToRetrieveDialogue)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_tryToRetrieveDialogue_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.setSpouseRoomMarriageDialogue)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_setSpouseRoomMarriageDialogue_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(NPC), nameof(NPC.setRandomAfternoonMarriageDialogue)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.NPC_setRandomAfternoonMarriageDialogue_Prefix)) ); // Child patches harmony.Patch( original: typeof(Character).GetProperty("displayName").GetMethod, postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.Character_displayName_Getter_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(Child), nameof(Child.reloadSprite)), postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.Child_reloadSprite_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(Child), nameof(Child.resetForPlayerEntry)), postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.Child_resetForPlayerEntry_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(Child), nameof(Child.dayUpdate)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.Child_dayUpdate_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(Child), nameof(Child.isInCrib)), prefix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.Child_isInCrib_Prefix)) ); /* * harmony.Patch( * original: AccessTools.Method(typeof(Child), nameof(Child.tenMinuteUpdate)), * postfix: new HarmonyMethod(typeof(NPCPatches), nameof(NPCPatches.Child_tenMinuteUpdate_Postfix)) * ); */ // Location patches harmony.Patch( original: AccessTools.Method(typeof(Beach), nameof(Beach.checkAction)), prefix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.Beach_checkAction_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(ManorHouse), nameof(ManorHouse.performAction)), prefix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.ManorHouse_performAction_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(FarmHouse), nameof(FarmHouse.checkAction)), postfix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.FarmHouse_checkAction_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(FarmHouse), nameof(FarmHouse.updateFarmLayout)), postfix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.FarmHouse_updateFarmLayout_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(FarmHouse), nameof(FarmHouse.getWalls)), postfix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.FarmHouse_getWalls_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(FarmHouse), nameof(FarmHouse.getFloors)), postfix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.FarmHouse_getFloors_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(GameLocation), nameof(GameLocation.performAction)), prefix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.GameLocation_performAction_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(GameLocation), nameof(GameLocation.answerDialogue)), prefix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.GameLocation_answerDialogue_prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(FarmHouse), "resetLocalState"), postfix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.FarmHouse_resetLocalState_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(Beach), "resetLocalState"), postfix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.Beach_resetLocalState_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(GameLocation), "checkEventPrecondition"), prefix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.GameLocation_checkEventPrecondition_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(FarmHouse), nameof(FarmHouse.performTenMinuteUpdate)), postfix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.FarmHouse_performTenMinuteUpdate_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(Desert), nameof(Desert.getDesertMerchantTradeStock)), postfix: new HarmonyMethod(typeof(LocationPatches), nameof(LocationPatches.Desert_getDesertMerchantTradeStock_Postfix)) ); // pregnancy patches harmony.Patch( original: AccessTools.Method(typeof(Utility), nameof(Utility.pickPersonalFarmEvent)), prefix: new HarmonyMethod(typeof(Pregnancy), nameof(Pregnancy.Utility_pickPersonalFarmEvent_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(QuestionEvent), nameof(QuestionEvent.setUp)), prefix: new HarmonyMethod(typeof(Pregnancy), nameof(Pregnancy.QuestionEvent_setUp_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(BirthingEvent), nameof(BirthingEvent.setUp)), prefix: new HarmonyMethod(typeof(Pregnancy), nameof(Pregnancy.BirthingEvent_setUp_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(BirthingEvent), nameof(BirthingEvent.tickUpdate)), prefix: new HarmonyMethod(typeof(Pregnancy), nameof(Pregnancy.BirthingEvent_tickUpdate_Prefix)) ); // Farmer patches harmony.Patch( original: AccessTools.Method(typeof(Farmer), nameof(Farmer.doDivorce)), prefix: new HarmonyMethod(typeof(FarmerPatches), nameof(FarmerPatches.Farmer_doDivorce_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(Farmer), nameof(Farmer.isMarried)), prefix: new HarmonyMethod(typeof(FarmerPatches), nameof(FarmerPatches.Farmer_isMarried_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(Farmer), nameof(Farmer.getSpouse)), prefix: new HarmonyMethod(typeof(FarmerPatches), nameof(FarmerPatches.Farmer_getSpouse_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(Farmer), nameof(Farmer.checkAction)), prefix: new HarmonyMethod(typeof(FarmerPatches), nameof(FarmerPatches.Farmer_checkAction_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(Farmer), nameof(Farmer.GetSpouseFriendship)), prefix: new HarmonyMethod(typeof(FarmerPatches), nameof(FarmerPatches.Farmer_GetSpouseFriendship_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(Farmer), nameof(Farmer.getChildren)), prefix: new HarmonyMethod(typeof(FarmerPatches), nameof(FarmerPatches.Farmer_getChildren_Prefix)) ); // UI patches harmony.Patch( original: AccessTools.Method(typeof(SocialPage), "drawNPCSlot"), prefix: new HarmonyMethod(typeof(UIPatches), nameof(UIPatches.SocialPage_drawNPCSlot_prefix)), transpiler: new HarmonyMethod(typeof(UIPatches), nameof(UIPatches.SocialPage_drawSlot_transpiler)) ); harmony.Patch( original: AccessTools.Method(typeof(SocialPage), "drawFarmerSlot"), transpiler: new HarmonyMethod(typeof(UIPatches), nameof(UIPatches.SocialPage_drawSlot_transpiler)) ); harmony.Patch( original: typeof(DialogueBox).GetConstructor(new Type[] { typeof(List <string>) }), prefix: new HarmonyMethod(typeof(UIPatches), nameof(UIPatches.DialogueBox_Prefix)) ); // Event patches harmony.Patch( original: AccessTools.Method(typeof(Event), nameof(Event.answerDialogueQuestion)), prefix: new HarmonyMethod(typeof(EventPatches), nameof(EventPatches.Event_answerDialogueQuestion_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(Event), "setUpCharacters"), postfix: new HarmonyMethod(typeof(EventPatches), nameof(EventPatches.Event_setUpCharacters_Postfix)) ); harmony.Patch( original: AccessTools.Method(typeof(Event), nameof(Event.command_playSound)), prefix: new HarmonyMethod(typeof(EventPatches), nameof(EventPatches.Event_command_playSound_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(Event), nameof(Event.command_loadActors)), prefix: new HarmonyMethod(typeof(EventPatches), nameof(EventPatches.Event_command_loadActors_Prefix)), postfix: new HarmonyMethod(typeof(EventPatches), nameof(EventPatches.Event_command_loadActors_Postfix)) ); // Object patches harmony.Patch( original: AccessTools.Method(typeof(Object), nameof(Object.draw), new Type[] { typeof(SpriteBatch), typeof(int), typeof(int), typeof(float) }), prefix: new HarmonyMethod(typeof(ObjectPatches), nameof(ObjectPatches.Object_draw_Prefix)) ); // Furniture patches harmony.Patch( original: AccessTools.Method(typeof(BedFurniture), nameof(BedFurniture.draw), new Type[] { typeof(SpriteBatch), typeof(int), typeof(int), typeof(float) }), prefix: new HarmonyMethod(typeof(FurniturePatches), nameof(FurniturePatches.BedFurniture_draw_Prefix)) ); // Game1 patches harmony.Patch( original: AccessTools.Method(typeof(Game1), nameof(Game1.prepareSpouseForWedding)), prefix: new HarmonyMethod(typeof(Game1Patches), nameof(Game1Patches.prepareSpouseForWedding_Prefix)) ); harmony.Patch( original: AccessTools.Method(typeof(Game1), nameof(Game1.getCharacterFromName), new Type[] { typeof(string), typeof(bool), typeof(bool) }), prefix: new HarmonyMethod(typeof(Game1Patches), nameof(Game1Patches.getCharacterFromName_Prefix)) ); // NetWorldState patch harmony.Patch( original: AccessTools.Method(typeof(NetWorldState), nameof(NetWorldState.hasWorldStateID)), prefix: new HarmonyMethod(typeof(NetWorldStatePatches), nameof(NetWorldStatePatches.hasWorldStateID_Prefix)) ); }
public static void GameLoop_OneSecondUpdateTicked(object sender, OneSecondUpdateTickedEventArgs e) { foreach (GameLocation location in Game1.locations) { if (location is FarmHouse) { FarmHouse fh = location as FarmHouse; if (fh.owner == null) { continue; } List <string> allSpouses = Misc.GetSpouses(fh.owner, 1).Keys.ToList(); List <string> bedSpouses = Misc.ReorderSpousesForSleeping(allSpouses.FindAll((s) => ModEntry.config.RoommateRomance || !fh.owner.friendshipData[s].RoommateMarriage)); foreach (NPC character in fh.characters) { if (!(character.currentLocation == fh)) { continue; } if (allSpouses.Contains(character.Name)) { if (Misc.IsInBed(fh, character.GetBoundingBox())) { character.farmerPassesThrough = true; if (!character.isMoving() && !Kissing.kissingSpouses.Contains(character.Name)) { Vector2 bedPos = Misc.GetSpouseBedPosition(fh, bedSpouses, character.Name); if (Game1.timeOfDay >= 2000 || Game1.timeOfDay <= 600) { character.position.Value = bedPos; character.ignoreScheduleToday = true; if (!character.isSleeping.Value) { Monitor.Log($"putting {character.Name} to sleep"); character.isSleeping.Value = true; } if (character.Sprite.CurrentAnimation == null) { if (!Misc.HasSleepingAnimation(character.Name)) { character.Sprite.StopAnimation(); character.faceDirection(0); } else { character.playSleepingAnimation(); } } } else { character.faceDirection(3); character.isSleeping.Value = false; } } else { character.isSleeping.Value = false; } character.HideShadow = true; } else if (Game1.timeOfDay < 2000 && Game1.timeOfDay > 600) { character.farmerPassesThrough = false; character.HideShadow = false; character.isSleeping.Value = false; } } } if (location == Game1.player.currentLocation && ModEntry.config.AllowSpousesToKiss) { Kissing.TrySpousesKiss(); } } } }