Example #1
0
        public static List <GameLocation> AllGameLocations(bool includeBuildings = true)
        {
            var allLocations = new List <GameLocation>();

            foreach (var gl in Game1.locations)
            {
                string name = gl.NameOrUniqueName;
                if (string.IsNullOrWhiteSpace(name))
                {
                    continue;
                }
                allLocations.Add(gl);
                if (includeBuildings && gl is StardewValley.Locations.BuildableGameLocation)
                {
                    StardewValley.Locations.BuildableGameLocation bl = gl as StardewValley.Locations.BuildableGameLocation;
                    foreach (var b in bl.buildings)
                    {
                        if (b.indoors.Value != null)
                        {
                            allLocations.Add(b.indoors.Value);
                        }
                        ;
                    }
                }
            }
            return(allLocations);
        }
Example #2
0
 //call on location change
 private static void AdvanceRoute()
 {
     if (!IsRouting)
     {
         return;
     }
     //Mod.instance.Monitor.Log("Advancing route...", LogLevel.Trace);
     Route.RemoveAt(0); //remove the current map from the list
     if (Route.Count == 0)
     {
         //route complete
         IsRouting = false;
         Route     = null;
         if (HasRoutingDestination)
         {
             //pathfind to final destination coordinates
             PathfindTo(RoutingDestinationX, RoutingDestinationY, IsCriticalRoute);
         }
     }
     else
     {
         //pathfind to the next map
         foreach (var w in Game1.player.currentLocation.warps)
         {
             if (w.TargetName == Route[0])
             {
                 PathfindTo(w.X, w.Y, IsCriticalRoute);
                 return;
             }
         }
         foreach (var w in Game1.player.currentLocation.doors.Keys)
         {
             if (Game1.player.currentLocation.doors[w] == Route[0])
             {
                 PathfindTo(w.X, w.Y + 1, IsCriticalRoute, true);
                 return;
             }
         }
         if (Game1.player.currentLocation is StardewValley.Locations.BuildableGameLocation)
         {
             StardewValley.Locations.BuildableGameLocation bl = Game1.player.currentLocation as StardewValley.Locations.BuildableGameLocation;
             foreach (var b in bl.buildings)
             {
                 if (b.indoors.Value.NameOrUniqueName == Route[0])
                 {
                     PathfindTo(b.getPointForHumanDoor().X, b.getPointForHumanDoor().Y + 1, IsCriticalRoute, true);
                     return;
                 }
             }
         }
     }
 }
Example #3
0
        private static List <LocationConnection> LocationConnections(GameLocation from)
        {
            var connections = new List <LocationConnection>();

            foreach (Warp warp in from.warps)
            {
                GameLocation targetLoc = Game1.getLocationFromName(warp.TargetName);
                if (targetLoc != null)
                {
                    var lc = new LocationConnection(warp.TargetName, warp.X, warp.Y, false, targetLoc.IsOutdoors);
                    connections.Add(lc);
                }
            }
            foreach (var doorDict in from.doors)
            {
                foreach (var door in doorDict)
                {
                    Point        point     = door.Key;
                    string       locName   = door.Value;
                    GameLocation targetLoc = Game1.getLocationFromName(locName);
                    if (targetLoc != null)
                    {
                        var lc = new LocationConnection(locName, point.X, point.Y, true, targetLoc.IsOutdoors);
                        connections.Add(lc);
                    }
                }
            }
            if (from is StardewValley.Locations.BuildableGameLocation)
            {
                StardewValley.Locations.BuildableGameLocation bl = from as StardewValley.Locations.BuildableGameLocation;
                foreach (var b in bl.buildings)
                {
                    if (b.indoors.Value != null)
                    {
                        var point   = b.humanDoor.Value;
                        var locName = b.indoors.Value.NameOrUniqueName;
                        var lc      = new LocationConnection(locName, point.X + b.tileX.Value, point.Y + b.tileY.Value, true, false);
                        connections.Add(lc);
                    }
                    ;
                }
            }
            return(connections);
        }
Example #4
0
        public static Dictionary <string, HashSet <string> > BuildRouteCache()
        {
            var returnValue = new Dictionary <string, HashSet <string> >();

            foreach (var gl in Game1.locations)
            {
                string key = gl.NameOrUniqueName;
                if (!string.IsNullOrWhiteSpace(key))// && !gl.isTemp())
                {
                    if (gl.warps != null && gl.warps.Count > 0)
                    {
                        //Mod.instance.Monitor.Log("Learning about " + key, LogLevel.Alert);
                        returnValue[key] = new HashSet <string>();
                        foreach (var w in gl.warps)
                        {
                            returnValue[key].Add(w.TargetName);
                        }
                        foreach (var d in gl.doors.Values)
                        {
                            returnValue[key].Add(d);
                        }
                        //foreach (var s in MapConnections[key]) Mod.instance.Monitor.Log("It connects to " + s, LogLevel.Warn);
                    }
                }
                if (gl is StardewValley.Locations.BuildableGameLocation)
                {
                    StardewValley.Locations.BuildableGameLocation bl = gl as StardewValley.Locations.BuildableGameLocation;
                    foreach (var b in bl.buildings)
                    {
                        if (!returnValue.ContainsKey(key))
                        {
                            returnValue[key] = new HashSet <string>();
                        }
                        returnValue[key].Add(b.indoors.Value.NameOrUniqueName);
                        //add the way in
                        returnValue[b.indoors.Value.NameOrUniqueName] = new HashSet <string>();
                        //add the way out
                        returnValue[b.indoors.Value.NameOrUniqueName].Add(key);
                    }
                }
            }
            return(returnValue);
        }