public override void DoFunction(GameLocation location, int x, int y, int power, StardewValley.Farmer who)
        {
            base.DoFunction(location, x, y, power, who);
            who.Stamina -= ((float)4f - (float)who.FarmingLevel * 0.2f);
            if (this._animal != null && this._animal.type.Value == "Dinosaur" && DataLoader.ModConfig.DisableMeatFromDinosaur)
            {
                return;
            }

            if (this._animal != null && this._animal.age.Value >= (int)this._animal.ageWhenMature.Value)
            {
                (this._animal.home.indoors.Value as AnimalHouse)?.animalsThatLiveHere.Remove(this._animal.myID.Value);
                this._animal.health.Value = -1;
                int numClouds   = this._animal.frontBackSourceRect.Width / 2;
                int cloudSprite = !DataLoader.ModConfig.Softmode ? 5 : 10;
                for (int i = 0; i < numClouds; i++)
                {
                    int   nonRedness = Game1.random.Next(0, 80);
                    Color cloudColor = new Color(255, 255 - nonRedness, 255 - nonRedness);;

                    Game1.currentLocation.temporarySprites.Add
                    (
                        new TemporaryAnimatedSprite
                        (
                            cloudSprite
                            , this._animal.position + new Vector2(Game1.random.Next(-Game1.tileSize / 2, this._animal.frontBackSourceRect.Width * 3)
                                                                  , Game1.random.Next(-Game1.tileSize / 2, this._animal.frontBackSourceRect.Height * 3))
                            , cloudColor
                            , 8
                            , false,
                            Game1.random.NextDouble() < .5 ? 50 : Game1.random.Next(30, 200), 0, Game1.tileSize
                            , -1
                            , Game1.tileSize, Game1.random.NextDouble() < .5 ? 0 : Game1.random.Next(0, 600)
                        )
                    {
                        scale  = Game1.random.Next(2, 5) * .25f,
                        alpha  = Game1.random.Next(2, 5) * .25f,
                        motion = new Vector2(0, (float)-Game1.random.NextDouble())
                    }
                    );
                }
                Color animalColor;
                float alfaFade;
                if (!DataLoader.ModConfig.Softmode)
                {
                    animalColor = Color.LightPink;
                    alfaFade    = .025f;
                }
                else
                {
                    animalColor = Color.White;
                    alfaFade    = .050f;
                }
                Game1.currentLocation.temporarySprites.Add
                (
                    new TemporaryAnimatedSprite
                    (
                        this._animal.Sprite.textureName.Value
                        , this._animal.Sprite.SourceRect
                        , this._animal.position
                        , this._animal.FacingDirection == Game1.left
                        , alfaFade
                        , animalColor
                    )
                {
                    scale = 4f
                }
                );
                if (!DataLoader.ModConfig.Softmode)
                {
                    Game1.playSound("killAnimal");
                }
                else
                {
                    Microsoft.Xna.Framework.Audio.Cue warptSound = Game1.soundBank.GetCue("wand");
                    warptSound.SetVariable("Pitch", 1800);
                    warptSound.Play();
                }

                MeatController.ThrowItem(MeatController.CreateMeat(this._animal), this._animal);
                who.gainExperience(0, 5);
                this._animal     = (FarmAnimal)null;
                this._tempAnimal = (FarmAnimal)null;
            }
        }
示例#2
0
        public static bool DoFunction(Axe __instance, GameLocation location, int x, int y, int power, StardewValley.Farmer who)
        {
            if (!IsMeatCleaver(__instance))
            {
                return(true);
            }

            string meatCleaverId = __instance.modData[MeatCleaverKey];

            BaseToolDoFunction(__instance, location, x, y, power, who);

            if (!__instance.IsEfficient)
            {
                who.Stamina -= ((float)4f - (float)who.FarmingLevel * 0.2f);
            }
            if (!Animals.ContainsKey(meatCleaverId))
            {
                return(false);
            }
            FarmAnimal farmAnimal = Animals[meatCleaverId];

            if (farmAnimal == null ||
                !MeatController.CanGetMeatFrom(Animals[meatCleaverId]) ||
                farmAnimal.age.Value < (int)farmAnimal.ageWhenMature.Value)
            {
                return(false);
            }

            (farmAnimal.home.indoors.Value as AnimalHouse)?.animalsThatLiveHere.Remove(farmAnimal.myID.Value);
            farmAnimal.health.Value = -1;
            int numClouds   = farmAnimal.frontBackSourceRect.Width / 2;
            int cloudSprite = !DataLoader.ModConfig.Softmode ? 5 : 10;

            for (int i = 0; i < numClouds; i++)
            {
                int   nonRedness = Game1.random.Next(0, 80);
                Color cloudColor = new Color(255, 255 - nonRedness, 255 - nonRedness);

                location.temporarySprites.Add(
                    new TemporaryAnimatedSprite
                    (
                        cloudSprite
                        , farmAnimal.position + new Vector2(Game1.random.Next(-Game1.tileSize / 2, farmAnimal.frontBackSourceRect.Width * 3), Game1.random.Next(-Game1.tileSize / 2, farmAnimal.frontBackSourceRect.Height * 3))
                        , cloudColor
                        , 8
                        , false,
                        Game1.random.NextDouble() < .5 ? 50 : Game1.random.Next(30, 200), 0, Game1.tileSize
                        , -1
                        , Game1.tileSize, Game1.random.NextDouble() < .5 ? 0 : Game1.random.Next(0, 600)
                    )
                {
                    scale  = Game1.random.Next(2, 5) * .25f,
                    alpha  = Game1.random.Next(2, 5) * .25f,
                    motion = new Vector2(0, (float)-Game1.random.NextDouble())
                }
                    );
            }

            Color animalColor;
            float alfaFade;

            if (!DataLoader.ModConfig.Softmode)
            {
                animalColor = Color.LightPink;
                alfaFade    = .025f;
            }
            else
            {
                animalColor = Color.White;
                alfaFade    = .050f;
            }

            location.temporarySprites.Add(
                new TemporaryAnimatedSprite
                (
                    farmAnimal.Sprite.textureName.Value
                    , farmAnimal.Sprite.SourceRect
                    , farmAnimal.position
                    , farmAnimal.FacingDirection == Game1.left
                    , alfaFade
                    , animalColor
                )
            {
                scale = 4f
            }
                );
            if (!DataLoader.ModConfig.Softmode)
            {
                location.playSound("killAnimal");
            }
            else
            {
                ICue warptSound = Game1.soundBank.GetCue("wand");
                warptSound.SetVariable("Pitch", 1800);
                warptSound.Play();
            }

            MeatController.ThrowItem(MeatController.CreateMeat(farmAnimal), farmAnimal);
            who.gainExperience(0, 5);
            Animals[meatCleaverId]     = (FarmAnimal)null;
            TempAnimals[meatCleaverId] = (FarmAnimal)null;
            return(false);
        }