Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[API] Fix issues #2673

Merged
merged 2 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions Exiled.API/Features/CustomStats/CustomHumeShieldStat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ namespace Exiled.API.Features.CustomStats
/// </summary>
public class CustomHumeShieldStat : HumeShieldStat
{
private const float DefaultCustomValue = -1;

/// <inheritdoc/>
public override float MaxValue => CustomMaxValue == default ? base.MaxValue : CustomMaxValue;
public override float MaxValue => CustomMaxValue == DefaultCustomValue ? base.MaxValue : CustomMaxValue;

/// <summary>
/// Gets or sets the multiplier for gaining HumeShield.
Expand All @@ -29,14 +31,14 @@ public class CustomHumeShieldStat : HumeShieldStat
/// <summary>
/// Gets or sets the maximum amount of HumeShield the player can have.
/// </summary>
public float CustomMaxValue { get; set; }
public float CustomMaxValue { get; set; } = DefaultCustomValue;

private float ShieldRegeneration => TryGetHsModule(out HumeShieldModuleBase controller) ? controller.HsRegeneration * ShieldRegenerationMultiplier : 0;

/// <inheritdoc/>
public override void Update()
{
if (MaxValue == default)
if (MaxValue == DefaultCustomValue)
{
base.Update();
return;
Expand Down Expand Up @@ -66,13 +68,7 @@ public override void Update()
if (CurValue >= MaxValue)
return;
CurValue = Mathf.MoveTowards(CurValue, MaxValue, delta);
return;
}

if (CurValue <= 0)
return;

CurValue += delta;
}
}
}
2 changes: 1 addition & 1 deletion Exiled.API/Features/DamageHandlers/CustomDamageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public CustomDamageHandler(Player target, BaseHandler baseHandler)
else if (Attacker.CurrentItem is not null && Attacker.CurrentItem.Type.IsWeapon() && baseHandler is BaseFirearmHandler)
CustomBase = new FirearmDamageHandler(Attacker.CurrentItem, target, baseHandler);
else
CustomBase = new DamageHandler(target, Attacker);
CustomBase = new DamageHandler(target, baseHandler);
}
else
{
Expand Down
Loading