mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-16 08:56:04 +01:00
Implement lazy loading of scripts when they enter a new block
This commit is contained in:
@@ -482,8 +482,8 @@ public class Scene {
|
||||
|
||||
for (SceneBlock block : visible) {
|
||||
if (!this.getLoadedBlocks().contains(block)) {
|
||||
this.getLoadedBlocks().add(block);
|
||||
this.onLoadBlock(block);
|
||||
this.getLoadedBlocks().add(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -491,11 +491,17 @@ public class Scene {
|
||||
// TODO optimize
|
||||
public void onLoadBlock(SceneBlock block) {
|
||||
for (SceneGroup group : block.groups) {
|
||||
// We load the script files for the groups here
|
||||
if (!group.isLoaded()) {
|
||||
this.getScriptManager().loadGroupFromScript(group);
|
||||
}
|
||||
|
||||
group.triggers.forEach(getScriptManager()::registerTrigger);
|
||||
}
|
||||
|
||||
// Spawn gadgets AFTER triggers are added
|
||||
for (SceneGroup group : block.groups) {
|
||||
this.getScriptManager().spawnGadgetsInGroup(block, group);
|
||||
this.getScriptManager().spawnGadgetsInGroup(group);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user