Pet Nicknames IPC implementation (#74)
* Pet Nicknames IPC implementation * Moodles works again
This commit is contained in:
@@ -216,9 +216,11 @@ public class PlayerDataFactory
|
||||
_logger.LogDebug("Heels is now: {heels}", previousData.HeelsData);
|
||||
if (objectKind == ObjectKind.Player)
|
||||
{
|
||||
// TODO: use petnames here and save it to moodles data for temporary transfer
|
||||
previousData.MoodlesData = await _ipcManager.Moodles.GetStatusAsync(playerRelatedObject.Address).ConfigureAwait(false) ?? string.Empty;
|
||||
_logger.LogDebug("Moodles is now: {moodles}", previousData.MoodlesData);
|
||||
|
||||
previousData.MoodlesData = _ipcManager.PetNames.GetLocalNames();
|
||||
_logger.LogDebug("Pet Nicknames is now: {moodles}", previousData.MoodlesData);
|
||||
}
|
||||
|
||||
if (previousData.FileReplacements.TryGetValue(objectKind, out HashSet<FileReplacement>? fileReplacements))
|
||||
|
||||
@@ -342,8 +342,9 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
||||
break;
|
||||
|
||||
case PlayerChanges.Moodles:
|
||||
// TODO: send it to petnames ipc here instead
|
||||
await _ipcManager.Moodles.SetStatusAsync(handler.Address, charaData.MoodlesData).ConfigureAwait(false);
|
||||
|
||||
await _ipcManager.PetNames.SetPlayerData(handler.Address, charaData.MoodlesData).ConfigureAwait(false);
|
||||
break;
|
||||
|
||||
case PlayerChanges.ForcedRedraw:
|
||||
@@ -582,6 +583,8 @@ public sealed class PairHandler : DisposableMediatorSubscriberBase
|
||||
await _ipcManager.Honorific.ClearTitleAsync(address).ConfigureAwait(false);
|
||||
Logger.LogDebug("[{applicationId}] Restoring Moodles for {alias}/{name}", applicationId, OnlineUser.User.AliasOrUID, name);
|
||||
await _ipcManager.Moodles.RevertStatusAsync(address).ConfigureAwait(false);
|
||||
Logger.LogDebug("[{applicationId}] Restoring Pet Nicknames for {alias}/{name}", applicationId, OnlineUser.User.AliasOrUID, name);
|
||||
await _ipcManager.PetNames.ClearPlayerData(address).ConfigureAwait(false);
|
||||
}
|
||||
else if (objectKind == ObjectKind.MinionOrMount)
|
||||
{
|
||||
|
||||
@@ -6,4 +6,5 @@ public record OptionalPluginWarning
|
||||
public bool ShownCustomizePlusWarning { get; set; } = false;
|
||||
public bool ShownHonorificWarning { get; set; } = false;
|
||||
public bool ShownMoodlesWarning { get; set; } = false;
|
||||
public bool ShowPetNicknamesWarning { get; set; } = false;
|
||||
}
|
||||
@@ -21,6 +21,7 @@ public sealed class CacheCreationService : DisposableMediatorSubscriberBase
|
||||
private Task? _cacheCreationTask;
|
||||
private CancellationTokenSource _honorificCts = new();
|
||||
private CancellationTokenSource _moodlesCts = new();
|
||||
private CancellationTokenSource _petNicknamesCts = new();
|
||||
private bool _isZoning = false;
|
||||
private readonly Dictionary<ObjectKind, CancellationTokenSource> _glamourerCts = new();
|
||||
|
||||
@@ -122,9 +123,15 @@ public sealed class CacheCreationService : DisposableMediatorSubscriberBase
|
||||
MoodlesChanged();
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: if event is needed for petnames add it here similar to moodles
|
||||
|
||||
Mediator.Subscribe<PetNamesMessage>(this, (msg) =>
|
||||
{
|
||||
if (_isZoning) return;
|
||||
if (!string.Equals(msg.PetNicknamesData, _playerData.MoodlesData, StringComparison.Ordinal))
|
||||
{
|
||||
Logger.LogDebug("Received Pet Nicknames change, updating player");
|
||||
PetNicknamesChanged();
|
||||
}
|
||||
});
|
||||
Mediator.Subscribe<PenumbraModSettingChangedMessage>(this, (msg) =>
|
||||
{
|
||||
Logger.LogDebug("Received Penumbra Mod settings change, updating player");
|
||||
@@ -194,6 +201,20 @@ public sealed class CacheCreationService : DisposableMediatorSubscriberBase
|
||||
}, token);
|
||||
}
|
||||
|
||||
private void PetNicknamesChanged()
|
||||
{
|
||||
_petNicknamesCts?.Cancel();
|
||||
_petNicknamesCts?.Dispose();
|
||||
_petNicknamesCts = new();
|
||||
var token = _petNicknamesCts.Token;
|
||||
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(3), token).ConfigureAwait(false);
|
||||
await AddPlayerCacheToCreate().ConfigureAwait(false);
|
||||
}, token);
|
||||
}
|
||||
|
||||
private void ProcessCacheCreation()
|
||||
{
|
||||
if (_isZoning) return;
|
||||
|
||||
Reference in New Issue
Block a user