d2ds1

package
v0.0.0-...-7f92c57 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: GPL-3.0 Imports: 6 Imported by: 3

Documentation

Overview

Package d2ds1 provides functionality for loading/processing DS1 Files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMaxGroupLen

func GetMaxGroupLen(t LayerGroupType) (max int)

GetMaxGroupLen returns maximum length of layer group of type given

Types

type DS1

type DS1 struct {
	Files              []string            // FilePtr table of file string pointers
	Objects            []Object            // Objects
	SubstitutionGroups []SubstitutionGroup // Substitution groups for the DS1

	Act              int32 // Act, from 1 to 5. This tells which Act table to use for the Objects list
	SubstitutionType int32 // SubstitutionType (layer type): 0 if no layer, else type 1 or type 2
	// contains filtered or unexported fields
}

DS1 represents the "stamp" data that is used to build up maps.

func Unmarshal

func Unmarshal(fileData []byte) (*DS1, error)

Unmarshal the given bytes to a DS1 struct

func (DS1) DeleteFloor

func (l DS1) DeleteFloor(idx int)

func (DS1) DeleteShadow

func (l DS1) DeleteShadow(idx int)

func (DS1) DeleteSubstitution

func (l DS1) DeleteSubstitution(idx int)

func (DS1) DeleteWall

func (l DS1) DeleteWall(idx int)

func (DS1) GetFloor

func (l DS1) GetFloor(idx int) *Layer

func (DS1) GetLayersGroup

func (l DS1) GetLayersGroup(t LayerGroupType) (group *layerGroup)

GetLayersGroup returns layer group depending on type given

func (DS1) GetShadow

func (l DS1) GetShadow(idx int) *Layer

func (DS1) GetSubstitution

func (l DS1) GetSubstitution(idx int) *Layer

func (DS1) GetWall

func (l DS1) GetWall(idx int) *Layer

func (DS1) Height

func (l DS1) Height() int

func (DS1) InsertFloor

func (l DS1) InsertFloor(idx int, newFloor *Layer)

func (DS1) InsertShadow

func (l DS1) InsertShadow(idx int, newShadow *Layer)

func (DS1) InsertSubstitution

func (l DS1) InsertSubstitution(idx int, newSubstitution *Layer)

func (DS1) InsertWall

func (l DS1) InsertWall(idx int, newWall *Layer)

func (*DS1) Marshal

func (ds1 *DS1) Marshal() []byte

Marshal encodes ds1 back to byte slice

func (DS1) PopFloor

func (l DS1) PopFloor() *Layer

func (DS1) PopShadow

func (l DS1) PopShadow() *Layer

func (DS1) PopSubstitution

func (l DS1) PopSubstitution() *Layer

func (DS1) PopWall

func (l DS1) PopWall() *Layer

func (DS1) PushFloor

func (l DS1) PushFloor(floor *Layer) *ds1Layers

func (DS1) PushShadow

func (l DS1) PushShadow(shadow *Layer) *ds1Layers

func (DS1) PushSubstitution

func (l DS1) PushSubstitution(sub *Layer) *ds1Layers

func (DS1) PushWall

func (l DS1) PushWall(wall *Layer) *ds1Layers

func (DS1) SetHeight

func (l DS1) SetHeight(h int)

func (*DS1) SetSize

func (ds1 *DS1) SetSize(w, h int)

SetSize sets the size of all layers in the DS1

func (*DS1) SetVersion

func (ds1 *DS1) SetVersion(v int)

SetVersion sets the ds1 version, can not be negative.

func (DS1) SetWidth

func (l DS1) SetWidth(w int)

func (DS1) Size

func (l DS1) Size() (w, h int)

func (*DS1) Unmarshal

func (ds1 *DS1) Unmarshal(fileData []byte) (*DS1, error)

Unmarshal the given bytes to a DS1 struct

func (*DS1) Version

func (ds1 *DS1) Version() int

Version returns the ds1 version

func (DS1) Width

func (l DS1) Width() int

type Layer

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

Layer is an abstraction of a tile grid with some helper methods

func (*Layer) Height

func (l *Layer) Height() int

Height returns the height of the tile grid

func (*Layer) SetHeight

func (l *Layer) SetHeight(h int) *Layer

SetHeight sets the height of the tile grid, minimum of 1

func (*Layer) SetSize

func (l *Layer) SetSize(w, h int) *Layer

SetSize sets the width and height of the tile grid

func (*Layer) SetTile

func (l *Layer) SetTile(x, y int, t *Tile)

SetTile sets the tile at the given x,y coordinate in the tile grid

func (*Layer) SetWidth

func (l *Layer) SetWidth(w int) *Layer

SetWidth sets the width of the tile grid, minimum of 1

func (*Layer) Size

func (l *Layer) Size() (w, h int)

Size returns the width and height of the tile grid

func (*Layer) Tile

func (l *Layer) Tile(x, y int) *Tile

Tile returns the tile at the given x,y coordinate in the grid, or nil if empty.

func (*Layer) Width

func (l *Layer) Width() int

Width returns the width of the tile grid

type LayerGroupType

type LayerGroupType int

LayerGroupType represents a type of layer (floor, wall, shadow, etc)

const (
	FloorLayerGroup LayerGroupType = iota
	WallLayerGroup
	ShadowLayerGroup
	SubstitutionLayerGroup
)

Layer group types

func (LayerGroupType) String

func (l LayerGroupType) String() string

type Object

type Object struct {
	Type  int
	ID    int
	X     int
	Y     int
	Flags int
	Paths []d2path.Path
}

Object is a game world object

func (*Object) Equals

func (o *Object) Equals(other *Object) bool

Equals checks if this Object is equivalent to the given Object

type SubstitutionGroup

type SubstitutionGroup struct {
	TileX         int32
	TileY         int32
	WidthInTiles  int32
	HeightInTiles int32
	Unknown       int32
}

SubstitutionGroup represents a substitution group in a DS1 file.

type Tile

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

Tile represents a tile record in a DS1 file.

func (*Tile) DecodeFloor

func (t *Tile) DecodeFloor(dw uint32)

DecodeFloor decodes as a floor record

func (*Tile) DecodeShadow

func (t *Tile) DecodeShadow(dw uint32)

DecodeShadow decodes as a shadow record

func (*Tile) DecodeWall

func (t *Tile) DecodeWall(dw uint32)

DecodeWall decodes as a wall record

func (*Tile) EncodeFloor

func (t *Tile) EncodeFloor(sw *d2datautils.StreamWriter)

EncodeFloor adds Floor's bits to stream writer given

func (*Tile) EncodeShadow

func (t *Tile) EncodeShadow(sw *d2datautils.StreamWriter)

EncodeShadow adds shadow's bits to stream writer given

func (*Tile) EncodeWall

func (t *Tile) EncodeWall(sw *d2datautils.StreamWriter)

EncodeWall adds wall's record's bytes into stream writer given

func (*Tile) Hidden

func (t *Tile) Hidden() bool

Hidden returns if wall is hidden

Jump to

Keyboard shortcuts

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