Ejemplo n.º 1
0
        internal override void Serialize(BinaryWriter w)
        {
            base.Serialize(w);

            w.Write(Explored);
            w.Write(Delayed);
            w.Write(Small);
            Position.Serialize(w);
            CellsAABB.Serialize(w);
            w.Write(CellsArea);

            w.Write(Cells.Count);
            foreach (Cell cell in Cells)
            {
                w.Write(cell.GlobalId);
            }

            w.Write(GridCellsId.Count);
            foreach (int g_cell_id in GridCellsId)
            {
                w.Write(g_cell_id);
            }
        }
Ejemplo n.º 2
0
        public ExploreCell(AABB aabb, List <Cell> cells, List <int> grid_cells_id, int id = -1)
            : base(aabb.Min.X, aabb.Min.Y, 0, aabb.Max.X, aabb.Max.Y, 0, MovementFlag.None, id)
        {
            InitExploreCell();

            Cells       = cells;
            GridCellsId = grid_cells_id;

            foreach (Cell c in Cells)
            {
                CellsArea += c.AABB.Area;
                CellsAABB  = CellsAABB.Extend(c.AABB);
            }

            AABB clampedCellsAABB = default(AABB);

            CellsAABB.Intersect(this.AABB, ref clampedCellsAABB);
            CellsAABB = clampedCellsAABB;

            var nearest_cell = cells.OrderBy(x => CellsAABB.Center.Distance2DSqr(x.AABB.Align(CellsAABB.Center))).First();

            Position = nearest_cell.AABB.Align(CellsAABB.Center);
        }