예제 #1
0
 public static void Postfix(Farmer who, Pet __instance)
 {
     if (__instance.isSleepingOnFarmerBed && __instance.currentLocation is FarmHouse)
     {
         __instance.position.Value = (StardewValley.Utility.PointToVector2(FarmHouseStates.getBedSpot(StardewValley.Utility.getHomeOfFarmer(who))) + new Microsoft.Xna.Framework.Vector2(-1f, 0f)) * 64f;
     }
 }
예제 #2
0
        internal void saveLoaded(object sender, StardewModdingAPI.Events.SaveLoadedEventArgs e)
        {
            //Game1.getFarm().grandpaScore.Value = 3;
            reloadStaticClasses();
            FarmHouseStates.harmony.Patch(
                original: AccessTools.Method(typeof(Farm), nameof(Farm.draw)),
                transpiler: new HarmonyMethod(AccessTools.Method(typeof(Farm_draw_Patch), nameof(Farm_draw_Patch.Transpiler))),
                postfix: new HarmonyMethod(AccessTools.Method(typeof(Farm_draw_Patch), nameof(Farm_draw_Patch.Postfix)))
                );
            FarmHouseStates.harmony.Patch(
                original: AccessTools.Method(typeof(Farm), nameof(Farm.leftClick)),
                transpiler: new HarmonyMethod(AccessTools.Method(typeof(Farm_leftClick_Patch), nameof(Farm_leftClick_Patch.Transpiler)))
                );
            FarmHouseStates.harmony.Patch(
                original: AccessTools.Method(typeof(Farm), nameof(Farm.checkAction)),
                transpiler: new HarmonyMethod(AccessTools.Method(typeof(Farm_checkAction_Patch), nameof(Farm_checkAction_Patch.Transpiler)))
                );
            FarmHouseStates.harmony.Patch(
                original: AccessTools.Method(typeof(Farm), nameof(Farm.addGrandpaCandles)),
                transpiler: new HarmonyMethod(AccessTools.Method(typeof(Farm_addGrandpaCandles_Patch), nameof(Farm_addGrandpaCandles_Patch.Transpiler)))
                );

            foreach (Farmer player in Game1.getAllFarmers())
            {
                if (player.currentLocation != null && player.currentLocation is FarmHouse)
                {
                    Logger.Log("Current location is a farmhouse; getting bed spot from this farmhouse.");
                    player.mostRecentBed  = StardewValley.Utility.PointToVector2(FarmHouseStates.getBedSpot(player.currentLocation as FarmHouse)) * 64f;
                    player.position.Value = new StardewValley.Network.NetPosition(new NetVector2(player.mostRecentBed));
                    player.position.X    -= 64f;
                    player.position.Y    += 32f;
                }
                Logger.Log(player.Name + "'s most recent bed: " + player.mostRecentBed.ToString());
            }
        }
