/// <summary>
 /// Restores all tracked machines after loading for proper rendering.
 /// </summary>
 public static void AfterLoad_RestoreTrackedMachines()
 {
     foreach (GameLocation loc in LocationUtilities.GetAllLocations())
     {
         foreach (StardewValley.Object obj in loc.Objects.Values)
         {
             if ((obj.heldObject.Value is CustomObject))
             {
                 //Don't want to render for tables since tables have special held object logic.
                 if (IsSameOrSubclass(typeof(TableTileComponent), obj.GetType()) == true)
                 {
                     continue;
                 }
                 else
                 {
                     if (TrackedMachines.ContainsKey(loc))
                     {
                         TrackedMachines[loc].Add(obj);
                     }
                     else
                     {
                         TrackedMachines.Add(loc, new List <SObject>()
                         {
                             obj
                         });
                     }
                 }
             }
         }
     }
 }
Exemple #2
0
        public override bool minutesElapsed(int minutes, GameLocation environment)
        {
            this.updateInfo();
            //ModCore.log(this.info.animationManager.currentAnimationName);

            if (this.updatesContainerObjectForProduction)
            {
                //ModCore.log("Update container object for production!");
                //this.MinutesUntilReady -= minutes;
                int remaining = minutes;
                //ModCore.log("Minutes elapsed: " + remaining);
                while (remaining > 0)
                {
                    if (LocationUtilities.IsThereWaterAtThisTile(environment, (int)this.TileLocation.X, (int)this.TileLocation.Y))
                    {
                        this.GetFluidManager().produceFluid(ModCore.ObjectManager.resources.getFluid("Water"), 100);
                    }
                    remaining -= 10;
                }

                return(false);
            }
            return(false);

            //return base.minutesElapsed(minutes, environment);
        }
Exemple #3
0
        public virtual void BehaviorUpdate()
        {
            GetTarget();
            Vector2 next = LocationUtilities.NextLocation(Combatant.transform.position, Target.transform.position, Combatant.speed);

            RB.MovePosition(next);
        }
Exemple #4
0
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
        //          SMAPI Events       //
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

        #region
        /// <summary>
        /// What happens when the player warps maps.
        /// </summary>
        /// <param name="o"></param>
        /// <param name="playerWarped"></param>
        public void OnPlayerLocationChanged(object o, EventArgs playerWarped)
        {
            this.spawnOreInMine();
            if (LocationUtilities.IsPlayerInMine() == false && LocationUtilities.IsPlayerInSkullCave() == false && LocationUtilities.IsPlayerInMineEnterance() == false)
            {
                this.visitedFloors.Clear();
            }
        }
Exemple #5
0
        private void GameEvents_OnAfterLoadedContent(object sender, System.EventArgs e)
        {
            MapInformation busStopEdit1 = new MapInformation(Instance, Instance.ModSettings.GetMap("busStop_edit1"));
            MapInformation busStopEdit2 = new MapInformation(Instance, Instance.ModSettings.GetMap("busStop_edit2"));
            MapInformation busStopEdit3 = new MapInformation(Instance, Instance.ModSettings.GetMap("busStop_edit3"));

            LocationUtilities.RegisterMap(Instance, "Maps\\BusStop", busStopEdit1);
            LocationUtilities.RegisterMap(Instance, "Maps\\BusStop", busStopEdit2);
            LocationUtilities.RegisterMap(Instance, "Maps\\BusStop", busStopEdit3);
        }
