Skip to content
This repository has been archived by the owner on Jan 19, 2025. It is now read-only.

Commit

Permalink
Fix TotalCharges setter in WearState
Browse files Browse the repository at this point in the history
  • Loading branch information
ITeMbI4 committed Jul 19, 2024
1 parent 244d90e commit bbcb09e
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions Exiled.API/Features/Items/Jailbird.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ public JailbirdWearState WearState
get => Base._deterioration.WearState;
set
{
TotalCharges = (int)value;
TotalDamageDealt = GetDamage(value);
TotalCharges = GetCharge(value);
Base._deterioration.RecheckUsage();
}
}
Expand Down Expand Up @@ -150,22 +150,6 @@ public float GetDamage(JailbirdWearState wearState)
throw new Exception("Wear state not found in charges to wear state mapping.");
}

/// <summary>
/// Gets the charge needed to reach a specific <see cref="JailbirdWearState"/>.
/// </summary>
/// <param name="wearState">The desired wear state to calculate the charge for.</param>
/// <returns>The charge value required to achieve the specified wear state.</returns>
public int GetCharge(JailbirdWearState wearState)
{
foreach (Keyframe keyframe in Base._deterioration._chargesToWearState.keys)
{
if (Base._deterioration.FloatToState(keyframe.value) == wearState)
return Mathf.RoundToInt(keyframe.time);
}

throw new Exception("Wear state not found in charges to wear state mapping.");
}

/// <summary>
/// Resets the Jailbird to normal.
/// </summary>
Expand Down

0 comments on commit bbcb09e

Please sign in to comment.