示例#1
0
 public SaveRings(ActualRings ar)
 {
     which1 = getWhich(ar.ring1.Value);
     which2 = getWhich(ar.ring2.Value);
     which3 = getWhich(ar.ring3.Value);
     which4 = getWhich(ar.ring4.Value);
 }
示例#2
0
 public SaveRings(ActualRings er)
 {
     which1 = getWhich(er.ring1);
     which2 = getWhich(er.ring2);
     which3 = getWhich(er.ring3);
     which4 = getWhich(er.ring4);
 }
示例#3
0
        public static void ring_onNewLocation(GameLocation location)
        {
            ActualRings ar = actualdata.GetValue(Game1.player, FarmerNotFound);

            Game1.player.leftRing.Value?.onNewLocation(Game1.player, location);
            Game1.player.rightRing.Value?.onNewLocation(Game1.player, location);
            ar.ring1.Value?.onNewLocation(Game1.player, location);
            ar.ring2.Value?.onNewLocation(Game1.player, location);
            ar.ring3.Value?.onNewLocation(Game1.player, location);
            ar.ring4.Value?.onNewLocation(Game1.player, location);
        }
示例#4
0
        /// <summary>
        /// Add the extra rings to the Netcode tree.
        /// </summary>
        public static void InitFarmer(Farmer f)
        {
            var actualrings = new ActualRings();

            f.NetFields.AddFields(
                actualrings.ring1,
                actualrings.ring2,
                actualrings.ring3,
                actualrings.ring4
                );
            actualdata.Add(f, actualrings);
        }
示例#5
0
        public static void ring_onMonsterSlay(Monster target, GameLocation location, Farmer who)
        {
            if (who == null)
            {
                return;
            }
            ActualRings ar = actualdata.GetValue(who, FarmerNotFound);

            who.leftRing.Value?.onMonsterSlay(target, location, who);
            who.rightRing.Value?.onMonsterSlay(target, location, who);
            ar.ring1.Value?.onMonsterSlay(target, location, who);
            ar.ring2.Value?.onMonsterSlay(target, location, who);
            ar.ring3.Value?.onMonsterSlay(target, location, who);
            ar.ring4.Value?.onMonsterSlay(target, location, who);
        }
示例#6
0
        public static void ring_onMonsterSlay(Farmer who, StardewValley.Monsters.Monster target)
        {
            if (who == null)
            {
                return;
            }
            ActualRings ar = actualdata.GetValue(who, FarmerNotFound);

            who.leftRing.Value?.onMonsterSlay(target);
            who.rightRing.Value?.onMonsterSlay(target);
            ar.ring1.Value?.onMonsterSlay(target);
            ar.ring2.Value?.onMonsterSlay(target);
            ar.ring3.Value?.onMonsterSlay(target);
            ar.ring4.Value?.onMonsterSlay(target);
        }
示例#7
0
        static public void AddEquipmentIcons(InventoryPage page)
        {
            ActualRings ar  = actualdata.GetValue(Game1.player, FarmerNotFound);
            int         inv = Game1.player.MaxItems - 12;

            //             name            x   y   id   up   dn   lt   rt, item
            AddIcon(page, "Hat", 0, 0, 102, inv, 103, -1, 110, Game1.player.hat.Value);
            AddIcon(page, "Shirt", 0, 16, 103, 102, 104, -1, 111, Game1.player.shirtItem.Value);
            AddIcon(page, "Pants", 0, 32, 104, 103, 108, -1, 112, Game1.player.pantsItem.Value);
            AddIcon(page, "Boots", 0, 48, 108, 104, -1, -1, 112, Game1.player.boots.Value);
            AddIcon(page, "Left Ring", 52, 0, 110, inv, 111, 102, 101, Game1.player.leftRing.Value);
            AddIcon(page, "Right Ring", 68, 0, 101, inv, 121, 110, 105, Game1.player.rightRing.Value);
            AddIcon(page, "Extra Ring 1", 52, 16, 111, 110, 112, 103, 121, ar.ring1.Value);
            AddIcon(page, "Extra Ring 2", 68, 16, 121, 101, 122, 111, 105, ar.ring2.Value);
            AddIcon(page, "Extra Ring 3", 52, 32, 112, 111, -1, 104, 122, ar.ring3.Value);
            AddIcon(page, "Extra Ring 4", 68, 32, 122, 121, -1, 112, 105, ar.ring4.Value);
        }
