• Manual
  • Scripting API
  • Asset Store
  • TycoonTerrain.Core
  • TileHandle
Search Results for

    Show / Hide Table of Contents
    • TycoonTerrain.Components
      • TycoonTileRendererBase
    • TycoonTerrain.Core
      • BoundsContainer
      • BoundsReservationRegister
      • CallbackHandle
      • CallbacksRegister
      • CardinalDirection
      • ChunkSet
      • ConstructableDefinition
      • CornerIndex
      • Extensions
      • IChunkListener
      • IntBound
      • LandTile
      • OnBoundsChangeCallback
      • PlacementValidResult
      • SurfaceOverlayMesh
      • TerrainGrid
      • TerrainModifiedEvent
      • TerrainSelection
      • TerrainTypeCollectionAsset
      • TerrainTypeDefinition
      • TerrainTypeTable
      • TileCorner
      • TileHandle
      • TilePosition
      • TileType
      • TycoonTileMap
      • TycoonTileRaycastHit
    • TycoonTerrain.Core.Generation
      • TerrainGenerationJob
    • TycoonTerrain.Core.Rendering
      • ChunkMesh
      • IMesh
      • NativeMeshData
      • RenderTerrainCliffChunkJob
      • RenderTerrainSurfaceChunkJob
      • RenderWaterChunkJob
      • RenderWaterCliffChunkJob
      • SubMeshTriangle
    • TycoonTerrain.Core.TerrainOperations
      • ClearWaterBodyOperation
      • CopyHeightMapOperation
      • CreateWaterBodyFloodOperation
      • DecreaseHeightCliffOperation
      • DecreaseHeightCorner
      • DecreaseHeightSmoothConnectedOperation
      • GetTilesInWaterBody
      • IncreaseHeightCliffOperation
      • IncreaseHeightCorner
      • IncreaseHeightSmoothConnectedOperation
      • ITerrainOperation
      • MaxHeightSmooth
      • OperationContext
      • OperationResult
      • SetHeightOperation
      • SetTileTypeInBoundsOperation
      • SetWaterLevelOperation
    • TycoonTerrain.Previewers
      • BuildingToolPreviewer
      • PreviewMeshes
      • TerrainPainterPreviewer
      • TerrainSelectionPreviewer
      • ToolPreviewerBase<T>
    • TycoonTerrain.Tools
      • BuildingTool
      • PainterTool
      • SceneryTool
      • SelectionToolBase
      • SnappingMode
      • TerraformingTool
      • ToolBase
      • WaterTool

    Struct TileHandle

    This struct is a utility struct that can be used as a pointer within the map grid. \n It holds a position and reference to the map and provides useful functions to interact with the underlying tile. \n User code should use this struct to interact with the underlying tile whenever possible.

    Namespace: TycoonTerrain.Core
    Assembly: TycoonTerrainAssembly.dll
    Syntax
    public struct TileHandle
    Remarks

    This struct is not intended to be stored in a member variable.

    Fields

    tilePosition

    The tile position of the tile this handle refers to.

    Declaration
    public readonly int2 tilePosition
    Field Value
    Type Description
    Unity.Mathematics.int2

    The tile position of the tile this handle refers to.

    Properties

    BottomCenterPosition

    Gets the bottom center position at the base of the tile in map space.

    Declaration
    public float3 BottomCenterPosition { get; }
    Property Value
    Type Description
    Unity.Mathematics.float3

    The bottom center position at the base of the tile in map space.

    CenterSurfaceHeight

    Gets the surface height of the tile center.

    Declaration
    public float CenterSurfaceHeight { get; }
    Property Value
    Type Description
    Single

    The surface height of the tile center.

    CenterSurfacePosition

    Gets the center surface position of the tile in map space.

    Declaration
    public float3 CenterSurfacePosition { get; }
    Property Value
    Type Description
    Unity.Mathematics.float3

    The center surface position of the tile in map space.

    IsCompletelySubmerged

    Gets a value indicating whether the surface of this tile is completely submerged.

    Declaration
    public bool IsCompletelySubmerged { get; }
    Property Value
    Type Description
    Boolean

    true if the surface of this tile is completely submerged; otherwise, false.

    IsInBounds

    Whether the current tile position lies within the map bounds.

    Declaration
    public bool IsInBounds { get; }
    Property Value
    Type Description
    Boolean

    true if the current tile position lies within the map bounds; otherwise, false.

    IsWaterLevelBelowSurface

    Gets a value indicating whether the water level of this tile is below the tile surface.

    Declaration
    public bool IsWaterLevelBelowSurface { get; }
    Property Value
    Type Description
    Boolean

    true if the water level of this tile is below the tile surface; otherwise, false.

    IsWaterLevelSurfaced

    Gets a value indicating whether this instance is water level surfaced.

    Declaration
    public bool IsWaterLevelSurfaced { get; }
    Property Value
    Type Description
    Boolean

    true if this instance is water level surfaced; otherwise, false.

    WaterLevel

    Gets the water level.

    Declaration
    public ushort WaterLevel { get; }
    Property Value
    Type Description
    UInt16

    The water level.

    Methods

    FromCenter(float3)

    Returns the position of the ray hit tile center with an optional offset.

    Declaration
    public float3 FromCenter(float3 offset = default(float3))
    Parameters
    Type Name Description
    Unity.Mathematics.float3 offset

    The offset from the center.

    Returns
    Type Description
    Unity.Mathematics.float3

    The map position that is offset from the tile center.

    GetClosestCorner(float2)

    Returns the corner index closest to the local position.

    Declaration
    public CornerIndex GetClosestCorner(float2 localPosition)
    Parameters
    Type Name Description
    Unity.Mathematics.float2 localPosition

    The local tile position, where x and y are in the range [0,1].

    Returns
    Type Description
    CornerIndex

    The corner index closest to the local position.

    GetClosestEdge(float2)

    Returns the edge direction closest to the local position.

    Declaration
    public CardinalDirection GetClosestEdge(float2 localPosition)
    Parameters
    Type Name Description
    Unity.Mathematics.float2 localPosition

    The local tile position, where x and y are in the range [0,1].

    Returns
    Type Description
    CardinalDirection

    The direction of the closest edge.

    GetCorner(CornerIndex)

    Gets the tile corner for the current tile.

    Declaration
    public TileCorner GetCorner(CornerIndex cornerIndex)
    Parameters
    Type Name Description
    CornerIndex cornerIndex

    The corner index.

    Returns
    Type Description
    TileCorner

    The tile corner for the current tile at cornerIndex.

    GetCornerPosition(CornerIndex)

    Gets the corner position of the tile for a given corner index.

    Declaration
    public float3 GetCornerPosition(CornerIndex cornerIndex)
    Parameters
    Type Name Description
    CornerIndex cornerIndex

    Index of the corner.

    Returns
    Type Description
    Unity.Mathematics.float3

    The corner position of the tile.

    GetData()

    Gets the tile data.

    Declaration
    public LandTile GetData()
    Returns
    Type Description
    LandTile

    The tile data.

    GetHeight(CornerIndex)

    Gets the height of the specified tile corner.

    Declaration
    public byte GetHeight(CornerIndex cornerIndex)
    Parameters
    Type Name Description
    CornerIndex cornerIndex

    The corner index.

    Returns
    Type Description
    Byte

    The height of the corner.

    GetNeighbourOrDefault(CardinalDirection)

    Gets the neighbour tile in a given direction if it exists or an invalid tile handle if the neighbouring tile does not exist.

    Declaration
    public TileHandle GetNeighbourOrDefault(CardinalDirection direction)
    Parameters
    Type Name Description
    CardinalDirection direction

    The direction.

    Returns
    Type Description
    TileHandle

    The neighbour tile in direction if it exists; an invalid tile handle if the neighbouring tile does not exist.

    GetSurfaceNormal(float2)

    Sample the surface normal at the given local tile position.

    Declaration
    public float3 GetSurfaceNormal(float2 localPosition)
    Parameters
    Type Name Description
    Unity.Mathematics.float2 localPosition

    The local tile position, where x and y are in the range [0,1].

    Returns
    Type Description
    Unity.Mathematics.float3

    GetSurfacePosition(float2)

    Sample the surface position at the given local tile position.

    Declaration
    public float3 GetSurfacePosition(float2 localPosition)
    Parameters
    Type Name Description
    Unity.Mathematics.float2 localPosition

    The local tile position, where x and y are in the range [0,1].

    Returns
    Type Description
    Unity.Mathematics.float3

    The map position of the surface on localPosition of the current tile.

    GetTilesInDirection(CardinalDirection, Int32)

    Gets a specified number of tiles in a given direction, starting from the current tile.

    Declaration
    public IEnumerable<TileHandle> GetTilesInDirection(CardinalDirection direction, int length)
    Parameters
    Type Name Description
    CardinalDirection direction

    The direction.

    Int32 length

    The number of tiles to return.

    Returns
    Type Description
    IEnumerable<TileHandle>

    The tiles in a given direction.

    IsEdgeFlush(CardinalDirection)

    Returns true when the two corners of the neighbouring tile in the given direction are equal to the adjacent corners of this tile, false otherwise.

    Declaration
    public bool IsEdgeFlush(CardinalDirection direction)
    Parameters
    Type Name Description
    CardinalDirection direction

    The direction to look for.

    Returns
    Type Description
    Boolean

    true when the two corners of the neighbouring tile in direction are equal to the adjacent corners of this tile; otherwise, false.

    IsWaterLevelAboveSurface(Int32)

    Determines whether water level is above surface.

    Declaration
    public bool IsWaterLevelAboveSurface(int waterLevel)
    Parameters
    Type Name Description
    Int32 waterLevel

    The water level.

    Returns
    Type Description
    Boolean

    true if water level is above surface; otherwise, false.

    IsWithinCenter(float2, Single)

    Gets whether the given local position is within the center of the tile considering the maximum distance from the center.

    Declaration
    public bool IsWithinCenter(float2 localPosition, float maxDistanceFromCenter)
    Parameters
    Type Name Description
    Unity.Mathematics.float2 localPosition

    The local tile position, where x and y are in the range [0,1].

    Single maxDistanceFromCenter

    The maximum distance to be considered within the tile center, in the range [0,1].

    Returns
    Type Description
    Boolean

    true if localPosition is within maxDistanceFromCenter from the tile center; false otherwise.

    Neighbours()

    Gets the neighbouring tiles of this tile.

    Declaration
    public IEnumerable<TileHandle> Neighbours()
    Returns
    Type Description
    IEnumerable<TileHandle>

    A TileHandle instance for each neighbouring tile, in the order North, East, South, West.

    SnapToCorners(float2)

    Returns the local position snapped to the closest tile corner.

    Declaration
    public float3 SnapToCorners(float2 localPosition)
    Parameters
    Type Name Description
    Unity.Mathematics.float2 localPosition

    The local tile position, where x and y are in the range [0,1].

    Returns
    Type Description
    Unity.Mathematics.float3

    The map position that is snapped to the nearest tile corner.

    SnapToEdge(float2, Single)

    Returns the local position snapped to the closest tile edge. Optionally provide an horizontal offset.

    Declaration
    public float3 SnapToEdge(float2 localPosition, float offset = 0F)
    Parameters
    Type Name Description
    Unity.Mathematics.float2 localPosition

    The local tile position, where x and y are in the range [0,1].

    Single offset

    The horizontal offset. Negative offset moves the position further into the tile, a positive offset moves it further outwards.

    Returns
    Type Description
    Unity.Mathematics.float3

    The map position that is snapped to the nearest tile edge center.

    SnapToGrid(float2, Int32)

    Returns the local position snapped to the center of the subgrid using the number of tile grid subdivisions.

    Declaration
    public float3 SnapToGrid(float2 localPosition, int numberOfSubdivisions)
    Parameters
    Type Name Description
    Unity.Mathematics.float2 localPosition

    The local tile position, where x and y are in the range [0,1].

    Int32 numberOfSubdivisions

    The number of sub divisions to snap to.

    Returns
    Type Description
    Unity.Mathematics.float3

    The map position that is snapped to the nearest subdivision.

    SnapToGrid(float2, Int32, float2)

    Returns the local position snapped to the center of the subgrid using the number of tile grid subdivisions and a local offset.

    Declaration
    public float3 SnapToGrid(float2 localPosition, int numberOfSubdivisions, float2 localOffset)
    Parameters
    Type Name Description
    Unity.Mathematics.float2 localPosition

    The local tile position, where x and y are in the range [0,1].

    Int32 numberOfSubdivisions

    The number of sub divisions to snap to.

    Unity.Mathematics.float2 localOffset

    The local offset within the sub grid in the range [0,1] for x and y.

    Returns
    Type Description
    Unity.Mathematics.float3

    The map position that is snapped to the nearest subdivision.

    TryGetNeighbour(CardinalDirection, out TileHandle)

    Try to retrieve the neighbouring tile of the current tile. Will return true if there is a neighbour in that direction, false otherwise.

    Declaration
    public bool TryGetNeighbour(CardinalDirection direction, out TileHandle handle)
    Parameters
    Type Name Description
    CardinalDirection direction

    The direction to look for a neighbour relative to this tile.

    TileHandle handle

    The resulting tile handle if a neighbour exists. An invalid tile handle if no neighbour exists.

    Returns
    Type Description
    Boolean

    true if this tile has a neighbour in direction; false otherwise.

    In This Article
    • Fields
      • tilePosition
    • Properties
      • BottomCenterPosition
      • CenterSurfaceHeight
      • CenterSurfacePosition
      • IsCompletelySubmerged
      • IsInBounds
      • IsWaterLevelBelowSurface
      • IsWaterLevelSurfaced
      • WaterLevel
    • Methods
      • FromCenter(float3)
      • GetClosestCorner(float2)
      • GetClosestEdge(float2)
      • GetCorner(CornerIndex)
      • GetCornerPosition(CornerIndex)
      • GetData()
      • GetHeight(CornerIndex)
      • GetNeighbourOrDefault(CardinalDirection)
      • GetSurfaceNormal(float2)
      • GetSurfacePosition(float2)
      • GetTilesInDirection(CardinalDirection, Int32)
      • IsEdgeFlush(CardinalDirection)
      • IsWaterLevelAboveSurface(Int32)
      • IsWithinCenter(float2, Single)
      • Neighbours()
      • SnapToCorners(float2)
      • SnapToEdge(float2, Single)
      • SnapToGrid(float2, Int32)
      • SnapToGrid(float2, Int32, float2)
      • TryGetNeighbour(CardinalDirection, out TileHandle)
    Back to top Tycoon Tile documentation