导出donburi的filter,以后外部系统就不需要再依赖donburi包了
This commit is contained in:
parent
7ce0d9aa7b
commit
01707edd32
@ -2,8 +2,11 @@ package ecs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/yohamta/donburi"
|
"github.com/yohamta/donburi"
|
||||||
|
"github.com/yohamta/donburi/component"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type IComponentType = component.IComponentType
|
||||||
|
|
||||||
type ComponentType[T any] struct {
|
type ComponentType[T any] struct {
|
||||||
*donburi.ComponentType[T]
|
*donburi.ComponentType[T]
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,13 @@ package main
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/yohamta/donburi/filter"
|
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/ecs/examples/rtss-cg/iwayside"
|
"joylink.club/ecs/examples/rtss-cg/iwayside"
|
||||||
"joylink.club/ecs/examples/rtss-cg/mwayside"
|
"joylink.club/ecs/examples/rtss-cg/mwayside"
|
||||||
"joylink.club/ecs/examples/rtss-cg/simulation"
|
"joylink.club/ecs/examples/rtss-cg/simulation"
|
||||||
"joylink.club/ecs/examples/rtss-cg/state"
|
"joylink.club/ecs/examples/rtss-cg/state"
|
||||||
"joylink.club/ecs/examples/rtss-cg/system"
|
"joylink.club/ecs/examples/rtss-cg/system"
|
||||||
|
"joylink.club/ecs/filter"
|
||||||
)
|
)
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -4,11 +4,11 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/yohamta/donburi/filter"
|
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/ecs/examples/rtss-cg/iwayside"
|
"joylink.club/ecs/examples/rtss-cg/iwayside"
|
||||||
"joylink.club/ecs/examples/rtss-cg/mwayside"
|
"joylink.club/ecs/examples/rtss-cg/mwayside"
|
||||||
"joylink.club/ecs/examples/rtss-cg/simulation"
|
"joylink.club/ecs/examples/rtss-cg/simulation"
|
||||||
|
"joylink.club/ecs/filter"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 物理区段状态检测
|
// 物理区段状态检测
|
||||||
|
@ -4,10 +4,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/yohamta/donburi/filter"
|
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/ecs/examples/rtss-cg/mwayside"
|
"joylink.club/ecs/examples/rtss-cg/mwayside"
|
||||||
"joylink.club/ecs/examples/rtss-cg/simulation"
|
"joylink.club/ecs/examples/rtss-cg/simulation"
|
||||||
|
"joylink.club/ecs/filter"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SwitchSystem struct {
|
type SwitchSystem struct {
|
||||||
|
@ -3,12 +3,12 @@ package system
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/yohamta/donburi/filter"
|
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/ecs/examples/rtss-cg/iwayside"
|
"joylink.club/ecs/examples/rtss-cg/iwayside"
|
||||||
"joylink.club/ecs/examples/rtss-cg/mwayside"
|
"joylink.club/ecs/examples/rtss-cg/mwayside"
|
||||||
"joylink.club/ecs/examples/rtss-cg/simulation"
|
"joylink.club/ecs/examples/rtss-cg/simulation"
|
||||||
"joylink.club/ecs/examples/rtss-cg/state"
|
"joylink.club/ecs/examples/rtss-cg/state"
|
||||||
|
"joylink.club/ecs/filter"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TrainSystem struct {
|
type TrainSystem struct {
|
||||||
|
@ -5,9 +5,9 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/yohamta/donburi/filter"
|
|
||||||
"joylink.club/ecs"
|
"joylink.club/ecs"
|
||||||
"joylink.club/ecs/examples/rtss/component"
|
"joylink.club/ecs/examples/rtss/component"
|
||||||
|
"joylink.club/ecs/filter"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TurnoutState struct {
|
type TurnoutState struct {
|
||||||
|
30
filter/filter.go
Normal file
30
filter/filter.go
Normal file
@ -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...)
|
||||||
|
}
|
7
go.mod
7
go.mod
@ -2,7 +2,6 @@ module joylink.club/ecs
|
|||||||
|
|
||||||
go 1.20
|
go 1.20
|
||||||
|
|
||||||
require (
|
require github.com/yohamta/donburi v1.3.8
|
||||||
github.com/yohamta/donburi v1.3.8
|
|
||||||
golang.org/x/time v0.3.0
|
replace github.com/yohamta/donburi => github.com/soul-walker/donburi v1.3.9
|
||||||
)
|
|
||||||
|
6
go.sum
6
go.sum
@ -1,8 +1,6 @@
|
|||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
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/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=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
|
2
query.go
2
query.go
@ -2,7 +2,7 @@ package ecs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/yohamta/donburi"
|
"github.com/yohamta/donburi"
|
||||||
"github.com/yohamta/donburi/filter"
|
"joylink.club/ecs/filter"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Query struct {
|
type Query struct {
|
||||||
|
7
world.go
7
world.go
@ -1,6 +1,7 @@
|
|||||||
package ecs
|
package ecs
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"math"
|
"math"
|
||||||
@ -54,6 +55,12 @@ type (
|
|||||||
}
|
}
|
||||||
// 世界执行函数
|
// 世界执行函数
|
||||||
ExecuteFunc func()
|
ExecuteFunc func()
|
||||||
|
RequestFunc func() any
|
||||||
|
|
||||||
|
WorldRequest struct {
|
||||||
|
req RequestFunc
|
||||||
|
context context.Context
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
type world struct {
|
type world struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user