示例#8
0
        public static void UpdateRings(GameTime time, GameLocation location, Farmer f)
        {
            void update(Ring r)
            {
                if (r != null)
                {
                    r.update(time, location, f);
                }
            };

            ActualRings ar = actualdata.GetValue(f, FarmerNotFound);

            update(f.leftRing.Value);
            update(f.rightRing.Value);
            update(ar.ring1.Value);
            update(ar.ring2.Value);
            update(ar.ring3.Value);
            update(ar.ring4.Value);
        }
示例#9
0
        public static IEnumerable <Ring> ListRings(Farmer f)
        {
            var r = new List <Ring>();

            void Add(Ring ring)
            {
                if (ring != null)
                {
                    r.Add(ring);
                }
            }

            ActualRings ar = ModEntry.actualdata.GetValue(f, ModEntry.FarmerNotFound);

            Add(f.leftRing.Value);
            Add(f.rightRing.Value);
            Add(ar.ring1.Value);
            Add(ar.ring2.Value);
            Add(ar.ring3.Value);
            Add(ar.ring4.Value);
            return(r);
        }
示例#10
0
        public static int CountWearingRing(Farmer f, int id)
        {
            bool IsRing(Ring r)
            {
                return(r != null && r.indexInTileSheet.Value == id);
            }

            ActualRings ar  = actualdata.GetValue(f, FarmerNotFound);
            int         res = 0;

            if (IsRing(f.leftRing.Value))
            {
                res++;
            }
            if (IsRing(f.rightRing.Value))
            {
                res++;
            }
            if (IsRing(ar.ring1.Value))
            {
                res++;
            }
            if (IsRing(ar.ring2.Value))
            {
                res++;
            }
            if (IsRing(ar.ring3.Value))
            {
                res++;
            }
            if (IsRing(ar.ring4.Value))
            {
                res++;
            }
            return(res);
        }
示例#11
0
        public static int CountWearingRing(Farmer f, int id)
        {
            bool IsRing(Ring r)
            {
                return(r != null && r.parentSheetIndex == id);
            }

            ActualRings ar  = actualdata.GetValue(f, FarmerNotFound);
            int         res = 0;

            if (IsRing(f.leftRing))
            {
                res++;
            }
            if (IsRing(f.rightRing))
            {
                res++;
            }
            if (IsRing(ar.ring1))
            {
                res++;
            }
            if (IsRing(ar.ring2))
            {
                res++;
            }
            if (IsRing(ar.ring3))
            {
                res++;
            }
            if (IsRing(ar.ring4))
            {
                res++;
            }
            return(res);
        }
示例#12
0
        static public bool EquipmentClick(ClickableComponent icon)
        {
            // Check that item type is compatible.
            // And play corresponding sound.
            var helditem = Game1.player.CursorSlotItem;

            // Convert special items (such as copper pan & Lewis pants)
            if (helditem is StardewValley.Tools.Pan)
            {
                helditem = new Hat(71);
            }
            if (helditem is StardewValley.Object && helditem.ParentSheetIndex == 71)
            {
                helditem = new Clothing(15);
            }
            if (helditem == null)
            {
                if (icon.item == null)
                {
                    return(false);
                }
                Game1.playSound("dwop");
            }
            else
            {
                switch (icon.name)
                {
                case "Hat":
                    if (!(helditem is Hat))
                    {
                        return(false);
                    }
                    Game1.playSound("grassyStep");
                    break;

                case "Shirt":
                    if (!(helditem is Clothing))
                    {
                        return(false);
                    }
                    if ((helditem as Clothing).clothesType.Value != (int)Clothing.ClothesType.SHIRT)
                    {
                        return(false);
                    }
                    Game1.playSound("sandyStep");
                    break;

                case "Pants":
                    if (!(helditem is Clothing))
                    {
                        return(false);
                    }
                    if ((helditem as Clothing).clothesType.Value != (int)Clothing.ClothesType.PANTS)
                    {
                        return(false);
                    }
                    Game1.playSound("sandyStep");
                    break;

                case "Boots":
                    if (!(helditem is Boots))
                    {
                        return(false);
                    }
                    Game1.playSound("sandyStep");
                    DelayedAction.playSoundAfterDelay("sandyStep", 150, null);
                    break;

                default:
                    if (!(helditem is Ring))
                    {
                        return(false);
                    }
                    Game1.playSound("crit");
                    break;
                }
            }

            // I have no idea why StardewValley does this in InventoryPage::setHeldItem, but I guess it might be important.
            if (helditem != null)
            {
                helditem.NetFields.Parent = null;
            }

            // Update inventory
            ActualRings ar = actualdata.GetValue(Game1.player, FarmerNotFound);

            switch (icon.name)
            {
            case "Hat":          Game1.player.hat.Set(helditem as Hat);            break;

            case "Shirt":        Game1.player.shirtItem.Set(helditem as Clothing); break;

            case "Pants":        Game1.player.pantsItem.Set(helditem as Clothing); break;

            case "Boots":        Game1.player.boots.Set(helditem as Boots);        break;

            case "Left Ring":    Game1.player.leftRing.Set(helditem as Ring);      break;

            case "Right Ring":   Game1.player.rightRing.Set(helditem as Ring);     break;

            case "Extra Ring 1": ar.ring1.Set(helditem as Ring);                   break;

            case "Extra Ring 2": ar.ring2.Set(helditem as Ring);                   break;

            case "Extra Ring 3": ar.ring3.Set(helditem as Ring);                   break;

            case "Extra Ring 4": ar.ring4.Set(helditem as Ring);                   break;

            default:
                getInstance().Monitor.Log($"ERROR: Trying to fit equipment item into invalid slot '{icon.name}'", LogLevel.Error);
                return(false);
            }

            // Equip/unequip
            (icon.item as Ring)?.onUnequip(Game1.player, Game1.currentLocation);
            (icon.item as Boots)?.onUnequip();
            (helditem as Ring)?.onEquip(Game1.player, Game1.currentLocation);
            (helditem as Boots)?.onEquip();

            // Swap items
            Game1.player.CursorSlotItem = Utility.PerformSpecialItemGrabReplacement(icon.item);
            icon.item = helditem;
            return(true);
        }
示例#13
0
        static public void EquipmentClick(StardewValley.Menus.ClickableComponent icon)
        {
            // Check that item type is compatible.
            // And play corresponding sound.
            var helditem = Game1.player.CursorSlotItem;

            if (helditem == null)
            {
                if (icon.item == null)
                {
                    return;
                }
                Game1.playSound("dwop");
            }
            else
            {
                switch (icon.name)
                {
                case "Hat":
                    if (!(helditem is Hat))
                    {
                        return;
                    }
                    Game1.playSound("grassyStep");
                    break;

                case "Boots":
                    if (!(helditem is Boots))
                    {
                        return;
                    }
                    Game1.playSound("sandyStep");
                    DelayedAction.playSoundAfterDelay("sandyStep", 150, null);
                    break;

                default:
                    if (!(helditem is Ring))
                    {
                        return;
                    }
                    Game1.playSound("crit");
                    break;
                }
            }

            // I have no idea why StardewValley does this in InventoryPage::setHeldItem, but I guess it might be important.
            if (helditem != null)
            {
                helditem.NetFields.Parent = null;
            }

            // Update inventory
            ActualRings ar = actualdata.GetValue(Game1.player, FarmerNotFound);

            switch (icon.name)
            {
            case "Hat":          Game1.player.hat.Set(helditem as Hat);         break;

            case "Left Ring":    Game1.player.leftRing.Set(helditem as Ring);   break;

            case "Right Ring":   Game1.player.rightRing.Set(helditem as Ring);  break;

            case "Boots":        Game1.player.boots.Set(helditem as Boots);     break;

            case "Extra Ring 1": ar.ring1.Set(helditem as Ring);                break;

            case "Extra Ring 2": ar.ring2.Set(helditem as Ring);                break;

            case "Extra Ring 3": ar.ring3.Set(helditem as Ring);                break;

            case "Extra Ring 4": ar.ring4.Set(helditem as Ring);                break;

            default:
                mon.Log($"ERROR: Trying to fit equipment item into invalid slot '{icon.name}'", LogLevel.Error);
                return;
            }

            // Equip/unequip
            (icon.item as Ring)?.onUnequip(Game1.player, Game1.currentLocation);
            (icon.item as Boots)?.onUnequip();
            (helditem as Ring)?.onEquip(Game1.player, Game1.currentLocation);
            (helditem as Boots)?.onEquip();

            // Swap items
            Game1.player.CursorSlotItem = icon.item;
            icon.item = helditem;
        }
