private void AttemptToWarpBoat(BoatStop stop) { if (!TryToChargeMoney(stop.Cost)) { Game1.drawObjectDialogue(Helper.Translation.Get("NotEnoughMoney", new { DestinationName = stop.TranslatedName })); return; } LocationRequest request = Game1.getLocationRequest(stop.TargetMapName); Game1.warpFarmer(request, stop.TargetX, stop.TargetY, stop.FacingDirectionAfterWarp); }
public void RegisterBoatStation(string stopId, string targetMapName, Dictionary <string, string> localizedDisplayName, int targetX, int targetY, int cost, int facingDirectionAfterWarp, string[] conditions, string translatedName) { var stop = ModEntry.Instance.BoatStops.SingleOrDefault(s => s.StopID.Equals(stopId)); if (stop == null) { stop = new BoatStop(); ModEntry.Instance.BoatStops.Add(stop); } stop.StopID = stopId; stop.TargetMapName = targetMapName; stop.LocalizedDisplayName = localizedDisplayName; stop.TargetX = targetX; stop.TargetY = targetY; stop.Cost = cost; stop.FacingDirectionAfterWarp = facingDirectionAfterWarp; stop.Conditions = conditions; stop.TranslatedName = translatedName; }
private void RemoveInvalidLocations() { for (int i = TrainStops.Count - 1; i >= 0; i--) { TrainStop stop = TrainStops[i]; if (Game1.getLocationFromName(stop.TargetMapName) == null) { Monitor.Log($"Could not find location {stop.TargetMapName}", LogLevel.Warn); TrainStops.RemoveAt(i); } } for (int i = BoatStops.Count - 1; i >= 0; i--) { BoatStop stop = BoatStops[i]; if (Game1.getLocationFromName(stop.TargetMapName) == null) { Monitor.Log($"Could not find location {stop.TargetMapName}", LogLevel.Warn); BoatStops.RemoveAt(i); } } }
private void LoadContentPacks() { //create the stop at the vanilla Railroad map TrainStop RailRoadStop = new TrainStop { TargetMapName = "Railroad", StopID = "Cherry.TrainStation", TargetX = Config.RailroadWarpX, TargetY = Config.RailroadWarpY, Cost = 0, TranslatedName = Helper.Translation.Get("TrainStationDisplayName") }; //create stop in willy's boat room BoatStop BoatTunnelStop = new BoatStop() { TargetMapName = "BoatTunnel", StopID = "Cherry.TrainStation", TargetX = 4, TargetY = 9, Cost = 0, TranslatedName = Helper.Translation.Get("BoatStationDisplayName") }; ContentPack content = new ContentPack(); content.TrainStops = new List <TrainStop>(); content.BoatStops = new List <BoatStop>(); TrainStops = new List <TrainStop>() { RailRoadStop }; BoatStops = new List <BoatStop>() { BoatTunnelStop }; foreach (IContentPack pack in Helper.ContentPacks.GetOwned()) { if (!pack.HasFile("TrainStops.json")) { Monitor.Log($"{pack.Manifest.UniqueID} is missing a \"TrainStops.json\"", LogLevel.Error); continue; } ContentPack cp = pack.LoadAsset <ContentPack>("TrainStops.json"); if (cp.TrainStops != null) { for (int i = 0; i < cp.TrainStops.Count; i++) { TrainStop stop = cp.TrainStops.ElementAt(i); stop.StopID = $"{pack.Manifest.UniqueID}{i}"; //assigns a unique stopID to every stop stop.TranslatedName = Localize(stop.LocalizedDisplayName); TrainStops.Add(cp.TrainStops.ElementAt(i)); } } if (cp.BoatStops != null) { for (int i = 0; i < cp.BoatStops.Count; i++) { BoatStop stop = cp.BoatStops.ElementAt(i); stop.StopID = $"{pack.Manifest.UniqueID}{i}"; //assigns a unique stopID to every stop stop.TranslatedName = Localize(stop.LocalizedDisplayName); BoatStops.Add(cp.BoatStops.ElementAt(i)); } } } }