Exemplo n.º 1
0
        /// <summary>
        ///     Apply other player's locations as own exploration
        /// </summary>
        private static void GetSharedExploration(On.Minimap.orig_UpdateExplore orig, Minimap self, float dt, Player player)
        {
            self.m_exploreTimer += Time.deltaTime;
            if (self.m_exploreTimer > self.m_exploreInterval)
            {
                if (ConfigUtil.Get <bool>("MapServer", "shareMapProgression"))
                {
                    if (self.m_exploreTimer + Time.deltaTime > self.m_exploreInterval)
                    {
                        var tempPlayerInfos = new List <ZNet.PlayerInfo>();
                        ZNet.instance.GetOtherPublicPlayers(tempPlayerInfos);

                        foreach (var tempPlayer in tempPlayerInfos)
                        {
                            ExploreLocal(tempPlayer.m_position);
                        }
                    }
                }

                if (playerIsOnShip && ConfigUtil.Get <float>("MapServer", "exploreRadiusSailing") > ConfigUtil.Get <float>("MapServer", "exploreRadius"))
                {
                    self.Explore(Player.m_localPlayer.transform.position, ConfigUtil.Get <float>("MapServer", "exploreRadiusSailing"));
                }
                else
                {
                    self.Explore(Player.m_localPlayer.transform.position, ConfigUtil.Get <float>("MapServer", "exploreRadius"));
                }
                orig(self, dt, player);
            }
        }
Exemplo n.º 2
0
        public static bool ExploreMap(Minimap minimap, Texture2D m_fogTexture, bool[] mapData)
        {
            try
            {
                var exploredChunkCounter = 0;
                var ySize = minimap.m_textureSize;
                Utils.Log($"Texture size is {minimap.m_textureSize}");

                for (var i = 0; i < mapData.Length; i++)
                {
                    if (!mapData[i])
                    {
                        continue;
                    }
                    if (minimap.Explore(i % ySize, i / ySize))
                    {
                        exploredChunkCounter++;
                    }
                }

                if (exploredChunkCounter > 0)
                {
                    m_fogTexture.Apply();
                }
            }
            catch (Exception e)
            {
                Utils.Log("An error occurred merging map data.");
                Debug.LogException(e);
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
        static void GenerateTestData(bool[] m_explored, Minimap _instance, Texture2D m_fogTexture,
                                     List <Minimap.PinData> m_pins)
        {
            Utils.Log("Generating test data...");
            var ySize = _instance.m_textureSize;

            if (!explored)
            {
                var exploredChunkCounter = 0;
                Utils.Log($"Discover whole map");
                if (_instance == null)
                {
                    Utils.Log("_instance is null");
                    return;
                }

                if (m_explored == null)
                {
                    Utils.Log("m_explored is null");
                    return;
                }

                for (var i = 0; i < m_explored.Length; i++)
                {
                    if (_instance.Explore(i % ySize, i / ySize))
                    {
                        exploredChunkCounter++;
                    }
                }

                if (exploredChunkCounter > 0)
                {
                    m_fogTexture.Apply();
                }

                explored = true;
            }

            var vals = Enum.GetValues(typeof(Minimap.PinType));

            for (int i = 0; i < 100; i++)
            {
                var randSpotX   = Random.Range(0, ySize);
                var randSpotY   = Random.Range(0, ySize);
                var randPos     = new Vector3(randSpotX, 0f, randSpotY);
                var randPinType = Random.Range(0, 5);

                _instance.AddPin(randPos, (Minimap.PinType)vals.GetValue(randPinType), "randompin" + i, true,
                                 Random.Range(0, 1) == 0);
            }
        }
Exemplo n.º 4
0
        public static void UpdateExplorePostfix(ref Minimap __instance, float dt, Player player)
        {
            if (__instance.m_exploreTimer != 0f)
            {
                return;
            }

            List <Player> playersInRange = new List <Player>();

            Player.GetPlayersInRange(player.transform.position, 20f, playersInRange);

            if (playersInRange.Any(p => p.GetControlledShip()))
            {
                __instance.Explore(player.transform.position, Main.boatExploreRadius.Value);
            }
        }
Exemplo n.º 5
0
            private static void UpdateExplorePrefix(ref Minimap __instance, float dt, Player player)
            {
                // if it's not time to update the map, return...
                if (__instance.m_exploreTimer != 0f || null == player)
                {
                    return;
                }

                bool extendExploreRadius = false;

                // if the player is controlling a ship
                if ((bool)player.GetControlledShip() || null != Ship.GetLocalShip())
                {
                    extendExploreRadius = true;
                }


                if (extendExploreRadius)
                {
                    __instance.Explore(player.transform.position, Settings.ExploreOnShipRadius.Value);
                }
            }
Exemplo n.º 6
0
        public static void GetSharedExploration(Minimap instance)
        {
            if (!Configuration.Current.MapServer.IsEnabled)
            {
                return;
            }

            if (Configuration.Current.MapServer.shareMapProgression)
            {
                if (instance.m_exploreTimer + Time.deltaTime > instance.m_exploreInterval)
                {
                    var tempPlayerInfos = new List <ZNet.PlayerInfo>();
                    ZNet.instance.GetOtherPublicPlayers(tempPlayerInfos);

                    foreach (var player in tempPlayerInfos)
                    {
                        ExploreLocal(player.m_position);
                    }
                }
            }

            instance.Explore(Player.m_localPlayer.transform.position, Configuration.Current.MapServer.exploreRadius);
        }