feat: add GameLifecycle service

This commit is contained in:
goat 2023-03-27 19:43:29 +02:00
parent 03a409306f
commit 9ff7eb801f
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B
3 changed files with 79 additions and 3 deletions

View file

@ -25,6 +25,8 @@ namespace Dalamud.Game;
[ServiceManager.BlockingEarlyLoadedService]
public sealed class Framework : IDisposable, IServiceType
{
private readonly GameLifecycle lifecycle;
private static Stopwatch statsStopwatch = new();
private readonly Stopwatch updateStopwatch = new();
@ -41,10 +43,11 @@ public sealed class Framework : IDisposable, IServiceType
[ServiceManager.ServiceDependency]
private readonly DalamudConfiguration configuration = Service<DalamudConfiguration>.Get();
[ServiceManager.ServiceConstructor]
private Framework(SigScanner sigScanner)
private Framework(SigScanner sigScanner, GameLifecycle lifecycle)
{
this.lifecycle = lifecycle;
this.hitchDetector = new HitchDetector("FrameworkUpdate", this.configuration.FrameworkUpdateHitch);
this.Address = new FrameworkAddressResolver();
@ -489,6 +492,10 @@ public sealed class Framework : IDisposable, IServiceType
this.IsFrameworkUnloading = true;
this.DispatchUpdateEvents = false;
// All the same, for now...
this.lifecycle.SetShuttingDown();
this.lifecycle.SetUnloading();
Log.Information("Framework::Destroy!");
Service<Dalamud>.Get().Unload();
this.RunPendingTickTasks();