-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsys_spawn.go
More file actions
75 lines (63 loc) · 1.35 KB
/
Copy pathsys_spawn.go
File metadata and controls
75 lines (63 loc) · 1.35 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package kar
import (
"time"
"github.com/mlange-42/ark/ecs"
)
// spawnItemData is a helper for delaying spawn events
type spawnItemData struct {
Pos Vec
Id uint8
Durability int
}
type spawnEffectData struct {
Pos Vec
Id uint8
}
var (
toSpawnItem = []spawnItemData{}
toSpawnEffect = []spawnEffectData{}
toRemove []ecs.Entity
)
type Spawn struct {
spawnInterval time.Duration
}
func (s *Spawn) Init() {
// s.spawnInterval = time.Second * 4
}
func (s *Spawn) Update() {
// gameDataRes.Duration += Tick
// gameDataRes.SpawnElapsed += Tick
// if gameDataRes.SpawnElapsed > s.spawnInterval {
// gameDataRes.SpawnElapsed = 0
// }
// if gameDataRes.SpawnElapsed == 0 {
// if world.Alive(currentPlayer) {
// p := mapAABB.GetUnchecked(currentPlayer).Pos
// mapEnemy.NewEntity(
// &AABB{
// Pos: p.Sub(Vec{50, 50}),
// Half: Vec{8, 4.5},
// },
// &Velocity{0.4, 0},
// ptr(CrabID),
// ptr(AnimationTick(0)),
// )
// }
// }
// Spawn item
for _, data := range toSpawnItem {
SpawnItem(data.Pos, data.Id, data.Durability)
}
// Spawn effect
for _, data := range toSpawnEffect {
SpawnEffect(data.Pos, data.Id)
}
toSpawnItem = toSpawnItem[:0]
toSpawnEffect = toSpawnEffect[:0]
for _, e := range toRemove {
world.RemoveEntity(e)
}
toRemove = toRemove[:0]
}
func (s *Spawn) Draw() {
}