diff --git a/component.go b/component.go index db27699..4bd36c7 100644 --- a/component.go +++ b/component.go @@ -2,8 +2,11 @@ package ecs import ( "github.com/yohamta/donburi" + "github.com/yohamta/donburi/component" ) +type IComponentType = component.IComponentType + type ComponentType[T any] struct { *donburi.ComponentType[T] } diff --git a/examples/rtss-cg/main.go b/examples/rtss-cg/main.go index 3ff43de..77c7cc4 100644 --- a/examples/rtss-cg/main.go +++ b/examples/rtss-cg/main.go @@ -3,13 +3,13 @@ package main import ( "time" - "github.com/yohamta/donburi/filter" "joylink.club/ecs" "joylink.club/ecs/examples/rtss-cg/iwayside" "joylink.club/ecs/examples/rtss-cg/mwayside" "joylink.club/ecs/examples/rtss-cg/simulation" "joylink.club/ecs/examples/rtss-cg/state" "joylink.club/ecs/examples/rtss-cg/system" + "joylink.club/ecs/filter" ) // diff --git a/examples/rtss-cg/system/section_system.go b/examples/rtss-cg/system/section_system.go index 2491016..e0c3869 100644 --- a/examples/rtss-cg/system/section_system.go +++ b/examples/rtss-cg/system/section_system.go @@ -4,11 +4,11 @@ import ( "fmt" "strings" - "github.com/yohamta/donburi/filter" "joylink.club/ecs" "joylink.club/ecs/examples/rtss-cg/iwayside" "joylink.club/ecs/examples/rtss-cg/mwayside" "joylink.club/ecs/examples/rtss-cg/simulation" + "joylink.club/ecs/filter" ) // 物理区段状态检测 diff --git a/examples/rtss-cg/system/switch_system.go b/examples/rtss-cg/system/switch_system.go index b029895..56cba81 100644 --- a/examples/rtss-cg/system/switch_system.go +++ b/examples/rtss-cg/system/switch_system.go @@ -4,10 +4,10 @@ import ( "fmt" "time" - "github.com/yohamta/donburi/filter" "joylink.club/ecs" "joylink.club/ecs/examples/rtss-cg/mwayside" "joylink.club/ecs/examples/rtss-cg/simulation" + "joylink.club/ecs/filter" ) type SwitchSystem struct { diff --git a/examples/rtss-cg/system/train_system.go b/examples/rtss-cg/system/train_system.go index b1775fb..3630cfd 100644 --- a/examples/rtss-cg/system/train_system.go +++ b/examples/rtss-cg/system/train_system.go @@ -3,12 +3,12 @@ package system import ( "fmt" - "github.com/yohamta/donburi/filter" "joylink.club/ecs" "joylink.club/ecs/examples/rtss-cg/iwayside" "joylink.club/ecs/examples/rtss-cg/mwayside" "joylink.club/ecs/examples/rtss-cg/simulation" "joylink.club/ecs/examples/rtss-cg/state" + "joylink.club/ecs/filter" ) type TrainSystem struct { diff --git a/examples/rtss/sys/trunout.sys.go b/examples/rtss/sys/trunout.sys.go index 02d5a67..aba3003 100644 --- a/examples/rtss/sys/trunout.sys.go +++ b/examples/rtss/sys/trunout.sys.go @@ -5,9 +5,9 @@ import ( "log" "time" - "github.com/yohamta/donburi/filter" "joylink.club/ecs" "joylink.club/ecs/examples/rtss/component" + "joylink.club/ecs/filter" ) type TurnoutState struct { diff --git a/filter/filter.go b/filter/filter.go new file mode 100644 index 0000000..bdf72c3 --- /dev/null +++ b/filter/filter.go @@ -0,0 +1,30 @@ +package filter + +import ( + "github.com/yohamta/donburi/component" + "github.com/yohamta/donburi/filter" +) + +type LayoutFilter = filter.LayoutFilter + +// 包含所有指定组件的匹配布局 +func Contains(components ...component.IComponentType) LayoutFilter { + return filter.Contains(components...) +} + +func And(filters ...LayoutFilter) LayoutFilter { + return filter.And(filters...) +} + +// 完全匹配包含指定的完全相同组件的布局 +func Exact(components []component.IComponentType) LayoutFilter { + return filter.Exact(components) +} + +func Not(f LayoutFilter) LayoutFilter { + return filter.Not(f) +} + +func Or(filters ...LayoutFilter) LayoutFilter { + return filter.Or(filters...) +} diff --git a/go.mod b/go.mod index d306653..8116882 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,6 @@ module joylink.club/ecs go 1.20 -require ( - github.com/yohamta/donburi v1.3.8 - golang.org/x/time v0.3.0 -) +require github.com/yohamta/donburi v1.3.8 + +replace github.com/yohamta/donburi => github.com/soul-walker/donburi v1.3.9 diff --git a/go.sum b/go.sum index dd4f7c6..b3b84a5 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,6 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/soul-walker/donburi v1.3.9 h1:7PjXLYWdnbIduJCr259WORgv8NjGCAxDAAhKUNUcCj4= +github.com/soul-walker/donburi v1.3.9/go.mod h1:5QkyraUjkzbMVTD2b8jaPFy1Uwjm/zdFN1c1lZGaezg= github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= -github.com/yohamta/donburi v1.3.8 h1:ca4NuhzJ8Jeb6GAEf6ecksa+l8JWaAnr0WLqG20TimU= -github.com/yohamta/donburi v1.3.8/go.mod h1:5QkyraUjkzbMVTD2b8jaPFy1Uwjm/zdFN1c1lZGaezg= -golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4= -golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= diff --git a/query.go b/query.go index 3ec778a..60d68ac 100644 --- a/query.go +++ b/query.go @@ -2,7 +2,7 @@ package ecs import ( "github.com/yohamta/donburi" - "github.com/yohamta/donburi/filter" + "joylink.club/ecs/filter" ) type Query struct { diff --git a/world.go b/world.go index f0bc4ff..8af71e4 100644 --- a/world.go +++ b/world.go @@ -1,6 +1,7 @@ package ecs import ( + "context" "fmt" "log" "math" @@ -54,6 +55,12 @@ type ( } // 世界执行函数 ExecuteFunc func() + RequestFunc func() any + + WorldRequest struct { + req RequestFunc + context context.Context + } ) type world struct {