Exemple #6
0
        /// <summary>
        /// Spawns ore in the mountain farm every day.
        /// </summary>
        public void mountainFarmDayUpdate()
        {
            if (LocationUtilities.Farm_IsFarmHiltopFarm() == false)
            {
                //ModCore.log("Farm is not hiltop farm!");
                return;
            }
            GameLocation farm = Game1.getFarm();

            List <OreVein> spawnableOreVeins = new List <OreVein>();

            //Get a list of all of the ores that can spawn on this mine level.
            foreach (KeyValuePair <string, OreVein> pair in this.oreVeins)
            {
                if ((pair.Value.resourceInfo as OreResourceInformation).spawnsOnFarm)
                {
                    spawnableOreVeins.Add(pair.Value);
                    //ModCore.log("Found an ore that spawns on the farm!");
                }
            }
            foreach (OreVein ore in spawnableOreVeins)
            {
                if ((ore.resourceInfo as OreResourceInformation).shouldSpawnOnFarm())
                {
                    int            amount    = (ore.resourceInfo as OreResourceInformation).getNumberOfNodesToSpawnFarm();
                    List <Vector2> openTiles = this.getFarmQuarryOpenTiles(ore);
                    if (openTiles.Count == 0)
                    {
                        //ModCore.log("No open farm tiles!");
                    }
                    amount = Math.Min(amount, openTiles.Count); //Only spawn for as many open tiles or the amount of nodes to spawn.
                    for (int i = 0; i < amount; i++)
                    {
                        int  position = Game1.random.Next(openTiles.Count);
                        bool didSpawn = this.spawnOreVein(ore.getItemInformation().id, farm, openTiles[position]);
                        if (didSpawn == false)
                        {
                            i--; //If the tile didn't spawn due to some odd reason ensure that the amount is spawned.
                            openTiles.Remove(openTiles[position]);
                            //amount = Math.Min(amount, openTiles.Count); //Only spawn for as many open tiles or the amount of nodes to spawn.
                            //ModCore.log("Did not spawn ore in the farm quarry!");
                        }
                        else
                        {
                            //ModCore.log("Spawned ore in the farm quarry!");
                            openTiles.Remove(openTiles[position]); //Remove that tile from the list of open tiles.
                        }
                    }
                }
                else
                {
                    //Ore doesn't meet spawn chance.
                }
            }
        }
Exemple #7
0
        public void Inject <T>(T obj, string assetName, ref object output)
        {
            var map = obj as Map;

            if (map == null)
            {
                throw new Exception($"Unexpected type for {assetName}");
            }

            map    = LocationUtilities.MergeMaps(map, assetName);
            output = map;
        }
Exemple #8
0
        /// <summary>
        /// Spawns ore in the mine depending on a lot of given variables such as floor level and spawn chance.
        /// </summary>
        public void spawnOreInMine()
        {
            int floorLevel = LocationUtilities.CurrentMineLevel();

            if (this.hasVisitedFloor(floorLevel))
            {
                //Already has spawned ores for this visit.
                return;
            }
            else
            {
                this.visitedFloors.Add(floorLevel);
            }
            List <OreVein> spawnableOreVeins = new List <OreVein>();

            //Get a list of all of the ores that can spawn on this mine level.
            foreach (KeyValuePair <string, OreVein> pair in this.oreVeins)
            {
                if (pair.Value.resourceInfo.canSpawnAtLocation() && (pair.Value.resourceInfo as OreResourceInformation).canSpawnOnCurrentMineLevel())
                {
                    spawnableOreVeins.Add(pair.Value);
                }
            }

            foreach (OreVein ore in spawnableOreVeins)
            {
                if (ore.resourceInfo.shouldSpawn())
                {
                    int            amount    = ore.resourceInfo.getNumberOfNodesToSpawn();
                    List <Vector2> openTiles = LocationUtilities.GetOpenObjectTiles(Game1.player.currentLocation, (OreVein)ore.getOne());
                    amount = Math.Min(amount, openTiles.Count); //Only spawn for as many open tiles or the amount of nodes to spawn.
                    for (int i = 0; i < amount; i++)
                    {
                        int  position = Game1.random.Next(openTiles.Count);
                        bool didSpawn = this.spawnOreVein(ore.getItemInformation().id, openTiles[position]);
                        if (didSpawn == false)
                        {
                            i--; //If the tile didn't spawn due to some odd reason ensure that the amount is spawned.
                            openTiles.Remove(openTiles[position]);
                        }
                        else
                        {
                            openTiles.Remove(openTiles[position]); //Remove that tile from the list of open tiles.
                        }
                    }
                }
                else
                {
                    //Ore doesn't meet spawn chance.
                }
                //ModCore.log("Spawned :" + amount + " pancake test ores!");
            }
        }
        public override bool minutesElapsed(int minutes, GameLocation environment)
        {
            int remaining = minutes;

            while (remaining > 0)
            {
                if (LocationUtilities.IsThereWaterAtThisTile(environment, (int)this.TileLocation.X, (int)this.TileLocation.Y))
                {
                    this.GetFluidManager().produceFluid(ModCore.ObjectManager.resources.getFluid("Water"), 100);
                }
                remaining -= 10;
            }
            return(false);
        }
