Ejemplo n.º 1
0
 public override bool doAction(Vector2 tileLocation, Farmer who)
 {
     if ((int)daysOfConstructionLeft <= 0 && tileLocation.X >= (float)(int)tileX && tileLocation.X <= (float)((int)tileX + 1) && tileLocation.Y == (float)(int)tileY)
     {
         if (!Game1.didPlayerJustRightClick(ignoreNonMouseHeldInput: true))
         {
             return(false);
         }
         ItemGrabMenu itemGrabMenu = new ItemGrabMenu(null, reverseGrab: true, showReceivingMenu: false, Utility.highlightShippableObjects, shipItem, "", null, snapToBottom: true, canBeExitedWithKey: true, playRightClickSound: false, allowRightClick: true, showOrganizeButton: false, 0, null, -1, this);
         itemGrabMenu.initializeUpperRightCloseButton();
         itemGrabMenu.setBackgroundTransparency(b: false);
         itemGrabMenu.setDestroyItemOnClick(b: true);
         itemGrabMenu.initializeShippingBin();
         Game1.activeClickableMenu = itemGrabMenu;
         if (who.IsLocalPlayer)
         {
             Game1.playSound("shwip");
         }
         if (Game1.player.FacingDirection == 1)
         {
             Game1.player.Halt();
         }
         Game1.player.showCarrying();
         return(true);
     }
     return(base.doAction(tileLocation, who));
 }
