Documentation ¶
Index ¶
- Constants
- func ConstructBackground(terrain map[geom.Key]procedural.Code, baseTiles map[procedural.Code]BaseTile, ...)
- type BaseTile
- type ComponentHandler
- type ComponentHandlerCall
- type ComponentHandlerFrame
- type Corner
- type CornerCollection
- type EdgeCollection
- type Encroachment
- type EncroachmentsCollection
- type Frame
- type Intner
- type Layer
- type Offset
- type Option
- type Options
Constants ¶
const ( BaseLayer = iota CornersLayer EncroachmentsLayer AdornmentsLayer // AdornmentsLayer has trees, bushes, rocks, anything with a bit of three-dimensionality. )
Variables ¶
This section is empty.
Functions ¶
func ConstructBackground ¶
func ConstructBackground(terrain map[geom.Key]procedural.Code, baseTiles map[procedural.Code]BaseTile, encroachments EncroachmentsCollection, field *geom.Field, prng *rand.Rand, handler ComponentHandler)
ConstructBackground takes terrain and translates it into handler calls that define the hexes that compose a background.
Types ¶
type BaseTile ¶
type BaseTile struct { Code procedural.Code `json:"code"` Texture string `json:"texture"` Variations Options `json:"variations"` }
type ComponentHandler ¶
type ComponentHandler func(frames ComponentHandlerCall)
type ComponentHandlerCall ¶
type ComponentHandlerCall struct { Frames []ComponentHandlerFrame X, Y int Z Layer }
type ComponentHandlerFrame ¶
type CornerCollection ¶
type CornerCollection struct { Texture string Corners map[geom.DirectionType]Corner }
func (CornerCollection) MarshalJSON ¶
func (e CornerCollection) MarshalJSON() ([]byte, error)
func (*CornerCollection) UnmarshalJSON ¶
func (e *CornerCollection) UnmarshalJSON(data []byte) error
type EdgeCollection ¶
type EdgeCollection struct { Texture string `json:"texture"` Options map[geom.DirectionType]Options `json:"options"` }
EdgeCollection maps the direction of neighbors to the appropriate encroachment info. type EdgeCollection map[geom.DirectionType]Options
func (EdgeCollection) MarshalJSON ¶
func (e EdgeCollection) MarshalJSON() ([]byte, error)
func (*EdgeCollection) UnmarshalJSON ¶
func (e *EdgeCollection) UnmarshalJSON(data []byte) error
UnmarshalJSON
type Encroachment ¶
type Encroachment struct { Description string `json:"description"` Over procedural.Code `json:"over"` Adjacent procedural.Code `json:"adjacent"` Edges EdgeCollection `json:"edges"` Corners CornerCollection `json:"corners"` }
type EncroachmentsCollection ¶
type EncroachmentsCollection map[string]Encroachment
EncroachmentsCollection is a mapping between the over and the adjacent codes of an encroachment, and the Encroachment itself. Keys are formatted as fmt.Sprintf("%s<-%s",over,adjacent). The idea is that there is one collection that is loaded in layers. First from core stuff built-in to the base game, then from a datafile if present, and also from an uncompressed directory structure potentially.
func (EncroachmentsCollection) Get ¶
func (ec EncroachmentsCollection) Get(over, adjacent procedural.Code) *Encroachment
func (EncroachmentsCollection) Put ¶
func (ec EncroachmentsCollection) Put(e Encroachment)
type Frame ¶
type Frame struct { Duration time.Duration `json:"duration"` Left int `json:"left"` Top int `json:"top"` }
func (Frame) MarshalJSON ¶
func (*Frame) UnmarshalJSON ¶
type Options ¶
type Options []Option
func (Options) Roll ¶
Roll the Options, taking the weighting of the relative Chances to pick one based on the randomized input from the passed intn function. Pass rand.Intn to quickly get non-reproducible, pseudo-random results. Will return nil if there are no Options. Will skip the call to the passed random number source if the collection of Options has less than 2 members.