Exemple #1
0
 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);
         }
     }
 }
Exemple #2
0
        private void AttemptToWarp(TrainStop stop)
        {
            if (!TryToChargeMoney(stop.Cost))
            {
                Game1.drawObjectDialogue(Helper.Translation.Get("NotEnoughMoney", new { DestinationName = stop.TranslatedName }));
                return;
            }
            LocationRequest request = Game1.getLocationRequest(stop.TargetMapName);

            request.OnWarp    += Request_OnWarp;
            destinationMessage = Helper.Translation.Get("ArrivalMessage", new { DestinationName = stop.TranslatedName });

            Game1.warpFarmer(request, stop.TargetX, stop.TargetY, stop.FacingDirectionAfterWarp);

            cue = Game1.soundBank.GetCue("trainLoop");
            cue.SetVariable("Volume", 100f);
            cue.Play();
        }
Exemple #3
0
        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")
            };

            ContentPack content = new ContentPack();

            content.TrainStops = new List <TrainStop>();
            content.TrainStops.Add(RailRoadStop);

            Helper.Data.WriteJsonFile("example.json", content);

            TrainStops = new List <TrainStop>()
            {
                RailRoadStop
            };

            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");
                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));
                }
            }
        }
Exemple #4
0
        public void RegisterTrainStation(string stopId, string targetMapName, Dictionary <string, string> localizedDisplayName, int targetX, int targetY, int cost, int facingDirectionAfterWarp, string[] conditions, string translatedName)
        {
            var stop = ModEntry.Instance.TrainStops.SingleOrDefault(s => s.StopID.Equals(stopId));

            if (stop == null)
            {
                stop = new TrainStop();
                ModEntry.Instance.TrainStops.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;
        }