EnumUtils
A library to help with creating and getting Enums
About this mod Author’s original text
LethalCompanyEnumUtils
A library with utilities for dynamically creating and getting Enums.
For feature requests or issues, go to my repo.
General Users
This mod is just a dependency for other mods, it doesn't add content by itself.
Recommended Install
Please use a mod manager. I recommend r2modman as the mod manager to use for Lethal Company.
Developer Quick-Start
Download the latest release from either the or the Releases.
Extract the zip and add a reference to the dll file of the mod in the IDE (Visual Studio, Rider, or etc) you use.
Enum Utilities
Getting Enums
Shortcuts for getting enums. There is various functions you can use.
Here are some of the examples.
[BepInPlugin(modGUID, modName, modVersion)]
public class ExampleModClass: BaseUnityPlugin
{
private void Start()
{
CauseOfDeath bludgeoning = EnumUtils.Parse("Bludgeoning");
if (EnumUtils.TryParse("Example", out CauseOfDeath example))
{
}
int numOfDeathCauses = EnumUtils.Count();
CauseOfDeath minDeathCause = EnumUtils.GetMinValue();
CauseOfDeath maxDeathCause = EnumUtils.GetMaxValue();
CauseOfDeath randomDeathCause = EnumUtils.GetRandom();
CauseOfDeath unusedDeathCauseValue = EnumUtils.GetFirstFreeValue();
string allDeathNames = EnumUtils.GetNames();
CauseOfDeath allDeathValues = EnumUtils.GetValues();
bool doesExampleDeathExist = EnumUtils.IsDefined("Example");
Type valueType = EnumUtils.GetUnderlyingType();
bool hasFlags = EnumUtils.IsPowerOfTwoEnum();
}
}
Creating Enums
You can use the EnumUtils class to create enums just like this.
[BepInPlugin(modGUID, modName, modVersion)]
public class ExampleModClass: BaseUnityPlugin
{
// Associate an unused enum value with a name of your choosing.
private static readonly CauseOfDeath Example = EnumUtils.Create("Example");
// Associate a specific enum value with a name of your choosing.
private static readonly CauseOfDeath Example2 = EnumUtils.Create("Example2", -1);
private void Awake()
{
}
}
Enum Holders
Another way to create enums.
Add the [EnumHolder] attribute to a class, run the RegisterAllEnumHolders function, and any static enum fields will have an enum value created with the name of the field. It'll select any unused enum value to be associated with that name (or if you specify a value it'll use that one).
using System.Reflection;
[BepInPlugin(modGUID, modName, modVersion)]
public class ExampleModClass: BaseUnityPlugin
{
private void Awake()
{
EnumUtils.RegisterAllEnumHolders(Assembly.GetExecutingAssembly());
}
}
[EnumHolder]
public static class ExampleEnumHolderClass
{
public static readonly CauseOfDeath Example;
public static readonly CauseOfDeath Example2 = (CauseOfDeath)-1;
}
Install & use Install: BepInEx plugin
- The archive from playbuff is the mod itself — usually a BepInEx plugin (a .dll or a plugin folder once unzipped).
- Recommended: use a community mod manager (such as r2modman) — pick this game, import the mod, and the manager sets up BepInEx and its dependencies for you.
- Manual route: install the BepInEx loader in the game folder, then drop the unzipped .dll or plugin folder into BepInEx/plugins/.
- Launch the game — the BepInEx console logs every plugin it loads; seeing this mod in the log means it is installed.
Mods with listed dependencies need those installed too, or they will not load. Options are usually changed in-game or in the plugin's config file.
Install these first, or the mod will not work: