ids

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: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = fmt.Errorf("not found")
View Source
var NameCheck = regexp.MustCompile(`^[a-z0-9_]+$`)

Functions

func NamedFind

func NamedFind[I ID, T any, D Named[T]](lt *ListTable[I, T, D], name string) D

func NamedUnique

func NamedUnique[I ID, T any, D Named[T]](lt *ListTable[I, T, D], name string) error

Types

type Act

type Act uint32

IDs are consecutive positive numbers valid within a world sub system. The zero value does represent a null instance.

func (Act) Top

func (Act) Top() string

type Clip

type Clip uint32

IDs are consecutive positive numbers valid within a world sub system. The zero value does represent a null instance.

func (Clip) Top

func (Clip) Top() string

type Cond

type Cond[T any, D Dec[T]] func(D) bool

type Dec

type Dec[T any] interface {
	*T
	UID() uint32
	Make(id uint32) T
	encoding.BinaryMarshaler
	encoding.BinaryUnmarshaler
}

type Dia

type Dia uint32

IDs are consecutive positive numbers valid within a world sub system. The zero value does represent a null instance.

func (Dia) Top

func (Dia) Top() string

type Grid

type Grid uint32

IDs are consecutive positive numbers valid within a world sub system. The zero value does represent a null instance.

func (Grid) Top

func (Grid) Top() string

type HashTable

type HashTable[I ID, T any, D Dec[T]] struct {
	Map  map[I]*Slot[T, D]
	Max  I
	Mods uint64
}

func (*HashTable[I, T, D]) All

func (ht *HashTable[I, T, D]) All(c Cond[T, D]) []D

func (*HashTable[I, T, D]) Each

func (lt *HashTable[I, T, D]) Each(f func(uint32, *Slot[T, D]) error) error

func (*HashTable[I, T, D]) Find

func (ht *HashTable[I, T, D]) Find(c Cond[T, D]) D

func (*HashTable[I, T, D]) From

func (ht *HashTable[I, T, D]) From(top Topic) (id I)

func (*HashTable[I, T, D]) Get

func (ht *HashTable[I, T, D]) Get(id I) (d D, _ error)

func (*HashTable[I, T, D]) Mark

func (ht *HashTable[I, T, D]) Mark(SyncFlag)

func (*HashTable[I, T, D]) New

func (ht *HashTable[I, T, D]) New() (D, error)

func (*HashTable[I, T, D]) Set

func (ht *HashTable[I, T, D]) Set(id I, d D) error

func (*HashTable[I, T, D]) Slot

func (ht *HashTable[I, T, D]) Slot(id I) ModSlot[I, T, D]

type ID

type ID interface {
	~uint32
	Top() string
}

type Img

type Img uint32

IDs are consecutive positive numbers valid within a world sub system. The zero value does represent a null instance.

func (Img) Top

func (Img) Top() string

type Info

type Info uint32

IDs are consecutive positive numbers valid within a world sub system. The zero value does represent a null instance.

func (Info) Top

func (Info) Top() string

type Inv

type Inv uint32

IDs are consecutive positive numbers valid within a world sub system. The zero value does represent a null instance.

func (Inv) Top

func (Inv) Top() string

type Item

type Item uint32

IDs are consecutive positive numbers valid within a world sub system. The zero value does represent a null instance.

func (Item) Top

func (Item) Top() string

type List

type List[I ID] []I

func (List[I]) Len

func (l List[I]) Len() int

func (List[I]) Less

func (l List[I]) Less(i, j int) bool

func (List[I]) Swap

func (l List[I]) Swap(i, j int)

func (List[I]) Unique

func (l List[I]) Unique() []I

type ListTable

type ListTable[I ID, T any, D Dec[T]] struct {
	List []Slot[T, D]
	Mods uint64
}

func (*ListTable[I, T, D]) All

func (lt *ListTable[I, T, D]) All(c Cond[T, D]) []D

func (*ListTable[I, T, D]) Each

func (lt *ListTable[I, T, D]) Each(f func(uint32, *Slot[T, D]) error) error

func (*ListTable[I, T, D]) Find

func (lt *ListTable[I, T, D]) Find(c Cond[T, D]) D

func (*ListTable[I, T, D]) From

func (lt *ListTable[I, T, D]) From(top Topic) (id I)

func (*ListTable[I, T, D]) Get

func (lt *ListTable[I, T, D]) Get(id I) (d D, _ error)

func (*ListTable[I, T, D]) Mark

func (lt *ListTable[I, T, D]) Mark(SyncFlag)

func (*ListTable[I, T, D]) New

func (lt *ListTable[I, T, D]) New() (D, error)

func (*ListTable[I, T, D]) Set

func (lt *ListTable[I, T, D]) Set(id I, d D) error

func (*ListTable[I, T, D]) Slot

func (lt *ListTable[I, T, D]) Slot(id I) ModSlot[I, T, D]

type Lvl

type Lvl uint32

IDs are consecutive positive numbers valid within a world sub system. The zero value does represent a null instance.

func (Lvl) Top

func (Lvl) Top() string

type Marker

type Marker interface{ Mark(SyncFlag) }

type ModSlot

type ModSlot[I ID, T any, D Dec[T]] struct {
	Table Marker
	*Slot[T, D]
}

func (ModSlot[I, T, D]) Mark

func (ts ModSlot[I, T, D]) Mark(sync SyncFlag)

func (ModSlot[I, T, D]) MarkAdd

func (ts ModSlot[I, T, D]) MarkAdd()

func (ModSlot[I, T, D]) MarkDel

func (ts ModSlot[I, T, D]) MarkDel()

func (ModSlot[I, T, D]) MarkMod

func (ts ModSlot[I, T, D]) MarkMod()

type Named

type Named[T any] interface {
	Dec[T]
	UID() uint32
	Named() string
}

type Obj

type Obj uint32

IDs are consecutive positive numbers valid within a world sub system. The zero value does represent a null instance.

func (Obj) Top

func (Obj) Top() string

type Pal

type Pal uint32

IDs are consecutive positive numbers valid within a world sub system. The zero value does represent a null instance.

func (Pal) Top

func (Pal) Top() string

type Pic

type Pic uint32

IDs are consecutive positive numbers valid within a world sub system. The zero value does represent a null instance.

func (Pic) Top

func (Pic) Top() string

type Prod

type Prod uint32

IDs are consecutive positive numbers valid within a world sub system. The zero value does represent a null instance.

func (Prod) Top

func (Prod) Top() string

type Slot

type Slot[T any, D Dec[T]] struct {
	Sync SyncFlag
	Data T
}

func (*Slot[T, D]) Empty

func (sl *Slot[T, D]) Empty() bool

type Spot

type Spot uint32

IDs are consecutive positive numbers valid within a world sub system. The zero value does represent a null instance.

func (Spot) Top

func (Spot) Top() string

type SyncFlag

type SyncFlag uint64
const (
	SyncNone SyncFlag = iota
	SyncAdd
	SyncDel
	SyncMod
)

type Topic

type Topic struct {
	Top string `json:"top"`
	ID  uint32 `json:"id"`
}

Topic is a compound id that identifies a specific game resource mostly used for pic, clip an img. It uses a text encoding, for example: "pic:123", "clip:42", "img:5" or "obj:1337".

func (Topic) MarshalText

func (t Topic) MarshalText() ([]byte, error)

func (Topic) String

func (t Topic) String() string

func (*Topic) UnmarshalText

func (t *Topic) UnmarshalText(raw []byte) error

type Tset

type Tset uint32

IDs are consecutive positive numbers valid within a world sub system. The zero value does represent a null instance.

func (Tset) Top

func (Tset) Top() string

Jump to

Keyboard shortcuts

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