Skip to content

Commit

Permalink
Allow TimeFactor = 0
Browse files Browse the repository at this point in the history
  • Loading branch information
mfigueirido committed Apr 2, 2024
1 parent a9d6f90 commit 95173e7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions FRBDK/Glue/Glue/CodeGeneration/EntityCodeWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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("}")
Expand Down

0 comments on commit 95173e7

Please sign in to comment.