level

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MapVersion is the version of the map structures.
	MapVersion int32 = 11
	// ObjectVersion is the version of object structures.
	ObjectVersion int32 = 27
	// SavefileVersion is the version of the save.
	SavefileVersion int32 = 13

	// InventorySize specifies how many items the inventory could hold.
	InventorySize int = 20

	// GradesOfShadow is the number of how much shadow (light) is possible.
	GradesOfShadow = 16
)
View Source
const (
	// LoopConfigEntryCount describes how many loop entries a level has.
	LoopConfigEntryCount = 64
	// LoopConfigEntrySize describes the size, in bytes, of a loop config entry.
	LoopConfigEntrySize = 15
)
View Source
const (
	// TextureAnimationCount describes how many entries of texture animations a level can have.
	TextureAnimationCount = 4

	// TextureAnimationEntrySize is the size, in bytes, of one animation entry.
	TextureAnimationEntrySize = 7
)
View Source
const (
	// TextureAnimationForward has the texture animation run in a linear loop.
	TextureAnimationForward = TextureAnimationLoopType(0x00)
	// TextureAnimationForthAndBack reverses the sequence at every end.
	TextureAnimationForthAndBack = TextureAnimationLoopType(0x01)
	// TextureAnimationBackAndForth reverses the sequence at every end.
	TextureAnimationBackAndForth = TextureAnimationLoopType(0x81)
)
View Source
const (
	// DefaultTextureAtlasSize is the amount of textures a level can hold.
	DefaultTextureAtlasSize = 54
	// FloorCeilingTextureLimit describes the amount of textures available for floors/ceilings.
	FloorCeilingTextureLimit = 32
)
View Source
const FineCoordinatesPerTileSide = 256

FineCoordinatesPerTileSide is the number of possible positions along an axis within a tile.

View Source
const (
	// MapNotesSize is the size, in bytes, of the map notes resource.
	MapNotesSize = 0x0800
)
View Source
const (
	// ObjectClassEntryHeaderSize is the size, in bytes, of the header prefix for each class entry.
	ObjectClassEntryHeaderSize = 6
)
View Source
const (
	// ObjectCrossReferenceEntrySize describes the size, in bytes, of a ObjectCrossReferenceEntry.
	ObjectCrossReferenceEntrySize = 10
)
View Source
const (
	// ObjectMainEntrySize describes the size, in bytes, of a ObjectMainEntry.
	ObjectMainEntrySize = 27
)
View Source
const (
	// ParametersSize is the serialized size, in bytes, of the Parameters structure.
	ParametersSize = 94
)
View Source
const (
	// SurveillanceObjectCount describes how many surveillance objects a level can have.
	SurveillanceObjectCount = 8
)

Variables

This section is empty.

Functions

func EmptyLevelData

func EmptyLevelData(param EmptyLevelParameters) [lvlids.PerLevel][]byte

EmptyLevelData returns an array of serialized data for an empty level.

Types

type AtlasIndex added in v1.8.0

type AtlasIndex byte

AtlasIndex is an index into the TextureAtlas.

type BaseInfo

type BaseInfo struct {
	// XSize is the horizontal extent of the map (West to East).
	XSize int32
	// YSize is the vertical extent of the map (South to North).
	YSize int32
	// XShift is the base value of XSize (XSize <= 1 << XShift).
	XShift int32
	// YShift is the base value of YSize (YSize <= 1 << YShift).
	YShift int32
	// ZShift is the base value of the height of the map.
	ZShift HeightShift

	// Cyberspace indicates whether the level is cyberspace.
	Cyberspace byte

	// Scheduler contains base information about the schedule table of the level.
	Scheduler SchedulerInfo
	// contains filtered or unexported fields
}

BaseInfo describes the basic parameters of a level map.

func DefaultBaseInfo

func DefaultBaseInfo(cyberspace bool) BaseInfo

DefaultBaseInfo returns an initialized instance.

type BlockPuzzleState added in v0.4.0

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

BlockPuzzleState describes the state of a block puzzle.

func NewBlockPuzzleState added in v0.4.0

func NewBlockPuzzleState(data []byte, height, width int) *BlockPuzzleState

NewBlockPuzzleState returns a new instance of a block puzzle state modifier. The returned instance works with the passed data slice directly.

func (*BlockPuzzleState) CellValue added in v0.4.0

func (state *BlockPuzzleState) CellValue(row, col int) int

CellValue returns the value of the identified cell.

func (*BlockPuzzleState) SetCellValue added in v0.4.0

func (state *BlockPuzzleState) SetCellValue(row, col int, value int)

SetCellValue sets the value of the identified cell.

type CeilingInfo

type CeilingInfo byte

CeilingInfo describes the properties of a ceiling.

func (CeilingInfo) AbsoluteHeight

func (info CeilingInfo) AbsoluteHeight() TileHeightUnit

AbsoluteHeight returns the height (from minimum floor height zero) of the ceiling. Internally, this value is stored "from maximum ceiling height 32" down. The range is [1..TileHeightUnitMax].

func (CeilingInfo) HasHazard

func (info CeilingInfo) HasHazard() bool

HasHazard returns true if the hazard flag is set.

func (CeilingInfo) TextureRotations

func (info CeilingInfo) TextureRotations() int

TextureRotations returns the rotation steps to apply for the ceiling texture. Valid range: [0..3].

func (CeilingInfo) WithAbsoluteHeight

func (info CeilingInfo) WithAbsoluteHeight(value TileHeightUnit) CeilingInfo

WithAbsoluteHeight returns a ceiling info that specifies the given absolute height. Internally, this value is stored "from maximum ceiling height 32" down. The allowed range is [1..TileHeightUnitMax].

