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

            var toRemove = new List <Building>();

            foreach (Cabin cabin in CabinHelper.GetCabinsInsides())
            {
                if (cabin.getFarmhand().Value.Name.Length == 0)
                {
                    toRemove.Add(CabinHelper.FindCabinOutside(cabin.getFarmhand()));
                }
            }

            foreach (Building building in toRemove)
            {
                Game1.getFarm().buildings.Remove(building);
            }

            Monitor.Log($"Removed {toRemove.Count} unused cabins");
        }
示例#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
        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");
                    }
                }
            }
        }
示例#4
0
        public ElevatorMenu() : base(1, 1, Game1.viewport.Width - 200, Game1.viewport.Height - 140, true)
        {
            numberOfPlayersPerColumn = Game1.viewport.Height / 100;
            numberOfColumns          = Game1.viewport.Width / 230;

            UpdatePosition();

            //If you want the elevator menu to show all cabins (not just the ones off the map), use this instead: players.AddRange(Game1.getAllFarmhands().Where(x => x.Name.Length > 0));
            players.AddRange(Game1.getAllFarmhands().Where(x => x.Name.Length > 0 && CabinHelper.FindCabinOutside(x)?.tileX.Value <= -10000));

            players = players.OrderBy(x => x != Game1.player).ThenBy(x => x.Name).ToList();            //Sort alphabetically, and put the local player first

            UpdateButtonList();

            forwardButton  = new ClickableTextureComponent(new Rectangle(base.xPositionOnScreen + base.width + 64 - 48, base.yPositionOnScreen + base.height - 48, 48, 44), Game1.mouseCursors, new Rectangle(365, 495, 12, 11), 4f, false);
            backwardButton = new ClickableTextureComponent(new Rectangle(base.xPositionOnScreen - 64, base.yPositionOnScreen + base.height - 48, 48, 44), Game1.mouseCursors, new Rectangle(352, 495, 12, 11), 4f, false);
        }