Moved initialization code into first tick.

This commit is contained in:
Kiri 2023-04-01 13:03:24 -07:00
parent fd674d870e
commit 78f4c30c2c

View File

@ -9,6 +9,7 @@ class JumperCablesMapLoader : EventHandler
{
Map<int, int> originalLinedefSpecials2;
Array<JumperCablesDeployed> deployedCables;
bool worldScanCompleted;
static JumperCablesMapLoader Get()
{
@ -17,13 +18,31 @@ class JumperCablesMapLoader : EventHandler
return loader;
}
override void WorldLoaded(WorldEvent e)
override void WorldUnloaded(WorldEvent e)
{
JumperCablesMapLoader loader = Get();
// Clear out anything from the last level.
deployedCables.Clear();
loader.originalLinedefSpecials2.Clear();
worldScanCompleted = false;
}
override void WorldLoaded(WorldEvent e)
{
// JumperCablesMapLoader loader = Get();
// // Clear out anything from the last level.
// deployedCables.Clear();
// loader.originalLinedefSpecials2.Clear();
// worldScanCompleted = false;
}
override void WorldTick()
{
JumperCablesMapLoader loader = Get();
if(!loader.worldScanCompleted) {
// Go through all the linedefs and make note of what they're
// supposed to do.
@ -33,6 +52,11 @@ class JumperCablesMapLoader : EventHandler
loader.originalLinedefSpecials2.Insert(line.index(), line.special);
}
}
loader.worldScanCompleted = true;
Console.printf("JMP: World scan completed.");
}
}
override void WorldLineActivated(WorldEvent e)
@ -57,7 +81,7 @@ class JumperCablesMapLoader : EventHandler
deployedCables.Push(cableActor);
// FIXME: Remove this.
Console.printf("Cables registered %d\n", deployedCables.size());
// Console.printf("Cables registered %d\n", deployedCables.size());
}
}