Skip to content

pseudopulse/WormAPI

Repository files navigation

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<Shader> clayDissolve = new LazyAsset<Shader>("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<GameObject> someObject = new DirectLazyAsset<GameObject>(
    (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<NetworkObject>();
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<GameObject>("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<GameObject>("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.

About

A general-purpose API for making Wormtown mods.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published