Example #1
0
 public override bool canBeRemoved(Farmer who)
 {
     if (mutex.IsLocked())
     {
         return(false);
     }
     return(base.canBeRemoved(who));
 }
Example #2
0
 public void resetForPlayerEntry(GameLocation l)
 {
     if (base.Age == 0)
     {
         base.Position = new Vector2(16f, 4f) * 64f + new Vector2(0f, -24f);
         if (Game1.timeOfDay >= 1800 && Sprite != null)
         {
             Sprite.StopAnimation();
             Sprite.currentFrame = Game1.random.Next(7);
         }
         else if (Sprite != null)
         {
             Sprite.setCurrentAnimation(getRandomNewbornAnimation());
         }
     }
     else if (base.Age == 1)
     {
         base.Position = new Vector2(16f, 4f) * 64f + new Vector2(0f, -12f);
         if (Game1.timeOfDay >= 1800 && Sprite != null)
         {
             Sprite.StopAnimation();
             Sprite.SpriteHeight = 16;
             Sprite.currentFrame = Game1.random.Next(7);
         }
         else if (Sprite != null)
         {
             Sprite.SpriteHeight = 32;
             Sprite.setCurrentAnimation(getRandomBabyAnimation());
         }
     }
     else if (base.Age == 2)
     {
         if (Sprite != null)
         {
             Sprite.SpriteHeight = 16;
         }
         if (Game1.timeOfDay >= 1800)
         {
             base.Position = new Vector2(16f, 4f) * 64f + new Vector2(0f, -24f);
             if (Sprite != null)
             {
                 Sprite.StopAnimation();
                 Sprite.SpriteHeight = 16;
                 Sprite.currentFrame = 7;
             }
         }
     }
     if (Sprite != null)
     {
         Sprite.loop = true;
     }
     if (drawOnTop && !mutex.IsLocked())
     {
         drawOnTop = false;
     }
     Sprite.UpdateSourceRect();
 }
Example #3
0
 public override bool answerDialogueAction(string questionAndAnswer, string[] questionParams)
 {
     if (questionAndAnswer == null)
     {
         return(false);
     }
     if (!(questionAndAnswer == "Museum_Collect"))
     {
         if (!(questionAndAnswer == "Museum_Donate"))
         {
             if (questionAndAnswer == "Museum_Rearrange_Yes" && !mutex.IsLocked())
             {
                 mutex.RequestLock(delegate
                 {
                     Game1.activeClickableMenu = new MuseumMenu(InventoryMenu.highlightNoItems)
                     {
                         exitFunction = delegate
                         {
                             mutex.ReleaseLock();
                         }
                     };
                 });
             }
         }
         else
         {
             mutex.RequestLock(delegate
             {
                 Game1.activeClickableMenu = new MuseumMenu(isItemSuitableForDonation)
                 {
                     exitFunction = delegate
                     {
                         mutex.ReleaseLock();
                     }
                 };
             });
         }
     }
     else
     {
         Game1.activeClickableMenu = new ItemGrabMenu(getRewardsForPlayer(Game1.player), reverseGrab: false, showReceivingMenu: true, null, null, "Rewards", collectedReward, snapToBottom: false, canBeExitedWithKey: true, playRightClickSound: false, allowRightClick: false, showOrganizeButton: false, 0, null, -1, this);
     }
     return(base.answerDialogueAction(questionAndAnswer, questionParams));
 }
        public void FixLidFrame()
        {
            if (_currentLidFrame == 0)
            {
                _currentLidFrame = StartingLidFrame.Value;
            }

            if (Mutex.IsLocked() && !Mutex.IsLockHeld())
            {
                _currentLidFrame = 135;
            }
            else
            {
                if (Mutex.IsLocked())
                {
                    return;
                }
                _currentLidFrame = StartingLidFrame.Value;
            }
        }
Example #5
0
 public void fixLidFrame()
 {
     if (currentLidFrame == 0)
     {
         currentLidFrame = startingLidFrame;
     }
     if ((bool)playerChest)
     {
         if (mutex.IsLocked() && !mutex.IsLockHeld())
         {
             currentLidFrame = getLastLidFrame();
         }
         else if (!mutex.IsLocked())
         {
             currentLidFrame = startingLidFrame;
         }
     }
     else if (currentLidFrame == 501 && mutex.IsLocked() && !mutex.IsLockHeld())
     {
         currentLidFrame = 503;
     }
 }
