diff --git a/component.go b/component.go index 677efde..db27699 100644 --- a/component.go +++ b/component.go @@ -1,8 +1,6 @@ package ecs import ( - "fmt" - "github.com/yohamta/donburi" ) @@ -20,32 +18,6 @@ func (c *ComponentType[T]) Set(entry *Entry, component *T) { c.ComponentType.Set(entry.Entry, component) } -// 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}) - }) -} - -// 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 { - panic(fmt.Sprintf("no entity has the component %s", c.ComponentType.Name())) - } - - return e -} - // SetValue sets the value of the component. func (c *ComponentType[T]) SetValue(entry *Entry, value T) { c.ComponentType.SetValue(entry.Entry, value) diff --git a/examples/rtss/main.go b/examples/rtss/main.go index 0c20e5e..9fde78d 100644 --- a/examples/rtss/main.go +++ b/examples/rtss/main.go @@ -1,10 +1,6 @@ package main -import ( - "fmt" - "math" - "strconv" -) +import "fmt" func main() { // w := ecs.NewWorld(20) @@ -43,10 +39,14 @@ func main() { // } // time.Sleep(5 * time.Second) - f := 2.1 - i := math.Floor(f) - d := f - i - fmt.Println(f, i, d) - f1, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", d), 64) - fmt.Println(f1) + // f := 2.1 + // i := math.Floor(f) + // d := f - i + // fmt.Println(f, i, d) + // f1, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", d), 64) + // fmt.Println(f1) + + var a []int + len := len(a) + fmt.Println(len) } diff --git a/world.go b/world.go index 9442efa..f0bc4ff 100644 --- a/world.go +++ b/world.go @@ -45,7 +45,7 @@ type ( Resume() SetSpeed(speed float64) error AddSystem(sys ...ISystem) - // 在世界线程执行 + // 在世界中执行逻辑(在世界运行线程中) Execute(fn ExecuteFunc) Close() // 世界时间间隔