prime31 / Nez

Nez is a free 2D focused framework that works with MonoGame and FNA
MIT License
1.76k stars 355 forks source link

Crash when adding FramesPerSecondCounter component in Initialize #731

Open puthre opened 1 year ago

puthre commented 1 year ago

adding

var fps = scene.CreateEntity("fps");
fps.AddComponent(new FramesPerSecondCounter());

leads to:

Unhandled exception. System.Collections.Generic.KeyNotFoundException: The given key '∞' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Nez.BitmapFonts.BitmapFont.get_Item(Char character) in /home/puthre/work/vr/TheMoonLeverage/src/Nez/Nez.Portable/Assets/BitmapFonts/BitmapFont.cs:line 150
   at Nez.BitmapFonts.BitmapFont.MeasureString(FontCharacterSource& text, Single maxWidth) in /home/puthre/work/vr/TheMoonLeverage/src/Nez/Nez.Portable/Assets/BitmapFonts/BitmapFont.cs:line 351
   at Nez.BitmapFonts.BitmapFont.MeasureString(String text, Single maxWidth) in /home/puthre/work/vr/TheMoonLeverage/src/Nez/Nez.Portable/Assets/BitmapFonts/BitmapFont.cs:line 305
   at Nez.BitmapFonts.BitmapFont.MeasureString(String text) in /home/puthre/work/vr/TheMoonLeverage/src/Nez/Nez.Portable/Assets/BitmapFonts/BitmapFont.cs:line 292
   at Nez.TextComponent.UpdateSize() in /home/puthre/work/vr/TheMoonLeverage/src/Nez/Nez.Portable/ECS/Components/Text/TextComponent.cs:line 119
   at Nez.TextComponent.SetText(String text) in /home/puthre/work/vr/TheMoonLeverage/src/Nez/Nez.Portable/ECS/Components/Text/TextComponent.cs:line 92
   at Nez.TextComponent.set_Text(String value) in /home/puthre/work/vr/TheMoonLeverage/src/Nez/Nez.Portable/ECS/Components/Text/TextComponent.cs:line 31
   at Nez.FramesPerSecondCounter.Update() in /home/puthre/work/vr/TheMoonLeverage/src/Nez/Nez.Portable/ECS/Components/Text/FramesPerSecondCounter.cs:line 141
   at Nez.Entity.Update() in /home/puthre/work/vr/TheMoonLeverage/src/Nez/Nez.Portable/ECS/Entity.cs:line 389
   at Nez.Scene.Update() in /home/puthre/work/vr/TheMoonLeverage/src/Nez/Nez.Portable/ECS/Scene.cs:line 402
   at Nez.Core.Update(GameTime gameTime) in /home/puthre/work/vr/TheMoonLeverage/src/Nez/Nez.Portable/Core.cs:line 257
   at Microsoft.Xna.Framework.Game.DoUpdate(GameTime gameTime)
   at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
   at TheMoonLeverageClient.Program.Main() in /home/puthre/work/vr/TheMoonLeverage/src/TheMoonLeverageClient/Program.cs:line 11

I will follow up with a PR in a moment.