Example #6
0
 public virtual bool IsBeingSleptIn(GameLocation location)
 {
     if (mutex.IsLocked())
     {
         return(true);
     }
     foreach (Farmer farmer in location.farmers)
     {
         if (farmer.GetBoundingBox().Intersects(getBoundingBox(tileLocation)))
         {
             return(true);
         }
     }
     return(false);
 }
Example #7
0
 protected override void resetSharedState()
 {
     if (Game1.netWorldState.Value.Bundles.ContainsKey(36) && !bundleMutex.IsLocked() && !Game1.eventUp && !Game1.MasterPlayer.hasOrWillReceiveMail("ccMovieTheater"))
     {
         bool   fail2 = false;
         bool[] array = Game1.netWorldState.Value.Bundles[36];
         for (int i = 0; i < array.Length; i++)
         {
             if (!array[i])
             {
                 fail2 = true;
                 return;
             }
         }
         if (!fail2)
         {
             restoreAreaCutscene();
         }
     }
     base.resetSharedState();
 }
Example #8
0
 public bool isInventoryOpen()
 {
     return(inventoryMutex.IsLocked());
 }
Example #9
0
        public override bool checkForAction(Farmer who, bool justCheckingForActivity = false)
        {
            if (justCheckingForActivity)
            {
                return(true);
            }
            List <Chest> nearby_chests = new List <Chest>();

            Vector2[] neighbor_tiles = new Vector2[8]
            {
                new Vector2(-1f, 1f),
                new Vector2(0f, 1f),
                new Vector2(1f, 1f),
                new Vector2(-1f, 0f),
                new Vector2(1f, 0f),
                new Vector2(-1f, -1f),
                new Vector2(0f, -1f),
                new Vector2(1f, -1f)
            };
            for (int i = 0; i < neighbor_tiles.Length; i++)
            {
                if (who.currentLocation is FarmHouse && who.currentLocation.getTileIndexAt((int)(tileLocation.X + neighbor_tiles[i].X), (int)(tileLocation.Y + neighbor_tiles[i].Y), "Buildings") == 173)
                {
                    nearby_chests.Add((who.currentLocation as FarmHouse).fridge.Value);
                    continue;
                }
                if (who.currentLocation is IslandFarmHouse && who.currentLocation.getTileIndexAt((int)(tileLocation.X + neighbor_tiles[i].X), (int)(tileLocation.Y + neighbor_tiles[i].Y), "Buildings") == 173)
                {
                    nearby_chests.Add((who.currentLocation as IslandFarmHouse).fridge.Value);
                    continue;
                }
                Vector2 tile_location   = new Vector2((int)(tileLocation.X + neighbor_tiles[i].X), (int)(tileLocation.Y + neighbor_tiles[i].Y));
                Object  neighbor_object = null;
                if (who.currentLocation.objects.ContainsKey(tile_location))
                {
                    neighbor_object = who.currentLocation.objects[tile_location];
                }
                if (neighbor_object != null && neighbor_object is Chest && (neighbor_object as Chest).SpecialChestType == Chest.SpecialChestTypes.None)
                {
                    nearby_chests.Add(neighbor_object as Chest);
                }
            }
            List <NetMutex> muticies = new List <NetMutex>();

            foreach (Chest chest in nearby_chests)
            {
                muticies.Add(chest.mutex);
            }
            if (!mutex.IsLocked())
            {
                MultipleMutexRequest multipleMutexRequest = null;
                multipleMutexRequest = new MultipleMutexRequest(muticies, delegate
                {
                    mutex.RequestLock(delegate
                    {
                        Vector2 topLeftPositionForCenteringOnScreen = Utility.getTopLeftPositionForCenteringOnScreen(800 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2);
                        Game1.activeClickableMenu = new CraftingPage((int)topLeftPositionForCenteringOnScreen.X, (int)topLeftPositionForCenteringOnScreen.Y, 800 + IClickableMenu.borderWidth * 2, 600 + IClickableMenu.borderWidth * 2, cooking: false, standalone_menu: true, nearby_chests);
                        Game1.activeClickableMenu.exitFunction = delegate
                        {
                            mutex.ReleaseLock();
                            multipleMutexRequest.ReleaseLocks();
                        };
                    }, delegate
                    {
                        multipleMutexRequest.ReleaseLocks();
                    });
                }, delegate
                {
                    Game1.showRedMessage(Game1.content.LoadString("Strings\\UI:Workbench_Chest_Warning"));
                });
            }
            return(true);
        }
