From 95173e7d93122d19358dcb08d7925e4f9105e162 Mon Sep 17 00:00:00 2001 From: Miguel Anxo Figueirido Prado Date: Tue, 2 Apr 2024 13:40:25 +0200 Subject: [PATCH] Allow TimeFactor = 0 --- FRBDK/Glue/Glue/CodeGeneration/EntityCodeWriter.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/FRBDK/Glue/Glue/CodeGeneration/EntityCodeWriter.cs b/FRBDK/Glue/Glue/CodeGeneration/EntityCodeWriter.cs index 644a5c549..790e17d5a 100644 --- a/FRBDK/Glue/Glue/CodeGeneration/EntityCodeWriter.cs +++ b/FRBDK/Glue/Glue/CodeGeneration/EntityCodeWriter.cs @@ -39,11 +39,13 @@ public static void GenerateFieldsAndProperties(EntitySave entity, ICodeBlock cod public static void GenerateActivity(IElement saveObject, ICodeBlock codeBlock) { codeBlock.Line("#if DEBUG"); - + // in codeblock, write code to check if the mLastTimeCalledActivity is equal to the current time. If so, throw an exception // 9/2/2023 - activity gets called 2x at the beginning. I'm not sure if this is desirable, but until I figure this out, I'm going - // to tolerate double calls on frame 0 - codeBlock.Line("if(mLastTimeCalledActivity > 0 && mLastTimeCalledActivity == FlatRedBall.TimeManager.CurrentScreenTime)") + // to tolerate double calls on frame 0. + // Miguel 02/04/2024 - Setting TimeFactor = 0 causes time to not advance causing this exception, but I think it should be a valid + // setting the user can choose. + codeBlock.Line("if(TimeManager.TimeFactor > 0 && mLastTimeCalledActivity > 0 && mLastTimeCalledActivity == FlatRedBall.TimeManager.CurrentScreenTime)") .Line("{") .Line(" throw new System.Exception(\"Activity was called twice in the same frame. This can cause objects to move 2x as fast.\");") .Line("}")