Documentation ¶
Index ¶
- type CrossReferenceList
- func (list *CrossReferenceList) AddObjectToMap(objectIndex uint16, tileMap TileMapReferencer, locations []TileLocation) (entryIndex CrossReferenceListIndex, err error)
- func (list *CrossReferenceList) Clear()
- func (list *CrossReferenceList) Encode() []byte
- func (list *CrossReferenceList) Entry(index CrossReferenceListIndex) *data.LevelObjectCrossReference
- func (list *CrossReferenceList) RemoveEntriesFromMap(firstIndex CrossReferenceListIndex, tileMap TileMapReferencer)
- type CrossReferenceListIndex
- type LevelObjectChain
- type LevelObjectChainLink
- type LevelObjectChainLinkGetter
- type LevelObjectChainStart
- type LevelObjectClassTable
- type TileLocation
- type TileMap
- type TileMapReferencer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CrossReferenceList ¶
type CrossReferenceList struct {
// contains filtered or unexported fields
}
CrossReferenceList provides the logic for handling the cross-reference table in level archives.
func DecodeCrossReferenceList ¶
func DecodeCrossReferenceList(serialized []byte) *CrossReferenceList
DecodeCrossReferenceList returns a new instance of a list, decoded from a serialized byte stream.
func NewCrossReferenceList ¶
func NewCrossReferenceList() *CrossReferenceList
NewCrossReferenceList returns a new instance of an uninitialized list. The size of the list defaults to the expected size of the cross-reference table.
func (*CrossReferenceList) AddObjectToMap ¶
func (list *CrossReferenceList) AddObjectToMap(objectIndex uint16, tileMap TileMapReferencer, locations []TileLocation) (entryIndex CrossReferenceListIndex, err error)
AddObjectToMap adds an object to the map, at the specified locations. The returned value is the first cross-reference index to be stored in the specified object. An error is returned should the list be exhausted. In an error case, any intermediate changes to the list are reverted.
func (*CrossReferenceList) Clear ¶
func (list *CrossReferenceList) Clear()
Clear resets the list to an initial state, returning all references to the pool of available entries.
func (*CrossReferenceList) Encode ¶
func (list *CrossReferenceList) Encode() []byte
Encode serializes the list into a bytestream.
func (*CrossReferenceList) Entry ¶
func (list *CrossReferenceList) Entry(index CrossReferenceListIndex) *data.LevelObjectCrossReference
Entry returns a pointer to the entry of given index.
func (*CrossReferenceList) RemoveEntriesFromMap ¶
func (list *CrossReferenceList) RemoveEntriesFromMap(firstIndex CrossReferenceListIndex, tileMap TileMapReferencer)
RemoveEntriesFromMap removes all entries starting with the provided index. The index should be one previously returned from AddObjectToMap.
type CrossReferenceListIndex ¶
type CrossReferenceListIndex uint16
CrossReferenceListIndex is an index into a cross reference list
type LevelObjectChain ¶
type LevelObjectChain struct {
// contains filtered or unexported fields
}
LevelObjectChain handles the logic for a chain of level objects.
func NewLevelObjectChain ¶
func NewLevelObjectChain(start LevelObjectChainStart, linkGetter LevelObjectChainLinkGetter) *LevelObjectChain
NewLevelObjectChain returns a new chain based on the given accessors.
func (*LevelObjectChain) AcquireLink ¶
func (chain *LevelObjectChain) AcquireLink() (index data.LevelObjectChainIndex, err error)
AcquireLink tries to reserve a new chain link from the chain. If the chain is exhausted, an error is returned.
func (*LevelObjectChain) Initialize ¶
func (chain *LevelObjectChain) Initialize(size int)
Initialize resets all entries to an clean state. All links will be added to the pool of available entries. The provided size is the number of possible links - excluding the start entry.
func (*LevelObjectChain) ReleaseLink ¶
func (chain *LevelObjectChain) ReleaseLink(index data.LevelObjectChainIndex)
ReleaseLink releases a link from the chain.
type LevelObjectChainLink ¶
type LevelObjectChainLink interface { // NextIndex returns the index of the next object. NextIndex() data.LevelObjectChainIndex // SetNextIndex sets the index of the next object. SetNextIndex(index data.LevelObjectChainIndex) // PreviousIndex returns the index of the previous object. PreviousIndex() data.LevelObjectChainIndex // SetPreviousIndex sets the index of the previous object. SetPreviousIndex(index data.LevelObjectChainIndex) }
LevelObjectChainLink is one entry of a chain of objects.
type LevelObjectChainLinkGetter ¶
type LevelObjectChainLinkGetter func(index data.LevelObjectChainIndex) LevelObjectChainLink
LevelObjectChainLinkGetter is a function to return links from a chain.
type LevelObjectChainStart ¶
type LevelObjectChainStart interface { LevelObjectChainLink // ReferenceIndex returns the index of a referenced object. ReferenceIndex() data.LevelObjectChainIndex // SetReferenceIndex sets the index of a referenced object. SetReferenceIndex(index data.LevelObjectChainIndex) }
LevelObjectChainStart is the first entry of object chains. The previous entries are unused links.
type LevelObjectClassTable ¶
type LevelObjectClassTable struct {
// contains filtered or unexported fields
}
LevelObjectClassTable is a list of generic class entries.
func DecodeLevelObjectClassTable ¶
func DecodeLevelObjectClassTable(serialized []byte, entrySize int) *LevelObjectClassTable
DecodeLevelObjectClassTable reads a class table with entries of given size from the serialized byte array.
func NewLevelObjectClassTable ¶
func NewLevelObjectClassTable(entrySize int, entryCount int) *LevelObjectClassTable
NewLevelObjectClassTable returns a new table of given amount of entries, each with the requested size. The size includes the LevelObjectPrefix size.
func (*LevelObjectClassTable) AsChain ¶
func (table *LevelObjectClassTable) AsChain() *LevelObjectChain
AsChain returns a view on the table, interpreting it as a level object chain.
func (*LevelObjectClassTable) Count ¶
func (table *LevelObjectClassTable) Count() int
Count returns the amount of entries in the table.
func (*LevelObjectClassTable) Encode ¶
func (table *LevelObjectClassTable) Encode() []byte
Encode serializes the table to an array of bytes.
func (*LevelObjectClassTable) Entry ¶
func (table *LevelObjectClassTable) Entry(index data.LevelObjectChainIndex) *data.LevelObjectClassEntry
Entry returns the reference to a specified entry of the table.
type TileLocation ¶
type TileLocation struct {
// contains filtered or unexported fields
}
TileLocation specifies the location of a tile in the map. It contains the X and Y values of the tile.
func AtTile ¶
func AtTile(x, y uint16) TileLocation
AtTile returns a tile location with the specified coordinates.
func (TileLocation) XY ¶
func (loc TileLocation) XY() (x, y uint16)
XY returns the X and Y values of the location.
type TileMap ¶
type TileMap struct {
// contains filtered or unexported fields
}
TileMap contains the tiles of a map
func DecodeTileMap ¶
DecodeTileMap decodes a tile map from a byte array. It expects the given size.
func NewTileMap ¶
NewTileMap returns a new instance of a tile map.
func (*TileMap) Entry ¶
func (tileMap *TileMap) Entry(location TileLocation) *data.TileMapEntry
Entry returns the tile at the given location.
func (*TileMap) ReferenceIndex ¶
func (tileMap *TileMap) ReferenceIndex(location TileLocation) CrossReferenceListIndex
ReferenceIndex returns the index of the first cross-reference for the given tile.
func (*TileMap) SetReferenceIndex ¶
func (tileMap *TileMap) SetReferenceIndex(location TileLocation, index CrossReferenceListIndex)
SetReferenceIndex sets the index of the first cross-reference for the given tile.
type TileMapReferencer ¶
type TileMapReferencer interface { // ReferenceIndex returns the index of the first cross-reference for the given tile. ReferenceIndex(location TileLocation) CrossReferenceListIndex // SetReferenceIndex sets the index of the first cross-reference for the given tile. SetReferenceIndex(location TileLocation, index CrossReferenceListIndex) }
TileMapReferencer is an interface for keeping cross-references in a tile map.