Ejemplo n.º 1
0
        public static IEnumerable <LSAgent> ScanAll(int gridX, int gridY, int deltaCount,
                                                    LSAgent sourceAgent,
                                                    AllegianceType targetAllegiance)
        {
            long sourceX = sourceAgent.Body._position.x;
            long sourceY = sourceAgent.Body._position.y;

            for (int i = 0; i < deltaCount; i++)
            {
                ScanNode tempNode = GridManager.GetScanNode(
                    gridX + DeltaCache.CacheX [i],
                    gridY + DeltaCache.CacheY [i]);

                if (tempNode.IsNotNull())
                {
                    foreach (FastBucket <LSInfluencer> tempBucket in tempNode.BucketsWithAllegiance(sourceAgent, targetAllegiance))
                    {
                        BitArray arrayAllocation = tempBucket.arrayAllocation;
                        for (int j = 0; j < tempBucket.PeakCount; j++)
                        {
                            if (arrayAllocation.Get(j))
                            {
                                LSAgent tempAgent = tempBucket [j].Agent;
                                if (true)//conditional(tempAgent))
                                {
                                    yield return(tempAgent);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static IEnumerable <LSAgent> ScanAll(int gridX, int gridY, int deltaCount, Func <LSAgent, bool> agentConditional, Func <byte, bool> bucketConditional)
        {
            for (int i = 0; i < deltaCount; i++)
            {
                ScanNode tempNode = GridManager.GetScanNode(
                    gridX + DeltaCache.CacheX [i],
                    gridY + DeltaCache.CacheY [i]);

                if (tempNode.IsNotNull())
                {
                    foreach (FastBucket <LSInfluencer> tempBucket in tempNode.BucketsWithAllegiance(bucketConditional))
                    {
                        BitArray arrayAllocation = tempBucket.arrayAllocation;
                        for (int j = 0; j < tempBucket.PeakCount; j++)
                        {
                            if (arrayAllocation.Get(j))
                            {
                                LSAgent tempAgent = tempBucket [j].Agent;
                                if (agentConditional(tempAgent))
                                {
                                    yield return(tempAgent);
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public static IEnumerable <LSAgent> ScanAll(Vector2d position, long radius, Func <LSAgent, bool> agentConditional, Func <byte, bool> bucketConditional)
        {
            int xMin = ((position.x - radius - GridManager.OffsetX) / (long)GridManager.ScanResolution).ToInt();
            int xMax = ((position.x + radius - GridManager.OffsetX) / (long)GridManager.ScanResolution).CeilToInt();
            int yMin = ((position.y - radius - GridManager.OffsetY) / (long)GridManager.ScanResolution).ToInt();
            int yMax = ((position.y + radius - GridManager.OffsetY) / (long)GridManager.ScanResolution).CeilToInt();

            long fastRadius = radius * radius;

            for (int x = xMin; x <= xMax; x++)
            {
                for (int y = yMin; y <= yMax; y++)
                {
                    ScanNode tempNode = GridManager.GetScanNode(
                        x,
                        y);

                    if (tempNode.IsNotNull())
                    {
                        foreach (FastBucket <LSInfluencer> tempBucket in tempNode.BucketsWithAllegiance(bucketConditional))
                        {
                            BitArray arrayAllocation = tempBucket.arrayAllocation;
                            for (int j = 0; j < tempBucket.PeakCount; j++)
                            {
                                if (arrayAllocation.Get(j))
                                {
                                    LSAgent tempAgent = tempBucket [j].Agent;

                                    long distance = (tempAgent.Body.Position - position).FastMagnitude();
                                    if (distance < fastRadius)
                                    {
                                        if (agentConditional(tempAgent))
                                        {
                                            yield return(tempAgent);
                                        }
                                    }
                                    else
                                    {
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }