Пример #1
0
        private static bool UseItem(Farmer who, string id)
        {
            Dictionary <string, WarpItem> items = Utils.GetWarpItems();

            if (items.ContainsKey(id))
            {
                WarpItem item = items[id];
                if (item.Destination.ToLower() == "_all")
                {
                    WarpHandler.ShowWarpMenu("", item.Consume);
                    return(true);
                }
                Color color = Utils.ParseColor(item.Color);
                DoTotemWarpEffects(color, id, item.Consume, who, (f) => WarpHandler.DirectWarp(item.Destination, item.IgnoreDisabled));
                return(true);
            }
            return(false);
        }
Пример #2
0
        public static void ButtonPressed(object sender, ButtonPressedEventArgs action)
        {
            if (action.IsSuppressed())
            {
                return;
            }
            Farmer who = Game1.player;

            if (action.Button.IsActionButton())
            {
                if (CanUseHere(who))
                {
                    if (who.ActiveObject != null && !(who.ActiveObject is Furniture))
                    {
                        if (!who.canMove || who.ActiveObject.isTemporarilyInvisible)
                        {
                            return;
                        }
                        string id = null;
                        if (ModEntry.dgaAPI != null)
                        {
                            id = ModEntry.dgaAPI.GetDGAItemId(who.ActiveObject);
                        }
                        if (id == null)
                        {
                            id = who.ActiveObject.ParentSheetIndex.ToString();
                        }
                        if (UseItem(who, id))
                        {
                            ModEntry.helper.Input.Suppress(action.Button);
                        }
                    }
                }
            }
            else if (action.Button.IsUseToolButton() && who.CurrentTool is Wand && ModEntry.config.AccessFromWand && ModEntry.config.MenuEnabled)
            {
                if (CanUseHere(who) && who.CanMove)
                {
                    WarpHandler.ShowWarpMenu("_wand");
                    ModEntry.helper.Input.Suppress(action.Button);
                }
            }
        }