-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSystem.go
42 lines (35 loc) · 910 Bytes
/
System.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package bone
import (
"github.com/EngoEngine/ecs"
"github.com/EngoEngine/engo/common"
)
type DragonBoneEntity struct {
*ecs.BasicEntity
*common.RenderComponent
*common.SpaceComponent
}
type DragonBoneSystem struct {
renderer *common.RenderSystem
}
func (d *DragonBoneSystem) New(world *ecs.World) {
for _, system := range world.Systems() {
switch sys := system.(type) {
case *common.RenderSystem:
d.renderer = sys
}
}
}
func (d *DragonBoneSystem) Add(basic *ecs.BasicEntity, render *common.RenderComponent, space *common.SpaceComponent) {
_, ok := render.Drawable.(*ArmatureDisplay)
if !ok {
panic("Add Wrong Render To DragonBoneSystem")
}
render.SetShader(DragonBoneDefaultShader)
d.renderer.Add(basic, render, space)
}
func (d *DragonBoneSystem) Remove(basic ecs.BasicEntity) {
d.renderer.Remove(basic)
}
func (ui *DragonBoneSystem) Update(dt float32) {
Factory.Update(dt)
}