[RT] C# Scripts in the Owlcat Mod Template - WittleWolfie/OwlcatModdingWiki GitHub Wiki
Rogue Trader Template - C# Scripts
As with UMM mods, C# scripts in the Owlcat template can be used to define and run Harmony patches, define custom Blueprint, Component, Action types etc.
To enable Visual Studio project support in the mod template, make sure you have the Visual Studio Editor package installed
Assembly Definition
To create a C# script, first create an Assembly Definition asset in your mod's Scripts folder
Then create a C# script asset
Entry point
To run code when your mod loads (eg. to run Harmony patches) add an entry point method to a class in a C# script. It must be public
, static
and be annotated with a OwlcatModificationEnterPoint
attribute
public class MyScript
{
[OwlcatModificationEnterPoint]
public static void Load(OwlcatModification mod)
{
// Your code here
}
}
TypeIds
and GuidClassBinder
(Custom Blueprints, Components, etc.)
Note: These instructions also work for UMM mods, if for some reason you want to make your UMM mod's components available to template mods.
If you want to reference types from your script assemblies in blueprints, they will need to be added to GuidClassBinder
. To make your types visible to the binder, first add a TypeIdAttribue
with a unique GUID to each class
[TypeId("186f54c7f41448c3a8c497d1df4b6bd8")]
class MyComponent : BlueprintComponent
{
}
[TypeId("acf7ee13d7b143129c589dad4d2e3e1a")]
class MyAction : GameAction
{
public override string GetCaption() => "My game action";
public override void RunAction() { }
}
Then create a class named ClassesWithGuid
with a static List<(Type, string)>
field named Classes
. It must be declared in the root namespace and the names and field type must match these exactly. Add an entry to this list for each type you annotated in the step above
class ClassesWithGuid
{
public static List<(Type, string)> Classes = new List<(Type, string)>()
{
(typeof(MyComponent), "186f54c7f41448c3a8c497d1df4b6bd8"),
(typeof(MyAction), "acf7ee13d7b143129c589dad4d2e3e1a")
};
}
TODO:
Publicizer for Owlcat template
If you need access to non-public members in Owlcat assemblies you either need to use reflection in your script or use a tool to "publicize" these members.
TODO: publicizer setup instructions
Additionally, you will need to enable "Allow 'unsafe' Code" in your assembly definition: