Update to use AgentUpdate event

This commit is contained in:
Haselnussbomber 2025-11-08 11:47:31 +01:00
parent 700aaa4a5d
commit af8b61f08a
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1
2 changed files with 24 additions and 7 deletions

View file

@ -54,7 +54,7 @@ internal unsafe class RecipeData : IInternalDisposableService
this.clientState.Login += this.Update;
this.clientState.Logout += this.OnLogout;
this.clientState.LevelChanged += this.OnlevelChanged;
this.gameGui.UnlocksUpdate += this.Update;
this.gameGui.AgentUpdate += this.OnAgentUpdate;
}
/// <inheritdoc/>
@ -63,7 +63,7 @@ internal unsafe class RecipeData : IInternalDisposableService
this.clientState.Login -= this.Update;
this.clientState.Logout -= this.OnLogout;
this.clientState.LevelChanged -= this.OnlevelChanged;
this.gameGui.UnlocksUpdate -= this.Update;
this.gameGui.AgentUpdate -= this.OnAgentUpdate;
}
/// <summary>
@ -121,6 +121,12 @@ internal unsafe class RecipeData : IInternalDisposableService
}
}
private void OnAgentUpdate(AgentUpdateFlag agentUpdateFlag)
{
if (agentUpdateFlag.HasFlag(AgentUpdateFlag.UnlocksUpdate))
this.Update();
}
private void Update()
{
// based on Client::Game::UI::RecipeNote.InitializeStructs

View file

@ -49,9 +49,9 @@ internal unsafe class UnlockState : IInternalDisposableService, IUnlockState
[ServiceManager.ServiceConstructor]
private UnlockState()
{
this.clientState.Login += this.UpdateUnlocks;
this.clientState.Login += this.OnLogin;
this.clientState.Logout += this.OnLogout;
this.gameGui.UnlocksUpdate += this.UpdateUnlocks;
this.gameGui.AgentUpdate += this.OnAgentUpdate;
}
/// <inheritdoc/>
@ -62,9 +62,9 @@ internal unsafe class UnlockState : IInternalDisposableService, IUnlockState
/// <inheritdoc/>
void IInternalDisposableService.DisposeService()
{
this.clientState.Login -= this.UpdateUnlocks;
this.clientState.Login -= this.OnLogin;
this.clientState.Logout -= this.OnLogout;
this.gameGui.UnlocksUpdate -= this.UpdateUnlocks;
this.gameGui.AgentUpdate -= this.OnAgentUpdate;
}
/// <inheritdoc/>
@ -577,12 +577,23 @@ internal unsafe class UnlockState : IInternalDisposableService, IUnlockState
return UIState.Instance()->IsUnlockLinkUnlockedOrQuestCompleted(unlockLink);
}
private void OnLogin()
{
this.Update();
}
private void OnLogout(int type, int code)
{
this.cachedUnlockedRowIds.Clear();
}
private void UpdateUnlocks()
private void OnAgentUpdate(AgentUpdateFlag agentUpdateFlag)
{
if (agentUpdateFlag.HasFlag(AgentUpdateFlag.UnlocksUpdate))
this.Update();
}
private void Update()
{
if (!this.IsLoaded)
return;