示例#1
0
 public virtual void ReserveForNPC()
 {
     mutex.RequestLock();
 }
示例#2
0
        public override bool checkAction(Farmer who, GameLocation l)
        {
            if (who != null && !who.canMove)
            {
                return(false);
            }
            if (rider == null)
            {
                mutex.RequestLock(delegate
                {
                    if (who.mount != null || rider != null || who.FarmerSprite.PauseForSingleAnimation)
                    {
                        mutex.ReleaseLock();
                    }
                    else if ((getOwner() == Game1.player || (getOwner() == null && (Game1.player.horseName.Value == null || Game1.player.horseName.Value.Length == 0 || Utility.findHorseForPlayer(Game1.player.UniqueMultiplayerID) == null))) && base.Name.Length <= 0)
                    {
                        foreach (Building current in (Game1.getLocationFromName("Farm") as Farm).buildings)
                        {
                            if ((int)current.daysOfConstructionLeft <= 0 && current is Stable)
                            {
                                Stable stable = current as Stable;
                                if (stable.getStableHorse() == this)
                                {
                                    stable.owner.Value = who.UniqueMultiplayerID;
                                    stable.updateHorseOwnership();
                                }
                                else if ((long)stable.owner == who.UniqueMultiplayerID)
                                {
                                    stable.owner.Value = 0L;
                                    stable.updateHorseOwnership();
                                }
                            }
                        }
                        if (Game1.player.horseName.Value == null || Game1.player.horseName.Value.Length == 0)
                        {
                            Game1.activeClickableMenu = new NamingMenu(nameHorse, Game1.content.LoadString("Strings\\Characters:NameYourHorse"), Game1.content.LoadString("Strings\\Characters:DefaultHorseName"));
                        }
                    }
                    else if (who.items.Count > who.CurrentToolIndex && who.items[who.CurrentToolIndex] != null && who.Items[who.CurrentToolIndex] is Hat)
                    {
                        if (hat.Value != null)
                        {
                            Game1.createItemDebris((Hat)hat, base.position, facingDirection);
                            hat.Value = null;
                        }
                        else
                        {
                            Hat value = who.Items[who.CurrentToolIndex] as Hat;
                            who.Items[who.CurrentToolIndex] = null;
                            hat.Value = value;
                            Game1.playSound("dirtyHit");
                        }
                        mutex.ReleaseLock();
                    }
                    else
                    {
                        rider             = who;
                        rider.freezePause = 5000;
                        rider.synchronizedJump(6f);
                        rider.Halt();
                        if (rider.Position.X < base.Position.X)
                        {
                            rider.faceDirection(1);
                        }
                        l.playSound("dwop");
                        mounting.Value         = true;
                        rider.isAnimatingMount = true;
                        rider.completelyStopAnimatingOrDoingAction();
                        rider.faceGeneralDirection(Utility.PointToVector2(GetBoundingBox().Center), 0, opposite: false, useTileCalculations: false);
                    }
                });
                return(true);
            }
            dismounting.Value      = true;
            rider.isAnimatingMount = true;
            farmerPassesThrough    = false;
            rider.TemporaryPassableTiles.Clear();
            Vector2 position = Utility.recursiveFindOpenTileForCharacter(rider, rider.currentLocation, rider.getTileLocation(), 8);

            base.Position = new Vector2(position.X * 64f + 32f - (float)(GetBoundingBox().Width / 2), position.Y * 64f + 4f);
            roomForHorseAtDismountTile = !base.currentLocation.isCollidingPosition(GetBoundingBox(), Game1.viewport, isFarmer: true, 0, glider: false, this);
            base.Position          = rider.Position;
            dismounting.Value      = false;
            rider.isAnimatingMount = false;
            Halt();
            if (!position.Equals(Vector2.Zero) && Vector2.Distance(position, rider.getTileLocation()) < 2f)
            {
                rider.synchronizedJump(6f);
                l.playSound("dwop");
                rider.freezePause = 5000;
                rider.Halt();
                rider.xOffset          = 0f;
                dismounting.Value      = true;
                rider.isAnimatingMount = true;
                dismountTile           = position;
                Game1.debugOutput      = "dismount tile: " + position.ToString();
            }
            else
            {
                dismount();
            }
            return(true);
        }
