public static bool Prefix(ref string description, GameLocation location, Event __instance)
        {
            Logger.Log("Prefixing event at " + location.name + "...");
            if (!(location is Farm))
            {
                return(true);
            }
            Logger.Log("Event is at the farm...");
            string[] strArray = description.Split(' ');
            int      index    = 0;

            while (index < strArray.Length)
            {
                if (!strArray[index + 1].Equals("-1"))
                {
                    Logger.Log("Found coordinates for character setup: " + strArray[index + 1] + ", " + strArray[index + 2]);
                    Vector2 offset = FarmState.getFrontDoorOffset();
                    int     x      = Convert.ToInt32(strArray[index + 1]) + (int)offset.X;
                    int     y      = Convert.ToInt32(strArray[index + 2]) + (int)offset.Y;
                    Logger.Log("Offset coordinates to " + x + ", " + y);
                    strArray[index + 1] = x.ToString();
                    strArray[index + 2] = y.ToString();
                }
                index += 4;
            }
            description = "";
            foreach (string descPart in strArray)
            {
                description += descPart + " ";
            }
            description = description.Substring(0, description.Length - 1);
            Logger.Log("Returning \n" + description);
            return(true);
        }
Exemple #2
0
        private void GameLoop_GameLaunched(object sender, StardewModdingAPI.Events.GameLaunchedEventArgs e)
        {
            ObjectIDHelper.init();
            //FarmHouseStates.harmony.Patch(
            //    original: Helper.Reflection.GetMethod(new FarmHouse(), "doSetVisibleFloor").MethodInfo,
            //    prefix: new HarmonyMethod(AccessTools.Method(typeof(FarmHouse_doSetVisibleFloor_Patch), nameof(FarmHouse_doSetVisibleFloor_Patch.Prefix)))
            //);
            //Farmer Patches
            //FarmHouseStates.harmony.Patch(
            //    original: typeof(Farmer).GetConstructor(new Type[]
            //    {
            //        typeof(FarmerSprite),
            //        typeof(Vector2),
            //        typeof(int),
            //        typeof(string),
            //        typeof(List<Item>),
            //        typeof(bool)
            //    }),
            //    postfix: new HarmonyMethod(AccessTools.Method(typeof(Farmer_Ctor_Patch), nameof(Farmer_Ctor_Patch.Postfix)))
            //);

            FarmState.init();
            FarmHouseStates.init();
            OtherLocations.DecoratableStates.init();
            OtherLocations.FakeDecor.FakeDecorHandler.init();
        }
Exemple #3
0
        public static void Postfix(Farm __instance)
        {
            IReflectedField <NetRectangle> houseSource      = FarmHouseStates.reflector.GetField <NetRectangle>(__instance, "houseSource");
            IReflectedField <NetRectangle> greenhouseSource = FarmHouseStates.reflector.GetField <NetRectangle>(__instance, "greenhouseSource");

            houseSource.SetValue(new NetRectangle(new Microsoft.Xna.Framework.Rectangle(0, 0, 0, 0)));
            greenhouseSource.SetValue(new NetRectangle(new Microsoft.Xna.Framework.Rectangle(0, 0, 0, 0)));
            FarmState.init();
            FarmState.setUpFarm(__instance);
        }
Exemple #4
0
        //internal void drawStuff(object sender, StardewModdingAPI.Events.RenderedHudEventArgs e)
        //{
        //    FarmHouseStates.testCaster.draw(e.SpriteBatch);
        //}

        internal void reloadStaticClasses()
        {
            Logger.Log("Reloading static classes...");
            FarmHouseStates.init();
            FarmHouseStates.clearAll();
            FarmState.init();
            FarmState.setUpFarm(Game1.getFarm());
            OtherLocations.DecoratableStates.init();
            OtherLocations.DecoratableStates.clearAll();
            OtherLocations.FakeDecor.FakeDecorHandler.init();
            //FarmHouseStates.render = FarmHouseStates.renderFarmHouse(Utility.getHomeOfFarmer(Game1.player));
            Logger.Log("House location is " + FarmState.houseLocation.ToString());
            Logger.Log("getPorchStandingSpot() returned " + FarmState.getPorchStandingSpot().ToString());
        }
        public static bool Prefix(StardewValley.Object __instance)
        {
            if (__instance.parentSheetIndex == 688 && FarmState.hasFarmWarpChanged())
            {
                Vector2 farmWarp = FarmState.farmWarpLocation;
                Game1.warpFarmer("Farm", (int)farmWarp.X, (int)farmWarp.Y, false);

                Game1.fadeToBlackAlpha                   = 0.99f;
                Game1.screenGlow                         = false;
                Game1.player.temporarilyInvincible       = false;
                Game1.player.temporaryInvincibilityTimer = 0;
                Game1.displayFarmer                      = true;

                return(false);
            }
            return(true);
        }
 public static void applyPatio(Farm farm, string spouse)
 {
     Map patioMap = getPatioMap(spouse, true);
     if(patioMap == null)
     {
         patioMap = getPatioMap("Default");
         if (patioMap == null)
             return;
     }
     Vector2 standingSpot = new Vector2(2, 4);
     if (patioMap.Properties.ContainsKey("Standing"))
     {
         standingSpot = FarmState.getCoordsFromString(patioMap.Properties["Standing"]);
     }
     patio = new Patio(standingSpot, patioMap, spouse);
     MapUtilities.MapMerger.pasteMap(farm, patio.patioMap, (int)FarmState.spouseOutdoorLocation.X, (int)FarmState.spouseOutdoorLocation.Y);
     //patio.pasteMap(farm, (int)FarmState.spouseOutdoorLocation.X, (int)FarmState.spouseOutdoorLocation.Y);
 }
 public static bool Prefix(string action, Farmer who, Location tileLocation, bool __result, GameLocation __instance)
 {
     if (action == "Mailbox")
     {
         Logger.Log(Game1.player.name + " checked the mailbox at " + tileLocation.ToString() + "...");
         if (__instance is Farm)
         {
             Logger.Log("Mailbox was on the farm...");
             Point mailboxPosition = FarmState.getMailboxPosition(Game1.player);
             Logger.Log(Game1.player.name + "'s mailbox is at " + mailboxPosition.ToString());
             if (tileLocation.X != mailboxPosition.X || tileLocation.Y != mailboxPosition.Y)
             {
                 Logger.Log("Mailbox did not belong to " + Game1.player.name);
                 return(true);
             }
             Logger.Log("Mailbox belonged to " + Game1.player.name);
             __instance.mailbox();
             __result = true;
             return(false);
         }
     }
     return(true);
 }