-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* SetAmmo&CategoryLimit * Patch for GetAmmoLimit * CringeCodeButFunctional * Cringe 2 * Fix documentation * Fixes * changes * SetAmmoLimit partial fix * AddOperation error fix * Fix `SetAmmoLimit` `SetCategoryLimit` * fixes * Custom limits with armor * unused using * unused using * ResetCustomLimit check using method --------- Co-authored-by: Nameless <[email protected]> Co-authored-by: Ika <[email protected]>
- Loading branch information
1 parent
3bb2e28
commit 79a268c
Showing
5 changed files
with
240 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="GetCustomAmmoLimit.cs" company="Exiled Team"> | ||
// Copyright (c) Exiled Team. All rights reserved. | ||
// Licensed under the CC BY-SA 3.0 license. | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
namespace Exiled.Events.Patches.Fixes | ||
{ | ||
using System; | ||
|
||
using Exiled.API.Extensions; | ||
using Exiled.API.Features; | ||
using HarmonyLib; | ||
using InventorySystem.Configs; | ||
using UnityEngine; | ||
|
||
/// <summary> | ||
/// Patches the <see cref="InventoryLimits.GetAmmoLimit(ItemType, ReferenceHub)"/> delegate. | ||
/// Sync <see cref="Player.SetAmmoLimit(API.Enums.AmmoType, ushort)"/>. | ||
/// Changes <see cref="ushort.MaxValue"/> to <see cref="ushort.MinValue"/>. | ||
/// </summary> | ||
[HarmonyPatch(typeof(InventoryLimits), nameof(InventoryLimits.GetAmmoLimit), new Type[] { typeof(ItemType), typeof(ReferenceHub) })] | ||
internal static class GetCustomAmmoLimit | ||
{ | ||
#pragma warning disable SA1313 | ||
private static void Postfix(ItemType ammoType, ReferenceHub player, ref ushort __result) | ||
{ | ||
if (!Player.TryGet(player, out Player ply) || !ply.CustomAmmoLimits.TryGetValue(ammoType.GetAmmoType(), out ushort limit)) | ||
return; | ||
|
||
__result = (ushort)Mathf.Clamp(limit + __result - InventoryLimits.GetAmmoLimit(null, ammoType), ushort.MinValue, ushort.MaxValue); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="GetCustomCategoryLimit.cs" company="Exiled Team"> | ||
// Copyright (c) Exiled Team. All rights reserved. | ||
// Licensed under the CC BY-SA 3.0 license. | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
namespace Exiled.Events.Patches.Fixes | ||
{ | ||
using System; | ||
|
||
using Exiled.API.Features; | ||
using HarmonyLib; | ||
using InventorySystem.Configs; | ||
using UnityEngine; | ||
|
||
/// <summary> | ||
/// Patches the <see cref="InventoryLimits.GetCategoryLimit(ItemCategory, ReferenceHub)"/> delegate. | ||
/// Sync <see cref="Player.SetCategoryLimit(ItemCategory, sbyte)"/>, . | ||
/// Changes <see cref="ushort.MaxValue"/> to <see cref="ushort.MinValue"/>. | ||
/// </summary> | ||
[HarmonyPatch(typeof(InventoryLimits), nameof(InventoryLimits.GetCategoryLimit), new Type[] { typeof(ItemCategory), typeof(ReferenceHub), })] | ||
internal static class GetCustomCategoryLimit | ||
{ | ||
#pragma warning disable SA1313 | ||
private static void Postfix(ItemCategory category, ReferenceHub player, ref sbyte __result) | ||
{ | ||
if (!Player.TryGet(player, out Player ply) || !ply.CustomCategoryLimits.TryGetValue(category, out sbyte limit)) | ||
return; | ||
|
||
__result = (sbyte)Mathf.Clamp(limit + __result - InventoryLimits.GetCategoryLimit(null, category), sbyte.MinValue, sbyte.MaxValue); | ||
} | ||
} | ||
} |