Documentation ¶
Index ¶
- func CreateShapePath(region *Region, shapeEdgeOrder *[]int) *[]*Vec2
- func NewRegionShape(region *Region, shapeEdgeOrder *[]int) (shape *regionShape)
- type CenterPoint
- type Continent
- func (continent *Continent) CreateShapes(shapeName string)
- func (continent *Continent) CreateSomeRegions()
- func (continent *Continent) Json() string
- func (continent *Continent) MakeNeighbors()
- func (continent *Continent) MinRegionSize() int
- func (continent *Continent) NeighborLessRegions() []*Region
- func (continent *Continent) UpdateCenterPoints(fastGrowCount uint)
- func (continent *Continent) UpdateRegionSizes()
- type ContinentConfig
- type ContinentCreationStrategy
- type ContinentDescription
- type Hexagon
- type HexagonGrid
- type Position
- type Region
- func (region *Region) AssignHexagon(hex *Hexagon) *Region
- func (region *Region) AssignHexagons(hexagons []*Hexagon) *Region
- func (region *Region) IsNeighbor(other *Region) bool
- func (region *Region) RegionLessNeighborHexagons() (regionLess []*Hexagon)
- func (region *Region) RegionSize() int
- func (region *Region) ShapeHexagons() (shape []*Hexagon)
- func (region *Region) SingleRandomShapeHexagon() *Hexagon
- type RegionGrid
- type RegionGridMask
- type RegionGroup
- type Vec2
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateShapePath ¶
func NewRegionShape ¶
Types ¶
type CenterPoint ¶
CenterPoint represents a point together with an inner and outer radius.
type Continent ¶
type Continent struct { Width uint `json:"width"` Height uint `json:"height"` Shapes []map[string]*[]*Vec2 `json:"regions"` CenterPoints []CenterPoint `json:"centerPoints"` RegionSizes []float64 `json:"regionSizes"` Neighbors []*[]int `json:"neighbors"` // contains filtered or unexported fields }
func NewContinent ¶
func (*Continent) CreateShapes ¶
func (*Continent) CreateSomeRegions ¶
func (continent *Continent) CreateSomeRegions()
func (*Continent) MakeNeighbors ¶
func (continent *Continent) MakeNeighbors()
func (*Continent) MinRegionSize ¶
func (*Continent) NeighborLessRegions ¶
func (*Continent) UpdateCenterPoints ¶
func (*Continent) UpdateRegionSizes ¶
func (continent *Continent) UpdateRegionSizes()
type ContinentConfig ¶
type ContinentConfig struct { GridWidth uint `json:"gridWidth"` GridHeight uint `json:"gridHeight"` GridOuterPaddingX uint `json:"gridOuterPaddingX"` GridOuterPaddingY uint `json:"gridOuterPaddingY"` GridInnerPaddingX uint `json:"gridInnerPaddingX"` GridInnerPaddingY uint `json:"gridInnerPaddingY"` GridHexWidth uint `json:"gridHexWidth"` GridHexHeight uint `json:"gridHexHeight"` HexWidth uint `json:"hexWidth"` HexHeight uint `json:"hexHeight"` HexPaddingX uint `json:"hexPaddingX"` HexPaddingY uint `json:"hexPaddingY"` MinimalGrowIterations uint `json:"minimalGrowIterations"` FastGrowIterations uint `json:"fastGrowIterations"` MaxRegionSizeFactor float64 `json:"maxRegionSizeFactor"` ProbabilityCreateRegionAt float64 `json:"probabilityCreateRegionAt"` DivisibilityBy uint `json:"divisibilityBy"` }
type ContinentCreationStrategy ¶
type ContinentCreationStrategy struct { RegionGrid RegionGridMask ContinentConfig Continent *Continent MaxRegionSize int // contains filtered or unexported fields }
func NewContinentCreationStrategy ¶
func NewContinentCreationStrategy(cfg ContinentConfig) (strategy *ContinentCreationStrategy)
NewContinentCreationStrategy creates a new instacnce of ContinentCreationStrategy
func (*ContinentCreationStrategy) BuildContinent ¶
func (strategy *ContinentCreationStrategy) BuildContinent(onProgress func(float64)) *Continent
BuildContinent runs the full continent creation algorithm.
Should never be called twice. Should be called right after creating a new instance of ContinentCreationStrategy.
func (*ContinentCreationStrategy) ForEachGridRegion ¶
func (strategy *ContinentCreationStrategy) ForEachGridRegion(fn gridRegionFn)
type ContinentDescription ¶
type ContinentDescription struct { Continent *Continent `json:"continent"` Config *ContinentConfig `json:"config"` }
func NewContinentDescription ¶
func NewContinentDescription(continent *Continent, config *ContinentConfig) (cd *ContinentDescription)
func (*ContinentDescription) Json ¶
func (cd *ContinentDescription) Json() string
func (*ContinentDescription) PrettyJson ¶
func (cd *ContinentDescription) PrettyJson() string
type Hexagon ¶
type Hexagon struct {
Row, Col uint
Left, Top float64
CenterPoint Vec2
Region *Region
NeighborNorth *Hexagon
NeighborNorthEast *Hexagon
NeighborSouthEast *Hexagon
NeighborSouth *Hexagon
NeighborSouthWest *Hexagon
NeighborNorthWest *Hexagon
NeighborRight *Hexagon
NeighborLeft *Hexagon
// contains filtered or unexported fields
}
The Hexagon represents a hexagon.
func NewHexagon ¶
NewHexagon creates a new Hexagon.
Normally this is done by the HexagonGrid and you do not need to create hexagons by yourself.
func (*Hexagon) NeighborsWithRegionCount ¶
NeighborsWithRegionCount returns the number of neighbor hexagons which are assigned to a region.
type HexagonGrid ¶
type HexagonGrid struct {
Width, Height uint
// contains filtered or unexported fields
}
func NewHexagonGrid ¶
func NewHexagonGrid(width, height, hexWidth, hexHeight, paddingX, paddingY uint) (grid *HexagonGrid)
func (*HexagonGrid) CanvasHeight ¶
func (grid *HexagonGrid) CanvasHeight() uint
func (*HexagonGrid) CanvasWidth ¶
func (grid *HexagonGrid) CanvasWidth() uint
func (*HexagonGrid) Hexagon ¶
func (grid *HexagonGrid) Hexagon(x, y uint) *Hexagon
type Region ¶
type Region struct {
// contains filtered or unexported fields
}
func (*Region) AssignHexagon ¶
func (*Region) AssignHexagons ¶
func (*Region) IsNeighbor ¶
func (*Region) RegionLessNeighborHexagons ¶
func (*Region) RegionSize ¶
func (*Region) ShapeHexagons ¶
func (*Region) SingleRandomShapeHexagon ¶
type RegionGrid ¶
type RegionGrid struct {
// contains filtered or unexported fields
}
func NewRegionGrid ¶
func NewRegionGrid(width, height uint) *RegionGrid
func (*RegionGrid) Height ¶
func (grid *RegionGrid) Height() uint
func (*RegionGrid) IsInsideGrid ¶
func (grid *RegionGrid) IsInsideGrid(x, y uint) bool
func (*RegionGrid) Region ¶
func (grid *RegionGrid) Region(x, y uint) *Region
func (*RegionGrid) SetRegion ¶
func (grid *RegionGrid) SetRegion(x, y uint, region *Region) *RegionGrid
func (*RegionGrid) Width ¶
func (grid *RegionGrid) Width() uint
type RegionGridMask ¶
type RegionGridMask struct {
// contains filtered or unexported fields
}
func NewRegionGridMask ¶
func NewRegionGridMask(rand *rand.Rand, width, height, divisibilityBy uint, probabilityCreateRegionAt float64) *RegionGridMask
func (*RegionGridMask) ShouldCreateRegionAt ¶
func (grid *RegionGridMask) ShouldCreateRegionAt(x, y uint) bool
type RegionGroup ¶
type RegionGroup struct {
Regions []*Region
}
func NewRegionGroup ¶
func NewRegionGroup(maxRegionCount int) (group *RegionGroup)
func (*RegionGroup) Append ¶
func (group *RegionGroup) Append(region *Region)
func (*RegionGroup) IsInside ¶
func (group *RegionGroup) IsInside(region *Region) bool
func (*RegionGroup) IsOverlapping ¶
func (group *RegionGroup) IsOverlapping(other *RegionGroup) bool
func (*RegionGroup) Merge ¶
func (group *RegionGroup) Merge(other *RegionGroup)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Copyright (C) 2014-2020 Wolfger Schramm <wolfger@spearwolf.de>
|
Copyright (C) 2014-2020 Wolfger Schramm <wolfger@spearwolf.de> |
Copyright (C) 2014-2020 Wolfger Schramm <wolfger@spearwolf.de>
|
Copyright (C) 2014-2020 Wolfger Schramm <wolfger@spearwolf.de> |
Click to show internal directories.
Click to hide internal directories.