Documentation ¶
Overview ¶
Package aoi 提供了一种有效的方法来处理 AOI(Area of Interest)问题。
AOI 问题是在大规模多人在线游戏中常见的问题,它涉及到确定哪些对象对玩家来说是“感兴趣的”, 也就是说,哪些对象在玩家的视野范围内。
这个包提供了一种数据结构和一些方法来有效地解决这个问题。
Index ¶
- type EntityJoinVisionEventHandle
- type EntityLeaveVisionEventHandle
- type TwoDimensional
- func (slf *TwoDimensional[EID, PosType, E]) AddEntity(entity E)
- func (slf *TwoDimensional[EID, PosType, E]) DeleteEntity(entity E)
- func (slf *TwoDimensional[EID, PosType, E]) GetFocus(id EID) map[EID]E
- func (slf TwoDimensional) OnEntityJoinVisionEvent(entity, target E)
- func (slf TwoDimensional) OnEntityLeaveVisionEvent(entity, target E)
- func (slf *TwoDimensional[EID, PosType, E]) Refresh(entity E)
- func (slf TwoDimensional) RegEntityJoinVisionEvent(handle EntityJoinVisionEventHandle[EID, PosType, E])
- func (slf TwoDimensional) RegEntityLeaveVisionEvent(handle EntityLeaveVisionEventHandle[EID, PosType, E])
- func (slf *TwoDimensional[EID, PosType, E]) SetAreaSize(width, height int)
- func (slf *TwoDimensional[EID, PosType, E]) SetSize(width, height int)
- type TwoDimensionalEntity
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EntityJoinVisionEventHandle ¶
type EntityJoinVisionEventHandle[EID generic.Basic, PosType generic.SignedNumber, E TwoDimensionalEntity[EID, PosType]] func(entity, target E)
type EntityLeaveVisionEventHandle ¶
type EntityLeaveVisionEventHandle[EID generic.Basic, PosType generic.SignedNumber, E TwoDimensionalEntity[EID, PosType]] func(entity, target E)
type TwoDimensional ¶
type TwoDimensional[EID generic.Basic, PosType generic.SignedNumber, E TwoDimensionalEntity[EID, PosType]] struct { // contains filtered or unexported fields }
func NewTwoDimensional ¶
func NewTwoDimensional[EID generic.Basic, PosType generic.SignedNumber, E TwoDimensionalEntity[EID, PosType]](width, height, areaWidth, areaHeight int) *TwoDimensional[EID, PosType, E]
func (*TwoDimensional[EID, PosType, E]) AddEntity ¶
func (slf *TwoDimensional[EID, PosType, E]) AddEntity(entity E)
func (*TwoDimensional[EID, PosType, E]) DeleteEntity ¶
func (slf *TwoDimensional[EID, PosType, E]) DeleteEntity(entity E)
func (*TwoDimensional[EID, PosType, E]) GetFocus ¶
func (slf *TwoDimensional[EID, PosType, E]) GetFocus(id EID) map[EID]E
func (TwoDimensional) OnEntityJoinVisionEvent ¶
func (slf TwoDimensional) OnEntityJoinVisionEvent(entity, target E)
OnEntityJoinVisionEvent 在新对象进入视野时将会立刻执行被注册的事件处理函数
func (TwoDimensional) OnEntityLeaveVisionEvent ¶
func (slf TwoDimensional) OnEntityLeaveVisionEvent(entity, target E)
OnEntityLeaveVisionEvent 在新对象离开视野时将会立刻执行被注册的事件处理函数
func (*TwoDimensional[EID, PosType, E]) Refresh ¶
func (slf *TwoDimensional[EID, PosType, E]) Refresh(entity E)
func (TwoDimensional) RegEntityJoinVisionEvent ¶
func (slf TwoDimensional) RegEntityJoinVisionEvent(handle EntityJoinVisionEventHandle[EID, PosType, E])
RegEntityJoinVisionEvent 在新对象进入视野时将会立刻执行被注册的事件处理函数
func (TwoDimensional) RegEntityLeaveVisionEvent ¶
func (slf TwoDimensional) RegEntityLeaveVisionEvent(handle EntityLeaveVisionEventHandle[EID, PosType, E])
RegEntityLeaveVisionEvent 在新对象离开视野时将会立刻执行被注册的事件处理函数
func (*TwoDimensional[EID, PosType, E]) SetAreaSize ¶
func (slf *TwoDimensional[EID, PosType, E]) SetAreaSize(width, height int)
func (*TwoDimensional[EID, PosType, E]) SetSize ¶
func (slf *TwoDimensional[EID, PosType, E]) SetSize(width, height int)
type TwoDimensionalEntity ¶
type TwoDimensionalEntity[EID generic.Basic, PosType generic.SignedNumber] interface { // GetTwoDimensionalEntityID 获取 AOI 对象 ID GetTwoDimensionalEntityID() EID // GetVision 获取视距 GetVision() float64 // GetPosition 获取位置 GetPosition() geometry.Point[PosType] }
TwoDimensionalEntity 基于2D定义的AOI对象功能接口
- AOI 对象提供了 AOI 系统中常用的属性,诸如位置坐标和视野范围等
Click to show internal directories.
Click to hide internal directories.