Revision Difference
FixingSimulateLoops#546666
<cat>Code.Misc</cat>⤶
<title>Fixing Loops in Simulate Calls</title>⤶
⤶
Using any type of loop in a Simulate call can cause problems.⤶
⤶
Specifically, recompiling a game while an entity is executing a for loop every frame will majorly increase your compile time. Thankfully, there is a simple way to fix this.⤶
⤶
By adding a few lines of code, the entity will stop the loop when the game reaches a low enough FPS. If there is a way to specifically detect if the engine is compiling/hotloading, please change this article to reflect that, because this isn't a particularly secure method and could theoretically be abused by dumbfucks.⤶
⤶
```⤶
// Do this thing 10 times.⤶
for ( int i = 0; i < 10; i++ ) {⤶
if ( PerformanceStats.FrameTime >= 0.5f ) break;⤶
// Do this thing.⤶
}⤶
```⤶
⤶
This tells the entity to break out of the loop if FPS is below 2, which usually happens during compile-time.⤶