/// <summary> /// Resets the current grid surface with new values for the tile shape and arrangement, origin, orientation, wrapping behavior, and grid size. /// </summary> /// <param name="hexDescriptor">The descriptor structure with details about the shape and arrangement of hexagonal tiles.</param> /// <param name="origin">The origin of the plane.</param> /// <param name="orientation">The orientation of the plane.</param> /// <param name="isAxis0Wrapped">Indicates whether the first axis exhibits wrap-around behavior at the grid boundaries.</param> /// <param name="isAxis1Wrapped">Indicates whether the second axis exhibits wrap-around behavior at the grid boundaries.</param> /// <param name="size">The size of the grid, in terms of the number of tiles along the first and second axes of the surface..</param> /// <returns>A reference to the current surface.</returns> public RectangularHexGrid Reset(HexGridDescriptor hexDescriptor, Vector3 origin, Quaternion orientation, bool isAxis0Wrapped, bool isAxis1Wrapped, IntVector2 size) { midpoint = hexDescriptor.midpoint; majorCorner = hexDescriptor.majorCorner; minorCorner = hexDescriptor.minorCorner; midpointIsFirstAxis = hexDescriptor.midpointIsFirstAxis; axisStyle = hexDescriptor.axisStyle; _originIsObtuse = Vector2.Dot(midpoint, minorCorner) < Vector2.Dot(midpoint, majorCorner); if (axisStyle == HexGridAxisStyles.Straight) { _faceAxis0 = midpoint * 2f; _faceAxis1 = majorCorner + minorCorner; } else { _faceAxis0 = midpoint * 2f; if (_originIsObtuse) { _faceAxis1 = majorCorner + minorCorner + midpoint; } else { _faceAxis1 = majorCorner + minorCorner - midpoint; } } if (!midpointIsFirstAxis) { GeneralUtility.Swap(ref _faceAxis0, ref _faceAxis1); } Reset(new WrappableAxis2(_faceAxis0 * size.x, isAxis0Wrapped), new WrappableAxis2(_faceAxis1 * size.y, isAxis1Wrapped), origin, orientation); this.size = size; topology = null; Initialize(); return(this); }
/// <summary> /// Creates a hexagonally tiled grid surface instance with the given tile shape and arrangement, origin, orientation, wrapping behavior, and grid size. /// </summary> /// <param name="hexDescriptor">The descriptor structure with details about the shape and arrangement of hexagonal tiles.</param> /// <param name="origin">The origin of the plane.</param> /// <param name="orientation">The orientation of the plane.</param> /// <param name="isAxis0Wrapped">Indicates whether the first axis exhibits wrap-around behavior at the grid boundaries.</param> /// <param name="isAxis1Wrapped">Indicates whether the second axis exhibits wrap-around behavior at the grid boundaries.</param> /// <param name="size">The size of the grid, in terms of the number of tiles along the first and second axes of the surface..</param> /// <returns>A hexagonally tiled grid surface.</returns> public static RectangularHexGrid Create(HexGridDescriptor hexDescriptor, Vector3 origin, Quaternion orientation, bool isAxis0Wrapped, bool isAxis1Wrapped, IntVector2 size) { return(CreateInstance <RectangularHexGrid>().Reset(hexDescriptor, origin, orientation, isAxis0Wrapped, isAxis1Wrapped, size)); }