添加方法注释
This commit is contained in:
parent
2949aa52e1
commit
200352eb58
@ -21,6 +21,7 @@ func (c *ComponentType[T]) Set(entry *Entry, component *T) {
|
||||
}
|
||||
|
||||
// Each iterates over the entities that have the component.
|
||||
// 使用Each方法时必须在World线程中执行,即调用World.Execute执行
|
||||
func (c *ComponentType[T]) Each(w World, callback func(*Entry)) {
|
||||
c.ComponentType.Each(w.(*world).world, func(entry *donburi.Entry) {
|
||||
callback(&Entry{Entry: entry})
|
||||
@ -28,12 +29,14 @@ func (c *ComponentType[T]) Each(w World, callback func(*Entry)) {
|
||||
}
|
||||
|
||||
// First returns the first entity that has the component.
|
||||
// 使用First方法时必须在World线程中执行,即调用World.Execute执行
|
||||
func (c *ComponentType[T]) First(w World) (*Entry, bool) {
|
||||
entry, ok := c.ComponentType.First(w.(*world).world)
|
||||
return &Entry{entry}, ok
|
||||
}
|
||||
|
||||
// MustFirst returns the first entity that has the component or panics.
|
||||
// 使用MustFirst方法时必须在World线程中执行,即调用World.Execute执行
|
||||
func (c *ComponentType[T]) MustFirst(w World) *Entry {
|
||||
e, ok := c.First(w)
|
||||
if !ok {
|
||||
|
2
world.go
2
world.go
@ -78,7 +78,7 @@ func NewComponentType[T any](opts ...interface{}) *ComponentType[T] {
|
||||
return &ComponentType[T]{ct}
|
||||
}
|
||||
|
||||
// 新建一个标签
|
||||
// 新建一个标签(注意:新建的标签如果作为全局变量,使用Each,First等方法时必须在World线程中执行,即调用World.Execute执行)
|
||||
func NewTag() *ComponentType[struct{}] {
|
||||
return NewComponentType[struct{}]()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user