Skip to content

Commit

Permalink
Merge pull request #324 from ffxivcode/master
Browse files Browse the repository at this point in the history
Added HasModule IPC
  • Loading branch information
awgil authored Apr 3, 2024
2 parents 4aee58d + 8fbdd35 commit e20db83
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion BossMod/Framework/IPCProvider.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
namespace BossMod;
using Dalamud.Game.ClientState.Objects.Types;

namespace BossMod;

class IPCProvider : IDisposable
{
private List<Action> _disposeActions = new();

public IPCProvider(Autorotation autorotation)
{
Register("HasModule", (GameObject obj) => ModuleRegistry.FindByOID(obj.DataId) != null);
Register("IsMoving", () => ActionManagerEx.Instance!.InputOverride.IsMoving());
Register("ForbiddenZonesCount", () => autorotation.Hints.ForbiddenZones.Count);
Register("InitiateCombat", () => autorotation.ClassActions?.UpdateAutoAction(CommonActions.AutoActionAIFight, float.MaxValue, true));
Expand All @@ -25,6 +28,13 @@ private void Register<TRet>(string name, Func<TRet> func)
_disposeActions.Add(p.UnregisterFunc);
}

private void Register<TRet, T1>(string name, Func<TRet, T1> func)
{
var p = Service.PluginInterface.GetIpcProvider<TRet, T1>("BossMod." + name);
p.RegisterFunc(func);
_disposeActions.Add(p.UnregisterFunc);
}

private void Register(string name, Action func)
{
var p = Service.PluginInterface.GetIpcProvider<object>("BossMod." + name);
Expand Down

0 comments on commit e20db83

Please sign in to comment.