Exemple #10
0
        public string GetMapUrl(LocationPart part)
        {
            if (part == null)
            {
                return(null);
            }
            if (part.Latitude.HasValue && part.Longitude.HasValue)
            {
                return($"https://www.google.com/maps/search/{part.Latitude.Value.ToString("0.000000")},{part.Longitude.Value.ToString("0.000000")}");
            }
            var address = LocationUtilities.AddressForLocation(part).Replace(Environment.NewLine, ",");

            if (!string.IsNullOrWhiteSpace(address))
            {
                return($"https://www.google.com/maps/search/{address}");
            }
            return(null);
        }
 /// <summary>
 /// Checks to see if the resource can spawn at the given game location.
 /// </summary>
 /// <param name="Location"></param>
 /// <returns></returns>
 public override bool canSpawnAtLocation(GameLocation Location)
 {
     if (this.spawnsOnFarm && Location is StardewValley.Farm)
     {
         return(true);
     }
     if (this.spawnsInQuarry && Location is StardewValley.Locations.Mountain)
     {
         return(true);
     }
     if (this.spawnInRegularMine && LocationUtilities.IsPlayerInMine())
     {
         return(true);
     }
     if (this.spawnInSkullCavern && LocationUtilities.IsPlayerInSkullCave())
     {
         return(true);
     }
     return(false);
 }
        /// <summary>
        /// Checks to see if this ore can be spawned on the current mine level.
        /// </summary>
        /// <returns></returns>
        public bool canSpawnOnCurrentMineLevel()
        {
            int level = LocationUtilities.CurrentMineLevel();

            foreach (IntRange range in this.floorsToSpawnOn)
            {
                bool compareFun = false;
                if (this.canSpawnOnThisFloor == null)
                {
                    compareFun = false;
                }
                else
                {
                    compareFun = this.canSpawnOnThisFloor(level);
                }

                if (range.ContainsInclusive(level) || compareFun == true)
                {
                    foreach (IntRange exclude in this.floorsToExclude)
                    {
                        bool excludeFun = false;
                        if (this.excludeSpawnOnThisFloor == null)
                        {
                            excludeFun = false;
                        }
                        else
                        {
                            excludeFun = this.excludeSpawnOnThisFloor(level);
                        }
                        //Make this include exlude fun for regular mine. See above in this function.
                        if (exclude.ContainsInclusive(level) || excludeFun)
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
            }
            return(false);
        }
Exemple #13
0
        public LocationPart GeocodeIfRequired(LocationPart part)
        {
            if (part == null || string.IsNullOrWhiteSpace(GetApiKey()))
            {
                return(part);
            }
            // Don't geocode if we already have coordinate values
            if (part.Latitude.HasValue && part.Longitude.HasValue)
            {
                return(part);
            }
            var address = LocationUtilities.AddressForLocation(part);
            var results = Geocode(address);

            if (!results.Any())
            {
                return(part);
            }
            var result = results.First();

            part.Latitude  = result.Latitude;
            part.Longitude = result.Longitude;
            return(part);
        }
Exemple #14
0
        public static void Tab()
        {
            GUILayout.BeginHorizontal();
            GUILayout.Space(5);
            SearchString = Prefab.TextField(SearchString, "Search: ", 466);
            GUILayout.EndHorizontal();

            Prefab.ScrollView(new Rect(0, 25 + 5, 466, 250 - (25 + 10)), "Players", ref PlayersScroll, () =>
            {
                for (int i = 0; i < Provider.clients.Count; i++)
                {
                    Player player = Provider.clients[i].player;

                    if (player == OptimizationVariables.MainPlayer || player == null || (SearchString != "" && player.name.IndexOf(SearchString, StringComparison.OrdinalIgnoreCase) == -1))
                    {
                        continue;
                    }

                    bool Friend     = FriendUtilities.IsFriendly(player);
                    bool Spectating = MiscOptions.SpectatedPlayer == player;
                    bool Selected   = player == SelectedPlayer;

                    string color = Friend ? "<color=#00ff00ff>" : "";

                    if (Prefab.Button((Selected ? "<b>" : "") + (Spectating ? "<color=#0000ffff>[SPECTATING]</color> " : "") + color + $"{player.name}" + (Friend ? "</color>" : "") + (Selected ? "</b>" : ""), 400))
                    {
                        SelectedPlayer = player;
                    }

                    GUILayout.Space(2);
                }
            });

            Prefab.MenuArea(new Rect(0, 250 + 10, 190, 175), "OPTIONS", () =>
            {
                if (SelectedPlayer == null)
                {
                    return;
                }

                CSteamID steamId = SelectedPlayer.channel.owner.playerID.steamID;

                GUILayout.BeginHorizontal();
                GUILayout.BeginVertical();
                if (FriendUtilities.IsFriendly(SelectedPlayer))
                {
                    if (Prefab.Button("Remove Friend", 150))
                    {
                        FriendUtilities.RemoveFriend(SelectedPlayer);
                    }
                }
                else
                {
                    if (Prefab.Button("Add Friend", 150))
                    {
                        FriendUtilities.AddFriend(SelectedPlayer);
                    }
                }

                if (MiscOptions.SpectatedPlayer != SelectedPlayer)
                {
                    if (Prefab.Button("Spectate", 150))
                    {
                        MiscOptions.SpectatedPlayer = SelectedPlayer;
                    }
                }
                else if (MiscOptions.SpectatedPlayer != null && MiscOptions.SpectatedPlayer == SelectedPlayer)
                {
                    if (Prefab.Button("End Spectating", 150))
                    {
                        MiscOptions.SpectatedPlayer = null;
                    }
                }

                if (MiscOptions.CamPlayer != SelectedPlayer)
                {
                    if (Prefab.Button("Player Cam", 150))
                    {
                        MiscOptions.CamPlayer = SelectedPlayer;
                    }
                }
                else if (MiscOptions.CamPlayer != null && MiscOptions.CamPlayer == SelectedPlayer)
                {
                    if (Prefab.Button("Remove Cam", 150))
                    {
                        MiscOptions.CamPlayer = null;
                    }
                }


                if (MiscOptions.NoMovementVerification)
                {
                    if (Prefab.Button("Teleport to player", 150))
                    {
                        OptimizationVariables.MainPlayer.transform.position = SelectedPlayer.transform.position;
                    }
                }

                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            });

            Prefab.MenuArea(new Rect(190 + 6, 250 + 10, 270, 175), "INFO", () =>
            {
                if (SelectedPlayer == null)
                {
                    return;
                }

                GUILayout.BeginHorizontal();
                GUILayout.BeginVertical();

                GUILayout.Label("SteamID:");
                GUILayout.TextField(SelectedPlayer.channel.owner.playerID.steamID.ToString(), Prefab._TextStyle);
                GUILayout.Space(2);

                GUILayout.TextField("Closest Location: " + LocationUtilities.GetClosestLocation(SelectedPlayer.transform.position).name, Prefab._TextStyle);
                GUILayout.Label("Current Weapon: " + (SelectedPlayer.equipment.asset != null ? SelectedPlayer.equipment.asset.itemName : "Fists"), Prefab._TextStyle);
                GUILayout.Label("Current Vehicle: " + (SelectedPlayer.movement.getVehicle() != null ? SelectedPlayer.movement.getVehicle().asset.name : "No Vehicle"), Prefab._TextStyle);
                GUILayout.Label("Current Group Members: " + Provider.clients.Count(c => c.player != SelectedPlayer && c.player.quests.isMemberOfSameGroupAs(SelectedPlayer)), Prefab._TextStyle);

                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            });
        }
        private void GameEvents_AfterContentLoaded(object sender, EventArgs e)
        {
            var caveEdit = new MapInformation(Instance, Instance.ModSettings.GetMap("farmCave_Edit"));

            LocationUtilities.RegisterMap(Instance, "Maps\\FarmCave", caveEdit);
        }
Exemple #16
0
        public void BehaviorUpdate()
        {
            Vector2 v = LocationUtilities.NextLocation(Combatant.transform.position, Node.transform.position, Combatant.speed);

            rb.MovePosition(v);
        }
Exemple #17
0
    public static void Tab()
    {
        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
        GUILayout.Space(5f);
        PlayersTab.SearchString = Prefab.TextField(PlayersTab.SearchString, "Поиск: ", 466);
        GUILayout.EndHorizontal();
        Prefab.ScrollView(new Rect(0f, 30f, 466f, 215f), "Игроки", ref PlayersTab.PlayersScroll, delegate()
        {
            for (int i = 0; i < Provider.clients.Count; i++)
            {
                Player player = Provider.clients[i].player;
                bool flag     = player == OptimizationVariables.MainPlayer || player == null || (PlayersTab.SearchString != "" && player.name.IndexOf(PlayersTab.SearchString, StringComparison.OrdinalIgnoreCase) == -1);
                if (!flag)
                {
                    bool flag2  = FriendUtilities.IsFriendly(player);
                    bool flag3  = MiscOptions.SpectatedPlayer == player;
                    bool flag4  = false;
                    bool flag5  = player == PlayersTab.SelectedPlayer;
                    string text = flag4 ? "<color=#ff0000ff>" : (flag2 ? "<color=#00ff00ff>" : "");
                    bool flag6  = Prefab.Button(string.Concat(new string[]
                    {
                        flag5 ? "<b>" : "",
                        flag3 ? "<color=#0000ffff>[НАБЛЮДЕНИЕ]</color> " : "",
                        text,
                        player.name,
                        (flag2 || flag4) ? "</color>" : "",
                        flag5 ? "</b>" : ""
                    }), 400f, 25f, new GUILayoutOption[0]);
                    if (flag6)
                    {
                        PlayersTab.SelectedPlayer = player;
                    }
                    GUILayout.Space(2f);
                }
            }
        }, 20, new GUILayoutOption[0]);
        Prefab.MenuArea(new Rect(0f, 260f, 190f, 175f), "ОПЦИИ", delegate
        {
            bool flag = PlayersTab.SelectedPlayer == null;
            if (!flag)
            {
                CSteamID steamID = PlayersTab.SelectedPlayer.channel.owner.playerID.steamID;
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.BeginVertical(new GUILayoutOption[0]);
                bool flag2 = FriendUtilities.IsFriendly(PlayersTab.SelectedPlayer);
                if (flag2)
                {
                    bool flag3 = Prefab.Button("Убрать из друзей", 150f, 25f, new GUILayoutOption[0]);
                    if (flag3)
                    {
                        FriendUtilities.RemoveFriend(PlayersTab.SelectedPlayer);
                    }
                }
                else
                {
                    bool flag4 = Prefab.Button("Добавить в друзья", 150f, 25f, new GUILayoutOption[0]);
                    if (flag4)
                    {
                        FriendUtilities.AddFriend(PlayersTab.SelectedPlayer);
                    }
                }
                bool flag11 = Prefab.Button("Наблюдаль", 150f, 25f, new GUILayoutOption[0]);
                if (flag11)
                {
                    MiscOptions.SpectatedPlayer = PlayersTab.SelectedPlayer;
                }
                bool flag12 = MiscOptions.SpectatedPlayer != null && MiscOptions.SpectatedPlayer == PlayersTab.SelectedPlayer;
                if (flag12)
                {
                    bool flag13 = Prefab.Button("Не наблюдать", 150f, 25f, new GUILayoutOption[0]);
                    if (flag13)
                    {
                        MiscOptions.SpectatedPlayer = null;
                    }
                }
                bool noMovementVerification = MiscOptions.NoMovementVerification;
                if (noMovementVerification)
                {
                    bool flag14 = Prefab.Button("Телепортироваться", 150f, 25f, new GUILayoutOption[0]);
                    if (flag14)
                    {
                        OptimizationVariables.MainPlayer.transform.position = PlayersTab.SelectedPlayer.transform.position;
                    }
                }
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            }
        });
        Prefab.MenuArea(new Rect(196f, 260f, 270f, 175f), "Информация", delegate
        {
            bool flag = PlayersTab.SelectedPlayer == null;
            if (!flag)
            {
                int count          = Provider.clients.Count((SteamPlayer c) => c.player != PlayersTab.SelectedPlayer && c.player.quests.isMemberOfSameGroupAs(PlayersTab.SelectedPlayer));
                int counnt         = Convert.ToInt32(count) + 1;
                string finishcount = Convert.ToString(counnt);

                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.BeginVertical(new GUILayoutOption[0]);
                GUILayout.Label("SteamID:", new GUILayoutOption[0]);
                GUILayout.TextField(PlayersTab.SelectedPlayer.channel.owner.playerID.steamID.ToString(), Prefab._TextStyle, new GUILayoutOption[0]);
                GUILayout.Space(2f);
                GUILayout.TextField("Локация: " + LocationUtilities.GetClosestLocation(PlayersTab.SelectedPlayer.transform.position).name, Prefab._TextStyle, new GUILayoutOption[0]);
                GUILayout.TextField("Координаты X,Y,Z:\r\n" + SelectedPlayer.transform.position.ToString(), Prefab._TextStyle, new GUILayoutOption[0]);
                GUILayout.Label("Оружие: " + ((PlayersTab.SelectedPlayer.equipment.asset != null) ? PlayersTab.SelectedPlayer.equipment.asset.itemName : "Fists"), Prefab._TextStyle, new GUILayoutOption[0]);
                GUILayout.Label("Транспорт: " + ((PlayersTab.SelectedPlayer.movement.getVehicle() != null) ? PlayersTab.SelectedPlayer.movement.getVehicle().asset.name : "No Vehicle"), Prefab._TextStyle, new GUILayoutOption[0]);
                GUILayout.Label("Кол-во в группе: " + finishcount, Prefab._TextStyle, new GUILayoutOption[0]);
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            }
        });
    }