# 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
没有合适的资源?快使用搜索试试~ 我知道了~
V49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.ra
共796个文件
webp:174个
png:122个
md:119个
需积分: 0 3 下载量 31 浏览量
2024-01-18
07:31:25
上传
评论
收藏 298.33MB RAR 举报
温馨提示
V49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.
资源推荐
资源详情
资源评论
收起资源包目录
V49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.rarV49 9.0.2.ra (796个子文件)
animationsbundle 2.45MB
animatorbundle 165KB
FlipMods.TooManyEmotes.cfg 7KB
BepInEx.cfg 5KB
Chaos.Diversity.cfg 4KB
evaisa.lethalthings.cfg 4KB
me.pm.TheDeadSnake.cfg 3KB
ScoopysVarietyMod.cfg 3KB
MaskedEnemyRework.cfg 3KB
ShaosilGaming.GeneralImprovements.cfg 2KB
LethalThings.AudioVolume.cfg 2KB
Junypai.GamblersMod.cfg 2KB
Bits.StrangeObjects.cfg 2KB
Dreamweave.CompanyBuildingEnhancements.cfg 2KB
Jordo.NeedyCats.cfg 2KB
FlipMods.HotbarPlus.cfg 2KB
HDLethalCompany.cfg 2KB
Kittenji.DontTouchMe.cfg 2KB
Symbiosis.cfg 2KB
com.github.fredolx.meteomultiplier.cfg 2KB
InfiniteEmote.cfg 2KB
RugbugRedfern.SkinwalkerMod.cfg 2KB
x753.Mimics.cfg 1KB
me.eladnlg.customhud.cfg 1KB
chillax.bastard.mod.cfg 1KB
Frack.DarkMist.cfg 1KB
EmployeeAssignments.cfg 1KB
MoreEmotes.cfg 1KB
Electric.OuijaBoard.cfg 900B
x753.More_Suits.cfg 895B
FlipMods.ReservedItemSlotCore.cfg 870B
LethalPresents.cfg 811B
Rocksnotch.IncreasedDeadlines.cfg 682B
RickArg.lethalcompany.helmetcameras.cfg 675B
FlipMods.ReservedFlashlightSlot.cfg 604B
FlipMods.ReservedWalkieSlot.cfg 580B
PushCompany.cfg 562B
SpectateEnemy.cfg 392B
com.elitemastereric.garagedoorfix.cfg 390B
SalakStudios.BetterShotgunShells.cfg 388B
evaisa.lethallib.cfg 382B
suskitech.LCAlwaysHearActiveWalkie.cfg 374B
Hotoni.TZPHEAL.cfg 351B
HookGenPatcher.cfg 339B
boombox.cfg 324B
me.kdcf.termspeak.cfg 318B
ShaosilGaming.FlashlightFix.cfg 301B
twig.latecompany.cfg 283B
atomic.terminalapi.cfg 282B
FlipMods.ReservedSprayPaintSlot.cfg 267B
jamil.corporate_restructure.cfg 263B
atomic.terminalclock.cfg 248B
QuickRestart.cfg 234B
Mhz.disableunitylogs.cfg 230B
Pinta.PintoBoy.cfg 199B
VoiceHUD.cfg 125B
chillaxbundle 8.52MB
stardust-video.0.8a8937eeb2b2c3216dcd9e09a643c16b6e8482c5.css 692KB
style.css 152KB
regular.css 38KB
medium.css 38KB
iconfont.css 25KB
light_u.css 3KB
light.css 3KB
bp-icon-font.css 2KB
map.css 908B
harmony_interop_cache.dat 92KB
chainloader_typeloader.dat 23KB
diversity 36.51MB
MoreHead.dll 16.68MB
MoreCompany.dll 9.88MB
NeedyCats.dll 9.68MB
Mimics.dll 6.72MB
DontTouchMe.dll 5.37MB
LocalizationCore_BepInEx5.dll 3.04MB
MMHOOK_Assembly-CSharp.dll 2.61MB
PintoBoy.dll 1.8MB
Symbiosis.dll 575KB
LCOuijaBoard.dll 573KB
Mono.Cecil.dll 332KB
EladsHUD.dll 256KB
0Harmony.dll 200KB
MonoMod.Utils.dll 184KB
LethalThings.dll 170KB
BepInEx.dll 125KB
TooManyEmotes.dll 114KB
SkinwalkerMod.dll 113KB
0Harmony20.dll 109KB
MonoMod.RuntimeDetour.dll 104KB
Diversity.dll 93KB
Mono.Cecil.Pdb.dll 85KB
LethalLib.dll 68KB
MonoMod.dll 65KB
LethalLevelLoader.dll 54KB
ReservedItemSlotCore.dll 45KB
Mono.Cecil.Mdb.dll 42KB
BepInEx.Preloader.dll 42KB
MoreEmotes1.3.2.dll 40KB
GamblersMod.dll 40KB
CompanyBuildingEnhancements.dll 35KB
共 796 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
酸奶公园
- 粉丝: 798
- 资源: 51
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于Java的医药管理系统.zip
- (源码)基于Java和MySQL的学生信息管理系统.zip
- (源码)基于ASP.NET Core的零售供应链管理系统.zip
- (源码)基于PythonSpleeter的戏曲音频处理系统.zip
- (源码)基于Spring Boot的监控与日志管理系统.zip
- (源码)基于C++的Unix V6++二级文件系统.zip
- (源码)基于Spring Boot和JPA的皮皮虾图片收集系统.zip
- (源码)基于Arduino和Python的实时歌曲信息液晶显示屏展示系统.zip
- (源码)基于C++和C混合模式的操作系统开发项目.zip
- (源码)基于Arduino的全球天气监控系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功