Die API-Referenz stammt aus den Go-Doc-Kommentaren im Quellcode und ist auf Englisch verfasst.
package placement
import "github.com/nsgo-dev/game/pkg/placement"Übersicht
Package placement is experimental: its API and documented formats may change in a minor release. See the API stability policy. provides deterministic square-grid footprint placement.
Index
Typen
type Failure struct {
Cell Cell
Reason string
}Failure explains why one footprint cell cannot be placed.
type Footprint struct {
ID string
Cells []Cell
}Footprint lists occupied cells relative to a placement origin.
func Rotate(f Footprint, quarterTurns int) FootprintRotate rotates a footprint clockwise in 90-degree increments around its origin.
type Grid[T comparable] struct {
Width, Height int
// contains filtered or unexported fields
}Grid stores values occupying a bounded square grid.
func New[T comparable](width, height int) *Grid[T]New returns an empty grid with the given dimensions.
func (g *Grid[T]) CanPlace(f Footprint, at Cell) []FailureCanPlace reports every out-of-bounds or occupied cell for a footprint.
func (g *Grid[T]) Place(f Footprint, at Cell, value T) errorPlace stores value in every cell of a footprint, or returns its first failure.
func (g *Grid[T]) Remove(f Footprint, at Cell)Remove clears every cell occupied by a footprint.