using Dalamud.Plugin; using Dalamud.Plugin.Ipc; using Lifestream.Enums; using LightlessSync.Interop.Ipc.Framework; using LightlessSync.Services.Mediator; using Microsoft.Extensions.Logging; namespace LightlessSync.Interop.Ipc; public sealed class IpcCallerLifestream : IpcServiceBase { private static readonly IpcServiceDescriptor LifestreamDescriptor = new("Lifestream", "Lifestream", new Version(0, 0, 0, 0)); private readonly ICallGateSubscriber _executeLifestreamCommand; private readonly ICallGateSubscriber _isHere; private readonly ICallGateSubscriber _goToHousingAddress; private readonly ICallGateSubscriber _isBusy; private readonly ICallGateSubscriber _abort; private readonly ICallGateSubscriber _changeWorld; private readonly ICallGateSubscriber _changeWorldById; private readonly ICallGateSubscriber _aetheryteTeleport; private readonly ICallGateSubscriber _aetheryteTeleportById; private readonly ICallGateSubscriber _canChangeInstance; private readonly ICallGateSubscriber _getCurrentInstance; private readonly ICallGateSubscriber _getNumberOfInstances; private readonly ICallGateSubscriber _changeInstance; private readonly ICallGateSubscriber<(ResidentialAetheryteKind, int, int)> _getCurrentPlotInfo; public IpcCallerLifestream(IDalamudPluginInterface pi, LightlessMediator lightlessMediator, ILogger logger) : base(logger, lightlessMediator, pi, LifestreamDescriptor) { _executeLifestreamCommand = pi.GetIpcSubscriber("Lifestream.ExecuteCommand"); _isHere = pi.GetIpcSubscriber("Lifestream.IsHere"); _goToHousingAddress = pi.GetIpcSubscriber("Lifestream.GoToHousingAddress"); _isBusy = pi.GetIpcSubscriber("Lifestream.IsBusy"); _abort = pi.GetIpcSubscriber("Lifestream.Abort"); _changeWorld = pi.GetIpcSubscriber("Lifestream.ChangeWorld"); _changeWorldById = pi.GetIpcSubscriber("Lifestream.ChangeWorldById"); _aetheryteTeleport = pi.GetIpcSubscriber("Lifestream.AetheryteTeleport"); _aetheryteTeleportById = pi.GetIpcSubscriber("Lifestream.AetheryteTeleportById"); _canChangeInstance = pi.GetIpcSubscriber("Lifestream.CanChangeInstance"); _getCurrentInstance = pi.GetIpcSubscriber("Lifestream.GetCurrentInstance"); _getNumberOfInstances = pi.GetIpcSubscriber("Lifestream.GetNumberOfInstances"); _changeInstance = pi.GetIpcSubscriber("Lifestream.ChangeInstance"); _getCurrentPlotInfo = pi.GetIpcSubscriber<(ResidentialAetheryteKind, int, int)>("Lifestream.GetCurrentPlotInfo"); CheckAPI(); } public void ExecuteLifestreamCommand(string command) { if (!APIAvailable) return; _executeLifestreamCommand.InvokeAction(command); } public bool IsHere(AddressBookEntryTuple entry) { if (!APIAvailable) return false; return _isHere.InvokeFunc(entry); } public void GoToHousingAddress(AddressBookEntryTuple entry) { if (!APIAvailable) return; _goToHousingAddress.InvokeAction(entry); } public bool IsBusy() { if (!APIAvailable) return false; return _isBusy.InvokeFunc(); } public void Abort() { if (!APIAvailable) return; _abort.InvokeAction(); } public bool ChangeWorld(string worldName) { if (!APIAvailable) return false; return _changeWorld.InvokeFunc(worldName); } public bool AetheryteTeleport(string aetheryteName) { if (!APIAvailable) return false; return _aetheryteTeleport.InvokeFunc(aetheryteName); } public bool ChangeWorldById(uint worldId) { if (!APIAvailable) return false; return _changeWorldById.InvokeFunc(worldId); } public bool AetheryteTeleportById(uint aetheryteId) { if (!APIAvailable) return false; return _aetheryteTeleportById.InvokeFunc(aetheryteId); } public bool CanChangeInstance() { if (!APIAvailable) return false; return _canChangeInstance.InvokeFunc(); } public int GetCurrentInstance() { if (!APIAvailable) return -1; return _getCurrentInstance.InvokeFunc(); } public int GetNumberOfInstances() { if (!APIAvailable) return -1; return _getNumberOfInstances.InvokeFunc(); } public void ChangeInstance(int instanceNumber) { if (!APIAvailable) return; _changeInstance.InvokeAction(instanceNumber); } public (ResidentialAetheryteKind, int, int)? GetCurrentPlotInfo() { if (!APIAvailable) return (ResidentialAetheryteKind.None, -1, -1); return _getCurrentPlotInfo.InvokeFunc(); } }