Loading...
Searching...
No Matches
CityBuilderCore.IsometricMap Class Reference

Detailed Description

implementation for various map and grid functions on an isometric grid with 2d sprites

https://citybuilder.softleitner.com/manual

Inheritance diagram for CityBuilderCore.IsometricMap:
CityBuilderCore.DefaultMap CityBuilderCore.MapBase CityBuilderCore.IMap CityBuilderCore.IGridOverlay CityBuilderCore.IGridPositions CityBuilderCore.IGridRotations

Public Member Functions

override Vector3 ClampPosition (Vector3 position)
 clamps a position to be inside the maps size
if, for example, a position 5,-10 is passed for a map that starts at 0,0 the position will be clamped to 5,0
 
override 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)
 
override Vector3 GetPositionFromCenter (Vector3 center)
 calculates the cells corner position from its center
 
override Vector3 GetVariance ()
 get position variance for walkers and such, can be used so walkers on the same point dont overlap
 
- Public Member Functions inherited from CityBuilderCore.DefaultMap
override bool IsBuildable (Vector2Int point, int mask, object tag=null)
 checks if a point is ok to build on or if the map somehow blocks building there
 
override bool IsWalkable (Vector2Int point)
 check if a point can be walked on and may be used in pathfinding
 
override bool CheckGround (Vector2Int point, Object[] options)
 checks the ground for certain features
for example in tilemap base maps this would be a tile
 
- Public Member Functions inherited from CityBuilderCore.MapBase
bool IsInside (Vector2Int position)
 checks if a point is inside the map size
 
bool IsBuildable (Vector2Int position, int mask, object tag=null)
 checks if a point is ok to build on or if the map somehow blocks building there
 
bool IsWalkable (Vector2Int position)
 check if a point can be walked on and may be used in pathfinding
 
bool CheckGround (Vector2Int position, Object[] options)
 checks the ground for certain features
for example in tilemap base maps this would be a tile
 
void Show ()
 shows grid lines on the map
 
void Hide ()
 hides grid lines on the map
 
virtual Vector2Int ClampPoint (Vector2Int point)
 clamps a point to be inside the maps size
 
virtual Vector2Int GetGridPosition (Vector3 position)
 turns a world position into a map point
 
virtual Vector3 GetWorldPosition (Vector2Int position)
 turns a map point into the world position in its lower corner
 
virtual void SetRotation (Transform transform, Vector3 direction)
 adjusts a transform in order to visually reflect the direction it is facing
 
virtual void SetRotation (Transform transform, float rotation)
 adjusts a transform by a rotation in degrees
 
virtual float GetRotation (Vector3 direction)
 calculates a numeric rotation in degrees from a direction
 
virtual Vector3 GetDirection (float angle)
 calculates a direction from a numeric roation
 

Protected Member Functions

override void OnDrawGizmos ()
 
- Protected Member Functions inherited from CityBuilderCore.MapBase
virtual void Awake ()
 
virtual void Start ()
 

Properties

override Vector3 WorldCenter [get]
 world position at the center of the map
 
- Properties inherited from CityBuilderCore.MapBase
virtual bool IsHex [get]
 whether we're on a hexagonal map which may need some special handling
 
virtual bool IsXY [get]
 whether the map grid is in xy, usually in 2d games
3d games often use Y as the height axis and have their grid in XZ
 
virtual Vector3 CellOffset [get]
 delta position from one cell to the next
 
virtual Vector3 WorldCenter [get]
 world position at the center of the map
 
virtual Vector3 WorldSize [get]
 
Grid Grid [get]
 
- Properties inherited from CityBuilderCore.IMap

Additional Inherited Members

- Public Types inherited from CityBuilderCore.MapBase
enum  RotationMode { Rotate , Mirror , MirrorAndFlip , Disabled }
 
- Public Attributes inherited from CityBuilderCore.DefaultMap
Tilemap Ground
 
TileBase[] WalkingBlockingTiles
 
BlockingTile[] BuildingBlockingTiles
 
TaggedTiles[] TaggedBuildingTiles
 
- Public Attributes inherited from CityBuilderCore.MapBase
Vector2Int Size
 
Renderer GridVisual
 
float Variance
 
RotationMode Rotation
 

Member Function Documentation

◆ ClampPosition()

override Vector3 CityBuilderCore.IsometricMap.ClampPosition ( Vector3 position)
inlinevirtual

clamps a position to be inside the maps size
if, for example, a position 5,-10 is passed for a map that starts at 0,0 the position will be clamped to 5,0

Parameters
positionthe position to check
Returns
the clamped position

Reimplemented from CityBuilderCore.MapBase.

◆ GetCenterFromPosition()

override Vector3 CityBuilderCore.IsometricMap.GetCenterFromPosition ( Vector3 position)
inlinevirtual

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

Reimplemented from CityBuilderCore.MapBase.

◆ GetPositionFromCenter()

override Vector3 CityBuilderCore.IsometricMap.GetPositionFromCenter ( Vector3 center)
inlinevirtual

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

Reimplemented from CityBuilderCore.MapBase.

◆ GetVariance()

override Vector3 CityBuilderCore.IsometricMap.GetVariance ( )
inlinevirtual

get position variance for walkers and such, can be used so walkers on the same point dont overlap

Returns

Reimplemented from CityBuilderCore.MapBase.

◆ OnDrawGizmos()

override void CityBuilderCore.IsometricMap.OnDrawGizmos ( )
inlineprotectedvirtual

Reimplemented from CityBuilderCore.MapBase.

Property Documentation

◆ WorldCenter

override Vector3 CityBuilderCore.IsometricMap.WorldCenter
get

world position at the center of the map

Implements CityBuilderCore.IMap.