Documentation ¶
Index ¶
- Constants
- Variables
- func CalGridId(gridPosX int64, gridPosZ int64) int64
- type ChatMap
- type GridPos
- type UserChatData
- type ViewGrid
- func (g *ViewGrid) AddPlayer(playerData *UserChatData)
- func (g *ViewGrid) Broadcast(msgType proto.EnvelopeType, chatMsg googleProto.Message, exceptEntity int64)
- func (g *ViewGrid) BroadcastNearMessage(msgType proto.EnvelopeType, chatMsg googleProto.Message, exceptUser int64)
- func (g *ViewGrid) NineGridsAndPos() map[GridPos]*ViewGrid
- func (g *ViewGrid) PlayerById(userId int64) (*UserChatData, bool)
- func (g *ViewGrid) RangeNear(f func(grid *ViewGrid) bool)
- func (g *ViewGrid) RangeNearPlayers(f func(*UserChatData) bool)
- func (g *ViewGrid) RangePlayers(f func(*UserChatData) bool)
- func (g *ViewGrid) RemovePlayer(userId int64)
- func (g *ViewGrid) SetNearGrid(pos GridPos, nearG *ViewGrid) bool
Constants ¶
View Source
const VIEW_GRID_WITH float64 = 150.0 // 150M
视野网格 直径
Variables ¶
View Source
var NearPosOffsets = map[GridPos]proto.Vector3{ GRID_POS_LEFT_UP: proto.Vector3{X: -1, Y: 0, Z: 1}, GRID_POS_UP: proto.Vector3{X: 0, Y: 0, Z: 1}, GRID_POS_RIGHT_UP: proto.Vector3{X: 1, Y: 0, Z: 1}, GRID_POS_RIGHT: proto.Vector3{X: 1, Y: 0, Z: 0}, GRID_POS_RIGHT_DOWN: proto.Vector3{X: 1, Y: 0, Z: -1}, GRID_POS_DOWN: proto.Vector3{X: 0, Y: 0, Z: -1}, GRID_POS_LEFT_DOWN: proto.Vector3{X: -1, Y: 0, Z: -1}, GRID_POS_LEFT: proto.Vector3{X: -1, Y: 0, Z: 0}, }
Functions ¶
Types ¶
type ChatMap ¶
type ChatMap struct { AppId string MapId int32 Grids map[int64]*ViewGrid Users map[int64]*UserChatData }
func NewChatMap ¶
func (*ChatMap) AddPlayer ¶
func (mg *ChatMap) AddPlayer(player *UserChatData)
func (*ChatMap) RemovePlayer ¶
func (*ChatMap) UpdateAndAddPlayerRecord ¶
func (mg *ChatMap) UpdateAndAddPlayerRecord(player *UserChatData)
type UserChatData ¶
type UserChatData struct { UserId int64 `json:"userId"` Name string `json:"name"` RoleIcon string `json:"roleIcon"` MapId int32 `json:"mapId"` X float32 `json:"x"` Y float32 `json:"y"` Z float32 `json:"z"` SceneServiceAppId string `json:"sceneServiceAppId"` AgentAppId string `json:"agentAppId"` UserSocketId string `json:"userSocketId"` InGrid *ViewGrid `json:"-"` ChatCDs map[proto.ChatChannelType]int64 `json:"-"` // map[ChatChannelType]nextSendAt<ms> }
func NewUserChatData ¶
func (*UserChatData) UpChatCD ¶
func (p *UserChatData) UpChatCD(chatType proto.ChatChannelType)
type ViewGrid ¶
type ViewGrid struct { Id int64 PosX int64 PosZ int64 InMap int32 // contains filtered or unexported fields }
func NewViewGrid ¶
func (*ViewGrid) AddPlayer ¶
func (g *ViewGrid) AddPlayer(playerData *UserChatData)
func (*ViewGrid) Broadcast ¶
func (g *ViewGrid) Broadcast( msgType proto.EnvelopeType, chatMsg googleProto.Message, exceptEntity int64, )
/ <summary> / 对在grid中的玩家广播消息 / </summary>
func (*ViewGrid) BroadcastNearMessage ¶
func (g *ViewGrid) BroadcastNearMessage( msgType proto.EnvelopeType, chatMsg googleProto.Message, exceptUser int64, )
/ 对以该grid作为中心点的九宫格中的所以grid广播消息
func (*ViewGrid) NineGridsAndPos ¶
/ 查询以该grid为中心的 9宫格 grid
func (*ViewGrid) PlayerById ¶
func (g *ViewGrid) PlayerById(userId int64) (*UserChatData, bool)
func (*ViewGrid) RangeNearPlayers ¶
func (g *ViewGrid) RangeNearPlayers(f func(*UserChatData) bool)
func (*ViewGrid) RangePlayers ¶
func (g *ViewGrid) RangePlayers(f func(*UserChatData) bool)
func (*ViewGrid) RemovePlayer ¶
Click to show internal directories.
Click to hide internal directories.