func (CeilingInfo) WithHazard

func (info CeilingInfo) WithHazard(value bool) CeilingInfo

WithHazard returns a ceiling info with the hazard flag set according to given value.

func (CeilingInfo) WithTextureRotations

func (info CeilingInfo) WithTextureRotations(value int) CeilingInfo

WithTextureRotations returns a ceiling info that specifies the given the rotation steps. The provided value is normalized to the valid range.

type Coordinate

type Coordinate uint16

Coordinate describes a tile position in one dimension.

func CoordinateAt

func CoordinateAt(tile, fine byte) Coordinate

CoordinateAt returns a coordinate with given parameters.

func (Coordinate) Fine

func (coord Coordinate) Fine() byte

Fine returns the fine part of the coordinate.

func (Coordinate) Tile

func (coord Coordinate) Tile() byte

Tile returns the tile part of the coordinate.

type CyberspaceFlag

type CyberspaceFlag TileFlag

CyberspaceFlag describes simple properties of a map tile in cyberspace.

func (CyberspaceFlag) AsTileFlag

func (flag CyberspaceFlag) AsTileFlag() TileFlag

AsTileFlag returns the flags as regular tile flag value.

func (CyberspaceFlag) FlightPull

func (flag CyberspaceFlag) FlightPull() CyberspaceFlightPull

FlightPull returns the pull applying in a tile.

func (CyberspaceFlag) GameOfLifeState

func (flag CyberspaceFlag) GameOfLifeState() int

GameOfLifeState returns the current game-of-life state.

func (CyberspaceFlag) WithFlightPull

func (flag CyberspaceFlag) WithFlightPull(value CyberspaceFlightPull) CyberspaceFlag

WithFlightPull returns a flag instance with the given pull applied.

func (CyberspaceFlag) WithGameOfLifeState

func (flag CyberspaceFlag) WithGameOfLifeState(value int) CyberspaceFlag

WithGameOfLifeState returns a flag with the given game-of-life state set.

type CyberspaceFlightPull

type CyberspaceFlightPull byte

CyberspaceFlightPull describes a directed pull of hacker in cyberspace.

const (
	CyberspaceFlightPullNone          CyberspaceFlightPull = 0
	CyberspaceFlightPullWeakEast      CyberspaceFlightPull = 1
	CyberspaceFlightPullWeakWest      CyberspaceFlightPull = 2
	CyberspaceFlightPullWeakNorth     CyberspaceFlightPull = 3
	CyberspaceFlightPullWeakSouth     CyberspaceFlightPull = 4
	CyberspaceFlightPullMediumEast    CyberspaceFlightPull = 5
	CyberspaceFlightPullMediumWest    CyberspaceFlightPull = 6
	CyberspaceFlightPullMediumNorth   CyberspaceFlightPull = 7
	CyberspaceFlightPullMediumSouth   CyberspaceFlightPull = 8
	CyberspaceFlightPullStrongEast    CyberspaceFlightPull = 9
	CyberspaceFlightPullStrongWest    CyberspaceFlightPull = 10
	CyberspaceFlightPullStrongNorth   CyberspaceFlightPull = 11
	CyberspaceFlightPullStrongSouth   CyberspaceFlightPull = 12
	CyberspaceFlightPullMediumCeiling CyberspaceFlightPull = 13
	CyberspaceFlightPullMediumFloor   CyberspaceFlightPull = 14
	CyberspaceFlightPullStrongCeiling CyberspaceFlightPull = 15
	CyberspaceFlightPullStrongFloor   CyberspaceFlightPull = 16
)

CyberspaceFlightPull constants are listed below.

func CyberspaceFlightPulls

func CyberspaceFlightPulls() []CyberspaceFlightPull

CyberspaceFlightPulls returns all constants of CyberspaceFlightPull.

func (CyberspaceFlightPull) String

func (pull CyberspaceFlightPull) String() string

String returns a textual representation.

type Direction

type Direction byte

Direction is an enumeration of cardinal and ordinal directions. Cardinal directions describe sides, ordinal directions describe corners.

const (
	DirNorth Direction = iota
	DirNorthEast
	DirEast
	DirSouthEast
	DirSouth
	DirSouthWest
	DirWest
	DirNorthWest
)

Direction constants are listed below.

func (Direction) AsMask

func (dir Direction) AsMask() DirectionMask

AsMask returns the direction as a mask.

func (Direction) Offset

func (dir Direction) Offset(offset int) Direction

Offset returns a direction that you reach by offsetting this one by the given value. The direction goes in a circle, and both positive and negative offsets are allowed.

func (Direction) Plus

func (dir Direction) Plus(other Direction) DirectionMask

Plus is a shortcut for dir.AsMask().Plus(other).

type DirectionMask

type DirectionMask byte

DirectionMask is a bitfield combination of directions.

func (DirectionMask) Plus

func (mask DirectionMask) Plus(dir Direction) DirectionMask

Plus adds the mask of the given direction to this mask and returns the result.

type EmptyLevelParameters

type EmptyLevelParameters struct {
	// XSize specifies the expected width, in tiles. 0 (or less) will default.
	XSize int32
	// YSize specifies the expected height, in tiles. 0 (or less) will default.
	YSize int32
	// Cyberspace indicates whether the level should be marked as cyberspace.
	Cyberspace bool
	// MapModifier is called to make initial changes to the map before serializing.
	// This can be used to empty out starter tile on starter level.
	MapModifier func(x, y int, entry *TileMapEntry)
}

EmptyLevelParameters contain the values to create an empty level.

