/*********
        ** Present-related functions
        *********/

        public override bool checkAction(Location tileLocation, xTile.Dimensions.Rectangle viewport, Farmer who)
        {
            var location = new Point(tileLocation.X, tileLocation.Y);
            var stage    = info.DimensionImplementation.CurrentStage();

            if (Game1.didPlayerJustRightClick())
            {
                if ((stage == 1 || stage == 5 || Game1.stats.DaysPlayed - daysPlayedAtStageOpen >= 2) && presents.ContainsKey(stage) && presents[stage].ContainsKey(location))
                {
                    openPresent(stage, location);
                    return(true);
                }
            }
            return(base.checkAction(tileLocation, viewport, who));
        }
Пример #2
0
            public static void Postfix(Farmer __instance, xTile.Dimensions.Rectangle viewport, GameLocation currentLocation, ref Vector2 __state)
            {
                if (!IsModEnabled())
                {
                    return;
                }

                if (backwardsFarmer)
                {
                    Vector2   dest          = __state - (__instance.Position - __state);
                    int       width         = __instance.GetSpriteWidthForPositioning() * 4 * 3 / 4;
                    Rectangle destRectFloor = new Rectangle((int)Math.Floor(dest.X) - 8, (int)Math.Floor(dest.Y) - 16, width, 32);
                    Rectangle destRectCeil  = new Rectangle((int)Math.Ceiling(dest.X) + 8, (int)Math.Ceiling(dest.Y) + 16, width, 32);
                    Rectangle destRect      = Rectangle.Union(destRectCeil, destRectFloor);
                    if (!currentLocation.isCollidingPosition(destRect, viewport, true, -1, false, __instance))
                    {
                        __instance.Position = dest;
                    }
                }
            }
Пример #3
0
            public static bool Prefix(GameLocation __instance, Location tileLocation, xTile.Dimensions.Rectangle viewport, Farmer who)
            {
                if (!Config.EnableMod || !Game1.currentLocation.Name.Equals("Dreamscape"))
                {
                    return(true);
                }

                if (tileLocation.X == 21 && tileLocation.Y == 9)
                {
                    TemporaryAnimatedSprite t = __instance.getTemporarySpriteByID(5858585);
                    if (t != null && t is EmilysParrot)
                    {
                        (t as EmilysParrot).doAction();
                        return(false);
                    }
                }
                else if (new Rectangle(3, 20, 2, 2).Contains(new Point(tileLocation.X, tileLocation.Y)))
                {
                    __instance.localSound("yoba");
                    who.health  = who.maxHealth;
                    who.stamina = who.MaxStamina;
                }

                return(true);
            }
Пример #4
0
 public static bool Prefix(GameLocation __instance, Location tileLocation, xTile.Dimensions.Rectangle viewport, Farmer who, ref bool __result)
 {
     if (!Config.EnableMod)
     {
         return(true);
     }
     if (Config.AllowOthersToPick)
     {
         foreach (Farmer farmer in Game1.getAllFarmers())
         {
             var loc = farmer.Position + new Vector2(32, -88);
             if (who.currentLocation == farmer.currentLocation && farmer.hat.Value is not null && Vector2.Distance(Game1.GlobalToLocal(loc), Game1.getMousePosition().ToVector2()) < 32 && farmer.hat.Value.modData.TryGetValue(phaseKey, out string phaseString))
             {
                 if (ReadyToHarvest(farmer.hat.Value) && Utility.withinRadiusOfPlayer((int)farmer.Position.X, (int)farmer.Position.Y, 1, Game1.player))
                 {
                     HarvestHatCrop(farmer);
                     __result = true;
                     return(false);
                 }
             }
         }
     }
     else
     {
         var loc = Game1.player.Position + new Vector2(32, -88);
         if (Vector2.Distance(Game1.GlobalToLocal(loc), Game1.getMousePosition().ToVector2()) < 32 && Game1.player.hat.Value is not null && Game1.player.hat.Value.modData.TryGetValue(phaseKey, out string phaseString))
         {
             if (ReadyToHarvest(Game1.player.hat.Value))
             {
                 HarvestHatCrop(Game1.player);
                 __result = true;
                 return(false);
             }
         }
     }
     return(true);
 }
