This commit is contained in:
2025-07-03 19:05:34 +06:00
parent 565f2318fb
commit cd3e615ad3
2 changed files with 21 additions and 11 deletions

View File

@@ -18,16 +18,20 @@ void World::onUpdate(GameServer *server, float dtime) {
}
void World::onCEC_RegionsEnter(ContentEventController *cec, const std::vector<Pos::GlobalRegion> &enter) {
std::vector<Pos::GlobalRegion> World::onCEC_RegionsEnter(ContentEventController *cec, const std::vector<Pos::GlobalRegion> &enter) {
std::vector<Pos::GlobalRegion> out;
for(const Pos::GlobalRegion &pos : enter) {
std::unique_ptr<Region> &region = Regions[pos];
if(!region) {
region = std::make_unique<Region>();
NeedToLoad.push_back(pos);
auto iterRegion = Regions.find(pos);
if(iterRegion == Regions.end()) {
out.push_back(pos);
}
region->CECs.push_back(cec);
iterRegion->second->CECs.push_back(cec);
// Отправить клиенту информацию о чанках и сущностях
}
return out;
}
void World::onCEC_RegionsLost(ContentEventController *cec, const std::vector<Pos::GlobalRegion> &lost) {

View File

@@ -144,14 +144,10 @@ public:
World(DefWorldId_t defId);
~World();
/*
Обновить регионы
*/
void onUpdate(GameServer *server, float dtime);
/*
Подписывает игрока на отслеживаемые им регионы
Возвращает список не загруженных регионов, на которые соответственно игрока не получилось подписать
При подписи происходит отправка всех чанков и сущностей региона
*/
std::vector<Pos::GlobalRegion> onCEC_RegionsEnter(ContentEventController *cec, const std::vector<Pos::GlobalRegion> &enter);
void onCEC_RegionsLost(ContentEventController *cec, const std::vector<Pos::GlobalRegion> &lost);
@@ -168,6 +164,16 @@ public:
};
void pushRegions(std::vector<std::pair<Pos::GlobalRegion, RegionIn>>);
/*
Проверка использования регионов,
*/
void onUpdate(GameServer *server, float dtime);
/*
*/
DefWorldId_t getDefId() const { return DefId; }
};