/// <summary>Raised after the player presses a button on the keyboard, controller, or mouse.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void OnButtonPressed(object sender, ButtonPressedEventArgs e) { // handle pressed keys to save new warp locations if (!Context.IsWorldReady || e.Button != this.config.LocationSaveKey) { return; } if (!AllowedWarpLocations.Contains(Game1.currentLocation.Name)) { Game1.showGlobalMessage("You can't warp here!"); return; } if (Game1.player.ActiveObject != null) { WarpLocation location = this.GetWarpLocation(); switch (Game1.player.ActiveObject.ParentSheetIndex) { case 688: //Farm Totem this.SetWarpLocation(WarpLocationCategory.Farm, true, location); break; case 689: //Mountain Totem this.SetWarpLocation(WarpLocationCategory.Mountains, true, location); break; case 690: //Beach Totem this.SetWarpLocation(WarpLocationCategory.Beach, true, location); break; case 86: //Earth Crystal this.SetWarpLocation(WarpLocationCategory.Mountains, false, location); break; case 372: //Clam this.SetWarpLocation(WarpLocationCategory.Beach, false, location); break; case 261: //Desert Totem this.SetWarpLocation(WarpLocationCategory.Desert, true, location); break; case 768: //Solar essence this.SetWarpLocation(WarpLocationCategory.Desert, false, location); break; } this.Helper.Data.WriteJsonFile(LocationSaveFileName, WarpLocations); } else if (Game1.player.CurrentTool != null && Game1.player.CurrentTool is Wand) { //Return Scepter this.SetWarpLocation(WarpLocationCategory.Farm, false, this.GetWarpLocation()); this.Helper.Data.WriteJsonFile(LocationSaveFileName, WarpLocations); } }
/** * Updates where items warp you to. **/ private void SetWarpLocation(WarpLocationCategory locationType, bool fromTotem, WarpLocation newLocation) { switch (locationType) { case WarpLocationCategory.Farm: /*if (!config.UseSeperateLocationForEachItem) * { * WarpOverride.warpLocations.FarmWarpLocation_Scepter = newLocation; * Game1.showGlobalMessage("New Farm Warp Location Saved!"); * } * else*/ if (fromTotem) { WarpLocations.FarmWarpLocation_Totem = newLocation; Game1.showGlobalMessage("New Farm Warp Totem Location Saved!"); } else { WarpLocations.FarmWarpLocation_Scepter = newLocation; Game1.showGlobalMessage("New Farm Warp Scepter Location Saved!"); } break; case WarpLocationCategory.Mountains: if (!this.config.AdvancedMode) { WarpLocations.MountainWarpLocation_Totem = newLocation; WarpLocations.MountainWarpLocation_Obelisk = newLocation; Game1.showGlobalMessage("New Mountain Warp Location Saved!"); } else if (fromTotem) { WarpLocations.MountainWarpLocation_Totem = newLocation; Game1.showGlobalMessage("New Mountain Warp Totem Location Saved!"); } else { WarpLocations.MountainWarpLocation_Obelisk = newLocation; Game1.showGlobalMessage("New Mountain Warp Obelisk Location Saved!"); } break; case WarpLocationCategory.Beach: if (!this.config.AdvancedMode) { WarpLocations.BeachWarpLocation_Totem = newLocation; WarpLocations.BeachWarpLocation_Obelisk = newLocation; Game1.showGlobalMessage("New Beach Warp Location Saved!"); } else if (fromTotem) { WarpLocations.BeachWarpLocation_Totem = newLocation; Game1.showGlobalMessage("New Beach Warp Totem Location Saved!"); } else { WarpLocations.BeachWarpLocation_Obelisk = newLocation; Game1.showGlobalMessage("New Beach Warp Obelisk Location Saved!"); } break; } for (var index = 0; index < 12; ++index) { Game1.player.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(354, Game1.random.Next(25, 75), 6, 1, new Vector2( Game1.random.Next((int)Game1.player.position.X - Game1.tileSize * 4, (int)Game1.player.position.X + Game1.tileSize * 3), Game1.random.Next((int)Game1.player.position.Y - Game1.tileSize * 4, (int)Game1.player.position.Y + Game1.tileSize * 3)), false, Game1.random.NextDouble() < 0.5)); } }