-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a loader, and finished the refactoring for pathing
- Loading branch information
Showing
7 changed files
with
122 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using Arch.Core; | ||
using NovemberPirates.Systems; | ||
using Raylib_CsLo; | ||
using System.Diagnostics; | ||
using System.Numerics; | ||
|
||
namespace NovemberPirates.Scenes | ||
{ | ||
internal class LoadingSystem : GameSystem | ||
{ | ||
private BaseScene Scene; | ||
private int CurrentLoading; | ||
private bool LoadingComplete; | ||
private Stopwatch Stopwatch = new(); | ||
private LoadingPhase Phase = LoadingPhase.Text; | ||
public LoadingSystem(BaseScene baseScene) | ||
{ | ||
this.Scene = baseScene; | ||
} | ||
|
||
internal override void Update(World world) | ||
{ | ||
} | ||
|
||
internal override void UpdateNoCamera(World world) | ||
{ | ||
if (LoadingComplete || Scene.LoadingTasks.Count() == 0) | ||
return; | ||
var next = Scene.LoadingTasks.ElementAtOrDefault(CurrentLoading); | ||
if (next.Value is not null) | ||
{ | ||
var center = new Vector2(Raylib.GetScreenWidth() / 2, Raylib.GetScreenHeight() / 2); | ||
var text = $"Loading {next.Key} ({CurrentLoading + 1} of {Scene.LoadingTasks.Count()})"; | ||
var size = 48; | ||
var width = Raylib.MeasureText(text, size); | ||
if (Phase == LoadingPhase.Text) | ||
{ | ||
Raylib.DrawText(text, center.X - width / 2, center.Y, size, Raylib.BLUE); | ||
Console.WriteLine(text); | ||
Phase = LoadingPhase.Load; | ||
} | ||
else if (Phase == LoadingPhase.Load) | ||
{ | ||
Stopwatch = Stopwatch.StartNew(); | ||
next.Value(); | ||
Phase = LoadingPhase.Text; | ||
CurrentLoading++; | ||
Console.WriteLine($"Done - {Stopwatch.ElapsedMilliseconds}ms "); | ||
} | ||
} | ||
else | ||
LoadingComplete = true; | ||
|
||
} | ||
private enum LoadingPhase | ||
{ | ||
Text, | ||
Load | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters