Beispiel #1
0
            protected override void list_remove(object item)
            {
                Base_Static ent = (Base_Static)item;

                direct_contents.Remove((Game.Tile)ent);
                ent.__SetLocInternal(null);
            }
Beispiel #2
0
        public EntContentsTable(Base_Static owner, EntContentsTable copy_from)
        {
            this.owner = owner;

            var tmp = this.contents;

            this.contents      = copy_from.contents;
            copy_from.contents = tmp;
        }
Beispiel #3
0
        private static void ProcessFetchArgs(object a, object b, out Base_Static obj, out int range)
        {
            obj = (a as Base_Static ?? b as Base_Static);

            int?range_tmp = (a as int? ?? b as int?);

            if (obj == null || range_tmp == null)
            {
                Logger.DebugMajor("-> " + a + " " + b);
                throw new Exception("Bad arguments to map fetch.");
            }

            range = (int)range_tmp;
        }
Beispiel #4
0
            protected override void list_add(object item)
            {
                Base_Static ent = (Base_Static)item;

                if (ent is Game.Tile)
                {
                    direct_contents.Add((Game.Tile)ent);
                    ent.__SetLocInternal(owner);
                }
                else
                {
                    throw new Exception("BAD ITEM FOR ZONE CONTENTS!");
                }
            }
Beispiel #5
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);
        }
Beispiel #6
0
 public EntContentsTable(Base_Static owner)
 {
     this.owner = owner;
 }