procedural

package
v0.0.0-...-47a16e8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 30, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BlendTypeStrings

func BlendTypeStrings() []string

BlendTypeStrings returns a slice of all String values of the enum

func DeterministicIndexOf

func DeterministicIndexOf[V any](prng *rand.Rand, s []V) int

func StrategyTargetFilterStrings

func StrategyTargetFilterStrings() []string

StrategyTargetFilterStrings returns a slice of all String values of the enum

Types

type Blend

type Blend struct {
	Value Code
	Type  BlendType
}

type BlendType

type BlendType int
const (
	Noisy BlendType = iota
	Smooth
	Spiky
)

func BlendTypeString

func BlendTypeString(s string) (BlendType, error)

BlendTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func BlendTypeValues

func BlendTypeValues() []BlendType

BlendTypeValues returns all values of the enum

func (BlendType) IsABlendType

func (i BlendType) IsABlendType() bool

IsABlendType returns "true" if the value is listed in the enum definition. "false" otherwise

func (BlendType) MarshalJSON

func (i BlendType) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for BlendType

func (BlendType) String

func (i BlendType) String() string

func (*BlendType) UnmarshalJSON

func (i *BlendType) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for BlendType

type Code

type Code string

Code uniquely identifies either a Terrain or a Fill for an overworld tile.

type Generated

type Generated struct {
	Recipe string
	Paths  Paths

	// PathExtents are only being exposed for debugging purposes.
	PathExtents map[geom.DirectionType]geom.Key
	Terrain     map[geom.Key]Code

	Opponents          map[geom.Key]squad.RecipeID
	GenerationDuration time.Duration
}

func (*Generated) Complexity

func (g *Generated) Complexity() int

func (*Generated) MarshalJSON

func (g *Generated) MarshalJSON() ([]byte, error)

func (*Generated) UnmarshalJSON

func (g *Generated) UnmarshalJSON(data []byte) error

type Generator

type Generator struct {
	RecipeName       string
	MakePaths        pathFunc        `json:"pathGeneration"`
	Terrain          TerrainBuilder  `json:"terrainBuilder"`
	TerrainOverrides map[string]Code `json:"terrainSpecialOverrides"`

	Baddies OpponentSquads
}

Generator holds configuration data to construct overworld maps.

func (Generator) Generate

func (g Generator) Generate(seed int64, level int) Generated

Generate should take a recipe and output an overworld map.

func (*Generator) UnmarshalJSON

func (g *Generator) UnmarshalJSON(b []byte) error

type LinearGradientTerrainStrategy

type LinearGradientTerrainStrategy struct {
	TargetFilter  StrategyTargetFilter
	Overflows     Code
	Underflows    Code
	Gradients     TerrainGradientSlice
	PathOverrides map[Code]Code
}

func (*LinearGradientTerrainStrategy) Build

func (ts *LinearGradientTerrainStrategy) Build(prng *rand.Rand, paths Paths) map[geom.Key]Code

type NoiseTerrainStrategy

type NoiseTerrainStrategy struct {
	Smoothing  int
	Outside    Code
	Components TerrainChances
}

func (*NoiseTerrainStrategy) Build

func (ts *NoiseTerrainStrategy) Build(prng *rand.Rand, paths Paths) map[geom.Key]Code

type OpponentSquad

type OpponentSquad struct {
	ID           squad.RecipeID
	Chance       int
	Min          int
	Max          int
	OnlySpawnsOn []Code
}

type OpponentSquads

type OpponentSquads []OpponentSquad

func (OpponentSquads) Generate

func (s OpponentSquads) Generate(prng *rand.Rand, paths Paths, terrainCodes map[geom.Key]Code) map[geom.Key]squad.RecipeID

type Pair

type Pair[K, V any] struct {
	// contains filtered or unexported fields
}

type Paths

type Paths struct {
	Algorithm string
	Seed      int64

	Start    geom.Key
	Goal     geom.Key
	Nodes    map[geom.Key]Placement
	Specials map[string][]geom.Key
}

Paths represents a procedurally generated set of pathways.

func (Paths) Connect

func (paths Paths) Connect(a, b geom.Key)

type Placement

type Placement struct {
	Connections map[geom.DirectionType]struct{}
}

Placement holds info about what roads or paths have been placed on a Key.

type RadialGradientTerrainStrategy

type RadialGradientTerrainStrategy struct {
	Overflows     Code
	Underflows    Code
	Gradients     TerrainGradientSlice
	PathOverrides map[Code]Code
	// contains filtered or unexported fields
}

func (*RadialGradientTerrainStrategy) Build

func (ts *RadialGradientTerrainStrategy) Build(prng *rand.Rand, paths Paths) map[geom.Key]Code

type StrategyTargetFilter

type StrategyTargetFilter int
const (
	AnyTarget StrategyTargetFilter = iota
	Widest
	Narrowest
)

func StrategyTargetFilterString

func StrategyTargetFilterString(s string) (StrategyTargetFilter, error)

StrategyTargetFilterString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func StrategyTargetFilterValues

func StrategyTargetFilterValues() []StrategyTargetFilter

StrategyTargetFilterValues returns all values of the enum

func (StrategyTargetFilter) Generate

func (f StrategyTargetFilter) Generate(prng *rand.Rand, extents map[geom.DirectionType]geom.Key) geom.DirectionType

func (StrategyTargetFilter) IsAStrategyTargetFilter

func (i StrategyTargetFilter) IsAStrategyTargetFilter() bool

IsAStrategyTargetFilter returns "true" if the value is listed in the enum definition. "false" otherwise

func (StrategyTargetFilter) MarshalJSON

func (i StrategyTargetFilter) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for StrategyTargetFilter

func (StrategyTargetFilter) String

func (i StrategyTargetFilter) String() string

func (*StrategyTargetFilter) UnmarshalJSON

func (i *StrategyTargetFilter) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface for StrategyTargetFilter

type TerrainBuilder

type TerrainBuilder interface {
	Build(prng *rand.Rand, paths Paths) map[geom.Key]Code
}

TerrainBuilder is anything that can generate terrain for a set of paths.

type TerrainChances

type TerrainChances []struct {
	Value  Code
	Chance int
}

type TerrainGradient

type TerrainGradient struct {
	Portions float64 // How much of the map this gradient is responsible for.
	Value    Code
	Blend    *Blend
}

type TerrainGradientSlice

type TerrainGradientSlice []TerrainGradient

func (TerrainGradientSlice) SubGradient

func (gradients TerrainGradientSlice) SubGradient(percent float64) (int, float64)

SubGradient returns which gradient the percent through indicates, as well as the percent through that gradient.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL