添加方法注释

This commit is contained in:
walker 2023-09-21 17:47:10 +08:00
parent 2949aa52e1
commit 200352eb58
2 changed files with 4 additions and 1 deletions

View File

@ -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 {

View File

@ -78,7 +78,7 @@ func NewComponentType[T any](opts ...interface{}) *ComponentType[T] {
return &ComponentType[T]{ct}
}
// 新建一个标签
// 新建一个标签注意新建的标签如果作为全局变量使用EachFirst等方法时必须在World线程中执行即调用World.Execute执行
func NewTag() *ComponentType[struct{}] {
return NewComponentType[struct{}]()
}