Fix chat and other players not showing up
This commit is contained in:
@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
type Player struct {
|
||||
sync.RWMutex
|
||||
sync.RWMutex // Keep this for network operations
|
||||
Model rl.Model
|
||||
Texture rl.Texture2D
|
||||
PosActual rl.Vector3
|
||||
@ -31,9 +31,7 @@ type Player struct {
|
||||
}
|
||||
|
||||
func (p *Player) MoveTowards(target Tile, deltaTime float32, mapGrid [][]Tile) {
|
||||
p.Lock()
|
||||
defer p.Unlock()
|
||||
|
||||
// No need for lock here as this is called from a single thread (game loop)
|
||||
targetPos := rl.Vector3{
|
||||
X: float32(target.X * TileSize),
|
||||
Y: mapGrid[target.X][target.Y].Height * TileHeight,
|
||||
@ -53,7 +51,7 @@ func (p *Player) MoveTowards(target Tile, deltaTime float32, mapGrid [][]Tile) {
|
||||
|
||||
oldFrame := p.AnimationFrame
|
||||
p.AnimationFrame += int32(deltaTime * 60)
|
||||
rl.TraceLog(rl.LogInfo, "Walk frame update: %d -> %d (delta: %f)",
|
||||
rl.TraceLog(rl.LogDebug, "Walk frame update: %d -> %d (delta: %f)",
|
||||
oldFrame, p.AnimationFrame, deltaTime)
|
||||
} else {
|
||||
wasMoving := p.IsMoving
|
||||
@ -65,7 +63,7 @@ func (p *Player) MoveTowards(target Tile, deltaTime float32, mapGrid [][]Tile) {
|
||||
|
||||
oldFrame := p.AnimationFrame
|
||||
p.AnimationFrame += int32(deltaTime * 60)
|
||||
rl.TraceLog(rl.LogInfo, "Idle frame update: %d -> %d (delta: %f)",
|
||||
rl.TraceLog(rl.LogDebug, "Idle frame update: %d -> %d (delta: %f)",
|
||||
oldFrame, p.AnimationFrame, deltaTime)
|
||||
}
|
||||
|
||||
@ -116,6 +114,7 @@ func (p *Player) UpdatePosition(state *pb.PlayerState, tickRate time.Duration) {
|
||||
}
|
||||
|
||||
func (p *Player) ForceResync(state *pb.PlayerState) {
|
||||
// Keep this lock since it's called from the network goroutine
|
||||
p.Lock()
|
||||
defer p.Unlock()
|
||||
|
||||
|
Reference in New Issue
Block a user