示例#1
0
        private void Goto(string command, string[] args)
        {
            if (!Context.IsMainPlayer)
            {
                Monitor.Log("You must be the server to do that");
                return;
            }


            if (args.Length < 1)
            {
                return;
            }

            string farmerName = args[0];

            Monitor.Log($"Attempting to warp to {farmerName}'s house");

            foreach (Farmer player in Game1.getAllFarmers())
            {
                if (player.Name.ToLower() == farmerName.ToLower())
                {
                    Console.WriteLine($"Found a match: {player.Name}, ID={player.UniqueMultiplayerID}");
                    Cabin cabin = CabinHelper.FindCabinInside(player);

                    Game1.warpFarmer(cabin.uniqueName.Value, cabin.warps[0].X, cabin.warps[0].Y - 1, 0);                    //Does this work when the cabin is upgraded?
                    return;
                }
            }
        }
示例#2
0
        private void BringBackCabin(string command, string[] args)
        {
            if (!Context.IsMainPlayer)
            {
                Monitor.Log("You must be the server to do that");
                return;
            }

            if (args.Length < 1)
            {
                Monitor.Log("Which player's house?");
                return;
            }

            if (Game1.getFarm() != Game1.player.currentLocation)
            {
                Monitor.Log("You need to be on the farm");
                return;
            }

            string farmerName = args[0];

            Monitor.Log($"Attempting to move {farmerName}'s house back");

            foreach (Farmer player in Game1.getAllFarmers())
            {
                if (player.Name.ToLower() == farmerName.ToLower())
                {
                    Monitor.Log($"Found a match: {player.Name}, ID={player.UniqueMultiplayerID}");

                    Building targetBuilding = CabinHelper.FindCabinOutside(player);
                    Cabin    cabin          = CabinHelper.FindCabinInside(player);
                    if (cabin != null && targetBuilding != null)
                    {
                        targetBuilding.GetType()
                        .GetField("tileX", BindingFlags.Instance | BindingFlags.Public)                           //tileX is readonly
                        .SetValue(targetBuilding, new NetInt(Game1.player.getTileX()));

                        targetBuilding.GetType()
                        .GetField("tileY", BindingFlags.Instance | BindingFlags.Public)                           //tileY is readonly
                        .SetValue(targetBuilding, new NetInt(Game1.player.getTileY() - 1));

                        foreach (var warp in cabin.warps)
                        {
                            warp.TargetX = targetBuilding.humanDoor.X + (int)targetBuilding.tileX.Value;
                            warp.TargetY = targetBuilding.humanDoor.Y + (int)targetBuilding.tileY.Value + 1;
                        }

                        Monitor.Log($"Moved it");
                    }
                    else
                    {
                        Monitor.Log("Could not find the cabin");
                    }
                }
            }
        }
示例#3
0
        public override void OnClicked()
        {
            Console.WriteLine($"Warping to {player.Name}'s cabin");

            Cabin cabin = CabinHelper.FindCabinInside(player);

            Game1.warpFarmer(cabin.uniqueName.Value, cabin.warps[0].X, cabin.warps[0].Y - 1, 0);

            Game1.activeClickableMenu.exitThisMenu(false);
        }
示例#4
0
        private void MoveCabinFarAway(string command, string[] args)
        {
            if (!Context.IsMainPlayer)
            {
                Monitor.Log("You must be the server to do that");
                return;
            }

            if (args.Length < 1)
            {
                return;
            }

            string farmerName = args[0];

            Monitor.Log($"Attempting to move {farmerName}'s house (very) far away");

            foreach (Farmer player in Game1.getAllFarmers())
            {
                if (player.Name.ToLower() == farmerName.ToLower())
                {
                    Monitor.Log($"Found a match: {player.Name}, ID={player.UniqueMultiplayerID}");

                    Building targetBuilding = CabinHelper.FindCabinOutside(player);
                    Cabin    cabin          = CabinHelper.FindCabinInside(player);
                    if (cabin != null && targetBuilding != null)
                    {
                        targetBuilding.GetType()
                        .GetField("tileX", BindingFlags.Instance | BindingFlags.Public)                           //tileX is readonly
                        .SetValue(targetBuilding, new NetInt(-10000));

                        foreach (var warp in cabin.warps)
                        {
                            var d = CabinHelper.GetDoorPositionOfFirstElevatorBuilding();
                            warp.TargetX = d.X;
                            warp.TargetY = d.Y;
                        }

                        Monitor.Log($"Deleted the house (technically moved it out of bounds)");
                        return;
                    }
                    else
                    {
                        Monitor.Log("Could not find the cabin");
                    }
                }
            }
        }