Exemple #1
0
        /// <summary>
        /// Gets all npcs of this cell.
        /// </summary>
        /// <returns>collection of npcs</returns>
        public IEnumerable <Npc> GetAllNPCs(bool includeNeighbors)
        {
            var myNPCs = NPCs.Values;

            if (includeNeighbors)
            {
                return(myNPCs.Concat(NeighborCells.SelectMany(index => Map.Cells[index].GetAllNPCs(false))).Distinct());
            }
            return(myNPCs);
        }
Exemple #2
0
        /// <summary>
        /// Gets all mobs from map cell.
        /// </summary>
        /// /// <param name="includeNeighborCells">if set to true includes mobs fom neighbor cells</param>
        public IEnumerable <Mob> GetAllMobs(bool includeNeighborCells)
        {
            var myMobs = Mobs.Values;

            if (includeNeighborCells)
            {
                return(myMobs.Concat(NeighborCells.Select(index => Map.Cells[index]).SelectMany(cell => cell.GetAllMobs(false))).Distinct());
            }
            return(myMobs);
        }
Exemple #3
0
        /// <summary>
        /// Gets all players from map cell.
        /// </summary>
        /// <param name="includeNeighborCells">if set to true includes characters fom neighbor cells</param>
        public IEnumerable <Character> GetAllPlayers(bool includeNeighborCells)
        {
            var myPlayers = Players.Values;

            if (includeNeighborCells)
            {
                return(myPlayers.Concat(NeighborCells.Select(index => Map.Cells[index]).SelectMany(cell => cell.GetAllPlayers(false))).Distinct());
            }
            return(myPlayers);
        }
Exemple #4
0
        /// <summary>
        /// Gets player near point.
        /// </summary>
        /// <param name="x">x coordinate</param>
        /// <param name="z">z coordinate</param>
        /// <param name="range">minimum range to target, if set to 0 is not calculated</param>
        /// <param name="fraction">light, dark or both</param>
        /// <param name="includeDead">include dead players or not</param>
        /// <param name="includeNeighborCells">include players from neighbor cells, usually true</param>
        public IEnumerable <IKillable> GetPlayers(float x, float z, byte range, Fraction fraction = Fraction.NotSelected, bool includeDead = false, bool includeNeighborCells = true)
        {
            var myPlayers = Players.Values.Where(
                p => (includeDead || !p.IsDead) &&                                       // filter by death
                (p.Country == fraction || fraction == Fraction.NotSelected) &&           // filter by fraction
                (range == 0 || MathExtensions.Distance(x, p.PosX, z, p.PosZ) <= range)); // filter by range

            if (includeNeighborCells)
            {
                return(myPlayers.Concat(NeighborCells.Select(index => Map.Cells[index]).SelectMany(cell => cell.GetPlayers(x, z, range, fraction, includeDead, false))).Distinct());
            }
            return(myPlayers);
        }
Exemple #5
0
        /// <summary>
        /// Gets player near point.
        /// </summary>
        /// <param name="x">x coordinate</param>
        /// <param name="z">z coordinate</param>
        /// <param name="range">minimum range to target, if set to 0 is not calculated</param>
        /// <param name="country">light, dark or both</param>
        /// <param name="includeDead">include dead players or not</param>
        /// <param name="includeNeighborCells">include players from neighbor cells, usually true</param>
        public IEnumerable <Character> GetPlayers(float x, float z, byte range, CountryType country = CountryType.None, bool includeDead = false, bool includeNeighborCells = true)
        {
            var myPlayers = Players.Values.Where(
                p => (includeDead || !p.HealthManager.IsDead) &&                         // filter by death
                (p.CountryProvider.Country == country || country == CountryType.None) && // filter by fraction
                (range == 0 || MathExtensions.Distance(x, p.PosX, z, p.PosZ) <= range)); // filter by range

            if (includeNeighborCells)
            {
                return(myPlayers.Concat(NeighborCells.Select(index => Map.Cells[index]).SelectMany(cell => cell.GetPlayers(x, z, range, country, includeDead, false))).Distinct());
            }
            return(myPlayers);
        }