type FinePosition added in v1.8.0

type FinePosition struct {
	X byte
	Y byte
}

FinePosition contains the coordinates of an object within a tile.

func (FinePosition) SlopeFactorFor added in v1.8.0

func (pos FinePosition) SlopeFactorFor(tileType TileType) float32

SlopeFactorFor returns the factor of how much the slope of given tile type would apply at the fine position.

type FloorInfo

type FloorInfo byte

FloorInfo describes the properties of a floor.

func (FloorInfo) AbsoluteHeight

func (info FloorInfo) AbsoluteHeight() TileHeightUnit

AbsoluteHeight returns the floor height in range of [0..TileHeightUnitMax-1].

func (FloorInfo) HasHazard

func (info FloorInfo) HasHazard() bool

HasHazard returns true if the hazard flag is set.

func (FloorInfo) TextureRotations

func (info FloorInfo) TextureRotations() int

TextureRotations returns the rotation steps to apply for the floor texture. Valid range: [0..3].

func (FloorInfo) WithAbsoluteHeight

func (info FloorInfo) WithAbsoluteHeight(value TileHeightUnit) FloorInfo

WithAbsoluteHeight returns a floor info that specifies the given absolute height. The allowed range is [0..TileHeightUnitMax-1].

func (FloorInfo) WithHazard

func (info FloorInfo) WithHazard(value bool) FloorInfo

WithHazard returns a floor info with the hazard flag set according to given value.

func (FloorInfo) WithTextureRotations

func (info FloorInfo) WithTextureRotations(value int) FloorInfo

WithTextureRotations returns a floor info that specifies the given the rotation steps. The provided value is normalized to the valid range.

type HeightSemaphores

type HeightSemaphores [0x40]byte

HeightSemaphores is a placeholder for storing height transitions.

type HeightShift

type HeightShift int32

HeightShift indicates the vertical scale of a level.

func (HeightShift) ValueFromObjectHeight added in v0.4.0

func (shift HeightShift) ValueFromObjectHeight(raw HeightUnit) (float32, error)

ValueFromObjectHeight returns a floating point value in tiles based on an object height.

func (HeightShift) ValueFromTileHeight

func (shift HeightShift) ValueFromTileHeight(raw TileHeightUnit) (float32, error)

ValueFromTileHeight returns a floating point value in tiles based on a tile height.

func (HeightShift) ValueToObjectHeight added in v1.0.1

func (shift HeightShift) ValueToObjectHeight(value float32) HeightUnit

ValueToObjectHeight returns an object height value based on given floating point value.

type HeightUnit

type HeightUnit byte

HeightUnit describes a height in a range of 0..255.

type Level

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

Level is the complete structure defining all necessary data for a level.

func NewLevel

func NewLevel(resourceBase resource.ID, id int, localizer resource.Localizer) *Level

NewLevel returns a new instance.

func (*Level) DelObject added in v0.4.0

func (lvl *Level) DelObject(id ObjectID)

DelObject removes the identified object from the level.

func (*Level) EncodeState

func (lvl *Level) EncodeState() [lvlids.PerLevel][]byte

EncodeState returns a subset of encoded level data, which only includes data that is loaded (modified) by the level structure. For any data block that is not relevant, a zero length slice is returned.

func (*Level) ForEachObject added in v0.4.0

func (lvl *Level) ForEachObject(handler func(ObjectID, ObjectMainEntry))

ForEachObject iterates over all active objects and calls the given handler.

func (*Level) HasRoomForObjectOf added in v1.8.0

func (lvl *Level) HasRoomForObjectOf(class object.Class) bool

HasRoomForObjectOf returns true if the level can hold one object of given class.

func (*Level) ID

func (lvl *Level) ID() int

ID returns the identifier of the level.

func (*Level) InvalidateResources

func (lvl *Level) InvalidateResources(ids []resource.ID)

InvalidateResources resets all internally cached data.

func (*Level) IsCyberspace

func (lvl *Level) IsCyberspace() bool

IsCyberspace returns true if the level describes a cyberspace.

func (*Level) MapGridInfo

func (lvl *Level) MapGridInfo(pos TilePosition) (TileType, TileSlopeControl, WallHeights)

MapGridInfo returns the information necessary to draw a 2D map.

func (*Level) NewObject added in v0.4.0

func (lvl *Level) NewObject(class object.Class) (ObjectID, error)

NewObject attempts to allocate a new object for given class. The created object has no place in the world and must be placed. Returns 0 and an error if not possible.

func (*Level) Object added in v0.4.0

func (lvl *Level) Object(id ObjectID) *ObjectMainEntry

Object returns the main entry for the identified object.

func (*Level) ObjectCapacity added in v1.8.0

func (lvl *Level) ObjectCapacity() int

ObjectCapacity returns the number of objects that can be stored in this level.

func (*Level) ObjectClassData added in v0.4.0

func (lvl *Level) ObjectClassData(obj *ObjectMainEntry) *interpreters.Instance

ObjectClassData returns the raw class data for the given object.

func (*Level) ObjectClassStats added in v0.4.0

func (lvl *Level) ObjectClassStats(class object.Class) (active, capacity int)

ObjectClassStats returns the number of used and total possible entries of given class.

func (*Level) ObjectExtraData added in v1.8.0

func (lvl *Level) ObjectExtraData(obj *ObjectMainEntry) *interpreters.Instance

ObjectExtraData returns the raw extra data for the given object.

func (*Level) Parameters

func (lvl *Level) Parameters() *Parameters

Parameters returns the extra properties the level has.

func (*Level) SetHeightShift

func (lvl *Level) SetHeightShift(value HeightShift)