Ejemplo n.º 2
0
        public static void Postfix(Farm __instance, ref bool __result, Location tileLocation, Rectangle viewport, Farmer who)
        {
            if (__instance is FarmExtension)
            {
                return;
            }
            int binX = (Memory.isCustomFarmLoaded) ? Memory.loadedFarm.shippingBin.pointOfInteraction.x : 71;
            int binY = (Memory.isCustomFarmLoaded) ? Memory.loadedFarm.shippingBin.pointOfInteraction.y : 13;

            if (tileLocation.X >= binX && tileLocation.X <= binX + 1 && tileLocation.Y >= binY && tileLocation.Y <= binY + 1)
            {
                currentFarm = __instance;
                ItemGrabMenu itemGrabMenu = new ItemGrabMenu(null, true, false, new InventoryMenu.highlightThisItem(Utility.highlightShippableObjects), new ItemGrabMenu.behaviorOnItemSelect(shipItem), "", null, true, true, false, true, false, 0, null, -1, null);
                itemGrabMenu.initializeUpperRightCloseButton();
                itemGrabMenu.setBackgroundTransparency(false);
                itemGrabMenu.setDestroyItemOnClick(true);
                itemGrabMenu.initializeShippingBin();
                Game1.activeClickableMenu = itemGrabMenu;
                __instance.playSound("shwip");
                if (Game1.player.FacingDirection == 1)
                {
                    Game1.player.Halt();
                }
                Game1.player.showCarrying();
                __result = true;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Postfix method. Occurs after the original method of Farm.checkAction is executed.
        ///
        /// Reimplements operations pertaining to user clicking on the starting shipping bin,
        /// allowing for the shipping bin to be relocated.
        /// </summary>
        /// <param name="__instance">The instance of the Farm class</param>
        /// <param name="__result">The results from the original checkAction method.</param>
        /// <param name="tileLocation">From original method. The tile location that was clicked.</param>
        /// <param name="viewport">From original method. The user's viewport.</param>
        /// <param name="who">From original method. The farmer (player) who clicked</param>
        public static void Postfix(Farm __instance, ref bool __result, Location tileLocation, Rectangle viewport, Farmer who)
        {
            if (currentFarm != __instance)
            {
                currentFarm = __instance;
            }
            int binX = (customManager.Canon) ? 71 : customManager.ShippingBinPoints.X;
            int binY = (customManager.Canon) ? 13 : customManager.ShippingBinPoints.Y;

            if (tileLocation.X >= binX && tileLocation.X <= binX + 1 && tileLocation.Y >= binY && tileLocation.Y <= binY + 1)
            {
                ItemGrabMenu itemGrabMenu = new ItemGrabMenu(null, true, false, new InventoryMenu.highlightThisItem(Utility.highlightShippableObjects), new ItemGrabMenu.behaviorOnItemSelect(shipItem), "", null, true, true, false, true, false, 0, null, -1, null);
                itemGrabMenu.initializeUpperRightCloseButton();
                itemGrabMenu.setBackgroundTransparency(false);
                itemGrabMenu.setDestroyItemOnClick(true);
                itemGrabMenu.initializeShippingBin();
                Game1.activeClickableMenu = itemGrabMenu;
                __instance.playSound("shwip");
                if (Game1.player.FacingDirection == 1)
                {
                    Game1.player.Halt();
                }
                Game1.player.showCarrying();
                __result = true;
            }
            return;
        }
Ejemplo n.º 4
0
        private ItemGrabMenu ShippingBin()
        {
            ItemGrabMenu itemGrabMenu = new ItemGrabMenu(null, true, false,
                                                         Utility.highlightShippableObjects,
                                                         Game1.getFarm().shipItem, "", snapToBottom: true,
                                                         canBeExitedWithKey: true, playRightClickSound: false, context: this);

            itemGrabMenu.initializeUpperRightCloseButton();
            itemGrabMenu.setBackgroundTransparency(false);
            itemGrabMenu.setDestroyItemOnClick(true);
            itemGrabMenu.initializeShippingBin();
            return(itemGrabMenu);
        }
Ejemplo n.º 5
0
        private static void ShipmentBin(string tileActionString, Vector2 position)
        {
            MethodInfo   method       = typeof(Farm).GetMethod("shipItem");
            ItemGrabMenu itemGrabMenu = new ItemGrabMenu((List <Item>)null, true, false, new InventoryMenu.highlightThisItem(Utility.highlightShippableObjects), (ItemGrabMenu.behaviorOnItemSelect)Delegate.CreateDelegate(typeof(ItemGrabMenu.behaviorOnItemSelect), (object)Game1.getFarm(), method), "", (ItemGrabMenu.behaviorOnItemSelect)null, true, true, false, true, false, 0, (Item)null, -1, (object)null);

            itemGrabMenu.initializeUpperRightCloseButton();
            int num1 = 0;

            itemGrabMenu.setBackgroundTransparency((uint)num1 > 0U);
            int num2 = 1;

            itemGrabMenu.setDestroyItemOnClick((uint)num2 > 0U);
            itemGrabMenu.initializeShippingBin();
            Game1.activeClickableMenu = (IClickableMenu)itemGrabMenu;
        }
Ejemplo n.º 6
0
        private ItemGrabMenu ShippingBin()
        {
            MethodInfo method = typeof(Farm).GetMethod("shipItem", BindingFlags.Instance | BindingFlags.NonPublic);

            ItemGrabMenu.behaviorOnItemSelect behaviorOnItemSelectFunction = (ItemGrabMenu.behaviorOnItemSelect)Delegate.CreateDelegate(typeof(ItemGrabMenu.behaviorOnItemSelect), Game1.getFarm(), method);
            ItemGrabMenu itemGrabMenu = new ItemGrabMenu(null, true, false, new InventoryMenu.highlightThisItem(Utility.highlightShippableObjects), behaviorOnItemSelectFunction, "", null, true, true, false, true, false, 0, null, -1, null);

            itemGrabMenu.initializeUpperRightCloseButton();
            int num = 0;

            itemGrabMenu.setBackgroundTransparency(num != 0);
            int num2 = 1;

            itemGrabMenu.setDestroyItemOnClick(num2 != 0);
            itemGrabMenu.initializeShippingBin();
            return(itemGrabMenu);
        }
Ejemplo n.º 7
0
        /// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnButtonPressed(object sender, ButtonPressedEventArgs e)
        {
            if (!Context.IsWorldReady || !Context.IsPlayerFree)
            {
                return;
            }

            if (e.Button == Config.OpenShippingBox)
            {
                var func = typeof(Farm).GetMethod("shipItem", BindingFlags.Instance | BindingFlags.NonPublic, null, new[] { typeof(Item), typeof(Farmer) }, null);
                var del  = (ItemGrabMenu.behaviorOnItemSelect)Delegate.CreateDelegate(typeof(ItemGrabMenu.behaviorOnItemSelect), Game1.getFarm(), func);

                ItemGrabMenu itemGrabMenu = new ItemGrabMenu((List <Item>)null, true, false, Utility.highlightShippableObjects, del, "", null, true, true, false);
                itemGrabMenu.initializeUpperRightCloseButton();
                int num1 = 0;
                itemGrabMenu.setBackgroundTransparency(num1 != 0);
                int num2 = 1;
                itemGrabMenu.setDestroyItemOnClick(num2 != 0);
                itemGrabMenu.initializeShippingBin();
                Game1.activeClickableMenu = itemGrabMenu;
            }
        }
Ejemplo n.º 8
0
        private void onKeyPress(object mod, EventArgsKeyPressed args)
        {
            if (!Context.IsWorldReady || !Context.IsPlayerFree)
            {
                return;
            }

            if (args.KeyPressed == Config.OpenShippingBox.key)
            {
                var func = typeof(Farm).GetMethod("shipItem", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                var del  = (ItemGrabMenu.behaviorOnItemSelect)Delegate.CreateDelegate(typeof(ItemGrabMenu.behaviorOnItemSelect), Game1.getFarm(), func);

                ItemGrabMenu itemGrabMenu = new ItemGrabMenu((List <Item>)null, true, false, new InventoryMenu.highlightThisItem(Utility.highlightShippableObjects), del, "", (ItemGrabMenu.behaviorOnItemSelect)null, true, true, false, true, false, 0, (Item)null, -1, (object)null);
                itemGrabMenu.initializeUpperRightCloseButton();
                int num1 = 0;
                itemGrabMenu.setBackgroundTransparency(num1 != 0);
                int num2 = 1;
                itemGrabMenu.setDestroyItemOnClick(num2 != 0);
                itemGrabMenu.initializeShippingBin();
                Game1.activeClickableMenu = (IClickableMenu)itemGrabMenu;
            }
        }
Ejemplo n.º 9
0
 public static bool Prefix(xTile.Dimensions.Location tileLocation, xTile.Dimensions.Rectangle viewport, Farmer who, ref bool __result, Farm __instance)
 {
     if (tileLocation.X >= FarmState.shippingCrateLocation.X && tileLocation.X <= FarmState.shippingCrateLocation.X + 1 && (tileLocation.Y >= FarmState.shippingCrateLocation.Y - 1 && tileLocation.Y <= FarmState.shippingCrateLocation.Y))
     {
         //IReflectedMethod shipItem = FarmHouseStates.reflector.GetMethod(__instance, "shipItem");
         ItemGrabMenu itemGrabMenu = new ItemGrabMenu((IList <Item>)null, true, false, new InventoryMenu.highlightThisItem(StardewValley.Utility.highlightShippableObjects), new ItemGrabMenu.behaviorOnItemSelect(shipItem), "", (ItemGrabMenu.behaviorOnItemSelect)null, true, true, false, true, false, 0, (Item)null, -1, (object)__instance);
         itemGrabMenu.initializeUpperRightCloseButton();
         int num1 = 0;
         itemGrabMenu.setBackgroundTransparency(num1 != 0);
         int num2 = 1;
         itemGrabMenu.setDestroyItemOnClick(num2 != 0);
         itemGrabMenu.initializeShippingBin();
         Game1.activeClickableMenu = (IClickableMenu)itemGrabMenu;
         __instance.playSound("shwip");
         if (Game1.player.FacingDirection == 1)
         {
             Game1.player.Halt();
         }
         Game1.player.showCarrying();
         __result = true;
         return(false);
     }
     return(true);
 }
Ejemplo n.º 10
0
 public override bool checkAction(Location tileLocation, xTile.Dimensions.Rectangle viewport, Farmer who)
 {
     if (farmhouseRestored.Value && tileLocation.X >= shippingBinPosition.X && tileLocation.X <= shippingBinPosition.X + 1 && tileLocation.Y >= shippingBinPosition.Y - 1 && tileLocation.Y <= shippingBinPosition.Y)
     {
         ItemGrabMenu itemGrabMenu = new ItemGrabMenu(null, reverseGrab: true, showReceivingMenu: false, Utility.highlightShippableObjects, Game1.getFarm().shipItem, "", null, snapToBottom: true, canBeExitedWithKey: true, playRightClickSound: false, allowRightClick: true, showOrganizeButton: false, 0, null, -1, this);
         itemGrabMenu.initializeUpperRightCloseButton();
         itemGrabMenu.setBackgroundTransparency(b: false);
         itemGrabMenu.setDestroyItemOnClick(b: true);
         itemGrabMenu.initializeShippingBin();
         Game1.activeClickableMenu = itemGrabMenu;
         playSound("shwip");
         if (Game1.player.FacingDirection == 1)
         {
             Game1.player.Halt();
         }
         Game1.player.showCarrying();
         return(true);
     }
     if (getTileIndexAt(tileLocation.X, tileLocation.Y, "Buildings") != -1)
     {
         int tileIndexAt = getTileIndexAt(tileLocation.X, tileLocation.Y, "Buildings");
         if (tileIndexAt == 1470)
         {
             int actual_found_walnuts_count = Math.Max(0, Game1.netWorldState.Value.GoldenWalnutsFound.Value - 1);
             if (actual_found_walnuts_count < 100)
             {
                 Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\Locations:qiNutDoor", actual_found_walnuts_count));
             }
             else
             {
                 Game1.playSound("doorClose");
                 Game1.warpFarmer("QiNutRoom", 7, 8, 0);
             }
             return(true);
         }
     }
     if (getCharacterFromName("Birdie") != null && !getCharacterFromName("Birdie").IsInvisible&& (getCharacterFromName("Birdie").getTileLocation().Equals(new Vector2(tileLocation.X, tileLocation.Y)) || getCharacterFromName("Birdie").getTileLocation().Equals(new Vector2(tileLocation.X - 1, tileLocation.Y))))
     {
         if (!who.mailReceived.Contains("birdieQuestBegun"))
         {
             who.Halt();
             Game1.globalFadeToBlack(delegate
             {
                 startEvent(new Event(Game1.content.LoadString("Strings\\Locations:IslandSecret_Event_BirdieIntro"), -888999));
             });
             who.mailReceived.Add("birdieQuestBegun");
             return(true);
         }
         if (who.hasQuest(130) && !who.mailReceived.Contains("birdieQuestFinished") && who.ActiveObject != null && Utility.IsNormalObjectAtParentSheetIndex(who.ActiveObject, 870))
         {
             who.Halt();
             Game1.globalFadeToBlack(delegate
             {
                 who.reduceActiveItemByOne();
                 startEvent(new Event(Game1.content.LoadString("Strings\\Locations:IslandSecret_Event_BirdieFinished"), -666777));
             });
             who.mailReceived.Add("birdieQuestFinished");
             return(true);
         }
         if (who.mailReceived.Contains("birdieQuestFinished"))
         {
             if (who.ActiveObject != null)
             {
                 Game1.drawDialogue(getCharacterFromName("Birdie"), Utility.loadStringDataShort("ExtraDialogue", "Birdie_NoGift"));
             }
             else
             {
                 string possible = null;
                 try
                 {
                     possible = Game1.content.LoadStringReturnNullIfNotFound("Data\\ExtraDialogue:Birdie" + Game1.dayOfMonth);
                 }
                 catch (Exception)
                 {
                 }
                 if (possible != null && possible.Length > 0)
                 {
                     Game1.drawDialogue(getCharacterFromName("Birdie"), possible);
                 }
                 else
                 {
                     Game1.drawDialogue(getCharacterFromName("Birdie"), Utility.loadStringDataShort("ExtraDialogue", "Birdie" + Game1.dayOfMonth % 7));
                 }
             }
         }
     }
     return(base.checkAction(tileLocation, viewport, who));
 }
        /// <summary>Trigger the action for the tile under the cursor, if applicable.</summary>
        private bool TryAction()
        {
            if (Game1.numberOfSelectedItems != -1 || Game1.activeClickableMenu != null)
            {
                return(false);
            }

            // get tile undor cursor
            Vector2 actionPos  = this.GetActionCursor();
            Tile    actionTile = Game1.currentLocation.map.GetLayer("Buildings").Tiles[(int)actionPos.X, (int)actionPos.Y];

            if (actionTile == null)
            {
                return(false);
            }

            // get tile action
            PropertyValue propertyValue;

            actionTile.Properties.TryGetValue("Action", out propertyValue);
            if (propertyValue == null)
            {
                return(false);
            }
            string action = propertyValue.ToString();

            // handle action
            switch (action)
            {
            case "NewShippingBin":
            {
                ItemGrabMenu itemGrabMenu = new ItemGrabMenu(null, true, false, Utility.highlightShippableObjects, this.ShipItem, "", null, true, true, false);
                itemGrabMenu.initializeUpperRightCloseButton();
                itemGrabMenu.setBackgroundTransparency(false);
                itemGrabMenu.setDestroyItemOnClick(true);
                itemGrabMenu.initializeShippingBin();
                Game1.activeClickableMenu = itemGrabMenu;
                Game1.playSound("shwip");
                if (Game1.player.facingDirection == 1)
                {
                    Game1.player.Halt();
                }
                Game1.player.showCarrying();
                return(true);
            }

            case "TelescopeMessage":
            {
                Random   random   = new Random();
                string[] messages =
                {
                    "I wish Neil DeGrasse Tyson was here.",
                    "I call this star mine... and that one, oh, and that one too.",
                    "Astronomy compels the soul to look upward, and leads us from this world to another.",
                    "Be glad of life, because it gives you the chance to love and to work and to play and to look up at the stars.",
                    "The sky is the ultimate art gallery just above us.",
                    "'Stop acting so small. You are the universe in estatic motion.' - Rumi",
                    "The universe doesn't give you what you ask for with your thoughts, it gives you what you demand with your actions.",
                    "The darkest nights produce the brightest stars.",
                    "'there wouldn't be a sky full of stars if we were all meant to wish on the same one.' - Frances Clark",
                    "Stars can't shine without darkness.",
                    "I have loved the stars too fondly to be fearful of the night.",
                    "I know nothing with any certainty, but the sight of the stars makes me dream."
                };
                Game1.drawObjectDialogue(messages[random.Next(messages.Length)]);
                return(true);
            }
            }
            return(false);
        }