fix: Fixes NPC slowness. (#955)

* Adds the following configurations:
  * `movement.delay.npcMinDelay` - 0.1 - Pets or Non-monster NPCs
  * `movement.delay.npcMaxDelay` - 0.4 - Pets or Non-monster NPCs
  * `movement.delay.monsterMinDelay` - 0.4 - Non-pet Monsters or NPC vs Player Combat
  * `movement.delay.monsterMaxDelay` - 0.8 - Non-pet Monsters or NPC vs Player Combat
  * `movement.delay.monsterMinDex` - 150 - Dex maximum for delay by dex
  * `movement.delay.MinDex` - 190 - Dex maximum for delay by dex
This commit is contained in:
Kamron Batman 2022-03-10 22:55:06 -08:00 committed by GitHub
parent 44bd129734
commit bdee7bc671
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
357 changed files with 767 additions and 962 deletions

View file

@ -67,6 +67,12 @@ public static class ServerConfiguration
return Enum.TryParse(strValue, out T value) ? value : defaultValue;
}
public static double GetSetting(string key, double defaultValue)
{
m_Settings.Settings.TryGetValue(key, out var strValue);
return double.TryParse(strValue, out var value) ? value : defaultValue;
}
public static T? GetSetting<T>(string key) where T : struct, Enum
{
if (!m_Settings.Settings.TryGetValue(key, out var strValue))
@ -168,6 +174,24 @@ public static class ServerConfiguration
return value;
}
public static double GetOrUpdateSetting(string key, double defaultValue)
{
double value;
if (m_Settings.Settings.TryGetValue(key, out var strValue))
{
value = double.TryParse(strValue, out value) ? value : defaultValue;
}
else
{
SetSetting(key, (value = defaultValue).ToString());
}
return value;
}
public static void SetSetting(string key, double value) => SetSetting(key, value.ToString());
public static void SetSetting(string key, TimeSpan value) => SetSetting(key, value.ToString());
public static void SetSetting(string key, int value) => SetSetting(key, value.ToString());