~ruther/NosSmooth.Local

ref: 8a6eeb874448013c576ac7dea8477b66740bd64e NosSmooth.Local/src/Core/NosSmooth.LocalBinding/Hooks/INostaleHook.cs -rw-r--r-- 2.2 KiB
8a6eeb87 — Rutherther chore: bump versions 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//
//  INostaleHook.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Remora.Results;

namespace NosSmooth.LocalBinding.Hooks;

/// <summary>
/// A hook of a NosTale function.
/// </summary>
/// <typeparam name="TFunction">The function delegate.</typeparam>
/// <typeparam name="TWrapperFunction">A wrapper function that abstracts the call to original function. May get the neccessary object to call the function and accept only relevant arguments.</typeparam>
/// <typeparam name="TEventArgs">The event args used in case of a call.</typeparam>
public interface INostaleHook<TFunction, TWrapperFunction, TEventArgs> : INostaleHook
    where TFunction : Delegate
    where TWrapperFunction : Delegate
    where TEventArgs : System.EventArgs
{
    /// <summary>
    /// Gets the wrapper function delegate.
    /// </summary>
    public TWrapperFunction WrapperFunction { get; }

    /// <summary>
    /// Gets the original function delegate.
    /// </summary>
    public TFunction OriginalFunction { get; }

    /// <summary>
    /// An event fired in case the function is called from NosTale.
    /// </summary>
    public event EventHandler<TEventArgs>? Called;
}

/// <summary>
/// A hook of a NosTale function.
/// </summary>
public interface INostaleHook
{
    /// <summary>
    /// Gets the name of the function.
    /// </summary>
    /// <remarks>
    /// Usually denoted as Type.Method,
    /// for example PlayerManager.Walk.
    /// </remarks>
    public string Name { get; }

    /// <summary>
    /// Gets whether the hook is currently enabled.
    /// </summary>
    public bool IsEnabled { get; }

    /// <summary>
    /// Enable the hook.
    /// </summary>
    /// <remarks>
    /// If it already is enabled, does nothing.
    /// </remarks>
    /// <returns>A result that may or may not have succeeded.</returns>
    public Result Enable();

    /// <summary>
    /// Disable the hook.
    /// </summary>
    /// <remarks>
    /// If it already is disabled, does nothing.
    /// </remarks>
    /// <returns>A result that may or may not have succeeded.</returns>
    public Result Disable();
}
Do not follow this link