SetHeightShift changes the vertical scale of the level.

func (*Level) SetSurveillanceSource

func (lvl *Level) SetSurveillanceSource(index int, id ObjectID)

SetSurveillanceSource sets a surveillance source.

func (*Level) SetSurveillanceSurrogate

func (lvl *Level) SetSurveillanceSurrogate(index int, id ObjectID)

SetSurveillanceSurrogate sets a surveillance source.

func (*Level) SetTextureAtlasEntry

func (lvl *Level) SetTextureAtlasEntry(index int, textureIndex TextureIndex)

SetTextureAtlasEntry changes the entry of the atlas.

func (*Level) Size

func (lvl *Level) Size() (x, y int, z HeightShift)

Size returns the dimensions of the level.

func (*Level) SurveillanceSources

func (lvl *Level) SurveillanceSources() [SurveillanceObjectCount]ObjectID

SurveillanceSources returns the current sources of surveillance.

func (*Level) SurveillanceSurrogates

func (lvl *Level) SurveillanceSurrogates() [SurveillanceObjectCount]ObjectID

SurveillanceSurrogates returns the current surrogates of surveillance.

func (*Level) TextureAnimations

func (lvl *Level) TextureAnimations() []TextureAnimationEntry

TextureAnimations returns the list of animations.

func (*Level) TextureAtlas

func (lvl *Level) TextureAtlas() TextureAtlas

TextureAtlas returns the atlas for textures.

func (*Level) Tile

func (lvl *Level) Tile(pos TilePosition) *TileMapEntry

Tile returns the tile entry at given position.

func (*Level) UpdateObjectLocation added in v0.4.0

func (lvl *Level) UpdateObjectLocation(id ObjectID)

UpdateObjectLocation updates the reference table between object and tiles based on its current location.

type LightDeltaInfo added in v1.9.0

type LightDeltaInfo byte

LightDeltaInfo describes the light offsets for a tile.

func (LightDeltaInfo) OfCeiling added in v1.9.0

func (info LightDeltaInfo) OfCeiling() int

OfCeiling returns the delta value for the ceiling.

func (LightDeltaInfo) OfFloor added in v1.9.0

func (info LightDeltaInfo) OfFloor() int

OfFloor returns the delta value for the floor.

func (LightDeltaInfo) WithCeiling added in v1.9.0

func (info LightDeltaInfo) WithCeiling(value int) LightDeltaInfo

WithCeiling returns a new instance with the given ceiling value.

func (LightDeltaInfo) WithFloor added in v1.9.0

func (info LightDeltaInfo) WithFloor(value int) LightDeltaInfo

WithFloor returns a new instance with the given floor value.

type MapNotesPointer

type MapNotesPointer uint32

MapNotesPointer is an offset into the map notes resource.

type ObjectClassEntry

type ObjectClassEntry struct {
	ObjectID ObjectID
	Next     int16
	Prev     int16
	Data     []byte
}

ObjectClassEntry describes an entry in a object-class specific list.

func NewObjectClassEntry

func NewObjectClassEntry(dataSize int) *ObjectClassEntry

NewObjectClassEntry returns an instance with the given amount of bytes initialized for data.

func (*ObjectClassEntry) Code

func (entry *ObjectClassEntry) Code(coder serial.Coder)

Code serializes the entry with given coder, including the data array.

func (*ObjectClassEntry) Reset

func (entry *ObjectClassEntry) Reset()

Reset sets all members of the entry to zero, including all bytes of the data array.

type ObjectClassInfo

type ObjectClassInfo struct {
	DataSize   int
	EntryCount int
}

ObjectClassInfo contains meta information about a level object class in an archive.

func ObjectClassInfoFor

func ObjectClassInfoFor(class object.Class) ObjectClassInfo

ObjectClassInfoFor returns the info entry for the corresponding object class.

type ObjectClassTable

type ObjectClassTable []ObjectClassEntry

ObjectClassTable is a list of entries.

The first entry is reserved for internal use. For the reserved entry, the Next field identifies the head of the single-linked free chain, and the ObjectID field identifies the head of the double-linked used chain.

func DefaultObjectClassTable

func DefaultObjectClassTable(class object.Class) ObjectClassTable

DefaultObjectClassTable returns an initialized table for given object class.

func (ObjectClassTable) Allocate added in v0.4.0

func (table ObjectClassTable) Allocate() int

Allocate attempts to reserve an entry in the table and returns the corresponding index. returns 0 if exhausted.

func (ObjectClassTable) AllocateData

func (table ObjectClassTable) AllocateData(size int)

AllocateData prepares each entry to be able to store the given amount of bytes. This function drops any previously assigned data.

func (ObjectClassTable) AllocatedCount added in v1.8.0

func (table ObjectClassTable) AllocatedCount() int

AllocatedCount returns the number of how many objects are currently allocated in the table.

func (ObjectClassTable) Capacity added in v1.8.0

func (table ObjectClassTable) Capacity() int

Capacity returns the number of how many objects the table can hold.

func (ObjectClassTable) Code

func (table ObjectClassTable) Code(coder serial.Coder)

Code serializes the table with the provided coder.

func (ObjectClassTable) Release added in v0.4.0

func (table ObjectClassTable) Release(index int)

Release frees the identified entry.

func (ObjectClassTable) Reset

func (table ObjectClassTable) Reset()

Reset wipes the entire table and initializes all links. The bytes of the data members of each entry are reset to zero.

type ObjectCrossReferenceEntry

type ObjectCrossReferenceEntry struct {
	TileX int16
	TileY int16

	ObjectID       ObjectID
	NextInTile     int16
	NextTileForObj int16
}

