Jump to content

ModUtil in the source code


Recommended Posts

I found an interesting class in the source code.

public static class ModUtil
{
	public static void AddBuildingToPlanScreen(HashedString category, string building_id)
	public static void AddBuildingToHotkeyBuildMenu(HashedString category, string building_id, global::Action hotkey)
	public static KAnimFile AddKAnim(string name, TextAsset anim_file, TextAsset build_file, IList<Texture2D> textures)
	public static KAnimFile AddKAnim(string name, TextAsset anim_file, TextAsset build_file, Texture2D texture)
	public static Substance CreateSubstance(string name, Element.State state, KAnimFile kanim, Material material, Color32 colour, Color32 ui_colour, Color32 conduit_colour)
	public static void RegisterForTranslation(Type locstring_tree_root)
}

The first one adds a building to the build menu. It seems to do precisely the same as NightLib.AddBuilding, except my code is more advanced in the sense that my code can control where in the list the building is added and it can replace an existing building.

The rest looks interesting, but I haven't tried using any of them yet. The names are good indicators for their functionality, except CreateSubstance, which apparently might as well have been called CreateElement. It creates a unique elementID and stuff like that.

Now we just need to figure out how to use all of them (or wait for Klei to tell us).

I guess now somebody will figure out a way to read a char from a config file, Substract 'A' from it and add global::Action.BuildMenuKeyA. That should provide the ability to set hotkeys in a config file, which in turn allows the user to fix clashes of hotkeys between mods. If there are two buildings with the same hotkey, then it looks like the last loaded mod will win.

I didn't test any of this yet.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...