Skip to content

Commit

Permalink
add ReservedWeaponSlot support (#22)
Browse files Browse the repository at this point in the history
Release-as: 1.4.4
  • Loading branch information
Hypick122 committed Mar 4, 2024
1 parent 72497b3 commit 6a6d347
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions BetterShotgun/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,25 @@ public void OnReloadKeyPressed(InputAction.CallbackContext context)
item.StartReloadGun();
}

public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
if (_isLoaded || scene.name != "MainMenu")
return;

_isLoaded = true;
RegisterItem(Shotgun, "Shotgun", Config.ShotgunMaxDiscount, Config.ShotgunMinValue, Config.ShotgunMaxValue,
Config.ShotgunWeight, Config.ShotgunPrice, Config.ShotgunRarity);
RegisterItem(ShotgunShell, "Shell", Config.ShellMaxDiscount, Config.ShellMinValue, Config.ShellMaxValue, 0,
Config.ShellPrice, Config.ShellRarity);
if (!_isLoaded && scene.name == "MainMenu")
{
_isLoaded = true;

var ammoName = Config.ShellName;
if (Chainloader.PluginInfos.ContainsKey("FlipMods.ReservedWeaponSlot"))
{
ammoName = "Ammo";
Log.LogWarning(
"ReservedWeaponSlot detected, the name of the cartridges changes from \"Shell\" to \"Ammo\"");
}

RegisterItem(Shotgun, "Shotgun", Config.ShotgunMaxDiscount, Config.ShotgunMinValue, Config.ShotgunMaxValue,
Config.ShotgunWeight, Config.ShotgunPrice, Config.ShotgunRarity);
RegisterItem(ShotgunShell, ammoName, Config.ShellMaxDiscount, Config.ShellMinValue, Config.ShellMaxValue, 0,
Config.ShellPrice, Config.ShellRarity);
}
}

private static void RegisterItem(Item item, string name, int maxDiscount, int minValue, int maxValue, int weight,
Expand Down

0 comments on commit 6a6d347

Please sign in to comment.