feat(mpsync): 实体位置广播(EntityMove)与客户端在线玩家显示;mesh 顶点池复用(性能与内存.md §2)

This commit is contained in:
NianGao Dev
2026-08-16 00:05:17 +08:00
parent e70314fb3f
commit 95c8d677ea
10 changed files with 146 additions and 21 deletions

View File

@@ -40,6 +40,13 @@ func (h *mpHandler) OnBlockChange(m netproto.BlockChange) {
h.app.sess.World.SetBlock(m.X, m.Y, m.Z, block.NewState(m.BlockID, m.Meta))
}
// OnEntityMove 其他玩家移动(多人同步.md §3:客户端存储位置,渲染插值后置)。
func (h *mpHandler) OnEntityMove(m netproto.EntityMove) {
h.app.remoteMu.Lock()
h.app.remotePlayers[m.EntityID] = [3]float64{float64(m.X), float64(m.Y), float64(m.Z)}
h.app.remoteMu.Unlock()
}
// dialServer 连接服务器(多人游戏按钮,多人同步.md §2)。
func dialServer(a *clientApp, addr string, name string) error {
h := &mpHandler{app: a}