refactor: implemented engine's ILoadContent for loading content

This commit is contained in:
2025-07-25 21:53:38 +03:00
parent cc0476186e
commit 44a366f475
2 changed files with 8 additions and 5 deletions

View File

@@ -1,3 +1,4 @@
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Syntriax.Engine.Core;
@@ -5,7 +6,7 @@ using Syntriax.Engine.Integration.MonoGame;
namespace Pong.Behaviours;
public class ScoreLabel(bool IsLeft) : Label, IFirstFrameUpdate
public class ScoreLabel(bool IsLeft) : Label, IFirstFrameUpdate, ILoadContent
{
public readonly bool IsLeft = IsLeft;
@@ -13,9 +14,6 @@ public class ScoreLabel(bool IsLeft) : Label, IFirstFrameUpdate
public void FirstActiveFrame()
{
MonoGameWindow monoGameWindow = Universe.FindRequiredBehaviour<MonoGameWindowContainer>().Window;
Font = monoGameWindow.Content.Load<SpriteFont>("UbuntuMono");
pongManager = Universe.FindRequiredBehaviour<PongManager>();
pongManager.OnScoreUpdated += UpdateScores;
@@ -24,6 +22,11 @@ public class ScoreLabel(bool IsLeft) : Label, IFirstFrameUpdate
UpdateScores(pongManager);
}
public void LoadContent(ContentManager content)
{
Font = content.Load<SpriteFont>("UbuntuMono");
}
private void UpdateScores(PongManager pongManager)
{
if (IsLeft)