实现aoi九宫格算法

This commit is contained in:
knight0zh
2022-08-15 17:53:52 +08:00
parent 87a17cb7b9
commit 61954a83e5
11 changed files with 385 additions and 0 deletions

37
quadtree.go Normal file
View File

@@ -0,0 +1,37 @@
package aoi
import "sync"
const (
leftUp int = iota
rightUp
leftDown
rightDown
)
type Node struct {
AreaWidth int // 格子宽度(长=宽)
XStart int // 起始范围
YStart int // 起始范围
Deep int // 深度
Leaf bool // 是否为叶子节点
Parent *Node // 父节点
Child [4]*Node // 子节点
Entities sync.Map // 实体
}
type QuadTree struct {
Root *Node
}
func (q QuadTree) Add(entity *Entity) {
panic("implement me")
}
func (q QuadTree) Delete(entity *Entity) {
panic("implement me")
}
func (q QuadTree) Search(entity *Entity) (result []*Entity) {
panic("implement me")
}