예제 #3
0
 internal void fixPaths(NPC npc, FarmHouse house)
 {
     if (npc.getTileLocationPoint() == house.getEntryLocation())
     {
         Logger.Log(npc.name + " entered at the entry point, repositioning at modded entry (if any)...");
         npc.setTilePosition(FarmHouseStates.getEntryLocation(house));
     }
     Logger.Log("Fixing paths for " + npc.name + "...");
     if (npc.isMarried() && npc.getSpouse() == Game1.player)
     {
         Logger.Log(npc.name + " is married to " + Game1.player.name + "...");
         if (npc.controller != null && npc.controller.endPoint != null && npc.controller.endPoint == house.getKitchenStandingSpot())
         {
             Logger.Log(npc.name + " is pathing to the kitchen...");
             npc.willDestroyObjectsUnderfoot = false;
             npc.controller = new PathFindController(npc, house, FarmHouseStates.getKitchenSpot(house), 0);
             if (npc.controller.pathToEndPoint == null)
             {
                 npc.willDestroyObjectsUnderfoot = true;
                 npc.controller = new PathFindController(npc, house, FarmHouseStates.getKitchenSpot(house), 0);
                 npc.setNewDialogue(Game1.LoadStringByGender((int)((NetFieldBase <int, NetInt>)npc.gender), "Strings\\StringsFromCSFiles:NPC.cs.4500"), false, false);
             }
             else if (Game1.timeOfDay > 1300)
             {
                 if (Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth).ToLower().Equals("mon") || Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth).ToLower().Equals("fri") && !npc.name.Equals((object)"Maru") && (!npc.name.Equals((object)"Penny") && !npc.name.Equals((object)"Harvey")))
                 {
                     npc.setNewDialogue("MarriageDialogue", "funReturn_", -1, false, true);
                 }
                 else
                 {
                     npc.setNewDialogue("MarriageDialogue", "jobReturn_", -1, false, false);
                 }
             }
         }
         else if (npc.controller != null && npc.controller.endPoint != null && npc.controller.endPoint == house.getSpouseBedSpot(npc.name))
         {
             Logger.Log(npc.name + " is heading to bed...");
             npc.willDestroyObjectsUnderfoot = false;
             npc.controller = new PathFindController(npc, house, FarmHouseStates.getBedSpot(house, true), 0);
             if (npc.controller.pathToEndPoint == null)
             {
                 npc.willDestroyObjectsUnderfoot = true;
                 npc.controller = new PathFindController(npc, house, FarmHouseStates.getBedSpot(house, true), 0);
                 npc.setNewDialogue(Game1.LoadStringByGender((int)((NetFieldBase <int, NetInt>)npc.gender), "Strings\\StringsFromCSFiles:NPC.cs.4500"), false, false);
             }
             else if (Game1.timeOfDay > 1300)
             {
                 if (Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth).ToLower().Equals("mon") || Game1.shortDayNameFromDayOfSeason(Game1.dayOfMonth).ToLower().Equals("fri") && !npc.name.Equals((object)"Maru") && (!npc.name.Equals((object)"Penny") && !npc.name.Equals((object)"Harvey")))
                 {
                     npc.setNewDialogue("MarriageDialogue", "funReturn_", -1, false, true);
                 }
                 else
                 {
                     npc.setNewDialogue("MarriageDialogue", "jobReturn_", -1, false, false);
                 }
             }
         }
     }
 }
예제 #4
0
 internal void setPlayerByBed(FarmHouse house)
 {
     if (Game1.player.currentLocation.Equals(house))
     {
         Point   bedPoint    = FarmHouseStates.getBedSpot(house, false);
         Vector2 bedLocation = new Vector2(bedPoint.X, bedPoint.Y);
         Game1.player.setTileLocation(bedLocation);
         Logger.Log("Bed set to " + bedLocation.ToString());
     }
 }
예제 #5
0
 public static void Postfix(Farmer __instance)
 {
     Logger.Log("Running constructor patch...");
     Logger.Log("Current bed before patch is " + __instance.mostRecentBed.ToString());
     if (__instance.currentLocation != null && __instance.currentLocation is FarmHouse)
     {
         Logger.Log("Current location is a farmhouse; getting bed spot from this farmhouse.");
         __instance.mostRecentBed = StardewValley.Utility.PointToVector2(FarmHouseStates.getBedSpot(__instance.currentLocation as FarmHouse)) * 64f;
     }
     else
     {
         Logger.Log("Current location was not a farmhouse; getting bed spot from " + __instance.name + "'s farmhouse...");
         foreach (GameLocation location in Game1.locations)
         {
             if (location is FarmHouse && (location as FarmHouse).owner == __instance)
             {
                 Logger.Log("Found " + __instance.name + "'s farmhouse.");
                 __instance.mostRecentBed = StardewValley.Utility.PointToVector2(FarmHouseStates.getBedSpot(location as FarmHouse)) * 64f;
             }
         }
     }
     Logger.Log("Most recent bed: " + __instance.mostRecentBed.ToString());
 }