Skip to content

Commit

Permalink
also show durability of raw knife
Browse files Browse the repository at this point in the history
  • Loading branch information
sp00ktober committed Aug 10, 2022
1 parent f8070a7 commit e292a57
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ For support or to discuss any other modding related topic you can join our [Star

## Changelog

0.0.4:

- include raw knife (the first tool you craft)

0.0.3:

- fix wrong durability value for iron axe
Expand Down
10 changes: 10 additions & 0 deletions ShowDurability/Patches/Dynamic/Slot_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace ShowDurability.Patches.Dynamic
[HarmonyPatch(typeof(Slot))]
class Slot_Patch
{
static float MAX_HEALTH_PRIMITIVE = 200f;
static float MAX_HEALTH_WOOD = 300f;
static float MAX_HEALTH_IRON = 600f;

Expand All @@ -30,6 +31,15 @@ public static void Refresh_Postfix(Slot __instance)

bar.SetFillAmount(__instance.CurrentItem.GetPropertyValue("Durability").Float.Current / MAX_HEALTH_IRON);

__instance.Refreshed.Send(__instance);
}
else if(__instance?.CurrentItem?.Name == "RAW KNIFE")
{
DurabilityBar bar = (DurabilityBar)AccessTools.Field(typeof(Slot), "m_DurabilityBar").GetValue(__instance);
bar.SetActive(true);

bar.SetFillAmount(__instance.CurrentItem.GetPropertyValue("Durability").Float.Current / MAX_HEALTH_PRIMITIVE);

__instance.Refreshed.Send(__instance);
}
}
Expand Down
4 changes: 2 additions & 2 deletions ShowDurability/ShowDurability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace ShowDurability
{
[BepInPlugin("com.sp00ktober.ShowDurability", "ShowDurability", "0.0.3")]
[BepInPlugin("com.sp00ktober.ShowDurability", "ShowDurability", "0.0.4")]
public class ShowDurability : BaseUnityPlugin
{
private void Awake()
Expand All @@ -20,7 +20,7 @@ private static void InitPatches()

try
{
Debug.Log("Applying patches from ShowDurability 0.0.3");
Debug.Log("Applying patches from ShowDurability 0.0.4");

Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.sp00ktober.de");

Expand Down
2 changes: 1 addition & 1 deletion ShowDurability/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ShowDurability",
"description": "BepInEx mod for Starsand to show the durability of some tools which have it normally hidden.",
"version_number": "0.0.3",
"version_number": "0.0.4",
"dependencies": [
"BepInEx-BepInExPack_Starsand-5.4.16"
],
Expand Down

0 comments on commit e292a57

Please sign in to comment.