Пример #5
0
 public override void MovePosition(GameTime time, xTile.Dimensions.Rectangle viewport, GameLocation currentLocation)
 {
     lastPosition = base.Position;
     if (xVelocity != 0f || yVelocity != 0f)
     {
         if (double.IsNaN((double)xVelocity) || double.IsNaN((double)yVelocity))
         {
             xVelocity = 0f;
             yVelocity = 0f;
         }
         Microsoft.Xna.Framework.Rectangle nextPosition = GetBoundingBox();
         nextPosition.X += (int)xVelocity;
         nextPosition.Y -= (int)yVelocity;
         if (!currentLocation.isCollidingPosition(nextPosition, viewport, false, DamageToFarmer, isGlider, this))
         {
             position.X += xVelocity;
             position.Y -= yVelocity;
             if (Slipperiness < 1000)
             {
                 xVelocity -= xVelocity / (float)Slipperiness;
                 yVelocity -= yVelocity / (float)Slipperiness;
                 if (Math.Abs(xVelocity) <= 0.05f)
                 {
                     xVelocity = 0f;
                 }
                 if (Math.Abs(yVelocity) <= 0.05f)
                 {
                     yVelocity = 0f;
                 }
             }
             if (!isGlider && invincibleCountdown > 0)
             {
                 slideAnimationTimer -= time.ElapsedGameTime.Milliseconds;
                 if (slideAnimationTimer < 0 && (Math.Abs(xVelocity) >= 3f || Math.Abs(yVelocity) >= 3f))
                 {
                     slideAnimationTimer = 100 - (int)(Math.Abs(xVelocity) * 2f + Math.Abs(yVelocity) * 2f);
                     ModEntry.mp.broadcastSprites(currentLocation, new TemporaryAnimatedSprite[]
                     {
                         new TemporaryAnimatedSprite(6, base.getStandingPosition() + new Vector2(-32f, -32f), Color.White * 0.75f, 8, Game1.random.NextDouble() < 0.5, 20f, 0, -1, -1f, -1, 0)
                         {
                             scale = 0.75f
                         }
                     });
                 }
             }
         }
         else if (isGlider || Slipperiness >= 8)
         {
             bool[] array = Utility.horizontalOrVerticalCollisionDirections(nextPosition, this, false);
             if (array[0])
             {
                 xVelocity   = -xVelocity;
                 position.X += (float)Math.Sign(xVelocity);
                 rotation   += (float)(3.1415926535897931 + (double)Game1.random.Next(-10, 11) * 3.1415926535897931 / 500.0);
             }
             if (array[1])
             {
                 yVelocity   = -yVelocity;
                 position.Y -= (float)Math.Sign(yVelocity);
                 rotation   += (float)(3.1415926535897931 + (double)Game1.random.Next(-10, 11) * 3.1415926535897931 / 500.0);
             }
             if (Slipperiness < 1000)
             {
                 xVelocity -= xVelocity / (float)Slipperiness / 4f;
                 yVelocity -= yVelocity / (float)Slipperiness / 4f;
                 if (Math.Abs(xVelocity) <= 0.05f)
                 {
                     xVelocity = 0f;
                 }
                 if (Math.Abs(yVelocity) <= 0.051f)
                 {
                     yVelocity = 0f;
                 }
             }
         }
         else
         {
             xVelocity -= xVelocity / (float)Slipperiness;
             yVelocity -= yVelocity / (float)Slipperiness;
             if (Math.Abs(xVelocity) <= 0.05f)
             {
                 xVelocity = 0f;
             }
             if (Math.Abs(yVelocity) <= 0.05f)
             {
                 yVelocity = 0f;
             }
         }
         if (isGlider)
         {
             return;
         }
     }
     if (moveUp)
     {
         if (((!Game1.eventUp || Game1.IsMultiplayer) && !currentLocation.isCollidingPosition(nextPosition(0), viewport, false, DamageToFarmer, isGlider, this)) || isCharging)
         {
             position.Y -= (float)(base.speed + base.addedSpeed);
             if (!ignoreMovementAnimations)
             {
                 Sprite.AnimateUp(time, 0, "");
             }
             base.FacingDirection = 0;
             faceDirection(0);
         }
         else
         {
             Microsoft.Xna.Framework.Rectangle tmp = nextPosition(0);
             tmp.Width /= 4;
             bool leftCorner = currentLocation.isCollidingPosition(tmp, viewport, false, DamageToFarmer, isGlider, this);
             tmp.X += tmp.Width * 3;
             bool rightCorner = currentLocation.isCollidingPosition(tmp, viewport, false, DamageToFarmer, isGlider, this);
             if (leftCorner && !rightCorner && !currentLocation.isCollidingPosition(nextPosition(1), viewport, false, DamageToFarmer, isGlider, this))
             {
                 position.X += (float)base.speed * ((float)time.ElapsedGameTime.Milliseconds / 64f);
             }
             else if (rightCorner && !leftCorner && !currentLocation.isCollidingPosition(nextPosition(3), viewport, false, DamageToFarmer, isGlider, this))
             {
                 position.X -= (float)base.speed * ((float)time.ElapsedGameTime.Milliseconds / 64f);
             }
             if (!currentLocation.isTilePassable(nextPosition(0), viewport) || !base.willDestroyObjectsUnderfoot)
             {
                 Halt();
             }
             else if (base.willDestroyObjectsUnderfoot)
             {
                 new Vector2((float)(base.getStandingX() / 64), (float)(base.getStandingY() / 64 - 1));
                 if (currentLocation.characterDestroyObjectWithinRectangle(nextPosition(0), true))
                 {
                     currentLocation.playSound("stoneCrack", NetAudio.SoundContext.Default);
                     position.Y -= (float)(base.speed + base.addedSpeed);
                 }
                 else
                 {
                     blockedInterval += time.ElapsedGameTime.Milliseconds;
                 }
             }
             if (onCollision != null)
             {
                 onCollision(currentLocation);
             }
         }
     }
     else if (moveRight)
     {
         if (((!Game1.eventUp || Game1.IsMultiplayer) && !currentLocation.isCollidingPosition(nextPosition(1), viewport, false, DamageToFarmer, isGlider, this)) || isCharging)
         {
             position.X += (float)(base.speed + base.addedSpeed);
             if (!ignoreMovementAnimations)
             {
                 Sprite.AnimateRight(time, 0, "");
             }
             base.FacingDirection = 1;
             faceDirection(1);
         }
         else
         {
             Microsoft.Xna.Framework.Rectangle tmp2 = nextPosition(1);
             tmp2.Height /= 4;
             bool topCorner = currentLocation.isCollidingPosition(tmp2, viewport, false, DamageToFarmer, isGlider, this);
             tmp2.Y += tmp2.Height * 3;
             bool bottomCorner = currentLocation.isCollidingPosition(tmp2, viewport, false, DamageToFarmer, isGlider, this);
             if (topCorner && !bottomCorner && !currentLocation.isCollidingPosition(nextPosition(2), viewport, false, DamageToFarmer, isGlider, this))
             {
                 position.Y += (float)base.speed * ((float)time.ElapsedGameTime.Milliseconds / 64f);
             }
             else if (bottomCorner && !topCorner && !currentLocation.isCollidingPosition(nextPosition(0), viewport, false, DamageToFarmer, isGlider, this))
             {
                 position.Y -= (float)base.speed * ((float)time.ElapsedGameTime.Milliseconds / 64f);
             }
             if (!currentLocation.isTilePassable(nextPosition(1), viewport) || !base.willDestroyObjectsUnderfoot)
             {
                 Halt();
             }
             else if (base.willDestroyObjectsUnderfoot)
             {
                 new Vector2((float)(base.getStandingX() / 64 + 1), (float)(base.getStandingY() / 64));
                 if (currentLocation.characterDestroyObjectWithinRectangle(nextPosition(1), true))
                 {
                     currentLocation.playSound("stoneCrack", NetAudio.SoundContext.Default);
                     position.X += (float)(base.speed + base.addedSpeed);
                 }
                 else
                 {
                     blockedInterval += time.ElapsedGameTime.Milliseconds;
                 }
             }
             if (onCollision != null)
             {
                 onCollision(currentLocation);
             }
         }
     }
     else if (moveDown)
     {
         if (((!Game1.eventUp || Game1.IsMultiplayer) && !currentLocation.isCollidingPosition(nextPosition(2), viewport, false, DamageToFarmer, isGlider, this)) || isCharging)
         {
             position.Y += (float)(base.speed + base.addedSpeed);
             if (!ignoreMovementAnimations)
             {
                 Sprite.AnimateDown(time, 0, "");
             }
             base.FacingDirection = 2;
             faceDirection(2);
         }
         else
         {
             Microsoft.Xna.Framework.Rectangle tmp3 = nextPosition(2);
             tmp3.Width /= 4;
             bool leftCorner2 = currentLocation.isCollidingPosition(tmp3, viewport, false, DamageToFarmer, isGlider, this);
             tmp3.X += tmp3.Width * 3;
             bool rightCorner2 = currentLocation.isCollidingPosition(tmp3, viewport, false, DamageToFarmer, isGlider, this);
             if (leftCorner2 && !rightCorner2 && !currentLocation.isCollidingPosition(nextPosition(1), viewport, false, DamageToFarmer, isGlider, this))
             {
                 position.X += (float)base.speed * ((float)time.ElapsedGameTime.Milliseconds / 64f);
             }
             else if (rightCorner2 && !leftCorner2 && !currentLocation.isCollidingPosition(nextPosition(3), viewport, false, DamageToFarmer, isGlider, this))
             {
                 position.X -= (float)base.speed * ((float)time.ElapsedGameTime.Milliseconds / 64f);
             }
             if (!currentLocation.isTilePassable(nextPosition(2), viewport) || !base.willDestroyObjectsUnderfoot)
             {
                 Halt();
             }
             else if (base.willDestroyObjectsUnderfoot)
             {
                 new Vector2((float)(base.getStandingX() / 64), (float)(base.getStandingY() / 64 + 1));
                 if (currentLocation.characterDestroyObjectWithinRectangle(nextPosition(2), true))
                 {
                     currentLocation.playSound("stoneCrack", NetAudio.SoundContext.Default);
                     position.Y += (float)(base.speed + base.addedSpeed);
                 }
                 else
                 {
                     blockedInterval += time.ElapsedGameTime.Milliseconds;
                 }
             }
             if (onCollision != null)
             {
                 onCollision(currentLocation);
             }
         }
     }
     else if (moveLeft)
     {
         if (((!Game1.eventUp || Game1.IsMultiplayer) && !currentLocation.isCollidingPosition(nextPosition(3), viewport, false, DamageToFarmer, isGlider, this)) || isCharging)
         {
             position.X          -= (float)(base.speed + base.addedSpeed);
             base.FacingDirection = 3;
             if (!ignoreMovementAnimations)
             {
                 Sprite.AnimateLeft(time, 0, "");
             }
             faceDirection(3);
         }
         else
         {
             Microsoft.Xna.Framework.Rectangle tmp4 = nextPosition(3);
             tmp4.Height /= 4;
             bool topCorner2 = currentLocation.isCollidingPosition(tmp4, viewport, false, DamageToFarmer, isGlider, this);
             tmp4.Y += tmp4.Height * 3;
             bool bottomCorner2 = currentLocation.isCollidingPosition(tmp4, viewport, false, DamageToFarmer, isGlider, this);
             if (topCorner2 && !bottomCorner2 && !currentLocation.isCollidingPosition(nextPosition(2), viewport, false, DamageToFarmer, isGlider, this))
             {
                 position.Y += (float)base.speed * ((float)time.ElapsedGameTime.Milliseconds / 64f);
             }
             else if (bottomCorner2 && !topCorner2 && !currentLocation.isCollidingPosition(nextPosition(0), viewport, false, DamageToFarmer, isGlider, this))
             {
                 position.Y -= (float)base.speed * ((float)time.ElapsedGameTime.Milliseconds / 64f);
             }
             if (!currentLocation.isTilePassable(nextPosition(3), viewport) || !base.willDestroyObjectsUnderfoot)
             {
                 Halt();
             }
             else if (base.willDestroyObjectsUnderfoot)
             {
                 new Vector2((float)(base.getStandingX() / 64 - 1), (float)(base.getStandingY() / 64));
                 if (currentLocation.characterDestroyObjectWithinRectangle(nextPosition(3), true))
                 {
                     currentLocation.playSound("stoneCrack", NetAudio.SoundContext.Default);
                     position.X -= (float)(base.speed + base.addedSpeed);
                 }
                 else
                 {
                     blockedInterval += time.ElapsedGameTime.Milliseconds;
                 }
             }
             if (onCollision != null)
             {
                 onCollision(currentLocation);
             }
         }
     }
     else if (!ignoreMovementAnimations)
     {
         if (moveUp)
         {
             Sprite.AnimateUp(time, 0, "");
         }
         else if (moveRight)
         {
             Sprite.AnimateRight(time, 0, "");
         }
         else if (moveDown)
         {
             Sprite.AnimateDown(time, 0, "");
         }
         else if (moveLeft)
         {
             Sprite.AnimateLeft(time, 0, "");
         }
     }
     if ((blockedInterval < 3000 || (float)blockedInterval > 3750f) && blockedInterval >= 5000)
     {
         base.speed      = 4;
         isCharging      = true;
         blockedInterval = 0;
     }
     if (DamageToFarmer > 0 && Game1.random.NextDouble() < 0.00033333333333333332)
     {
         if (base.Name.Equals("Shadow Guy") && Game1.random.NextDouble() < 0.3)
         {
             if (Game1.random.NextDouble() < 0.5)
             {
                 currentLocation.playSound("grunt", NetAudio.SoundContext.Default);
                 return;
             }
             currentLocation.playSound("shadowpeep", NetAudio.SoundContext.Default);
             return;
         }
         else if (!base.Name.Equals("Shadow Girl"))
         {
             if (base.Name.Equals("Ghost"))
             {
                 currentLocation.playSound("ghost", NetAudio.SoundContext.Default);
                 return;
             }
             if (!base.Name.Contains("Slime"))
             {
                 base.Name.Contains("Jelly");
             }
         }
     }
 }
Пример #6
0
        public override bool checkAction(Location tileLocation, xTile.Dimensions.Rectangle viewport, StardewValley.Farmer who)
        {
            Vector2 vector = new Vector2((float)tileLocation.X, (float)tileLocation.Y);

            if (this.objects.ContainsKey(vector) && this.objects[vector].Type != null)
            {
                if ((this.objects[vector].Type.Equals("Crafting") || this.objects[vector].Type.Equals("interactive")) && this.objects[vector].name.Equals("Bee House"))
                {
                    Object beeHive = this.objects[vector];
                    if (!beeHive.readyForHarvest.Value)
                    {
                        return(false);
                    }
                    beeHive.honeyType.Value = new Object.HoneyType?(Object.HoneyType.Wild);
                    string str  = "Wild";
                    int    num6 = 0;

                    Crop crop = this.findCloseFlower(beeHive.TileLocation);
                    if (crop != null)
                    {
                        str = Game1.objectInformation[crop.indexOfHarvest.Value].Split(new char[]
                        {
                            '/'
                        })[0];
                        int indexOfHarvest = crop.indexOfHarvest.Value;
                        if (indexOfHarvest != 376)
                        {
                            switch (indexOfHarvest)
                            {
                            case 591:
                                beeHive.honeyType.Value = new Object.HoneyType?(Object.HoneyType.Tulip);
                                break;

                            case 593:
                                beeHive.honeyType.Value = new Object.HoneyType?(Object.HoneyType.SummerSpangle);
                                break;

                            case 595:
                                beeHive.honeyType.Value = new Object.HoneyType?(Object.HoneyType.FairyRose);
                                break;

                            case 597:
                                beeHive.honeyType.Value = new Object.HoneyType?(Object.HoneyType.BlueJazz);
                                break;
                            }
                        }
                        else
                        {
                            beeHive.honeyType.Value = new Object.HoneyType?(Object.HoneyType.Poppy);
                        }
                        num6 = Convert.ToInt32(Game1.objectInformation[crop.indexOfHarvest.Value].Split(new char[]
                        {
                            '/'
                        })[1]) * 2;
                    }
                    if (beeHive.heldObject.Value != null)
                    {
                        beeHive.heldObject.Value.name = str + " Honey";
                        string displayName = framework.helper.Reflection.GetMethod(beeHive, "loadDisplayName").Invoke <string>();
                        beeHive.heldObject.Value.displayName = displayName;
                        beeHive.heldObject.Value.Price      += num6;
                        if (Game1.currentSeason.Equals("winter"))
                        {
                            beeHive.heldObject.Value      = null;
                            beeHive.readyForHarvest.Value = false;
                            beeHive.showNextIndex.Value   = false;
                            return(false);
                        }
                        if (who.IsMainPlayer && !who.addItemToInventoryBool(beeHive.heldObject.Value, false))
                        {
                            Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588", new object[0]));
                            return(false);
                        }
                        Game1.playSound("coin");
                    }
                    beeHive.readyForHarvest.Value = false;
                    beeHive.showNextIndex.Value   = false;
                    if (!Game1.currentSeason.Equals("winter"))
                    {
                        beeHive.heldObject.Value  = new Object(Vector2.Zero, 340, null, false, true, false, false);
                        beeHive.MinutesUntilReady = 2400 - Game1.timeOfDay + 4320;
                    }
                    return(true);
                }
            }

            return(base.checkAction(tileLocation, viewport, who));
        }