Skip to content

Commit

Permalink
chore: add check for ReservedItemSlotCore
Browse files Browse the repository at this point in the history
Release-as: 1.4.3
  • Loading branch information
Hypick122 committed Feb 28, 2024
1 parent e83b16f commit 17f556a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion BetterShotgun/BetterShotgun.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<AssemblyName>Hypick.BetterShotgun</AssemblyName>
<Product>BetterShotgun</Product>
<Version>1.4.2</Version>
<Version>1.4.3</Version>

<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
Expand Down
5 changes: 3 additions & 2 deletions BetterShotgun/Patches/ShotgunItemPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Reflection.Emit;
using HarmonyLib;
using UnityEngine;
using UnityEngine.InputSystem;

namespace Hypick.Patches;

Expand Down Expand Up @@ -67,12 +68,12 @@ private static string GetCustomTooltip(ShotgunItem item)
var newToolTips = Plugin.Config.AmmoCheckAnimation ? "Reload / Check" : "Reload";

if (!Plugin.Config.ShowAmmoCount)
return $"{newToolTips}: [{Plugin.Config.ReloadKeybind.ToUpper()}]";
return $"{newToolTips}: [{Plugin.InputActionsInstance.ReloadKey.GetBindingDisplayString()}]";

var maxAmmo = Plugin.Config.ReloadNoLimit ? "" : "2";
var ammoInfo = Plugin.Config.InfiniteAmmo ? "" : $"{item.shellsLoaded}/{maxAmmo}";

return $"{newToolTips} ({ammoInfo}): [{Plugin.Config.ReloadKeybind.ToUpper()}]";
return $"{newToolTips} ({ammoInfo}): [{Plugin.InputActionsInstance.ReloadKey.GetBindingDisplayString()}]";
}

# endregion
Expand Down
17 changes: 13 additions & 4 deletions BetterShotgun/Plugin.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
Expand All @@ -24,7 +25,7 @@ public class Plugin : BaseUnityPlugin

private readonly Harmony _harmony = new(PluginInfo.PLUGIN_GUID);

private static Keybinds InputActionsInstance = new Keybinds();
public static readonly Keybinds InputActionsInstance = new Keybinds();

private List<Item> AllItems => Resources.FindObjectsOfTypeAll<Item>()
.Concat(FindObjectsByType<Item>(FindObjectsInactive.Include, FindObjectsSortMode.InstanceID)).ToList();
Expand All @@ -45,7 +46,6 @@ private void Awake()

SceneManager.sceneLoaded += OnSceneLoaded;

Log.LogInfo($"Applying patches...");
_harmony.PatchAll();
Log.LogInfo($"Patches applied");

Expand All @@ -56,7 +56,15 @@ private void Awake()

public void SetupKeybindCallbacks()
{
InputActionsInstance.ReloadKey.AddBinding($"<keyboard>/{Config.ReloadKeybind}");
var key = Config.ReloadKeybind;
if (Chainloader.PluginInfos.ContainsKey("FlipMods.ReservedItemSlotCore"))
{
key = "E";
Log.LogWarning("ReservedItemSlotCore detected, ReloadKeybind set to default value (E)");
}

InputActionsInstance.ReloadKey.AddBinding($"<keyboard>/{key}");

if (Config.ReloadKeybind.Replace("<keyboard>/", "") != "e")
{
Log.LogInfo($"Start ReloadKeybind with key {InputActionsInstance.ReloadKey.GetBindingDisplayString()}");
Expand All @@ -66,7 +74,8 @@ public void SetupKeybindCallbacks()

public void OnReloadKeyPressed(InputAction.CallbackContext context)
{
if (!context.performed || GameNetworkManager.Instance == null || GameNetworkManager.Instance.localPlayerController == null)
if (!context.performed || GameNetworkManager.Instance == null ||
GameNetworkManager.Instance.localPlayerController == null)
return;

PlayerControllerB player = GameNetworkManager.Instance.localPlayerController;
Expand Down
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

## [1.4.2](https://github.com/Hypick122/BetterShotgun/compare/v1.4.1...v1.4.2) (2024-02-25)


### Miscellaneous Chores

* minor changes ([ff5cbfe](https://github.com/Hypick122/BetterShotgun/commit/ff5cbfe71b6d20ceea475bf27323bbce7a7449cf))
* AmmoCheckAnimation changed from "true" to "false" by default
* Changed the name of shotgun ammo in the store from "Ammo" to "Shell"
* Added more logging

## [1.4.1](https://github.com/Hypick122/BetterShotgun/compare/v1.4.0...v1.4.1) (2024-02-18)

Expand Down
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Available settings in the config:
- **[BETA]** AmmoCheckAnimation (default = false)
- Adds ammo check animation to the reload button
- ReloadKeybind (default = false, vanilla = E)
- Changes the reload key to the one you set
- Changes the reload key to the one you set (incompatible with ReservedItemSlotCore)
- ReloadNoLimit (default = false)
- Allows you to endlessly reload your shotgun
- SkipReloadAnimation (default = false)
Expand Down Expand Up @@ -93,7 +93,7 @@ Available settings in the config:
- **[BETA]** AmmoCheckAnimation (по умолчанию = false)
- Добавляет анимацию проверки патронов на кнопку перезарядки
- ReloadKeybind (по умолчанию = false, ванилла = E)
- Меняет клавишу перезарядки на установленную вами
- Меняет клавишу перезарядки на установленную вами (несовместимо с ReservedItemSlotCore)
- ReloadNoLimit (по умолчанию = false)
- Позволяет бесконечно перезаряжать дробовик
- SkipReloadAnimation (по умолчанию = false)
Expand Down Expand Up @@ -129,9 +129,7 @@ This project is licensed under the [MIT License](https://github.com/Hypick122/Be

## Latest version

### [1.4.2](https://github.com/Hypick122/BetterShotgun/compare/v1.4.1...v1.4.2) (2024-02-26)
### [1.4.3](https://github.com/Hypick122/BetterShotgun/compare/v1.4.1...v1.4.2) (2024-02-28)

- AmmoCheckAnimation changed from "true" to "false" by default
- Changed the name of shotgun ammo in the store from "Ammo" to "Shell"
- Added more logging
- Added check for the presence of ReservedItemSlotCore. If it is set, then ReloadKeybind is set to [E]

0 comments on commit 17f556a

Please sign in to comment.