starbound

package
v0.0.0-...-4483bf6 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BTreeDB5BlockFree  = []byte("FF")
	BTreeDB5BlockIndex = []byte("II")
	BTreeDB5BlockLeaf  = []byte("LL")
)
View Source
var (
	ErrDidNotReachLeaf  = errors.New("starbound: did not reach a leaf node")
	ErrInvalidData      = errors.New("starbound: data appears to be corrupt")
	ErrInvalidKeyLength = errors.New("starbound: invalid key length")
	ErrKeyNotFound      = errors.New("starbound: key not found")
)

Functions

func ReadBytes

func ReadBytes(r io.Reader) (p []byte, err error)

func ReadDynamic

func ReadDynamic(r io.Reader) (v interface{}, err error)

func ReadList

func ReadList(r io.Reader) (l []interface{}, err error)

func ReadMap

func ReadMap(r io.Reader) (m map[string]interface{}, err error)

func ReadString

func ReadString(r io.Reader) (s string, err error)

func ReadVarint

func ReadVarint(r io.Reader) (v int64, err error)

func ReadVaruint

func ReadVaruint(r io.Reader) (v uint64, err error)

Types

type BTreeDB5

type BTreeDB5 struct {
	Name      string
	BlockSize int
	KeySize   int
	Swap      bool
	// contains filtered or unexported fields
}

func NewBTreeDB5

func NewBTreeDB5(r io.ReaderAt) (db *BTreeDB5, err error)

func (*BTreeDB5) FreeBlock

func (db *BTreeDB5) FreeBlock() int

func (*BTreeDB5) GetReader

func (db *BTreeDB5) GetReader(key []byte) (r io.Reader, err error)

func (*BTreeDB5) RootBlock

func (db *BTreeDB5) RootBlock() int

type IndexEntry

type IndexEntry struct {
	Offset, Size int64
}

type LeafReader

type LeafReader struct {
	// contains filtered or unexported fields
}

func NewLeafReader

func NewLeafReader(db *BTreeDB5, block int) *LeafReader

func (*LeafReader) Read

func (l *LeafReader) Read(p []byte) (n int, err error)

Reads n bytes from the LeafReader, jumping to the next leaf when necessary.

func (*LeafReader) Skip

func (l *LeafReader) Skip(n int) error

Increments the LeafReader pointer by n bytes. This may require several reads from the underlying ReaderAt as the LeafReader reaches the boundary of the current leaf.

type SBAsset6

type SBAsset6 struct {
	FileCount int
	Index     map[string]IndexEntry
	Metadata  map[string]interface{}
	// contains filtered or unexported fields
}

func NewSBAsset6

func NewSBAsset6(r io.ReaderAt) (a *SBAsset6, err error)

func (*SBAsset6) GetReader

func (a *SBAsset6) GetReader(path string) (r io.Reader, err error)

func (*SBAsset6) ReadIndex

func (a *SBAsset6) ReadIndex() error

type Tile

type Tile struct {
	ForegroundMaterial    int16
	ForegroundHueShift    uint8
	ForegroundVariant     uint8
	ForegroundMod         int16
	ForegroundModHueShift uint8
	BackgroundMaterial    int16
	BackgroundHueShift    uint8
	BackgroundVariant     uint8
	BackgroundMod         int16
	BackgroundModHueShift uint8
	Liquid                uint8
	LiquidLevel           float32
	LiquidPressure        float32
	LiquidInfinite        bool
	Collision             uint8
	DungeonID             uint16
	Biome1, Biome2        uint8
	Indestructible        bool
}

type VersionedJSON

type VersionedJSON struct {
	Name       string
	HasVersion bool
	Version    int
	Data       interface{}
}

VersionedJSON represents a JSON-compatible data structure which additionally has a name and version associated with it so that the reader may migrate the structure based on the name/version.

func ReadVersionedJSON

func ReadVersionedJSON(r io.Reader) (v VersionedJSON, err error)

func (*VersionedJSON) List

func (v *VersionedJSON) List(keys ...string) []interface{}

Gets the list at the specified key path if there is one; otherwise, nil.

func (*VersionedJSON) Map

func (v *VersionedJSON) Map(keys ...string) map[string]interface{}

Gets the map at the specified key path if there is one; otherwise, nil.

func (*VersionedJSON) Value

func (v *VersionedJSON) Value(keys ...string) interface{}

Gets the value at a specific key path if there is one; otherwise, nil.

type World

type World struct {
	*BTreeDB5
	Metadata      VersionedJSON
	Width, Height int
}

A World is a representation of a Starbound world, enabling read access to individual regions in the world as well as its metadata.

func NewWorld

func NewWorld(r io.ReaderAt) (w *World, err error)

NewWorld creates and initializes a new World using r as the data source.

func (*World) GetEntities

func (w *World) GetEntities(x, y int) (e []VersionedJSON, err error)

func (*World) GetReader

func (w *World) GetReader(layer, x, y int) (r io.Reader, err error)

func (*World) GetTiles

func (w *World) GetTiles(x, y int) (t []Tile, err error)

func (*World) ReadMetadata

func (w *World) ReadMetadata() error

Jump to

Keyboard shortcuts

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