MCPcopy
hub / github.com/aceld/zinx / GetGIDByPos

Method GetGIDByPos

zinx_app_demo/mmo_game/core/aoi.go:136–141  ·  view source on GitHub ↗

GetGIDByPos Get the corresponding grid ID by horizontal and vertical coordinates 通过横纵坐标获取对应的格子ID

(x, y float32)

Source from the content-addressed store, hash-verified

134// GetGIDByPos Get the corresponding grid ID by horizontal and vertical coordinates
135// 通过横纵坐标获取对应的格子ID
136func (m *AOIManager) GetGIDByPos(x, y float32) int {
137 gx := (int(x) - m.MinX) / m.grIDWIDth()
138 gy := (int(y) - m.MinY) / m.grIDLength()
139
140 return gy*m.CntsX + gx
141}
142
143// GetPIDsByPos Get all PlayerIDs within the surrounding nine grids by horizontal and vertical coordinates
144// 通过横纵坐标得到周边九宫格内的全部PlayerIDs

Callers 4

GetPIDsByPosMethod · 0.95
AddToGrIDByPosMethod · 0.95
RemoveFromGrIDByPosMethod · 0.95
UpdatePosMethod · 0.80

Calls 2

grIDWIDthMethod · 0.95
grIDLengthMethod · 0.95

Tested by

no test coverage detected