FeralCommon
A collection of common utilities and classes that are used across various FeralCompany projects
Date uploaded | 7 months ago |
Version | 0.1.3 |
Download link | FeralCompany-FeralCommon-0.1.3.zip |
Downloads | 1596 |
Dependency string | FeralCompany-FeralCommon-0.1.3 |
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
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.
}
CHANGELOG
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
[Unreleased]
- Nothing, yet.
Version [v0.2.1] (2024-07-07)
- Deprecate
Version [v0.2.0] (2024-04-27)
Added
- Add
GameItem
enum andGameItems
utility class.- Additionally, added
GameItemExtensions
for convenience methods against the enum.
- Additionally, added
- Added
GameObjectExtensions
. - Added
GrabbableObjectExtensions
. - Added
NumberExtensions
.
Changed
ObjectInspector
now expands all types by default, so detailedTypes is no longer necessary.
Fixed
ObjectInspector
would get stuck on a few types. This has been fixed.
Version [v0.1.3] (2024-04-23)
Added
- Added
HarmonyExtension
, namelyPatchNamespace
which scans the provided namespace and requests each type within to be patched.
Version [v0.1.2] (2024-04-23)
Changed
- Better looking mod icon.
Version [v0.1.1] (2024-04-23)
Added
- Added
Diff
toObjectInspector
. - Added
Mask
- Added
EnumConfig
- Added normalized log output for
ObjectInspector
- Removed
UnityTool
Fixed
- Don't use ranges in Configs if no Min/Max is specified.
Version [v0.1.0] (2024-04-19)
Added
- Add ObjectInspector
- Add UnityTool
- Add
LocalPlayerNullable
toPlayer
utility
Changed
- Update LethalConfig dependency to 1.4.1
- Make use of its optional assembly specification (thanks AinaVT! <3)
activeByDefault
optional parameter inButtonToggle
Trivial
- Change website url on Thunderstore to https://github.com/FeralCompany
Version [v0.0.7 -> v0.0.12] (2024-04-15)
Changed
- Fixed various aspects of build cycle.
- No code updates.
- Just testing build cycle changes.
Version [v0.0.6] (2024-04-15)
Added
- Abstract Harmony initializer with lazy access to Harmony instance
- Various utilities
- Tightened scopes where possible
- Better README.md
- Added usage examples and a link to the contribution guidelines
Changed
- InputUtils
and LethalConfig are now hard dependencies.
- I can no longer be arsed to deal with the nightmare that is soft dependencies. With how efficient Thunderstore and r2modman are, there's no downside to having them as hard dependencies.
- With this change, I think that usage is even better than before, and significantly less confusing.
Version [v0.0.5] (2024-04-14)
Added
- Added BoolConfig
- Added support for
ButtonPress
andButtonToggle
- Soft InputUtils integration
Fixed
- Added missing converter for ColorConfig
- Fixed
Start
andUpdate
methods not being called
Version [v0.0.4] (2024-04-12)
Added
- Added
FeralCommon.Config.ColorConfig
- Added implicit operators for
ConfigEntry
andColorEntry.Value
Version [v0.0.3] (2024-04-12)
Fixes
- Fixed build and packaging issues.
Version [v0.0.2] (2024-04-11)
Added
- Soft LethalConfig integration
Version [v0.0.1] (2024-04-08)
Added
- Initial release