From 5c1e3a2862fc80572eabcfcbab387bc02a134ce5 Mon Sep 17 00:00:00 2001 From: WayZer Date: Wed, 7 Sep 2022 20:24:31 +0800 Subject: [PATCH] Add `WorldBeforeLoadEvent` and `WorldEndLoadEvent` (#7523) * Add `WorldBeforeLoadEvent` and `WorldEndLoadEvent` * rename --- core/src/mindustry/core/World.java | 2 ++ core/src/mindustry/game/EventType.java | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/core/src/mindustry/core/World.java b/core/src/mindustry/core/World.java index 3922c65908..01bfb0986c 100644 --- a/core/src/mindustry/core/World.java +++ b/core/src/mindustry/core/World.java @@ -202,6 +202,7 @@ public class World{ */ public void beginMapLoad(){ generating = true; + Events.fire(new WorldLoadBeginEvent()); } /** @@ -209,6 +210,7 @@ public class World{ * A WorldLoadEvent will be fire. */ public void endMapLoad(){ + Events.fire(new WorldLoadEndEvent()); for(Tile tile : tiles){ //remove legacy blocks; they need to stop existing diff --git a/core/src/mindustry/game/EventType.java b/core/src/mindustry/game/EventType.java index faaad3d6be..9699e17393 100644 --- a/core/src/mindustry/game/EventType.java +++ b/core/src/mindustry/game/EventType.java @@ -77,8 +77,13 @@ public class EventType{ public static class MusicRegisterEvent{} /** Called *after* all the modded files have been added into Vars.tree */ public static class FileTreeInitEvent{} - /** Called when a game begins and the world tiles are loaded. Entities are not yet loaded at this stage. */ + + /** Called when a game begins and the world tiles are loaded, just set `generating = false`. Entities are not yet loaded at this stage. */ public static class WorldLoadEvent{} + /** Called when the world begin to load, just set `generating = true`. */ + public static class WorldLoadBeginEvent{} + /** Called when a game begins and the world tiles are initiated. About to updates tile proximity and sets up physics for the world(Before WorldLoadEvent) */ + public static class WorldLoadEndEvent{} public static class SaveLoadEvent{ public final boolean isMap;