コード例 #1
0
        private void Mark2x2(Placeable p, int zShift, Content content, Vector2Int cell)
        {
            Vector2 point  = BuffCToWorld(cell);
            Vector3 point3 = BuffCToWorld(cell).AddZ(zShift == 0 ? 0f : 0.5f);
            Vector2 cPoint = p.GetClosestPoint(point3).XY();

            if (cPoint == point)
            {
                int c = BuffCToBuffC(cell, zShift);
                buffer[c].Content                  |= content;
                buffer[c - 1].Content              |= content;
                buffer[c - buffSize.x].Content     |= content;
                buffer[c - buffSize.x - 1].Content |= content;
            }
            else if ((point - cPoint).Abs().IsLessEq(buffCSize))
            {
                int c = BuffCToBuffC(cell, zShift);
                if (point.IsLessEq(cPoint) || (!cPoint.IsLessEq(point) && TestCloseHit(p, point3 + (Vector3)buffCSizeHalf)))
                {
                    buffer[c].Content |= content;
                }

                if (point.IsYLessXGrEq(cPoint) || (!cPoint.IsYLessXGrEq(point) && TestCloseHit(p, point3 + new Vector3(-buffCSizeHalf.x, buffCSizeHalf.y, 0))))
                {
                    buffer[c - 1].Content |= content;
                }

                if (cPoint.IsLessEq(point) || (!point.IsLessEq(cPoint) && TestCloseHit(p, point3 - (Vector3)buffCSizeHalf)))
                {
                    buffer[c - 1 - buffSize.x].Content |= content;
                }

                if (cPoint.IsYLessXGrEq(point) || (!point.IsYLessXGrEq(cPoint) && TestCloseHit(p, point3 + new Vector3(buffCSizeHalf.x, -buffCSizeHalf.y, 0))))
                {
                    buffer[c - buffSize.x].Content |= content;
                }
            }
        }
コード例 #2
0
        private bool TestCloseHit(Placeable p, Vector3 point)
        {
            Vector3 cPoint = p.GetClosestPoint(point);

            return((point.XY() - cPoint.XY()).Abs().IsLessEq(buffCSizeHalf));
        }