示例#3
0
 private void shake(Vector2 tileLocation, bool doEvenIfStillShaking)
 {
     if (!((maxShake == 0f) | doEvenIfStillShaking))
     {
         return;
     }
     shakeLeft = (Game1.player.getTileLocation().X > tileLocation.X || ((Game1.player.getTileLocation().X == tileLocation.X && Game1.random.NextDouble() < 0.5) ? true : false));
     maxShake  = (float)Math.PI / 128f;
     if (!townBush && (int)tileSheetOffset == 1 && inBloom(Game1.GetSeasonForLocation(currentLocation), Game1.dayOfMonth))
     {
         string season   = ((int)overrideSeason == -1) ? Game1.GetSeasonForLocation(currentLocation) : Utility.getSeasonNameFromNumber(overrideSeason);
         int    shakeOff = -1;
         if (!(season == "spring"))
         {
             if (season == "fall")
             {
                 shakeOff = 410;
             }
         }
         else
         {
             shakeOff = 296;
         }
         if ((int)size == 3)
         {
             shakeOff = 815;
         }
         if ((int)size == 4)
         {
             shakeOff = 73;
         }
         if (shakeOff == -1)
         {
             return;
         }
         tileSheetOffset.Value = 0;
         setUpSourceRect();
         Random r = new Random((int)tileLocation.X + (int)tileLocation.Y * 5000 + (int)Game1.uniqueIDForThisGame + (int)Game1.stats.DaysPlayed);
         if ((int)size == 3 || (int)size == 4)
         {
             int number = 1;
             for (int i = 0; i < number; i++)
             {
                 if ((int)size == 4)
                 {
                     uniqueSpawnMutex.RequestLock(delegate
                     {
                         Game1.player.team.MarkCollectedNut("Bush_" + currentLocation.Name + "_" + tileLocation.X + "_" + tileLocation.Y);
                         Game1.createItemDebris(new Object(shakeOff, 1), new Vector2(getBoundingBox().Center.X, getBoundingBox().Bottom - 2), 0, currentLocation, getBoundingBox().Bottom);
                     });
                 }
                 else
                 {
                     Game1.createObjectDebris(shakeOff, (int)tileLocation.X, (int)tileLocation.Y);
                 }
             }
         }
         else
         {
             int number2 = r.Next(1, 2) + Game1.player.ForagingLevel / 4;
             for (int j = 0; j < number2; j++)
             {
                 Game1.createItemDebris(new Object(shakeOff, 1, isRecipe: false, -1, Game1.player.professions.Contains(16) ? 4 : 0), Utility.PointToVector2(getBoundingBox().Center), Game1.random.Next(1, 4));
             }
         }
         if ((int)size != 3)
         {
             DelayedAction.playSoundAfterDelay("leafrustle", 100);
         }
     }
     else if (tileLocation.X == 20f && tileLocation.Y == 8f && Game1.dayOfMonth == 28 && Game1.timeOfDay == 1200 && !Game1.player.mailReceived.Contains("junimoPlush"))
     {
         Game1.player.addItemByMenuIfNecessaryElseHoldUp(new Furniture(1733, Vector2.Zero), junimoPlushCallback);
     }
     else if (tileLocation.X == 28f && tileLocation.Y == 14f && Game1.player.eventsSeen.Contains(520702) && !Game1.player.hasMagnifyingGlass && Game1.currentLocation is Town)
     {
         (Game1.currentLocation as Town).initiateMagnifyingGlassGet();
     }
     else if (tileLocation.X == 47f && tileLocation.Y == 100f && Game1.player.secretNotesSeen.Contains(21) && Game1.timeOfDay == 2440 && Game1.currentLocation is Town && !Game1.player.mailReceived.Contains("secretNote21_done"))
     {
         Game1.player.mailReceived.Add("secretNote21_done");
         (Game1.currentLocation as Town).initiateMarnieLewisBush();
     }
 }
示例#4
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;
                }
                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)
                {
                    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);
        }