Loading...
Searching...
No Matches
CityBuilderCore.IGridPositions Interface Reference

Detailed Description

transforms between grid and world positions

Inheritance diagram for CityBuilderCore.IGridPositions:
CityBuilderCore.MapBase CityBuilderCore.Tests.DebugMap CityBuilderCore.DefaultMap CityBuilderCore.HexagonMap CityBuilderCore.IsometricMap CityBuilderCore.TerrainMap

Public Member Functions

Vector2Int GetGridPosition (Vector3 position)
 turns a world position into a map point
 
Vector3 GetWorldPosition (Vector2Int point)
 turns a map point into the world position in its lower corner
 
Vector3 GetCenterFromPosition (Vector3 position)
 calculates the cells center from its corner position
to get the cell center from any position in it use Extensions.GetWorldCenterPosition(IGridPositions, Vector3)
 
Vector3 GetPositionFromCenter (Vector3 center)
 calculates the cells corner position from its center
 

Member Function Documentation

◆ GetCenterFromPosition()

Vector3 CityBuilderCore.IGridPositions.GetCenterFromPosition ( Vector3 position)

calculates the cells center from its corner position
to get the cell center from any position in it use Extensions.GetWorldCenterPosition(IGridPositions, Vector3)

Parameters
positionabsolute world space position of the cell cornder
Returns
center of the cell in absolute world space

Implemented in CityBuilderCore.IsometricMap, CityBuilderCore.MapBase, and CityBuilderCore.Tests.DebugMap.

◆ GetGridPosition()

Vector2Int CityBuilderCore.IGridPositions.GetGridPosition ( Vector3 position)

turns a world position into a map point

Parameters
positionabsolute world space position(transform.position)
Returns
map point of the cell the position was inside

Implemented in CityBuilderCore.MapBase, and CityBuilderCore.Tests.DebugMap.

◆ GetPositionFromCenter()

Vector3 CityBuilderCore.IGridPositions.GetPositionFromCenter ( Vector3 center)

calculates the cells corner position from its center

Parameters
centerabsolute world space position of the cell center
Returns
corner of the cell in absolute world space

Implemented in CityBuilderCore.IsometricMap, CityBuilderCore.MapBase, and CityBuilderCore.Tests.DebugMap.

◆ GetWorldPosition()

Vector3 CityBuilderCore.IGridPositions.GetWorldPosition ( Vector2Int point)

turns a map point into the world position in its lower corner

Parameters
pointmap/cell point
Returns
absolute world position in the corner of the cell

Implemented in CityBuilderCore.MapBase, and CityBuilderCore.Tests.DebugMap.