Use external library for API interface and IPC.

This commit is contained in:
Ottermandias 2022-10-08 02:02:33 +02:00
parent b3f048bfe6
commit 918d5db6a6
69 changed files with 4026 additions and 1873 deletions

68
tmp/Ipc/PluginState.cs Normal file
View file

@ -0,0 +1,68 @@
using System;
using Dalamud.Plugin;
using Penumbra.Api.Helpers;
namespace Penumbra.Api;
public static partial class Ipc
{
public static class Initialized
{
public const string Label = $"Penumbra.{nameof( Initialized )}";
public static EventProvider Provider( DalamudPluginInterface pi )
=> new(pi, Label);
public static EventSubscriber Subscriber( DalamudPluginInterface pi, params Action[] actions )
{
var ret = new EventSubscriber( pi, Label );
foreach( var action in actions )
{
ret.Event += action;
}
return ret;
}
}
public static class Disposed
{
public const string Label = $"Penumbra.{nameof( Disposed )}";
public static EventProvider Provider( DalamudPluginInterface pi )
=> new(pi, Label);
public static EventSubscriber Subscriber( DalamudPluginInterface pi, params Action[] actions )
{
var ret = new EventSubscriber( pi, Label );
foreach( var action in actions )
{
ret.Event += action;
}
return ret;
}
}
public static class ApiVersion
{
public const string Label = $"Penumbra.{nameof( ApiVersion )}";
public static FuncProvider< int > Provider( DalamudPluginInterface pi, Func< int > func )
=> new(pi, Label, func);
public static FuncSubscriber< int > Subscriber( DalamudPluginInterface pi )
=> new(pi, Label);
}
public static class ApiVersions
{
public const string Label = $"Penumbra.{nameof( ApiVersions )}";
public static FuncProvider< (int Breaking, int Features) > Provider( DalamudPluginInterface pi, Func< (int, int) > func )
=> new(pi, Label, func);
public static FuncSubscriber< (int Breaking, int Features) > Subscriber( DalamudPluginInterface pi )
=> new(pi, Label);
}
}