コード例 #1
0
        public override void DoFunction(GameLocation location, int x, int y, int power, StardewValley.Farmer who)
        {
            this.lastUser = who;
            Game1.recentMultiplayerRandom  = new Random((int)(short)Game1.random.Next((int)short.MinValue, 32768));
            this.CurrentParentTileIndex    = InitialParentTileIndex;
            this.indexOfMenuItemView.Value = IndexOfMenuItemView;

            if (this._animal != null)
            {
                this._animal.doEmote(20, true);

                if (!DataLoader.ModConfig.DisableFriendshipInscreseWithTreats)
                {
                    double professionAjust = 1.0;
                    if (!_animal.isCoopDweller() && who.professions.Contains(3) || _animal.isCoopDweller() && who.professions.Contains(2))
                    {
                        professionAjust += DataLoader.ModConfig.PercentualAjustOnFriendshipInscreaseFromProfessions;
                    }
                    this._animal.friendshipTowardFarmer.Value = Math.Min(1000, this._animal.friendshipTowardFarmer.Value + (int)Math.Ceiling(professionAjust * this.attachments[0].Price * (1.0 + this.attachments[0].Quality * 0.25) / (this._animal.price.Value / 1000.0)));
                }
                if (!DataLoader.ModConfig.DisableMoodInscreseWithTreats)
                {
                    this._animal.happiness.Value = byte.MaxValue;
                }

                if (DataLoader.ModConfig.EnableTreatsCountAsAnimalFeed)
                {
                    this._animal.fullness.Value = byte.MaxValue;
                }

                TreatsController.FeedAnimalTreat(this._animal, this.attachments[0]);

                if (this.attachments[0].Category == StardewValley.Object.MilkCategory)
                {
                    this._animal.age.Value = Math.Min(this._animal.ageWhenMature.Value - 1, this._animal.age.Value + 1);
                }

                --this.attachments[0].Stack;
                if (this.attachments[0].Stack <= 0)
                {
                    Game1.showGlobalMessage(DataLoader.i18n.Get("Tool.FeedingBasket.ItemConsumed", new { itemName = this.attachments[0].DisplayName }));
                    this.attachments[0] = (StardewValley.Object)null;
                }
            }
            else if (this._pet != null)
            {
                this._pet.doEmote(20, true);

                if (!DataLoader.ModConfig.DisableFriendshipInscreseWithTreats)
                {
                    this._pet.friendshipTowardFarmer.Value = Math.Min(Pet.maxFriendship, this._pet.friendshipTowardFarmer.Value + 6);
                }
                TreatsController.FeedPetTreat(this.attachments[0]);

                --this.attachments[0].Stack;
                if (this.attachments[0].Stack <= 0)
                {
                    Game1.showGlobalMessage(DataLoader.i18n.Get("Tool.FeedingBasket.ItemConsumed", new { itemName = this.attachments[0].DisplayName }));
                    this.attachments[0] = (StardewValley.Object)null;
                }
            }
            this._animal = null;
            this._pet    = null;

            if (Game1.activeClickableMenu == null)
            {
                who.CanMove = true;
                who.completelyStopAnimatingOrDoingAction();
            }
            else
            {
                who.Halt();
            }
            who.UsingTool      = false;
            who.canReleaseTool = true;

            DataLoader.Helper.Reflection.GetMethod(this, "finish").Invoke();
        }