search

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func AndFilter added in v1.3.0

func AndFilter(fns ...filterFn) filterFn

func ComponentFilter added in v1.3.0

func ComponentFilter[T types.Component](f func(comp T) bool) filterFn

func NewSearch

func NewSearch() searchBuilder

NewSearch creates a new search. It receives arbitrary filters that are used to filter entities.

func OrFilter added in v1.3.0

func OrFilter(fns ...filterFn) filterFn

Types

type AndSearch added in v1.3.0

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

func (*AndSearch) Collect added in v1.3.0

func (andSearch *AndSearch) Collect(eCtx engine.Context) ([]types.EntityID, error)

func (*AndSearch) Count added in v1.3.0

func (andSearch *AndSearch) Count(eCtx engine.Context) (int, error)

func (*AndSearch) Each added in v1.3.0

func (andSearch *AndSearch) Each(eCtx engine.Context, callback CallbackFn) error

func (*AndSearch) First added in v1.3.0

func (andSearch *AndSearch) First(eCtx engine.Context) (types.EntityID, error)

func (*AndSearch) MustFirst added in v1.3.0

func (andSearch *AndSearch) MustFirst(eCtx engine.Context) types.EntityID

type CallbackFn

type CallbackFn func(types.EntityID) bool

type EntitySearch added in v1.3.0

type EntitySearch interface {
	Searchable
	Where(componentFilter filterFn) EntitySearch
}

func NewLegacySearch added in v1.3.0

func NewLegacySearch(componentFilter filter.ComponentFilter) EntitySearch

TODO: should deprecate this in the future.

type NotSearch added in v1.3.0

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

func (*NotSearch) Collect added in v1.3.0

func (notSearch *NotSearch) Collect(eCtx engine.Context) ([]types.EntityID, error)

func (*NotSearch) Count added in v1.3.0

func (notSearch *NotSearch) Count(eCtx engine.Context) (int, error)

func (*NotSearch) Each added in v1.3.0

func (notSearch *NotSearch) Each(eCtx engine.Context, callback CallbackFn) error

func (*NotSearch) First added in v1.3.0

func (notSearch *NotSearch) First(eCtx engine.Context) (types.EntityID, error)

func (*NotSearch) MustFirst added in v1.3.0

func (notSearch *NotSearch) MustFirst(eCtx engine.Context) types.EntityID

type OrSearch added in v1.3.0

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

func (*OrSearch) Collect added in v1.3.0

func (orSearch *OrSearch) Collect(eCtx engine.Context) ([]types.EntityID, error)

func (*OrSearch) Count added in v1.3.0

func (orSearch *OrSearch) Count(eCtx engine.Context) (int, error)

func (*OrSearch) Each added in v1.3.0

func (orSearch *OrSearch) Each(eCtx engine.Context, callback CallbackFn) error

func (*OrSearch) First added in v1.3.0

func (orSearch *OrSearch) First(eCtx engine.Context) (types.EntityID, error)

func (*OrSearch) MustFirst added in v1.3.0

func (orSearch *OrSearch) MustFirst(eCtx engine.Context) types.EntityID
type Search struct {
	// contains filtered or unexported fields
}

Search represents a search for entities. It is used to filter entities based on their components. It receives arbitrary filters that are used to filter entities. It contains a cache that is used to avoid re-evaluating the search. So it is not recommended to create a new search every time you want to filter entities with the same search.

func (*Search) Collect added in v1.3.0

func (s *Search) Collect(eCtx engine.Context) ([]types.EntityID, error)

func (*Search) Count

func (s *Search) Count(eCtx engine.Context) (ret int, err error)

Count returns the number of entities that match the search.

func (*Search) Each

func (s *Search) Each(eCtx engine.Context, callback CallbackFn) (err error)

Each iterates over all entities that match the search. If you would like to stop the iteration, return false to the callback. To continue iterating, return true.

func (*Search) Entity added in v1.3.0

func (s *Search) Entity(componentFilter filter.ComponentFilter) EntitySearch

func (*Search) First

func (s *Search) First(eCtx engine.Context) (id types.EntityID, err error)

First returns the first entity that matches the search.

func (*Search) MustFirst

func (s *Search) MustFirst(eCtx engine.Context) types.EntityID

func (*Search) Where

func (s *Search) Where(componentFilter filterFn) EntitySearch

Once the where clause method is activated the search will ONLY return results if a where clause returns true and no error.

type Searchable added in v1.3.0

type Searchable interface {
	Each(eCtx engine.Context, callback CallbackFn) error
	First(eCtx engine.Context) (types.EntityID, error)
	MustFirst(eCtx engine.Context) types.EntityID
	Count(eCtx engine.Context) (int, error)
	Collect(eCtx engine.Context) ([]types.EntityID, error)
	// contains filtered or unexported methods
}

func And added in v1.3.0

func And(searches ...Searchable) Searchable

func Not added in v1.3.0

func Not(search Searchable) Searchable

func Or added in v1.3.0

func Or(searches ...Searchable) Searchable

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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