Rewrite parts of ClientState (#2065)

- Completely relies on hooks now, instead of the Framework.Update loop
- Support for Logout codes
This commit is contained in:
Haselnussbomber 2024-11-11 17:28:40 +01:00 committed by GitHub
parent c88e008672
commit c7facaf072
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 120 additions and 67 deletions

View file

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
@ -89,7 +89,7 @@ internal class AutoUpdateManager : IServiceType
t =>
{
t.Result.Login += this.OnLogin;
t.Result.Logout += this.OnLogout;
t.Result.Logout += (int type, int code) => this.OnLogout();
});
Service<Framework>.GetAsync().ContinueWith(t => { t.Result.Update += this.OnUpdate; });

View file

@ -22,6 +22,13 @@ public interface IClientState
/// <param name="level">The level of the corresponding ClassJob.</param>
public delegate void LevelChangeDelegate(uint classJobId, uint level);
/// <summary>
/// A delegate type used for the <see cref="Logout"/> event.
/// </summary>
/// <param name="type">The type of logout.</param>
/// <param name="code">The success/failure code.</param>
public delegate void LogoutDelegate(int type, int code);
/// <summary>
/// Event that gets fired when the current Territory changes.
/// </summary>
@ -46,7 +53,7 @@ public interface IClientState
/// <summary>
/// Event that fires when a character is logging out.
/// </summary>
public event Action Logout;
public event LogoutDelegate Logout;
/// <summary>
/// Event that fires when a character is entering PvP.