forked from zllangct/ecs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworld_sync.go
59 lines (47 loc) · 949 Bytes
/
world_sync.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package ecs
import "time"
type SyncWorld struct {
ecsWorld
}
func NewSyncWorld(config *WorldConfig) *SyncWorld {
w := &SyncWorld{}
w.ecsWorld.init(config)
return w
}
func (w *SyncWorld) Startup() {
w.startup()
}
func (w *SyncWorld) Update() {
w.update()
}
func (w *SyncWorld) Optimize(t time.Duration, force bool) {}
func (w *SyncWorld) Stop() {
w.stop()
}
func (w *SyncWorld) NewEntity() Entity {
return w.newEntity().Entity()
}
func (w *SyncWorld) DestroyEntity(entity Entity) {
info, ok := w.getEntityInfo(entity)
if !ok {
return
}
info.Destroy(w)
}
func (w *SyncWorld) Add(entity Entity, components ...IComponent) {
info, ok := w.getEntityInfo(entity)
if !ok {
return
}
info.Add(w, components...)
}
func (w *SyncWorld) Remove(entity Entity, components ...IComponent) {
info, ok := w.getEntityInfo(entity)
if !ok {
return
}
info.Remove(w, components...)
}
func (w *SyncWorld) getWorld() IWorld {
return w
}