WormAPI

版本 v1.0.0·更新於 2025-05-27

A general-purpose API for making Wormtown mods.

模組介紹 作者原文

WormAPI

A utilities library to make modding wormtown easier!

AssetHelper

  • Provides DirectLazyAsset and LazyAsset for getting game assets once they become available.
  • LazyAsset allows for automatically finding an asset by name and retrieving it once it becomes available. Casts to the asset once found, and null otherwise.
  • DirectLazyAsset takes a scene-load delegate to try and find the asset once a scene has been loaded. Casts to the asset once found, and null otherwise.

LazyAsset clayDissolve = new LazyAsset("Clay_WithDissolve");

clayDissolve.onAssetLoad += () => { // this will run on the first scene where the specified asset was found

Shader shader = clayDissolve; // implicitly casts back to the asset type

};

DirectLazyAsset someObject = new DirectLazyAsset(

(root) => { // this will be called on scene load until we find our object

return GameObject.Find("some object chain");

}

);

someObject.onAssetLoad += () => { // this will be called once we have our objects

GameObject obj = someObject;

Debug.Log(obj);

};

PrefabAPI

  • Utility for creating mock "prefabs" at runtime.
  • Has a method to automatically register a NetworkObject once the NetworkManager has loaded.

GameObject testObject = new("A Test Object");

testObject.MakePrefab(); // this object becomes a mock prefab. it will no longer be destroyed on spawn and is parented to an inactive root object, making it become active once cloned.

testObject.AddComponent();

testObject.MarkNetworkPrefab(); // this object becomes registered to the networked prefabs list once available

WormAbilityAPI

  • Greatly simplifies creating worm abilities, via the AddWormAbility() method
  • Automatically handles adjusting the UI to accomodate for them.

GameObject prefab = testbundle.LoadAsset("TestAbility.prefab");

WormAbilityAPI.AddWormAbility(new WormAbilityInfo() {

WormAbilityObject = prefab,

AbilityNotes = new() {

"A Note About Our Ability"

}

});

EquipmentAPI

  • The same as WormAbilityAPI, but for pardner equipments.
  • Automatically handles adding equipments to the spawnable pool for the cheat menu.

GameObject prefab = testbundle.LoadAsset("TestEquipment.prefab");

EquipmentAPI.AddEquipment(new EquipmentInfo() {

Name = "Test Pardner Equipment",

Prefab = prefab

});

LanguageAPI

  • A utility for adding localization pairs for languages.

LanguageAPI.AddString("ABILITY_TESTWORM_NAME", "Worm Test Ability");

LanguageAPI.AddString("ABILITY_TESTWORM_DESC", "Head to Worm City."); // defaults to english

LanguageAPI.AddString("ABILITY_TESTWORM_DESC", "Fahren Sie nach Wurmstadt", LanguageAPI.Language.German); // can specify which language

CommonAssets

  • A list of named LazyAssets for common game assets. Currently just the main shaders.

LayerIndex

  • A named list of the numerical IDs for every collision layer in the game.

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

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

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

前置依賴

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

HookGenPatcher_Wormtown-HookGenPatcherBepInEx_Wormtown-BepInExPack

檔案與校驗

檔案名稱
WormAPI-1.0.0.zip
檔案大小
65.0 KiB