Skip to content

Instantly share code, notes, and snippets.

@Kriknav
Created February 9, 2019 21:38
Show Gist options
  • Save Kriknav/3a34926fbbe1c0d31e40066bf67770c1 to your computer and use it in GitHub Desktop.
Save Kriknav/3a34926fbbe1c0d31e40066bf67770c1 to your computer and use it in GitHub Desktop.
SmartHunter ShowUnchanged patch
diff --git a/SmartHunter/Game/Data/Monster.cs b/SmartHunter/Game/Data/Monster.cs
index a52830e..178e318 100644
--- a/SmartHunter/Game/Data/Monster.cs
+++ b/SmartHunter/Game/Data/Monster.cs
@@ -245,19 +245,26 @@ namespace SmartHunter.Game.Data
static bool CanShow(DateTimeOffset initialTime, DateTimeOffset? lastChangedTime, bool showUnchanged, float hideAfterSeconds)
{
- if (!showUnchanged && lastChangedTime == null)
+ // Special cases that don't require any time calculations:
+ // If the user always wants to see unchanged parts, return true
+ if (showUnchanged)
{
- return false;
+ return true;
}
- DateTimeOffset time = initialTime;
- if (lastChangedTime != null)
+ // NOTE: There could be another config option added AlwaysShowChanged(StatusEffects|Parts) that hides the bar until it changes for the first time
+ // then always shows it, this could then replace the if statement above
+ //if (showUnchanged || (alwaysShowChanged && lastChangedTime != null))
+ //{ return true; }
+
+ // ...but if they just want to see changed parts, but this one has never changed, no need to calculate either, return false
+ else if (lastChangedTime == null)
{
- time = lastChangedTime.Value;
- }
+ return false;
+ }
- var hideTime = time.AddSeconds(hideAfterSeconds);
- if (hideTime < DateTimeOffset.UtcNow)
+ // User wants to see only changed, and this one has changed, so figure out if it's visible or hidden based on timeout setting
+ if ((lastChangedTime ?? initialTime).AddSeconds(hideAfterSeconds) < DateTimeOffset.UtcNow)
{
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment