mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Add IGameLifecycle (#1287)
This commit is contained in:
parent
8a6269c178
commit
0ac5c240f6
2 changed files with 32 additions and 10 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.IoC.Internal;
|
||||
using Dalamud.Plugin.Services;
|
||||
|
||||
namespace Dalamud.Game;
|
||||
|
||||
|
|
@ -11,7 +12,10 @@ namespace Dalamud.Game;
|
|||
[PluginInterface]
|
||||
[InterfaceVersion("1.0")]
|
||||
[ServiceManager.BlockingEarlyLoadedService]
|
||||
public class GameLifecycle : IServiceType
|
||||
#pragma warning disable SA1015
|
||||
[ResolveVia<IGameLifecycle>]
|
||||
#pragma warning restore SA1015
|
||||
public class GameLifecycle : IServiceType, IGameLifecycle
|
||||
{
|
||||
private readonly CancellationTokenSource dalamudUnloadCts = new();
|
||||
private readonly CancellationTokenSource gameShutdownCts = new();
|
||||
|
|
@ -26,19 +30,13 @@ public class GameLifecycle : IServiceType
|
|||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a token that is cancelled when Dalamud is unloading.
|
||||
/// </summary>
|
||||
/// <inheritdoc/>
|
||||
public CancellationToken DalamudUnloadingToken => this.dalamudUnloadCts.Token;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a token that is cancelled when the game is shutting down.
|
||||
/// </summary>
|
||||
/// <inheritdoc/>
|
||||
public CancellationToken GameShuttingDownToken => this.gameShutdownCts.Token;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a token that is cancelled when a character is logging out.
|
||||
/// </summary>
|
||||
/// <inheritdoc/>
|
||||
public CancellationToken LogoutToken => this.logoutCts.Token;
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
24
Dalamud/Plugin/Services/IGameLifecycle.cs
Normal file
24
Dalamud/Plugin/Services/IGameLifecycle.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using System.Threading;
|
||||
|
||||
namespace Dalamud.Plugin.Services;
|
||||
|
||||
/// <summary>
|
||||
/// Class offering cancellation tokens for common gameplay events.
|
||||
/// </summary>
|
||||
public interface IGameLifecycle
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a token that is cancelled when Dalamud is unloading.
|
||||
/// </summary>
|
||||
public CancellationToken DalamudUnloadingToken { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a token that is cancelled when the game is shutting down.
|
||||
/// </summary>
|
||||
public CancellationToken GameShuttingDownToken { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a token that is cancelled when a character is logging out.
|
||||
/// </summary>
|
||||
public CancellationToken LogoutToken { get; }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue