ZortLib

版本 v1.0.0·更新於 2025-03-08

A Basic Library For Zort

模組介紹 作者原文

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(object, string): Gets private variable from instance

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

public void Awake()

{

string scene = ZortUtils.GetPrivateVariable(MyClass.instance, "scene");

Debug.Log(scene);

ZortUtils.SetPrivateVariable(MyClass.instance, "scene", "haha I changed it");

scene = ZortUtils.GetPrivateVariable(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"));

安裝與使用 安裝:按包內說明操作

  1. 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
  2. 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
  3. 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
  4. 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。

不同模組的安裝位置差異較大,包內說明是最可靠的依據。

前置依賴

下面這些內容需要先安裝,否則該模組不會生效:

BepInEx-BepInExPack

檔案與校驗

檔案名稱
ZortLib-1.0.0.zip
檔案大小
108.6 KiB