1#ifndef NANOMMO_SERVER_INTEREST_H_
2#define NANOMMO_SERVER_INTEREST_H_
33using Cells = std::map<Cell, std::vector<uint32_t>>;
35template <
typename Unit>
38 for (
const auto& [
id, unit] : units) {
39 cells[
CellOf(unit.x, unit.z)].push_back(
id);
46 std::vector<uint32_t>
here;
49 std::vector<uint32_t>
npcs;
54std::map<Cell, View>
Views(
const std::map<uint32_t, Player>& players,
55 const std::map<uint32_t, Monster>& monsters,
Cell CellOf(float x, float z)
bool Near(Cell from, Cell to)
Cells CellsOf(const std::map< uint32_t, Unit > &units)
constexpr int kInterestCells
Cells each way, so that a player gets everyone within 64 metres.
constexpr float kCellSize
In metres, like the client's chunks.
std::map< Cell, std::vector< uint32_t > > Cells
The ids of what's in each cell.
std::map< Cell, View > Views(const std::map< uint32_t, Player > &players, const std::map< uint32_t, Monster > &monsters, const Cells &npcs)
auto operator<=>(const Cell &) const =default
What the players in a cell get: the players, monsters and NPCs near it.
std::vector< uint32_t > here
std::vector< uint32_t > monsters
std::vector< uint32_t > players
std::vector< uint32_t > npcs