Details

Last Updated
last month
First Uploaded
last month
Downloads
345
Likes
1
Size
111KB
Dependency string
Ernedev-ZortLib-1.0.0
Dependants

Categories

ABOUT

A basic library for Zort Made by Erne

USAGE

Reference ZortLib.dll to your project

Add ZortLib as a dependency to your plugin class

[BepInPlugin(pluginGuid, pluginName, pluginVersion)]
[BepInDependency(ZortLib.libGuid, BepInDependency.DependencyFlags.HardDependency)]
public class MyClass : BaseUnityPlugin
{

}

Actions

sceneDelay: Invokes the actions after delay scene: Byte for numbering scenes

OnMenu(): Calls frame per second on menu OnLobby(): Calls frame per second on lobby OnGame(): Calls frame per second on game

OnceMenu(): Calls once start on menu OnceLobby(): Calls once start on lobby OnceGame(): CCalls once start on game

public void Awake()
{
    OnLobby += () => Debug.Log("Im at lobby");

    OnceLobby += LobbyOnce;
}

public void LobbyOnce => Debug.Log("Im joined to lobby");

Output :
"Im at lobby"
"Im joined to lobby"
"Im at lobby"
...

ZortUtils

InvokeIn(MonoBehaviour, float, Action) : Invokes the action

this.InvokeIn(3.5f, () =>
{
    Debug.Log("3,5 Seconds passed");
});

GetPrivateVariable<T>(object, string) : Gets private variable from instance SetPrivateVariable<T>(object, string, T) : Gets private variable from instance

public void Awake()
{
    string scene = ZortUtils.GetPrivateVariable<string>(MyClass.instance, "scene");
    Debug.Log(scene);

    ZortUtils.SetPrivateVariable<string>(MyClass.instance, "scene", "haha I changed it");
    scene = ZortUtils.GetPrivateVariable<string>(MyClass.instance, "scene");
    Debug.Log(scene);
}

... // Another class
private string scene = "nothing";
...

Output :
"nothing"
"haha I changed it"

InvokePrivateVoid(object, string, params object[]) : Invokes private method from instance

public override void OnceGame()
{
    ZortUtils.InvokePrivateVoid(MyClass.instance, "Noclip");
}

... // Another class
private void Noclip => Debug.Log("Noclip Open :)");
...

Output : 
"Noclip Open :)"

ReplaceMethod(Type, string, Type, string) : Replaces first method to second method

public void Awake()
{
    ZortUtils.ReplaceMethod(typeof(MyClass), "Awake", typeof(MyClass), "Method2");
    Method1();
    Method2();
}

private void Method1() => Debug.Log("First Method");
private void Method2() => Debug.Log("Second Method");

Output : 
"First Method"
"First Method"

PatchUtils

RegisterCallback(Type, string, Action, bool = false) : Registers a action calling after from method UnRegisterCallback(Type, string) : UnRegisters a callback

public override void OnceGame()
{
    // If its private -> RegisterCallback("Myclass", "StartGame", ...);
    RegisterCallback(typeof(MyClass), nameof(MyClass.StartGame), ()=> {
        Debug.Log("Noo I'm after the game starts");
    }, false);
}

public void StartGame() => Debug.Log("Game Is Started");

Output :
"Game Is Started"
"Noo I'm after the game starts"

Mono

Just use Mono.Instance if you need MonoBehaviour on anywhere

Mono.Instance.InvokeIn(1f, () => Debug.Log("Hi"));
Thunderstore development is made possible with ads. Please consider making an exception to your adblock.
Thunderstore development is made possible with ads. Please consider making an exception to your adblock.
Thunderstore development is made possible with ads. Please consider making an exception to your adblock.