示例#1
0
        public override void Entry(IModHelper helper)
        {
            ElevatorBuildingTexture = helper.Content.Load <Texture2D>("Hotel.png");           //Must be before PatchAll

            //Harmony patch everything
            Patch.PatchAll("me.ilyaki.elevator");

            //Commands
            helper.ConsoleCommands.Add("elevator_goto", "Warp to cabin. first arg is name of player", this.Goto);
            helper.ConsoleCommands.Add("elevator_relocateCabin", "Move cabin off the map and mark it for use by the elevator/hotel. first arg is name of player", this.MoveCabinFarAway);
            helper.ConsoleCommands.Add("elevator_addCabin", "Builds a cabin outside the map for elevator/hotel", this.AddNewCabin);
            helper.ConsoleCommands.Add("elevator_bringBackCabin", "Moves a cabin to your location, so it will not be used by the elevator. First arg is name of player", this.BringBackCabin);
            helper.ConsoleCommands.Add("elevator_makeBuildingHere", "Spawn an elevator building on top of you", (o, e) => { if (Context.IsMainPlayer)
                                                                                                                            {
                                                                                                                                CabinHelper.SpawnElevatorBuilding();
                                                                                                                            }
                                       });
            helper.ConsoleCommands.Add("elevator_removeUnusedElevatorCabins", "Remove any empty cabins inside the elevator system.", this.RemoveEmptyElevatorCabins);


            //Events
            StardewModdingAPI.Events.TimeEvents.AfterDayStarted += (o, e) => UpdateWarpsAndReloadTextures();

            StardewModdingAPI.Events.ControlEvents.KeyPressed += (o, e) =>
            {
                if (Game1.IsServer && e.KeyPressed == Microsoft.Xna.Framework.Input.Keys.F7)
                {
                    UpdateWarpsAndReloadTextures();
                }
            };

            StardewModdingAPI.Events.PlayerEvents.Warped += (o, e) =>
            {
                if (Game1.player.getTileX() <= -9000)                //The door position is a bit to the right of -10000
                {
                    //Something broke: this seems to happen when a cabin has been upgraded
                    var d = CabinHelper.GetDoorPositionOfFirstElevatorBuilding();
                    Game1.player.setTileLocation(new Microsoft.Xna.Framework.Vector2(d.X, d.Y));
                }
            };
        }