示例#14
0
        static public void AddEquipmentIcon(StardewValley.Menus.InventoryPage page, int x, int y, string name)
        {
            var rect = new Rectangle(
                page.xPositionOnScreen + 48 + x * 64,
                page.yPositionOnScreen + StardewValley.Menus.IClickableMenu.borderWidth + StardewValley.Menus.IClickableMenu.spaceToClearTopBorder + 256 - 12 + y * 64,
                64, 64
                );

            // Get the item that should be in this slot.
            Item item = null;

            if (x == 0)
            {
                if (y == 0)
                {
                    item = Game1.player.hat.Value;
                }
                if (y == 1)
                {
                    item = Game1.player.leftRing.Value;
                }
                if (y == 2)
                {
                    item = Game1.player.rightRing.Value;
                }
                if (y == 3)
                {
                    item = Game1.player.boots.Value;
                }
            }
            else
            {
                ActualRings ar = actualdata.GetValue(Game1.player, FarmerNotFound);
                if (y == 0)
                {
                    item = ar.ring1.Value;
                }
                if (y == 1)
                {
                    item = ar.ring2.Value;
                }
                if (y == 2)
                {
                    item = ar.ring3.Value;
                }
                if (y == 3)
                {
                    item = ar.ring4.Value;
                }
            }

            // Create the GUI element.
            int id        = 101 + 10 * x + y;
            var component = new StardewValley.Menus.ClickableComponent(rect, name)
            {
                myID                = id,
                downNeighborID      = y < 3 ? id + 1 : -1,
                upNeighborID        = y == 0 ? Game1.player.MaxItems - 12 + x : id - 1,
                upNeighborImmutable = y == 0,
                rightNeighborID     = x == 0 ? id + 10 : 105,
                leftNeighborID      = x == 0 ? -1 : id - 10,
                item                = item
            };

            page.equipmentIcons.Add(component);
        }
示例#15
0
        static public void EquipmentClick(StardewValley.Menus.ClickableComponent icon)
        {
            // Check that item type is compatible.
            // And play corresponding sound.
            var helditem = Game1.player.CursorSlotItem;

            if (helditem == null)
            {
                if (icon.item == null)
                {
                    return;
                }
                Game1.playSound("dwop");
            }
            else
            {
                switch (icon.name)
                {
                case "Hat":
                    if (!(helditem is Hat))
                    {
                        return;
                    }
                    Game1.playSound("grassyStep");
                    break;

                case "Boots":
                    if (!(helditem is Boots))
                    {
                        return;
                    }
                    Game1.playSound("sandyStep");
                    DelayedAction.playSoundAfterDelay("sandyStep", 150, null);
                    break;

                default:
                    if (!(helditem is Ring))
                    {
                        return;
                    }
                    Game1.playSound("crit");
                    break;
                }
            }

            // Equip/unequip
            (icon.item as Ring)?.onUnequip(Game1.player, Game1.currentLocation);
            (icon.item as Boots)?.onUnequip();
            (helditem as Ring)?.onEquip(Game1.player, Game1.currentLocation);
            (helditem as Boots)?.onEquip();

            // Swap items
            Game1.player.CursorSlotItem = icon.item;
            icon.item = helditem;

            // Update inventory
            ActualRings ar = actualdata.GetValue(Game1.player, FarmerNotFound);

            if (icon.name == "Hat")
            {
                Game1.player.hat.Set(helditem as Hat);
            }
            if (icon.name == "Left Ring")
            {
                Game1.player.leftRing.Set(helditem as Ring);
            }
            if (icon.name == "Right Ring")
            {
                Game1.player.rightRing.Set(helditem as Ring);
            }
            if (icon.name == "Boots")
            {
                Game1.player.boots.Set(helditem as Boots);
            }
            if (icon.name == "Extra Ring 1")
            {
                ar.ring1.Set(helditem as Ring);
            }
            if (icon.name == "Extra Ring 2")
            {
                ar.ring2.Set(helditem as Ring);
            }
            if (icon.name == "Extra Ring 3")
            {
                ar.ring3.Set(helditem as Ring);
            }
            if (icon.name == "Extra Ring 4")
            {
                ar.ring4.Set(helditem as Ring);
            }
        }