Skip to content

Commit

Permalink
feat: builtin.Player 可以通过 GetConn 函数获取到网络连接
Browse files Browse the repository at this point in the history
  • Loading branch information
kercylan98 committed Jul 18, 2023
1 parent 8835e4a commit 31ad0ee
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions game/builtin/player.go
Original file line number Diff line number Diff line change
@@ -19,6 +19,10 @@ func (slf *Player[ID]) GetID() ID {
return slf.id
}

func (slf *Player[ID]) GetConn() *server.Conn {
return slf.conn
}

func (slf *Player[ID]) UseConn(conn *server.Conn) {
if conn == nil {
return
2 changes: 2 additions & 0 deletions game/player.go
Original file line number Diff line number Diff line change
@@ -6,6 +6,8 @@ import "github.com/kercylan98/minotaur/server"
type Player[ID comparable] interface {
// GetID 获取玩家ID
GetID() ID
// GetConn 获取玩家连接
GetConn() *server.Conn
// UseConn 指定连接
UseConn(conn *server.Conn)
// Close 关闭玩家并且释放其资源

0 comments on commit 31ad0ee

Please sign in to comment.