Example #10
0
 public virtual void Update(GameTime time)
 {
     if (squawkTime > 0f)
     {
         squawkTime -= (float)time.ElapsedGameTime.TotalSeconds;
     }
     if (shakeTime > 0f)
     {
         shakeTime -= (float)time.ElapsedGameTime.TotalSeconds;
     }
     if (costShakeTime > 0f)
     {
         costShakeTime -= (float)time.ElapsedGameTime.TotalSeconds;
     }
     if (timeUntilChomp > 0f)
     {
         timeUntilChomp -= (float)time.ElapsedGameTime.TotalSeconds;
         if (timeUntilChomp <= 0f)
         {
             if (locationRef.Value == Game1.currentLocation)
             {
                 Game1.playSound("eat");
             }
             timeUntilChomp = 0f;
             shakeTime      = 0.25f;
             if (locationRef.Value.getTemporarySpriteByID(98765) != null)
             {
                 for (int j = 0; j < 6; j++)
                 {
                     locationRef.Value.temporarySprites.Add(new TemporaryAnimatedSprite("LooseSprites\\Cursors2", new Microsoft.Xna.Framework.Rectangle(9, 252, 3, 3), locationRef.Value.getTemporarySpriteByID(98765).position + new Vector2(8f, 8f) * 4f, Game1.random.NextDouble() < 0.5, 0f, Color.White)
                     {
                         motion               = new Vector2(Game1.random.Next(-1, 2), -6f),
                         acceleration         = new Vector2(0f, 0.25f),
                         rotationChange       = (float)Game1.random.Next(-4, 5) * 0.05f,
                         scale                = 4f,
                         animationLength      = 1,
                         totalNumberOfLoops   = 1,
                         interval             = 500 + Game1.random.Next(500),
                         layerDepth           = 1f,
                         drawAboveAlwaysFront = true
                     });
                 }
             }
             locationRef.Value.removeTemporarySpritesWithID(98765f);
             timeUntilSqwawk = 1f;
         }
     }
     if (timeUntilSqwawk > 0f)
     {
         timeUntilSqwawk -= (float)time.ElapsedGameTime.TotalSeconds;
         if (timeUntilSqwawk <= 0f)
         {
             timeUntilSqwawk = 0f;
             if (locationRef.Value == Game1.currentLocation)
             {
                 Game1.playSound("parrot_squawk");
             }
             squawkTime = 0.5f;
             shakeTime  = 0.5f;
         }
     }
     if (parrotPresent && currentState.Value > UpgradeState.StartBuilding)
     {
         if (currentState.Value == UpgradeState.Building)
         {
             Parrot flying_parrot = new Parrot(this, Utility.PointToVector2(tilePosition));
             flying_parrot.isPerchedParrot = true;
             parrots.Add(flying_parrot);
         }
         parrotPresent = false;
     }
     if (IsAvailable(use_cached_value: true))
     {
         bool player_nearby = false;
         if (currentState.Value == UpgradeState.Idle && !upgradeMutex.IsLocked() && Math.Abs(Game1.player.getTileLocationPoint().X - tilePosition.X) <= 1 && Math.Abs(Game1.player.getTileLocationPoint().Y - tilePosition.Y) <= 1)
         {
             player_nearby = true;
         }
         if (player_nearby != isPlayerNearby)
         {
             isPlayerNearby = player_nearby;
             if (isPlayerNearby)
             {
                 if (locationRef.Value == Game1.currentLocation)
                 {
                     Game1.playSound("parrot_squawk");
                 }
                 squawkTime    = 0.5f;
                 shakeTime     = 0.5f;
                 costShakeTime = 0.5f;
                 Game1.specialCurrencyDisplay.ShowCurrency("walnuts");
             }
             else
             {
                 Game1.specialCurrencyDisplay.ShowCurrency(null);
             }
         }
     }
     if ((UpgradeState)currentState == UpgradeState.Building && parrots.Count < 24)
     {
         if (nextParrotSpawn > 0f)
         {
             nextParrotSpawn -= (float)time.ElapsedGameTime.TotalSeconds;
         }
         if (nextParrotSpawn <= 0f)
         {
             nextParrotSpawn = 0.05f;
             Microsoft.Xna.Framework.Rectangle spawn_rectangle = upgradeRect.Value;
             spawn_rectangle.Inflate(5, 0);
             parrots.Add(new Parrot(this, Utility.getRandomPositionInThisRectangle(spawn_rectangle, Game1.random), parrots.Count % 10 == 0));
         }
     }
     for (int i = 0; i < parrots.Count; i++)
     {
         if (parrots[i].Update(time))
         {
             parrots.RemoveAt(i);
             i--;
         }
     }
 }