Beispiel #1
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);
        }