예제 #1
0
        public void DeleteBlock(Vector3i coord)
        {
            Vector3i clamped_coord = coord.Clamp(Math._000i, m_num_cells - Math._111i);

            Common.Assert(clamped_coord == coord);

            int index = coord.X + m_num_cells.X * (coord.Y + coord.Z * m_num_cells.Y);

            m_cells[index] = null;
        }
예제 #2
0
        Cell SafeCellAt(Vector3i index)
        {
            Vector3i clamped_index = index.Clamp(Math._000i, m_num_cells - Math._111i);

            if (index != clamped_index)
            {
                return(null);
            }

            return(CellAt(index));
        }
예제 #3
0
        public void DeleteBlock(Vector3i coord)
        {
            Vector3i clamped_coord = coord.Clamp(Math._000i, m_num_cells - Math._111i);

            Common.Assert(clamped_coord == coord);

            int index = coord.X + m_num_cells.X * (coord.Y + coord.Z * m_num_cells.Y);

            if (m_cells[index] != null)
            {
                m_z_count[coord.X + coord.Y * m_num_cells.Y]--;
            }

            m_cells[index] = null;
            update_top_most_flag(coord);
        }
예제 #4
0
        public void SetBlock(Vector3i coord, Vector2i tile_index)
        {
            Vector3i clamped_coord = coord.Clamp(Math._000i, m_num_cells - Math._111i);

            Common.Assert(clamped_coord == coord);

            int cell_index = coord.X + m_num_cells.X * (coord.Y + coord.Z * m_num_cells.Y);

            if (m_cells[cell_index] == null)
            {
                m_cells[cell_index] = new Cell();
            }

            TRS trs = TRS.Quad0_1;

            trs.S = SpriteSize;
            trs.T = GetCellPos(coord.Vector3());

            m_z_count[coord.X + coord.Y * m_num_cells.Y]++;
            m_cells[cell_index].Data = new RawSpriteTile(trs, tile_index, false, false);
            update_top_most_flag(coord);
        }
예제 #5
0
        public void SetBlock(Vector3i coord, Vector2i tile_index, bool second)
        {
            Vector3i clamped_coord = coord.Clamp(Math._000i, m_num_cells - Math._111i);

            Common.Assert(clamped_coord == coord);

            int cell_index = coord.X + m_num_cells.X * (coord.Y + coord.Z * m_num_cells.Y);

            if (m_cells[cell_index] == null)
            {
                m_cells[cell_index] = new Cell();
            }

            TRS quad = TRS.Quad0_1;
            //each z level happens to corresponds to the iso tile neighbour at +(1,1), hence the +coord.Z below
            Vector2 p = X * (coord.X + coord.Z) + Y * (coord.Y + coord.Z);

            quad.T = (p + Y).ProjectOnLine(p, Math._10);
//			#if 0
            float d = (p - quad.T).Length() * 2.0f;               // d should be =1

            quad.S = new Vector2(d, d);
//			#endif

            var data = new RawSpriteTile(quad, tile_index, false, false);

            if (second)
            {
                m_cells[cell_index].Data2    = data;
                m_cells[cell_index].Data1Set = true;
            }
            else
            {
                m_cells[cell_index].Data1    = data;
                m_cells[cell_index].Data2Set = true;
            }
        }
예제 #6
0
 /// <summary>Get the nearest point between this <see cref="Box3i"/> and a <see cref="Vector3i"/>. If the <see cref="Vector3i"/> is inside this <see cref="Box3i"/>, it is returned untouched.</summary>
 public void NearestPointTo( ref  Vector3i point , out Vector3i result)
 {
     Containment containment = Intersect(ref point);
         if(containment != Containment.Disjoint)
             result = point;
         else
             point.Clamp(ref Min, ref Max, out result);
         return;
 }
예제 #7
0
 /// <summary>Get the nearest point between this <see cref="Box3i"/> and a <see cref="Vector3i"/>. If the <see cref="Vector3i"/> is inside this <see cref="Box3i"/>, it is returned untouched.</summary>
 public Vector3i NearestPointTo( Vector3i point )
 {
     Vector3i result;
         Containment containment = Intersect(ref point);
         if(containment != Containment.Disjoint)
             result = point;
         else
             point.Clamp(ref Min, ref Max, out result);
         return result;
 }
예제 #8
0
 bool IsValidBlockIndex(Vector3i coord)
 {
     return(coord == coord.Clamp(Math._000i, m_num_cells - Math._111i));
 }