Implement IpcCallerMare and hand Mare control of any handled pairs

This commit is contained in:
Loporrit
2025-08-09 15:05:31 +00:00
parent e1d54aea43
commit 6bf60fe729
5 changed files with 129 additions and 13 deletions

View File

@@ -74,7 +74,7 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
_visibilityService.StartTracking(Pair.Ident);
Mediator.SubscribeKeyed<PlayerVisibilityMessage>(this, Pair.Ident, (msg) => UpdateVisibility(msg.IsVisible));
Mediator.SubscribeKeyed<PlayerVisibilityMessage>(this, Pair.Ident, (msg) => UpdateVisibility(msg.IsVisible, msg.Invalidate));
Mediator.Subscribe<ZoneSwitchStartMessage>(this, (_) =>
{
@@ -694,7 +694,7 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
}
}
private void UpdateVisibility(bool nowVisible)
private void UpdateVisibility(bool nowVisible, bool invalidate = false)
{
if (string.IsNullOrEmpty(PlayerName))
{
@@ -707,6 +707,22 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
$"Initializing User For Character {pc.Name}")));
}
// This was triggered by the character becoming handled by Mare, so unapply everything
// There seems to be a good chance that this races Mare and then crashes
if (!nowVisible && invalidate)
{
bool wasVisible = IsVisible;
IsVisible = false;
_charaHandler?.Invalidate();
_downloadCancellationTokenSource?.CancelDispose();
_downloadCancellationTokenSource = null;
if (wasVisible)
Logger.LogTrace("{this} visibility changed, now: {visi}", this, IsVisible);
Logger.LogDebug("Invalidating {this}", this);
UndoApplication();
return;
}
if (!IsVisible && nowVisible)
{
// This is deferred application attempt, avoid any log output