FeralCommon
A collection of common utilities and classes that are used across various FeralCompany projects
Last updated | 4 months ago |
Total downloads | 15205 |
Total rating | 0 |
Categories | Tools Libraries BepInEx |
Dependency string | FeralCompany-FeralCommon-0.2.1 |
Dependants | 8 other packages depend on this package |
This mod requires the following mods to function
BepInEx-BepInExPack
BepInEx pack for Mono Unity games. Preconfigured and ready to use.
Preferred version: 5.4.2100Rune580-LethalCompany_InputUtils
API/Library for creating Unity InputActions with in-game re-binding support. Provides an alternative UI that allows for supporting mods to have in-game re-bindable keybinds.
Preferred version: 0.7.4AinaVT-LethalConfig
Provides an in-game config menu for players to edit their configs, and an API for other mods to use and customize their entries.
Preferred version: 1.4.1README
FeralCommon
Deprecated
Please use FeralCompany instead!
This is a collection of common utilities and classes that are used across various FeralCompany projects.
Contributing
Please read the contribution guidelines before submitting a pull request. These guidelines will also help you set up your development environment.
Usage
Reference
<!-- Accessible via nuget source: https://nuget.windows10ce.com/nuget/v3/index.json -->
<!-- Thanks to Aaron Robinson for their efforts turning Thunderstore into a DLL repository -->
<!-- Do note, however, that updates are not propagated immediately. -->
<!-- See contribution guidelines for instructions on building this resource locally. -->
<PackageReference Include="FeralCompany-FeralCommon" Version="<Version>" PrivateAssets="all"/>
Buttons
Buttons are extremely simplified and abstracted InputActions, integrated with InputUtils.
Definition
// This class is used to define a button and a toggle that can be used in the game.
public static class Buttons
{
public static ButtonPress PressTest { get; } = new("pressTest", "Test Button Press", "<keyboard>/f");
public static ButtonToggle ToggleTest { get; } = new("toggleTest", "Test Button Toggle", "<keyboard>/t");
}
Event Listener
public void Awake() {
Buttons.PressTest.OnPressed(() => {
// This will be called when the button is pressed.
});
Buttons.ToggleTest.OnToggle(state => {
// This will be called whenever the button is toggled.
if (state) {
// This will be called when the button is toggled ON.
} else {
// This will be called when the button is toggled OFF.
}
});
}
Direct / Implicit Access
public void Update() {
if (Buttons.PressTest) {
// This will be true for a single frame when the button is pressed.
}
if (Buttons.ToggleTest) {
// This will be true (or false) until the button is pressed again.
}
}
Registration
[!IMPORTANT] You must call
RegisterButtons
in theLoad
method of your plugin. The registration method is closed after theLoad
method is called.
public void Load() {
RegisterButtons(typeof(MyButtons)); // Will only register static fields.
RegisterButtons(new MyButtons()); // Will only register instance fields.
}
Configs
Configs are extremely simplified and abstracted ConfigEntries, integrated with LethalConfig.
Definition
public static class MyConfigs {
public static readonly FloatConfig SomeFloat = new FloatConfig("Settings", "SomeFloat")
.WithDescription("Some Description")
.WithDefaultValue(0.5F)
.WithMin(0F)
.WithMax(1F)
.WithStep(0.001F);
}
Event Listener
public static void Awake() {
MyConfigs.SomeFloat.OnValueChanged(newValue => {
// This will be called whenever the value is changed.
});
}
Direct / Implicit Access
public static void Update() {
if (MyConfigs.SomeFloat <= 0.5F) {
// This will be true if the value is less than or equal to 0.5.
}
}
Registration
public void Load() {
RegisterConfigs(typeof(MyConfigs)); // Will only register static fields.
RegisterConfigs(new MyConfigs()); // Will only register instance fields.
}