mirror of
https://github.com/knight0zh/aoi.git
synced 2026-02-04 08:41:36 +08:00
实现aoi九宫格算法
This commit is contained in:
37
quadtree.go
Normal file
37
quadtree.go
Normal 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")
|
||||
}
|
||||
Reference in New Issue
Block a user