ObjectCrossReferenceEntry links objects and tiles.

func (*ObjectCrossReferenceEntry) Reset

func (entry *ObjectCrossReferenceEntry) Reset()

Reset clears the members of the entry.

func (*ObjectCrossReferenceEntry) SetTilePosition added in v1.8.0

func (entry *ObjectCrossReferenceEntry) SetTilePosition(pos TilePosition)

SetTilePosition sets the position for that entry.

func (ObjectCrossReferenceEntry) TilePosition added in v1.8.0

func (entry ObjectCrossReferenceEntry) TilePosition() TilePosition

TilePosition returns the position for that entry.

type ObjectCrossReferenceTable

type ObjectCrossReferenceTable []ObjectCrossReferenceEntry

ObjectCrossReferenceTable is a list of entries. The first entry is reserved for internal use. For the reserved entry, The NextInTile member refers to the head of the single-linked free chain.

func DefaultObjectCrossReferenceTable

func DefaultObjectCrossReferenceTable() ObjectCrossReferenceTable

DefaultObjectCrossReferenceTable returns an initialized table with a default size.

func (ObjectCrossReferenceTable) Allocate added in v0.4.0

func (table ObjectCrossReferenceTable) Allocate() int

Allocate attempts to reserve a free entry in the table and return its index. Returns 0 if exhausted.

func (ObjectCrossReferenceTable) Release added in v0.4.0

func (table ObjectCrossReferenceTable) Release(index int)

Release frees the entry with given index.

func (ObjectCrossReferenceTable) Reset

func (table ObjectCrossReferenceTable) Reset()

Reset wipes the entire table and initializes all links.

type ObjectID

type ObjectID int16

ObjectID identifies one object in a level. It is also the index into the main object table.

type ObjectMainEntry added in v1.5.0

type ObjectMainEntry struct {
	InUse byte

	Class    object.Class
	Subclass object.Subclass

	ClassTableIndex          int16
	CrossReferenceTableIndex int16
	Next                     ObjectID
	Prev                     ObjectID

	X         Coordinate
	Y         Coordinate
	Z         HeightUnit
	XRotation RotationUnit
	ZRotation RotationUnit
	YRotation RotationUnit

	Type object.Type

	Hitpoints int16

	Extra [4]byte
	// contains filtered or unexported fields
}

ObjectMainEntry describes an object in the level.

func (ObjectMainEntry) FinePosition added in v1.8.0

func (entry ObjectMainEntry) FinePosition() FinePosition

FinePosition returns the coordinates of the object within the tile.

func (*ObjectMainEntry) Reset added in v1.5.0

func (entry *ObjectMainEntry) Reset()

Reset clears the entry and resets all members.

func (ObjectMainEntry) TilePosition added in v1.8.0

func (entry ObjectMainEntry) TilePosition() TilePosition

TilePosition returns the tile coordinates of the object.

func (ObjectMainEntry) Triple added in v1.5.0

func (entry ObjectMainEntry) Triple() object.Triple

Triple returns the unique identifier of the entry.

type ObjectMainEntryModifier added in v1.8.0

type ObjectMainEntryModifier func(*ObjectMainEntry)

ObjectMainEntryModifier is a function that changes properties.

type ObjectMainTable added in v1.5.0

type ObjectMainTable []ObjectMainEntry

ObjectMainTable is a list of entries. The first entry is reserved for internal use. For the reserved entry, the Next field refers to the head of the single-linked free chain, and the CrossReferenceTableIndex refers to the head of the double-linked used chain.

func DefaultObjectMainTable added in v1.5.0

func DefaultObjectMainTable() ObjectMainTable

DefaultObjectMainTable returns an initialized table with a default size.

func (ObjectMainTable) Allocate added in v1.5.0

func (table ObjectMainTable) Allocate() ObjectID

Allocate attempts to find an available entry in the table and activates it. Returns 0 if not possible (exhausted).

func (ObjectMainTable) AllocatedCount added in v1.8.0

func (table ObjectMainTable) AllocatedCount() int

AllocatedCount returns the number of how many objects are currently allocated in the table.

func (ObjectMainTable) Capacity added in v1.8.0

func (table ObjectMainTable) Capacity() int

Capacity returns the number of how many objects the table can hold.

func (ObjectMainTable) Release added in v1.5.0

func (table ObjectMainTable) Release(id ObjectID)

Release deactivates the entry with given ID.

func (ObjectMainTable) Reset added in v1.5.0

func (table ObjectMainTable) Reset()

Reset wipes the entire table and initializes all links.

type Parameters

type Parameters struct {
	Size int16

	CeilingHazardLevel   byte
	FloorHazardLevel     byte
	FloorHazardIsGravity byte
	BiohazardRegister    byte
	RadiationRegister    byte
	// contains filtered or unexported fields
}

Parameters describes level-global properties. It also contains information on the auto-maps, which, as per original code, should have been in the game state.

func DefaultParameters

func DefaultParameters() Parameters

DefaultParameters returns a new instance of parameters.

type RealWorldFlag

type RealWorldFlag TileFlag

RealWorldFlag describes simple properties of a map tile in the real world.

func (RealWorldFlag) AsTileFlag

func (flag RealWorldFlag) AsTileFlag() TileFlag

AsTileFlag returns the flags as regular tile flag value.

func (RealWorldFlag) CeilingShadow

func (flag RealWorldFlag) CeilingShadow() int

CeilingShadow returns the ceiling shadow value. Range: [0..GradesOfShadow].

func (RealWorldFlag) Deconstructed

func (flag RealWorldFlag) Deconstructed() bool

