aoi

package
v0.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package aoi 在 pkg/spatial 之上提供兴趣区域(AOI)集合 diff:enter/leave/stay。 纯机制——不含网络同步;与 pkg/replicate 组合做增量下发。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Set

type Set[ID comparable] struct {
	// contains filtered or unexported fields
}

Set 记录上一帧可见实体集合,用于与当前可见集做 diff。

func NewSet

func NewSet[ID comparable]() *Set[ID]

NewSet 创建空的 AOI 集合。

func (*Set[ID]) Diff

func (s *Set[ID]) Diff(curr []spatial.Entity[ID]) (enter, leave, stay []ID)

Diff 比较当前可见实体与上一帧,返回 enter(新进入)/leave(离开)/stay(仍在视野内)。 curr 通常来自 spatial.Index.Nearby;顺序无关。

func (*Set[ID]) Len

func (s *Set[ID]) Len() int

Len 返回上一帧记录的可见实体数。

func (*Set[ID]) Reset

func (s *Set[ID]) Reset()

Reset 清空历史(玩家断线重连时可调用)。

func (*Set[ID]) Update

func (s *Set[ID]) Update(curr []spatial.Entity[ID])

Update 用当前可见集覆盖上一帧(在 Diff 之后调用)。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL