mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-10 04:12:54 +08:00
Smarter NPC loading (#2199)
This commit is contained in:
parent
b4b0b8d2a8
commit
b412a24657
@ -696,18 +696,6 @@ public final class Scene {
|
|||||||
npcBornEntries.addAll(loadNpcForPlayer(player));
|
npcBornEntries.addAll(loadNpcForPlayer(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear the unreachable group for client
|
|
||||||
var toUnload =
|
|
||||||
this.npcBornEntrySet.stream()
|
|
||||||
.filter(i -> !npcBornEntries.contains(i))
|
|
||||||
.map(SceneNpcBornEntry::getGroupId)
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
if (toUnload.size() > 0) {
|
|
||||||
broadcastPacket(new PacketGroupUnloadNotify(toUnload));
|
|
||||||
Grasscutter.getLogger().trace("Unload NPC Group {}", toUnload);
|
|
||||||
}
|
|
||||||
// exchange the new npcBornEntry Set
|
|
||||||
this.npcBornEntrySet = npcBornEntries;
|
this.npcBornEntrySet = npcBornEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1160,14 +1148,24 @@ public final class Scene {
|
|||||||
pos.toDoubleArray(),
|
pos.toDoubleArray(),
|
||||||
Grasscutter.getConfig().server.game.loadEntitiesForPlayerRange);
|
Grasscutter.getConfig().server.game.loadEntitiesForPlayerRange);
|
||||||
|
|
||||||
var sceneNpcBornEntries =
|
var sceneNpcBornCanidates =
|
||||||
npcList.stream().filter(i -> !this.npcBornEntrySet.contains(i)).toList();
|
npcList.stream().filter(i -> !this.npcBornEntrySet.contains(i)).toList();
|
||||||
|
|
||||||
|
List<SceneNpcBornEntry> sceneNpcBornEntries = new ArrayList<>();
|
||||||
|
sceneNpcBornCanidates.forEach(
|
||||||
|
i -> {
|
||||||
|
var groupInstance = scriptManager.getGroupInstanceById(i.getGroupId());
|
||||||
|
if (groupInstance == null) return;
|
||||||
|
if (i.getSuiteIdList() != null && !i.getSuiteIdList().contains(groupInstance.getActiveSuiteId())) return;
|
||||||
|
sceneNpcBornEntries.add(i);
|
||||||
|
});
|
||||||
|
|
||||||
if (sceneNpcBornEntries.size() > 0) {
|
if (sceneNpcBornEntries.size() > 0) {
|
||||||
this.broadcastPacket(new PacketGroupSuiteNotify(sceneNpcBornEntries));
|
this.broadcastPacket(new PacketGroupSuiteNotify(sceneNpcBornEntries));
|
||||||
Grasscutter.getLogger().trace("Loaded Npc Group Suite {}", sceneNpcBornEntries);
|
Grasscutter.getLogger().trace("Loaded Npc Group Suite {}", sceneNpcBornEntries);
|
||||||
}
|
}
|
||||||
return npcList;
|
|
||||||
|
return npcList.stream().filter(i -> this.npcBornEntrySet.contains(i) || sceneNpcBornEntries.contains(i)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadGroupForQuest(List<QuestGroupSuite> sceneGroupSuite) {
|
public void loadGroupForQuest(List<QuestGroupSuite> sceneGroupSuite) {
|
||||||
|
Loading…
Reference in New Issue
Block a user