Added documentation, support of log out and log on added.
This commit is contained in:
@@ -816,9 +816,12 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
{
|
||||
_logger.LogInformation("Starting DalamudUtilService");
|
||||
_framework.Update += FrameworkOnUpdate;
|
||||
if (IsLoggedIn)
|
||||
_clientState.Login += OnClientLogin;
|
||||
_clientState.Logout += OnClientLogout;
|
||||
|
||||
if (_clientState.IsLoggedIn)
|
||||
{
|
||||
_classJobId = _objectTable.LocalPlayer!.ClassJob.RowId;
|
||||
OnClientLogin();
|
||||
}
|
||||
|
||||
_logger.LogInformation("Started DalamudUtilService");
|
||||
@@ -831,6 +834,9 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
|
||||
Mediator.UnsubscribeAll(this);
|
||||
_framework.Update -= FrameworkOnUpdate;
|
||||
_clientState.Login -= OnClientLogin;
|
||||
_clientState.Logout -= OnClientLogout;
|
||||
|
||||
if (_FocusPairIdent.HasValue)
|
||||
{
|
||||
if (_framework.IsInFrameworkUpdateThread)
|
||||
@@ -845,6 +851,41 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void OnClientLogin()
|
||||
{
|
||||
if (IsLoggedIn)
|
||||
return;
|
||||
_ = RunOnFrameworkThread(() =>
|
||||
{
|
||||
if (IsLoggedIn)
|
||||
return;
|
||||
var localPlayer = _objectTable.LocalPlayer;
|
||||
IsLoggedIn = true;
|
||||
_lastZone = _clientState.TerritoryType;
|
||||
if (localPlayer != null)
|
||||
{
|
||||
_lastWorldId = (ushort)localPlayer.CurrentWorld.RowId;
|
||||
_classJobId = localPlayer.ClassJob.RowId;
|
||||
}
|
||||
_cid = RebuildCID();
|
||||
Mediator.Publish(new DalamudLoginMessage());
|
||||
});
|
||||
}
|
||||
|
||||
private void OnClientLogout(int type, int code)
|
||||
{
|
||||
if (!IsLoggedIn)
|
||||
return;
|
||||
_ = RunOnFrameworkThread(() =>
|
||||
{
|
||||
if (!IsLoggedIn)
|
||||
return;
|
||||
IsLoggedIn = false;
|
||||
_lastWorldId = 0;
|
||||
Mediator.Publish(new DalamudLogoutMessage());
|
||||
});
|
||||
}
|
||||
|
||||
public async Task WaitWhileCharacterIsDrawing(
|
||||
ILogger logger,
|
||||
GameObjectHandler handler,
|
||||
@@ -1272,23 +1313,6 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
if (isNormalFrameworkUpdate)
|
||||
return;
|
||||
|
||||
if (localPlayer != null && !IsLoggedIn)
|
||||
{
|
||||
_logger.LogDebug("Logged in");
|
||||
IsLoggedIn = true;
|
||||
_lastZone = _clientState.TerritoryType;
|
||||
_lastWorldId = (ushort)localPlayer.CurrentWorld.RowId;
|
||||
_cid = RebuildCID();
|
||||
Mediator.Publish(new DalamudLoginMessage());
|
||||
}
|
||||
else if (localPlayer == null && IsLoggedIn)
|
||||
{
|
||||
_logger.LogDebug("Logged out");
|
||||
IsLoggedIn = false;
|
||||
_lastWorldId = 0;
|
||||
Mediator.Publish(new DalamudLogoutMessage());
|
||||
}
|
||||
|
||||
if (_gameConfig != null
|
||||
&& _gameConfig.TryGet(Dalamud.Game.Config.SystemConfigOption.LodType_DX11, out bool lodEnabled))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user