Esempio n. 1
0
        public static ByTable operator -(ByTable a, object b)
        {
            var new_table = new ByTable(a);

            new_table.Remove(b);
            return(new_table);
        }
Esempio n. 2
0
        // low/high coords should be ordered correctly, but do not actually need to be
        private static ByTable FetchInternal(int low_x, int low_y, int low_z, int high_x, int high_y, int high_z, Base_Static filter = null, bool tiles_only = false)
        {
            // Clamp min/max within bounds of the map.
            // If we can't, return an empty table.
            if (low_x < 1)
            {
                low_x = 1;
            }
            else if (low_x > Game13.map_size_x)
            {
                return(new ByTable());
            }

            if (low_y < 1)
            {
                low_y = 1;
            }
            else if (low_y > Game13.map_size_y)
            {
                return(new ByTable());
            }

            if (low_z < 1)
            {
                low_z = 1;
            }
            else if (low_z > Game13.map_size_z)
            {
                return(new ByTable());
            }

            if (high_x > Game13.map_size_x)
            {
                high_x = Game13.map_size_x;
            }
            else if (high_x < 1)
            {
                return(new ByTable());
            }

            if (high_y > Game13.map_size_y)
            {
                high_y = Game13.map_size_y;
            }
            else if (high_y < 1)
            {
                return(new ByTable());
            }

            if (high_z > Game13.map_size_z)
            {
                high_z = Game13.map_size_z;
            }
            else if (high_z < 1)
            {
                return(new ByTable());
            }

            HashSet <Base_Zone> collected_zones = null;

            if (!tiles_only)
            {
                collected_zones = new HashSet <Base_Zone>();
            }

            // Build result table.
            var result_table = new ByTable();

            for (int x = low_x; x <= high_x; x++)
            {
                for (int y = low_y; y <= high_y; y++)
                {
                    for (int z = low_z; z <= high_z; z++)
                    {
                        var tile = __Map[x - 1, y - 1, z - 1];

                        //EXCLUDE
                        if (tile == filter)
                        {
                            continue;
                        }

                        result_table.Add(tile);

                        if (tiles_only)
                        {
                            continue;
                        }

                        result_table.Add(tile.contents);
                        if (tile.loc != null && !collected_zones.Contains((Base_Zone)tile.loc))
                        {
                            result_table.Add(tile.loc);
                            collected_zones.Add((Base_Zone)tile.loc);
                        }
                    }
                }
            }

            // Exclude some more because I'm dumb as hell.
            if (filter != null)
            {
                result_table.Remove(filter);
            }

            return(result_table);
        }