Player logs off 玩家下线
()
| 366 | // Player logs off |
| 367 | // 玩家下线 |
| 368 | func (p *Player) LostConnection() { |
| 369 | // 1 Get players in the surrounding AOI nine-grid |
| 370 | // 获取周围AOI九宫格内的玩家 |
| 371 | players := p.GetSurroundingPlayers() |
| 372 | |
| 373 | // 2 Assemble MsgID:201 message |
| 374 | // 封装MsgID:201消息 |
| 375 | msg := &pb.SyncPID{ |
| 376 | PID: p.PID, |
| 377 | } |
| 378 | |
| 379 | // 3 Send messages to surrounding players |
| 380 | // 向周围玩家发送消息 |
| 381 | for _, player := range players { |
| 382 | player.SendMsg(201, msg) |
| 383 | } |
| 384 | |
| 385 | // 4 Remove the current player from AOI in the world manager |
| 386 | // 世界管理器将当前玩家从AOI中摘除 |
| 387 | WorldMgrObj.AoiMgr.RemoveFromGrIDByPos(int(p.PID), p.X, p.Z) |
| 388 | WorldMgrObj.RemovePlayerByPID(p.PID) |
| 389 | } |
| 390 | |
| 391 | // SendMsg Send messages to the client, mainly serializing and sending the protobuf data of the pb Message |
| 392 | // |
no test coverage detected