Deconstructed returns whether the tile is marked as heavily deconstructed (should play spooky music).

func (RealWorldFlag) FloorShadow

func (flag RealWorldFlag) FloorShadow() int

FloorShadow returns the floor shadow value. Range: [0..GradesOfShadow].

func (RealWorldFlag) TileVisited

func (flag RealWorldFlag) TileVisited() bool

TileVisited returns whether the tile is marked as being visited (seen).

func (RealWorldFlag) UseAdjacentWallTexture

func (flag RealWorldFlag) UseAdjacentWallTexture() bool

UseAdjacentWallTexture returns whether the wall texture from the adjacent tile should be used for each side.

func (RealWorldFlag) WallTextureOffset

func (flag RealWorldFlag) WallTextureOffset() TileHeightUnit

WallTextureOffset returns the vertical offset (in tile height units) to apply for wall textures.

func (RealWorldFlag) WallTexturePattern

func (flag RealWorldFlag) WallTexturePattern() WallTexturePattern

WallTexturePattern returns the pattern to apply for walls.

func (RealWorldFlag) WithCeilingShadow

func (flag RealWorldFlag) WithCeilingShadow(value int) RealWorldFlag

WithCeilingShadow returns a new flag value with the given ceiling shadow set. Values beyond allowed range are ignored.

func (RealWorldFlag) WithDeconstructed

func (flag RealWorldFlag) WithDeconstructed(value bool) RealWorldFlag

WithDeconstructed returns a flag with the given deconstruction set.

func (RealWorldFlag) WithFloorShadow

func (flag RealWorldFlag) WithFloorShadow(value int) RealWorldFlag

WithFloorShadow returns a new flag value with the given floor shadow set. Values beyond allowed range are ignored.

func (RealWorldFlag) WithTileVisited

func (flag RealWorldFlag) WithTileVisited(value bool) RealWorldFlag

WithTileVisited returns a flag with the given deconstruction set.

func (RealWorldFlag) WithUseAdjacentWallTexture

func (flag RealWorldFlag) WithUseAdjacentWallTexture(value bool) RealWorldFlag

WithUseAdjacentWallTexture returns a flag with the given usage set.

func (RealWorldFlag) WithWallTextureOffset

func (flag RealWorldFlag) WithWallTextureOffset(value TileHeightUnit) RealWorldFlag

WithWallTextureOffset returns a flag value with the given wall texture offset.

func (RealWorldFlag) WithWallTexturePattern

func (flag RealWorldFlag) WithWallTexturePattern(value WallTexturePattern) RealWorldFlag

WithWallTexturePattern returns a flag with the given pattern set.

type RotationUnit

type RotationUnit byte

RotationUnit describes a rotation in the range 0..255.

func (RotationUnit) ToDegrees added in v0.4.0

func (unit RotationUnit) ToDegrees() float64

ToDegrees returns the value converted to degrees [0..360).

type SchedulerInfo

type SchedulerInfo struct {
	// Size describes the maximum amount of schedule entries in the table.
	Size int32
	// ScheduleCount is the current amount of active schedules.
	ScheduleCount int32
	// ElementSize is the size of an schedule entry, in bytes.
	ElementSize int32
	// GrowFlag indicates whether the schedule table can be resized.
	GrowFlag byte
	// contains filtered or unexported fields
}

SchedulerInfo describes the basic parameters of a level scheduler. Its entries are stored in the Schedules table.

func DefaultSchedulerInfo

func DefaultSchedulerInfo() SchedulerInfo

DefaultSchedulerInfo returns a new scheduler info structure with default values.

type SlopeFactors

type SlopeFactors [8]float32

SlopeFactors is a list of multipliers for each direction of a tile.

func (SlopeFactors) Negated

func (factors SlopeFactors) Negated() SlopeFactors

Negated returns the factors multiplied by -1.

type TextureAnimationEntry

type TextureAnimationEntry struct {
	FrameTime         uint16
	CurrentFrameTime  uint16
	CurrentFrameIndex byte
	FrameCount        byte
	LoopType          TextureAnimationLoopType
}

TextureAnimationEntry describes one entry of the texture animation table.

type TextureAnimationLoopType

type TextureAnimationLoopType byte

TextureAnimationLoopType describes how a texture animation loop should advance.

func TextureAnimationLoopTypes

func TextureAnimationLoopTypes() []TextureAnimationLoopType

TextureAnimationLoopTypes returns all constants.

func (TextureAnimationLoopType) String

func (loopType TextureAnimationLoopType) String() string

String returns the textual representation.

type TextureAtlas

type TextureAtlas []TextureIndex

TextureAtlas is a selection of textures for the level.

type TextureIndex

type TextureIndex int16

TextureIndex identifies one game texture.

type TileFlag

type TileFlag uint32

TileFlag describes simple properties of a map tile.

func (TileFlag) ForCyberspace

func (flag TileFlag) ForCyberspace() CyberspaceFlag

ForCyberspace interprets the flag value for cyberspace.

func (TileFlag) ForRealWorld

func (flag TileFlag) ForRealWorld() RealWorldFlag

ForRealWorld interprets the flag value for the real world.

func (TileFlag) MusicIndex

func (flag TileFlag) MusicIndex() int

MusicIndex returns the music identifier. Range: [0..15].

func (TileFlag) SlopeControl

func (flag TileFlag) SlopeControl() TileSlopeControl

SlopeControl returns the slope control as per flags.

func (TileFlag) WithMusicIndex

func (flag TileFlag) WithMusicIndex(value int) TileFlag

WithMusicIndex returns a new flag value with the given music index set. Values beyond allowed range are ignored.

