# LethalCompany InputUtils
Utilities for creating InputActions and having them be accessible in-game.
InputActions created through this mod are accessible in-game via the keybinds menu added in update v45.
#### For feature requests or issues head over to my [repo](https://github.com/Rune580/LethalCompanyInputUtils)
## General Users
This mod is just a dependency for other mods, it doesn't add content, but it allows mods to add keybinds.
### Where are my bind overrides stored?
Depends on the version of InputUtils:
- **>= 0.4.1** `BepInEx/config/controls`
- **<= 0.4.0** `BepInEx/controls`
### Recommended Install
Use a Mod manager. I won't provide support if a mod manager wasn't used, a mod manager makes it far easier to debug issues since users can just share a modpack code.
## Developer Quick-Start
*This Api/Mod is still in beta, please keep in mind that stuff may change.*
Feedback is appreciated.
Download the latest release from either the [Thunderstore](https://thunderstore.io/c/lethal-company/p/Rune580/LethalCompany_InputUtils) or the [Releases](https://github.com/Rune580/LethalCompanyInputUtils/releases).
Extract the zip and add a reference to the dll file of the mod in Visual Studio or Rider.
### Initializing Your Binds
- Create a **subclass of `LcInputActions`**
- An instance of this class will contain all `InputAction`s your mod wishes to bind inputs for
- Name the class appropriately
- Create InputActions [using Attributes](#using-attributes) and/or [at Runtime](#at-runtime)
```csharp
public class MyExampleInputClass : LcInputActions
{
[InputAction("<Keyboard>/g", Name = "Explode")]
public InputAction ExplodeKey { get; set; }
[InputAction("<Keyboard>/h", Name = "Another")]
public InputAction AnotherKey { get; set; }
}
```
### Using Attributes
- **Create instance properties** for all desired `InputActions`
- **Annotate** the instance properties with the `[InputAction(...)]` annotation
> [!IMPORTANT]
> For actions to be registered to the API, **Properties MUST be annotated with `[InputAction(...)]`**
>```csharp
>[InputAction("YourkbmPath", Name = "", GamepadPath = "", KbmInteractions = "", GamepadInteractions = "", ActionID = "", ActionType = InputActionType...)]
>```
#### Required Parameters
* `kbmPath`: The default bind for Keyboard and Mouse devices
#### Optional Parameters
* `Name`: The Displayed text in the game keybinds menu
* `GamepadPath`: The default bind for Gamepad devices
* `KbmInteractions`: Sets the interactions of the kbm binding. See [Interactions Docs](https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/api/UnityEngine.InputSystem.Interactions.html)
* `GamepadInteractions`: Sets the interactions of the gamepad binding. See [Interactions Docs](https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/api/UnityEngine.InputSystem.Interactions.html)
* `ActionID`: Overrides the generated actionId (Generally you don't want to change this)
* `ActionType`: Determines the behavior with which the action triggers. See [ActionType Docs](https://docs.unity3d.com/Packages/com.unity.inputsystem@1.0/api/UnityEngine.InputSystem.InputActionType.html)
So your Attribute could be written like this:
```csharp
[InputAction("<Keyboard>/minus", Name = "Explode")]
public InputAction ExplodeKey { get; set; }
```
Or with any combination of optional parameters:
```csharp
[InputAction("<Keyboard>/minus", Name = "Explode", GamepadPath = "<Gamepad>/Button North", KbmInteractions = "hold(duration = 5)")]
public InputAction ExplodeKey { get; set; }
```
> [!NOTE]
> In this case above the Hold Interaction is being used. This keybind triggers after being held for *5* seconds. See [Interactions Docs](https://docs.unity3d.com/Packages/com.unity.inputsystem@1.7/api/UnityEngine.InputSystem.Interactions.html)
### At Runtime
- **Override Method** `void CreateInputActions(in InputActionMapBuilder builder)`
- Use the builder to create InputActions
- **Reference InputAction** by calling `Asset["actionId"]` in your class
> [!IMPORTANT]
> Make sure you call `Finish()` after you're done creating each InputAction.
Here's an example usage of the runtime api
```csharp
public class MyExampleInputClass : LcInputActions
{
public static readonly MyExampleInputClass Instance = new();
public InputAction ExplodeKey => Asset["explodekey"];
public override void CreateInputActions(in InputActionMapBuilder builder)
{
builder.NewActionBinding()
.WithActionId("explodekey")
.WithActionType(InputActionType.Button)
.WithKbmPath("<Keyboard>/j")
.WithBindingName("Explode")
.Finish();
}
}
```
### Referencing Your Binds
To use your InputActions class, you need to instantiate it.
> [!IMPORTANT]
> Do **not** create more than one instance of your InputActions class.
> If your class is instantiated more than once, your InputActions are unlikely to work as intended.
The easiest (opinionated) way to do so would be to have a static instance in your plugin class.
```csharp
[BepInPlugin(...)]
[BepInDependency("com.rune580.LethalCompanyInputUtils", BepInDependency.DependencyFlags.HardDependency)]
public class MyExamplePlugin : BaseUnityPlugin
{
internal static MyExampleInputClass InputActionsInstance = new MyExampleInputClass();
}
```
You could also opt for instantiating the instance in the InputActions class (Singleton-style).
```csharp
public class MyExampleInputClass : LcInputActions
{
public static MyExampleInputClass Instance = new();
[InputAction("explodekey", "<Keyboard>/j", "<Gamepad>/Button North", Name = "Explode")]
public InputAction ExplodeKey { get; set; }
}
```
> [!IMPORTANT]
> #### But How Do I Get My Binds String?
> You may have noticed that `<keyboard>/yourKey` can be a little confusing for the special buttons. So try this:
> 1. First, arbitrarily set the value to some regular value or just an empty string
> 2. Then, load up your mod and change the keybind to the desired key
> 3. After, look in your `.../BepInEx/controls/YOURMODID.json` file
> 4. Find the `{"action":"myaction","origPath":"","path":"<Keyboard>/f8"}]}`
> 5. Last, copy that `path:""` from the far right i.e. `"<Keyboard>/f8"`
### Using Your Binds
You could then simply reference the instance anywhere you need to have your actions at.
```csharp
public class MyOtherClassOrMonoBehavior
{
public void DoSomething()
{
MyExamplePlugin.InputActionsInstance.ExplodeKey ...
}
}
```
or
```csharp
public class MyOtherClassOrMonoBehavior
{
public void DoSomething()
{
MyExampleInputClass.Instance.ExplodeKey ...
}
}
```
#### Best Practices
It is common to see tutorials call `InputAction.ReadValue<>()` or `InputAction.triggered` from mono-behaviour `Update()` functions.
```csharp
public class MyOtherClassOrMonoBehavior
{
public void Update()
{
DoSomething();
}
public void DoSomething()
{
if (!MyExamplePlugin.InputActionsInstance.ExplodeKey.triggered) return;
//Your executing code here
}
}
```
This approach is sufficient for 'continuous' actions, e.g. movement.
For 'discrete' actions, it's more appropriate to create event listeners that accept an `InputAction.CallbackContext`
and subscribe to `InputAction.performed`.
```csharp
public class MyOtherClassOrMonoBehavior
{
public void Awake()
{
SetupKeybindCallbacks();
}
// Name this whatever you like. It needs to be called exactly once, so
public void SetupKeybindCallbacks()
{
MyExamplePlugin.InputActionsInstance.ExplodeKey.performed += OnExplodeKeyPressed;
}
public void OnExplodeKeyPressed(InputAction.CallbackContext explodeConext)
{
if (!explodeConext.performed) return;
// Add more context checks if desired
// Your executing code here
}
}
```
### Using InputUtils as an Optional or Soft Dependency
First make sure to add the `[BepInDepe
没有合适的资源?快使用搜索试试~ 我知道了~
致命公司mod-by狛枝凪斗-封包v3.1.zip
共340个文件
md:60个
dll:59个
png:56个
需积分: 0 0 下载量 5 浏览量
2024-01-20
22:18:08
上传
评论
收藏 87.01MB ZIP 举报
温馨提示
致命公司mod-by狛枝凪斗-封包v3.1.zip
资源推荐
资源详情
资源评论
收起资源包目录
致命公司mod-by狛枝凪斗-封包v3.1.zip (340个子文件)
animationsbundle 2.45MB
animatorbundle 165KB
arialuni.cfg 27.82MB
Terminal-Translate.cfg 102KB
NewTerminal-Verbs.cfg 85KB
Normal-Translate.cfg 43KB
com.malco.lethalcompany.moreshipupgrades.cfg 27KB
SpecialText-Translate.cfg 14KB
NewTerminal-Other.cfg 8KB
FlipMods.TooManyEmotes.cfg 7KB
Item-Translate.cfg 7KB
HUD-Translate.cfg 7KB
BepInEx.cfg 5KB
NewTerminal-Special.cfg 5KB
MaskedEnemyRework.cfg 3KB
Stoneman.LethalProgression.cfg 3KB
Junypai.GamblersMod.cfg 2KB
EmployeeAssignments.cfg 2KB
CMD-ZH-Translate.cfg 2KB
HDLethalCompany.cfg 2KB
GuiText-Translate.cfg 2KB
RugbugRedfern.SkinwalkerMod.cfg 2KB
x753.Mimics.cfg 1KB
me.eladnlg.customhud.cfg 1KB
Haha.DynamicDeadline.cfg 1KB
com.github.lethalmods.lethalexpansioncore.cfg 1KB
BetterTeleporter.cfg 1KB
MoreEmotes.cfg 1KB
CMD-PY-Translate.cfg 1KB
Electric.OuijaBoard.cfg 901B
x753.More_Suits.cfg 895B
FlipMods.ReservedItemSlotCore.cfg 871B
com.elitemastereric.coroner.cfg 779B
LethalPresents.cfg 770B
FlipMods.ReservedFlashlightSlot.cfg 605B
FlipMods.ReservedWalkieSlot.cfg 580B
HookGenPatcher.cfg 500B
FlipMods.ObjectVolumeController.cfg 466B
evaisa.lethallib.cfg 382B
suskitech.LCAlwaysHearActiveWalkie.cfg 374B
NewTerminal-Unused.cfg 351B
SpectateEnemy.cfg 345B
boombox.cfg 324B
gravydevsupreme.xunity.resourceredirector.cfg 316B
twig.latecompany.cfg 283B
MegaPiggy.BuyableShotgunShells.cfg 243B
chainloader_typeloader.dat 18KB
harmony_interop_cache.dat 11KB
MoreCompany.dll 9.88MB
Mimics.dll 6.72MB
MMHOOK_Assembly-CSharp.dll 2.61MB
MMHOOK_Facepunch.Steamworks.Win64.dll 1.97MB
LCOuijaBoard.dll 575KB
MMHOOK_AmazingAssets.TerrainToMesh.dll 463KB
MMHOOK_DissonanceVoip.dll 409KB
Mono.Cecil.dll 332KB
EladsHUD.dll 256KB
0Harmony.dll 200KB
MonoMod.Utils.dll 184KB
SkinwalkerMod.dll 126KB
BepInEx.dll 123KB
TooManyEmotes.dll 118KB
0Harmony20.dll 109KB
MonoMod.RuntimeDetour.dll 104KB
Mono.Cecil.Pdb.dll 85KB
LethalLib.dll 75KB
XUnity.Common.dll 66KB
MonoMod.dll 65KB
LethalLevelLoader.dll 62KB
GameTranslator.dll 54KB
LethalProgression.dll 52KB
ReservedItemSlotCore.dll 50KB
Coroner.dll 48KB
LethalCompanyInputUtils.dll 46KB
GamblersMod.dll 44KB
EmployeeAssignments.dll 42KB
Mono.Cecil.Mdb.dll 42KB
BepInEx.Preloader.dll 42KB
MoreEmotes1.3.3.dll 41KB
NicholaScott.BepInEx.RuntimeNetcodeRPCValidator.dll 30KB
Mono.Cecil.Rocks.dll 27KB
MaskedEnemyRework.dll 26KB
winhttp.dll 25KB
winhttp.dll 25KB
MonoMod.RuntimeDetour.HookGen.dll 23KB
HarmonyXInterop.dll 23KB
SpectateEnemy.dll 21KB
MMHOOK_Facepunch Transport for Netcode for GameObjects.dll 20KB
BetterTeleporter.dll 19KB
ReservedFlashlightSlot.dll 18KB
ReservedWalkieSlot.dll 17KB
HDLethalCompany.dll 17KB
MoreSuits.dll 16KB
CustomBoomboxTracks.dll 14KB
ObjectVolumeController.dll 13KB
LethalPresents.dll 12KB
LateCompanyV1.0.10.dll 12KB
AlwaysHearWalkie.dll 11KB
AdditionalContentFramework.dll 11KB
ShipLoot.dll 10KB
共 340 条
- 1
- 2
- 3
- 4
资源评论
2401_82490636
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功