inv

package
v0.0.0-...-4ede3f3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package inv provides an item and inventory system.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Inv

type Inv struct {
	ID ids.Inv `json:"id"`
	geo.Dim
	Items []*Item `json:"-"`
	Sub   *Item   `json:"-"`
}

Inv is an inventory or container for items.

func (*Inv) Make

func (*Inv) Make(id uint32) Inv

func (*Inv) MarshalBinary

func (inv *Inv) MarshalBinary() ([]byte, error)

func (*Inv) UID

func (inv *Inv) UID() uint32

func (*Inv) UnmarshalBinary

func (inv *Inv) UnmarshalBinary(raw []byte) error

type InvTable

type InvTable = ids.ListTable[ids.Inv, Inv, *Inv]

type Item

type Item struct {
	ID   ids.Item `json:"id"`
	Prod ids.Prod `json:"prod"`
	Inv  ids.Inv  `json:"inv"`
	geo.Box
	Sub ids.Inv `json:"sub,omitempty"`
}

Item is an unique instance of a product in an inventory.

func (*Item) Make

func (*Item) Make(id uint32) Item

func (*Item) MarshalBinary

func (it *Item) MarshalBinary() ([]byte, error)

func (*Item) UID

func (it *Item) UID() uint32

func (*Item) UnmarshalBinary

func (it *Item) UnmarshalBinary(raw []byte) error

type ItemTable

type ItemTable = ids.ListTable[ids.Item, Item, *Item]

type Prod

type Prod struct {
	ID   ids.Prod `json:"id"`
	Name string   `json:"name"`
	geo.Dim
	Asset ids.Topic `json:"asset,omitempty"`
	Text  string    `json:"text,omitempty"`
}

Prod represents an abstract product or item type that has common attributes.

func (*Prod) Make

func (*Prod) Make(id uint32) Prod

func (*Prod) MarshalBinary

func (p *Prod) MarshalBinary() ([]byte, error)

func (*Prod) UID

func (p *Prod) UID() uint32

func (*Prod) UnmarshalBinary

func (p *Prod) UnmarshalBinary(raw []byte) error

type ProdTable

type ProdTable = ids.ListTable[ids.Prod, Prod, *Prod]

type Sys

type Sys struct {
	Prod ProdTable
	Item ItemTable
	Inv  InvTable
}

Sys is the inventory system where the ids map into corresponding lists offset by one.

func (*Sys) DelInv

func (s *Sys) DelInv(id ids.Inv) error

func (*Sys) DelItem

func (s *Sys) DelItem(id ids.Item) error

func (*Sys) DelProd

func (s *Sys) DelProd(id ids.Prod) error

func (*Sys) Move

func (s *Sys) Move(id ids.Item, to ids.Inv, pos *geo.Pos) error

func (*Sys) NewInv

func (s *Sys) NewInv(dim geo.Dim) (*Inv, error)

func (*Sys) NewItem

func (s *Sys) NewItem(prod *Prod) (*Item, error)

func (*Sys) NewProd

func (s *Sys) NewProd(name string) (*Prod, error)

Jump to

Keyboard shortcuts

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