MegaPiggy.LCEnumUtils
1.0.5
dotnet add package MegaPiggy.LCEnumUtils --version 1.0.5
NuGet\Install-Package MegaPiggy.LCEnumUtils -Version 1.0.5
<PackageReference Include="MegaPiggy.LCEnumUtils" Version="1.0.5" />
paket add MegaPiggy.LCEnumUtils --version 1.0.5
#r "nuget: MegaPiggy.LCEnumUtils, 1.0.5"
// Install MegaPiggy.LCEnumUtils as a Cake Addin #addin nuget:?package=MegaPiggy.LCEnumUtils&version=1.0.5 // Install MegaPiggy.LCEnumUtils as a Cake Tool #tool nuget:?package=MegaPiggy.LCEnumUtils&version=1.0.5
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 Thunderstore 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<CauseOfDeath>("Bludgeoning");
if (EnumUtils.TryParse("Example", out CauseOfDeath example))
{
}
int numOfDeathCauses = EnumUtils.Count<CauseOfDeath>();
CauseOfDeath minDeathCause = EnumUtils.GetMinValue<CauseOfDeath>();
CauseOfDeath maxDeathCause = EnumUtils.GetMaxValue<CauseOfDeath>();
CauseOfDeath randomDeathCause = EnumUtils.GetRandom<CauseOfDeath>();
CauseOfDeath unusedDeathCauseValue = EnumUtils.GetFirstFreeValue<CauseOfDeath>();
string[] allDeathNames = EnumUtils.GetNames<CauseOfDeath>();
CauseOfDeath[] allDeathValues = EnumUtils.GetValues<CauseOfDeath>();
bool doesExampleDeathExist = EnumUtils.IsDefined<CauseOfDeath>("Example");
Type valueType = EnumUtils.GetUnderlyingType<CauseOfDeath>();
bool hasFlags = EnumUtils.IsPowerOfTwoEnum<CauseOfDeath>();
}
}
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<CauseOfDeath>("Example");
// Associate a specific enum value with a name of your choosing.
private static readonly CauseOfDeath Example2 = EnumUtils.Create<CauseOfDeath>("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;
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- BepInEx.Core (>= 5.4.21)
- UnityEngine.Modules (>= 2022.3.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.