Documentation
¶
Index ¶
- Variables
- func NewGroupObserver(group Group, event ObserverEvent) *groupObserver
- type AllMatcher
- type AnyMatcher
- type BaseMatcher
- type Component
- type ComponentCallback
- type ComponentEvent
- type ComponentType
- type ComponentsByType
- type Entity
- type EntityID
- type Group
- type GroupCallback
- type GroupEvent
- type GroupObserver
- type Matcher
- type MatcherHash
- type NoneMatcher
- type ObserverEvent
- type Pool
- type TypesByType
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrComponentExists = errors.New("component exists") ErrComponentDoesNotExist = errors.New("component does not exist") )
提示消息
Functions ¶
func NewGroupObserver ¶
func NewGroupObserver(group Group, event ObserverEvent) *groupObserver
Types ¶
type AllMatcher ¶
type AllMatcher struct{ BaseMatcher }
func (*AllMatcher) Equals ¶
func (a *AllMatcher) Equals(m Matcher) bool
func (*AllMatcher) Matches ¶
func (a *AllMatcher) Matches(e Entity) bool
func (*AllMatcher) String ¶
func (a *AllMatcher) String() string
type AnyMatcher ¶
type AnyMatcher struct{ BaseMatcher }
func (*AnyMatcher) Equals ¶
func (a *AnyMatcher) Equals(m Matcher) bool
func (*AnyMatcher) Matches ¶
func (a *AnyMatcher) Matches(e Entity) bool
func (*AnyMatcher) String ¶
func (a *AnyMatcher) String() string
type BaseMatcher ¶
type BaseMatcher struct {
// contains filtered or unexported fields
}
func (*BaseMatcher) ComponentTypes ¶
func (b *BaseMatcher) ComponentTypes() []ComponentType
func (*BaseMatcher) Hash ¶
func (b *BaseMatcher) Hash() MatcherHash
type Component ¶
type Component interface {
Type() ComponentType
}
func NewComponentA ¶
func NewComponentB ¶
type ComponentCallback ¶
type ComponentEvent ¶
type ComponentEvent uint
const ( ComponentAdded ComponentEvent = iota ComponentReplaced ComponentWillBeRemoved ComponentRemoved )
type ComponentType ¶
type ComponentType uint16
const ( ComponentA ComponentType = iota ComponentB ComponentC ComponentD ComponentE ComponentF NumComponents )
Component index 组件--也就相当于数据块 会根据类型经行操作
func (ComponentType) ComponentTypes ¶
func (c ComponentType) ComponentTypes() []ComponentType
func (ComponentType) Equals ¶
func (c ComponentType) Equals(m Matcher) bool
func (ComponentType) Hash ¶
func (c ComponentType) Hash() MatcherHash
func (ComponentType) Matches ¶
func (c ComponentType) Matches(e Entity) bool
func (ComponentType) String ¶
func (c ComponentType) String() string
type ComponentsByType ¶
type ComponentsByType []Component
func (ComponentsByType) Len ¶
func (t ComponentsByType) Len() int
func (ComponentsByType) Less ¶
func (t ComponentsByType) Less(i, j int) bool
func (ComponentsByType) Swap ¶
func (t ComponentsByType) Swap(i, j int)
type Entity ¶
type Entity interface { AddComponent(cs ...Component) error ReplaceComponent(cs ...Component) WillRemoveComponent(ts ...ComponentType) error RemoveComponent(ts ...ComponentType) error RemoveAllComponents() RemoveAllCallbacks() AddCallback(ev ComponentEvent, cb ComponentCallback) HasCallbacks() bool ID() EntityID HasComponent(ts ...ComponentType) bool HasAnyComponent(ts ...ComponentType) bool Component(t ComponentType) (Component, error) Components() []Component ComponentIndices() []ComponentType }
实体的接口数据
type Group ¶
type Group interface { Entities() []Entity HandleEntity(e Entity) UpdateEntity(e Entity) WillRemoveEntity(e Entity) Matches(e Entity) bool ContainsEntity(e Entity) bool AddCallback(e GroupEvent, c GroupCallback) }
type GroupCallback ¶
type GroupEvent ¶
type GroupEvent uint
const ( EntityAdded GroupEvent = iota EntityWillBeRemoved EntityRemoved )
type GroupObserver ¶
type GroupObserver interface { CollectedEntities() []Entity Activate() Deactivate() ClearCollectedEntities() }
type Matcher ¶
type Matcher interface { Matches(entity Entity) bool Hash() MatcherHash ComponentTypes() []ComponentType Equals(m Matcher) bool String() string }
type MatcherHash ¶
type MatcherHash uint
func Hash ¶
func Hash(factor uint, ms ...Matcher) MatcherHash
type NoneMatcher ¶
type NoneMatcher struct{ BaseMatcher }
func (*NoneMatcher) Equals ¶
func (n *NoneMatcher) Equals(m Matcher) bool
func (*NoneMatcher) Matches ¶
func (n *NoneMatcher) Matches(e Entity) bool
func (*NoneMatcher) String ¶
func (n *NoneMatcher) String() string
type ObserverEvent ¶
type ObserverEvent uint
const ( ObserverEntityAdded ObserverEvent = iota ObserverEntityRemoved ObserverEntityAddedOrRemoved )
type Pool ¶
type Pool interface { CreateEntity(cs ...Component) Entity Entities() []Entity Count() int HasEntity(e Entity) bool DestroyEntity(e Entity) DestroyAllEntities() Group(m Matcher) Group }
func NewPool ¶
func NewPool(componentsLength ComponentType, index int) Pool
type TypesByType ¶
type TypesByType []ComponentType
func (TypesByType) Len ¶
func (ts TypesByType) Len() int
func (TypesByType) Less ¶
func (ts TypesByType) Less(i, j int) bool
func (TypesByType) Swap ¶
func (ts TypesByType) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.