func (TileFlag) WithSlopeControl

func (flag TileFlag) WithSlopeControl(ctrl TileSlopeControl) TileFlag

WithSlopeControl returns a new flag value with the given slope control set.

type TileHeightUnit

type TileHeightUnit byte

TileHeightUnit describes a height in a range of 0..32.

const (
	TileHeightUnitMin TileHeightUnit = 0
	TileHeightUnitMax TileHeightUnit = 32
)

TileHeightUnit constants are listed below.

type TileMap

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

TileMap is a rectangular set of tiles. The first index is the Y-axis, the second index the X-axis. This way the map can be serialized quicker.

func NewTileMap

func NewTileMap(width, height int) TileMap

NewTileMap returns a new, initialized map.

func (TileMap) Code

func (m TileMap) Code(coder serial.Coder)

Code serializes the map.

func (TileMap) Tile

func (m TileMap) Tile(pos TilePosition, xShift int) *TileMapEntry

Tile returns a pointer to the tile within the map for given position. Nil is returned for a coordinate outside the boundaries.

type TileMapEntry

type TileMapEntry struct {
	// Type indicates what kind of tile this is.
	Type TileType
	// Floor describes floor properties.
	Floor FloorInfo
	// Ceiling describes ceiling properties.
	Ceiling CeilingInfo
	// SlopeHeight indicates for non-flat tiles the height offset.
	SlopeHeight TileHeightUnit

	// FirstObjectIndex points into the level object cross reference table to the first object in this tile.
	FirstObjectIndex int16
	// TextureInfo describes tile texturing.
	TextureInfo TileTextureInfo
	// Flags contains arbitrary additional information.
	Flags TileFlag

	// SubClip is always 0xFF.
	SubClip byte

	// LightDelta describes the light offsets of this tile.
	LightDelta LightDeltaInfo
	// contains filtered or unexported fields
}

TileMapEntry describes one tile of the map.

func (TileMapEntry) CeilingTileHeightAt added in v1.8.0

func (tile TileMapEntry) CeilingTileHeightAt(pos FinePosition, height HeightShift) float32

CeilingTileHeightAt returns the height of the ceiling (in tile unit) at the given fine position.

func (TileMapEntry) FloorTileHeightAt added in v1.8.0

func (tile TileMapEntry) FloorTileHeightAt(pos FinePosition, height HeightShift) float32

FloorTileHeightAt returns the height of the floor (in tile unit) at the given fine position.

func (*TileMapEntry) Reset

func (tile *TileMapEntry) Reset()

Reset puts the tile into an initial state.

type TilePosition added in v1.8.0

type TilePosition struct {
	X byte
	Y byte
}

TilePosition contains the coordinates of a tile in a level.

type TileSlopeControl

type TileSlopeControl byte

TileSlopeControl defines how the floor and ceiling of a sloped tile should be processed.

const (
	TileSlopeControlCeilingInverted TileSlopeControl = 0
	TileSlopeControlCeilingMirrored TileSlopeControl = 1
	TileSlopeControlCeilingFlat     TileSlopeControl = 2
	TileSlopeControlFloorFlat       TileSlopeControl = 3
)

TileSlopeControl constants.

func TileSlopeControls

func TileSlopeControls() []TileSlopeControl

TileSlopeControls returns all control values.

func (TileSlopeControl) CeilingSlopeFactors

func (ctrl TileSlopeControl) CeilingSlopeFactors(tileType TileType) SlopeFactors

CeilingSlopeFactors returns the slope factors for the given tile type as per control constant.

func (TileSlopeControl) FloorSlopeFactors

func (ctrl TileSlopeControl) FloorSlopeFactors(tileType TileType) SlopeFactors

FloorSlopeFactors returns the slope factors for the given tile type as per control constant.

func (TileSlopeControl) String

func (ctrl TileSlopeControl) String() string

String returns the textual representation of the value.

type TileTextureInfo

type TileTextureInfo uint16

TileTextureInfo describes the textures used for a map tile.

func (TileTextureInfo) CeilingPaletteIndex

func (info TileTextureInfo) CeilingPaletteIndex() byte

CeilingPaletteIndex returns the palette index for the ceiling in cyberspace.

func (TileTextureInfo) CeilingTextureIndex

func (info TileTextureInfo) CeilingTextureIndex() AtlasIndex

CeilingTextureIndex returns the texture index into the texture atlas for the ceiling. Valid range [0..31]. This property is only valid in real world.

func (TileTextureInfo) FloorPaletteIndex

func (info TileTextureInfo) FloorPaletteIndex() byte

FloorPaletteIndex returns the palette index for the floor in cyberspace.

func (TileTextureInfo) FloorTextureIndex

func (info TileTextureInfo) FloorTextureIndex() AtlasIndex

FloorTextureIndex returns the texture index into the texture atlas for the floor. Valid range [0..31]. This property is only valid in real world.

func (TileTextureInfo) WallTextureIndex

func (info TileTextureInfo) WallTextureIndex() AtlasIndex

WallTextureIndex returns the texture index into the texture atlas for the walls. Valid range [0..63]. This property is only valid in real world.

func (TileTextureInfo) WithCeilingPaletteIndex

func (info TileTextureInfo) WithCeilingPaletteIndex(value byte) TileTextureInfo

WithCeilingPaletteIndex returns an info with given index set.

func (TileTextureInfo) WithCeilingTextureIndex

func (info TileTextureInfo) WithCeilingTextureIndex(value AtlasIndex) TileTextureInfo

WithCeilingTextureIndex returns an info with given index set. Values outside valid range are ignored.

func (TileTextureInfo) WithFloorPaletteIndex

func (info TileTextureInfo) WithFloorPaletteIndex(value byte) TileTextureInfo

WithFloorPaletteIndex returns an info with given index set.

func (TileTextureInfo) WithFloorTextureIndex

func (info TileTextureInfo) WithFloorTextureIndex(value AtlasIndex) TileTextureInfo

WithFloorTextureIndex returns an info with given index set. Values outside valid range are ignored.

func (TileTextureInfo) WithWallTextureIndex

func (info TileTextureInfo) WithWallTextureIndex(value AtlasIndex) TileTextureInfo

WithWallTextureIndex returns an info with given index set. Values outside valid range are ignored.

type TileType

type TileType byte

TileType describes the general type of a map tile.

const (
	TileTypeSolid TileType = 0x00
	TileTypeOpen  TileType = 0x01

	TileTypeDiagonalOpenSouthEast TileType = 0x02
	TileTypeDiagonalOpenSouthWest TileType = 0x03
	TileTypeDiagonalOpenNorthWest TileType = 0x04
	TileTypeDiagonalOpenNorthEast TileType = 0x05

	TileTypeSlopeSouthToNorth TileType = 0x06
	TileTypeSlopeWestToEast   TileType = 0x07
	TileTypeSlopeNorthToSouth TileType = 0x08
	TileTypeSlopeEastToWest   TileType = 0x09

	TileTypeValleySouthEastToNorthWest TileType = 0x0A
	TileTypeValleySouthWestToNorthEast TileType = 0x0B
	TileTypeValleyNorthWestToSouthEast TileType = 0x0C
	TileTypeValleyNorthEastToSouthWest TileType = 0x0D

	TileTypeRidgeNorthWestToSouthEast TileType = 0x0E
	TileTypeRidgeNorthEastToSouthWest TileType = 0x0F
	TileTypeRidgeSouthEastToNorthWest TileType = 0x10
	TileTypeRidgeSouthWestToNorthEast TileType = 0x11
)

Tiles come in different forms: Solid tiles can not be entered, Open tiles are regular tiles with a flat floor and a flat ceiling. DiagonalOpen tiles are those with flat floors and ceilings, and two walls cut off by one diagonal wall. Slope tiles have a sloped floor (or ceiling). Valley tiles have one floor vertex lower while Ridge tiles have one floor vertex higher than the other three.

func TileTypes

func TileTypes() []TileType

TileTypes returns a list of all known tile types.

func (TileType) Info

func (t TileType) Info() TileTypeInfo

Info returns the information associated with the tile type.

func (TileType) String

func (t TileType) String() string

String returns the textual representation of the type.

type TileTypeInfo

type TileTypeInfo struct {
	// Name is the textual representation of the tile type.
	Name string

	// SolidSides is a bitfield of cardinal directions describing solid walls.
	SolidSides DirectionMask

	// SlopeFloorFactors defines how a slope affects the floor in each direction of a tile [0.0 .. 1.0].
	SlopeFloorFactors SlopeFactors

	// SlopeInvertedType is the type that inverts the slope to form a solid tile if merged (e.g. floor & ceiling).
	// Types that have no slope invert themselves.
	SlopeInvertedType TileType
}

TileTypeInfo is the meta information about a tile type.

type UnknownL41

type UnknownL41 [1]byte

UnknownL41 is the unknown data of L41.

type UnknownL48

type UnknownL48 [0x30]byte

UnknownL48 is the unknown data of L48.

type UnknownL49

type UnknownL49 [0x1C0]byte

UnknownL49 is the unknown data of L49.

type UnknownL50

type UnknownL50 [2]byte

UnknownL50 is the unknown data of L50.

type UnknownL52

type UnknownL52 [2]byte

UnknownL52 is the unknown data of L52.

type WallHeights

type WallHeights struct {
	North [3]float32
	East  [3]float32
	South [3]float32
	West  [3]float32
}

WallHeights describes the height delta, in HeightUnits, one would take to cross to the other tile. A value of 0 means equal floor, a negative value a fall down. A value of 0x20 (= maximum of height units) means a solid wall.

For each cardinal direction, facing to the specified direction, the first entry is the left side, the second the center, and the third the right side.

func (*WallHeights) Reset

func (heights *WallHeights) Reset()

Reset sets all the heights to zero.

type WallHeightsMap

type WallHeightsMap [][]WallHeights

WallHeightsMap is rectangular table of wall heights, typically mirroring a tile map.

func NewWallHeightsMap

func NewWallHeightsMap(width, height int) WallHeightsMap

NewWallHeightsMap returns a new, initialized map.

func (*WallHeightsMap) CalculateFrom

func (m *WallHeightsMap) CalculateFrom(tileMap interface {
	Tile(pos TilePosition) *TileMapEntry
})

CalculateFrom updates all the wall heights according to the specified map.

func (WallHeightsMap) Tile

Tile returns a pointer to the tile within the map for given position.

type WallTexturePattern

type WallTexturePattern byte

WallTexturePattern describes how a wall texture should be applied for a tile.

const (
	WallTexturePatternRegular                 WallTexturePattern = 0
	WallTexturePatternFlipHorizontal          WallTexturePattern = 1
	WallTexturePatternFlipAlternating         WallTexturePattern = 2
	WallTexturePatternFlipAlternatingInverted WallTexturePattern = 3
)

WallTexturePattern constants are listed below.

func WallTexturePatterns

func WallTexturePatterns() []WallTexturePattern

WallTexturePatterns returns all available texture patterns.

func (WallTexturePattern) String

func (pattern WallTexturePattern) String() string

String returns the textual information.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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