Skip to content

Commit 7f2342c

Browse files
Merge pull request #46 from zzi-zzi-zzi/sidestep-helper
Update SideStep Helper
2 parents 0ed009e + 40d8c1f commit 7f2342c

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

Helpers/SideStep.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Diagnostics.CodeAnalysis;
44
using System.Linq;
@@ -20,27 +20,27 @@ public static class SideStep
2020
private static object? _sideStep;
2121

2222
private static Action? _loadAvoidanceFunction;
23-
private static Action<ulong, uint, Func<BattleCharacter, float, IEnumerable<AvoidInfo>>, float>? _addHandlerFunction;
24-
private static Func<ulong, uint, bool>? _removeHandlerFunction;
23+
private static Func<uint, bool>? _override;
24+
private static Func<uint, bool>? _removeOverride;
2525

2626
static SideStep()
2727
{
2828
FindSideStep();
2929
}
3030

31-
private static MethodInfo GetRemoveHandler2Params(object pluginInstance)
31+
private static MethodInfo GetRemoveHandler(object pluginInstance)
3232
{
3333
var t = pluginInstance.GetType();
3434

3535
var mi = t.GetMethod(
36-
"RemoveHandler",
36+
"RemoveOverride",
3737
BindingFlags.Instance | BindingFlags.Public,
3838
binder: null,
39-
types: new[] { typeof(ulong), typeof(uint) },
39+
types: new[] { typeof(uint) },
4040
modifiers: null);
4141

4242
if (mi == null)
43-
throw new MissingMethodException(t.FullName, "RemoveHandler(ulong, uint)");
43+
throw new MissingMethodException(t.FullName, "RemoveOverride(uint)");
4444

4545
return mi;
4646
}
@@ -65,8 +65,8 @@ private static void FindSideStep()
6565
{
6666

6767
_loadAvoidanceFunction = (Action)Delegate.CreateDelegate(typeof(Action), _sideStep, "LoadAvoidanceObjects");
68-
_addHandlerFunction = (Action<ulong, uint, Func<BattleCharacter, float, IEnumerable<AvoidInfo>>, float>)Delegate.CreateDelegate(typeof(Action<ulong, uint, Func<BattleCharacter, float, IEnumerable<AvoidInfo>>, float>), _sideStep, "AddHandler");
69-
_removeHandlerFunction = (Func<ulong, uint,bool>)Delegate.CreateDelegate(typeof(Func<ulong, uint,bool>), _sideStep, GetRemoveHandler2Params(_sideStep));
68+
_override = (Func<uint,bool>)Delegate.CreateDelegate(typeof(Func<uint, bool>), _sideStep, "Override");
69+
_removeOverride = (Func<uint,bool>)Delegate.CreateDelegate(typeof(Func<uint,bool>), _sideStep, "RemoveOverride");
7070
}
7171
catch (Exception e)
7272
{
@@ -88,24 +88,24 @@ public static void LoadAvoidanceObjects()
8888
_loadAvoidanceFunction.Invoke();
8989
}
9090

91-
public static bool RemoveHandler(ulong type, uint key)
91+
public static bool RemoveHandler(uint key)
9292
{
93-
if (_removeHandlerFunction == null)
93+
if (_removeOverride == null)
9494
{
9595
Log.Information("SideStepHelper: no RemoveHandler found.");
9696
return false;
9797
}
98-
return _removeHandlerFunction.Invoke(type, key);
98+
return _removeOverride.Invoke(key);
9999
}
100100

101-
public static void AddHandler(ulong type, uint key, Func<BattleCharacter, float, IEnumerable<AvoidInfo>> handler, float range = float.NaN)
101+
public static bool Override(uint key)
102102
{
103-
if (_addHandlerFunction == null)
103+
if (_override == null)
104104
{
105105
Log.Information("SideStepHelper: no AddHandler found.");
106-
return;
106+
return false;
107107
}
108-
_addHandlerFunction?.Invoke(type, key, handler, range);
108+
return _override.Invoke(key);
109109
}
110110

111111
}

0 commit comments

Comments
 (0)