mirror of
https://github.com/CPunch/gopenfusion.git
synced 2024-11-10 02:20:05 +00:00
24 lines
522 B
Go
24 lines
522 B
Go
package shard
|
|
|
|
import "github.com/CPunch/gopenfusion/core/entity"
|
|
|
|
func (server *ShardServer) getChunk(pos entity.ChunkPosition) *entity.Chunk {
|
|
chunk, ok := server.chunks[pos]
|
|
if !ok {
|
|
chunk = entity.NewChunk(pos)
|
|
server.chunks[pos] = chunk
|
|
}
|
|
|
|
return chunk
|
|
}
|
|
|
|
func (server *ShardServer) getViewableChunks(plr *entity.Player) []*entity.Chunk {
|
|
chunks := make([]*entity.Chunk, 0, 9)
|
|
|
|
for _, pos := range plr.GetChunk().GetAdjacentPositions() {
|
|
chunks = append(chunks, server.getChunk(pos))
|
|
}
|
|
|
|
return chunks
|
|
}
|