Decompiled source of EmeraudeFaune v1.2.1

plugins/EmeraudeFaune.dll

Decompiled 4 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EmeraudeFaune")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1+15549a9c399d1298b13aea7b8247a1519354880a")]
[assembly: AssemblyProduct("EmeraudeFaune")]
[assembly: AssemblyTitle("EmeraudeFaune")]
[assembly: AssemblyVersion("1.2.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace EmeraudeFaune
{
	internal static class Breeding
	{
		internal static readonly HashSet<string> Species = new HashSet<string> { "Lox", "Wolf" };

		internal const float FedDuration = 300f;

		internal static readonly Dictionary<string, float> VanillaFedDuration = new Dictionary<string, float>();

		internal static void RecordVanillaSatiety()
		{
			foreach (string item in Species)
			{
				GameObject prefab = PrefabManager.Instance.GetPrefab(item);
				Tameable val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<Tameable>() : null);
				if (!Object.op_Implicit((Object)(object)val))
				{
					Plugin.Log.LogWarning((object)("Satiété : " + item + " sans Tameable, ignoré"));
					continue;
				}
				VanillaFedDuration[item] = val.m_fedDuration;
				Plugin.Log.LogInfo((object)$"Satiété {item} : {val.m_fedDuration:0} s sauvage, {300f:0} s apprivoisé");
			}
		}
	}
	[HarmonyPatch(typeof(Tameable), "IsHungry")]
	internal static class TamedHungerPatch
	{
		private static void Prefix(Tameable __instance)
		{
			if (Breeding.VanillaFedDuration.TryGetValue(Utils.GetPrefabName(((Component)__instance).gameObject), out var value))
			{
				__instance.m_fedDuration = (__instance.IsTamed() ? 300f : value);
			}
		}
	}
	[HarmonyPatch(typeof(Procreation), "Procreate")]
	internal static class ProcreatePatch
	{
		private static readonly Func<Procreation, bool> IsPregnant = AccessTools.MethodDelegate<Func<Procreation, bool>>(AccessTools.Method(typeof(Procreation), "IsPregnant", (Type[])null, (Type[])null), (object)null, true);

		private static readonly Func<Procreation, bool> IsDue = AccessTools.MethodDelegate<Func<Procreation, bool>>(AccessTools.Method(typeof(Procreation), "IsDue", (Type[])null, (Type[])null), (object)null, true);

		private static void Prefix(Procreation __instance, Character ___m_character, ZNetView ___m_nview, out int __state)
		{
			__state = __instance.m_minOffspringLevel;
			if (Object.op_Implicit((Object)(object)___m_character) && Object.op_Implicit((Object)(object)___m_nview) && ___m_nview.IsValid() && ___m_nview.IsOwner())
			{
				string prefabName = Utils.GetPrefabName(((Component)__instance).gameObject);
				if (Breeding.Species.Contains(prefabName) && IsPregnant(__instance) && IsDue(__instance))
				{
					int level = ___m_character.GetLevel();
					int num = Math.Max(__instance.m_minOffspringLevel = Rules.OffspringMinLevel(level, Random.value, __state), level);
					Plugin.Log.LogInfo((object)$"Naissance {prefabName} : mère niveau {level}, petit niveau {num} ({num - 1} étoile(s))");
				}
			}
		}

		private static void Finalizer(Procreation __instance, int __state)
		{
			__instance.m_minOffspringLevel = __state;
		}
	}
	internal static class Drops
	{
		private static readonly Dictionary<string, List<Drop>> Vanilla = new Dictionary<string, List<Drop>>();

		internal static bool Ready;

		private static string applied;

		internal static void Apply(string text)
		{
			if (!Ready || text == applied)
			{
				return;
			}
			applied = text;
			LootRules.Result result = LootRules.Parse(text);
			foreach (string error in result.Errors)
			{
				Plugin.Log.LogWarning((object)("Butin : règle ignorée " + error));
			}
			foreach (string item in Vanilla.Keys.ToList())
			{
				CharacterDrop val = Find(item);
				if (Object.op_Implicit((Object)(object)val))
				{
					val.m_drops = Copy(Vanilla[item]);
				}
			}
			List<string> list = new List<string>();
			foreach (IGrouping<string, LootRule> item2 in from r in result.Rules
				group r by r.Creature)
			{
				CharacterDrop val2 = Find(item2.Key);
				if (!Object.op_Implicit((Object)(object)val2))
				{
					Plugin.Log.LogWarning((object)("Butin : créature " + item2.Key + " introuvable, ignorée"));
					continue;
				}
				if (!Vanilla.ContainsKey(item2.Key))
				{
					Vanilla[item2.Key] = Copy(val2.m_drops);
				}
				foreach (LootRule item3 in item2)
				{
					ApplyRule(val2, item3);
				}
				list.Add(item2.Key);
			}
			Plugin.Log.LogInfo((object)$"Butin : {result.Rules.Count} règle(s) lue(s), {result.Errors.Count} ignorée(s)");
			foreach (string item4 in list)
			{
				Plugin.Log.LogInfo((object)("Butin " + item4 + " : " + Describe(Find(item4).m_drops)));
			}
			foreach (string item5 in Vanilla.Keys.Except(list))
			{
				Plugin.Log.LogInfo((object)("Butin " + item5 + " : table du jeu de base rendue"));
			}
		}

		private static CharacterDrop Find(string creature)
		{
			GameObject prefab = PrefabManager.Instance.GetPrefab(creature);
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				return null;
			}
			return prefab.GetComponent<CharacterDrop>();
		}

		private static List<Drop> Copy(IEnumerable<Drop> drops)
		{
			return drops.Select((Func<Drop, Drop>)((Drop d) => new Drop
			{
				m_prefab = d.m_prefab,
				m_amountMin = d.m_amountMin,
				m_amountMax = d.m_amountMax,
				m_chance = d.m_chance,
				m_onePerPlayer = d.m_onePerPlayer,
				m_levelMultiplier = d.m_levelMultiplier,
				m_levelMultiplierNotAmount = d.m_levelMultiplierNotAmount,
				m_dontScale = d.m_dontScale
			})).ToList();
		}

		private static void ApplyRule(CharacterDrop drops, LootRule rule)
		{
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			Drop val = ((IEnumerable<Drop>)drops.m_drops).FirstOrDefault((Func<Drop, bool>)((Drop d) => Object.op_Implicit((Object)(object)d.m_prefab) && ((Object)d.m_prefab).name == rule.Item));
			if (val == null)
			{
				if (!rule.Add)
				{
					Plugin.Log.LogWarning((object)("Butin : " + rule.Item + " absent de " + rule.Creature + ", ignoré (écrire +" + LootRules.Describe(rule) + " pour l'ajouter)"));
					return;
				}
				GameObject prefab = PrefabManager.Instance.GetPrefab(rule.Item);
				if (!Object.op_Implicit((Object)(object)prefab))
				{
					Plugin.Log.LogWarning((object)("Butin : objet " + rule.Item + " introuvable, pas ajouté à " + rule.Creature));
					return;
				}
				val = new Drop
				{
					m_prefab = prefab,
					m_levelMultiplier = true
				};
				drops.m_drops.Add(val);
			}
			if (rule.Min.HasValue)
			{
				val.m_amountMin = rule.Min.Value;
				val.m_amountMax = Rules.AmountMax(rule.Max.Value);
			}
			if (rule.Chance.HasValue)
			{
				val.m_chance = rule.Chance.Value;
			}
		}

		private static string Describe(IEnumerable<Drop> drops)
		{
			return string.Join(", ", drops.Select(delegate(Drop d)
			{
				int num = Rules.DisplayMax(d.m_amountMin, d.m_amountMax);
				string arg = ((num > d.m_amountMin) ? $"{d.m_amountMin}–{num}" : $"{d.m_amountMin}");
				string arg2 = (Object.op_Implicit((Object)(object)d.m_prefab) ? ((Object)d.m_prefab).name : "?");
				return $"{arg2} {arg} {d.m_chance * 100f:0} %" + (d.m_levelMultiplier ? " ×étoiles" : "");
			}));
		}
	}
	public sealed class LootRule
	{
		public string Creature;

		public string Item;

		public int? Min;

		public int? Max;

		public float? Chance;

		public bool Add;
	}
	public static class LootRules
	{
		public sealed class Result
		{
			public readonly List<LootRule> Rules = new List<LootRule>();

			public readonly List<string> Errors = new List<string>();
		}

		public const int MaxAmount = 100;

		public const string Default = "Lox:LoxMeat=8-10, Lox:LoxPelt=4, Wolf:WolfMeat=4, Wolf:WolfPelt=2, Wolf:WolfFang@80%, Greydwarf:GreydwarfEye@100%, +Fenring_Cultist:WolfHairBundle=2-4, +Ulv:WolfHairBundle=1-2, +Fenring:WolfHairBundle=1-2";

		public static Result Parse(string text)
		{
			Result result = new Result();
			string[] array = (text ?? "").Split(',', '\n', '\r', ';');
			for (int i = 0; i < array.Length; i++)
			{
				string text2 = array[i].Trim();
				if (text2.Length != 0)
				{
					LootRule rule;
					string text3 = TryParseEntry(text2.Replace(" ", "").Replace("\t", ""), out rule);
					if (text3 == null)
					{
						result.Rules.Add(rule);
					}
					else
					{
						result.Errors.Add("« " + text2 + " » : " + text3);
					}
				}
			}
			return result;
		}

		private static string TryParseEntry(string entry, out LootRule rule)
		{
			rule = new LootRule();
			if (entry.StartsWith("+"))
			{
				rule.Add = true;
				entry = entry.Substring(1);
			}
			string text = null;
			string text2 = null;
			int num = entry.IndexOf('@');
			if (num >= 0)
			{
				text = entry.Substring(num + 1);
				entry = entry.Substring(0, num);
				if (text.Contains("="))
				{
					return "la quantité (=) s'écrit avant la chance (@)";
				}
				if (text.Contains("@"))
				{
					return "une seule chance (@) par règle";
				}
			}
			int num2 = entry.IndexOf('=');
			if (num2 >= 0)
			{
				text2 = entry.Substring(num2 + 1);
				entry = entry.Substring(0, num2);
				if (text2.Contains("="))
				{
					return "une seule quantité (=) par règle";
				}
			}
			int num3 = entry.IndexOf(':');
			if (num3 <= 0 || num3 == entry.Length - 1 || entry.IndexOf(':', num3 + 1) >= 0)
			{
				return "écrire Créature:Objet";
			}
			rule.Creature = entry.Substring(0, num3);
			rule.Item = entry.Substring(num3 + 1);
			if (text2 != null)
			{
				int min;
				int max;
				string text3 = ParseAmount(text2, out min, out max);
				if (text3 != null)
				{
					return text3;
				}
				rule.Min = min;
				rule.Max = max;
			}
			if (text != null)
			{
				if (!float.TryParse(text.EndsWith("%") ? text.Substring(0, text.Length - 1) : text, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
				{
					return "chance illisible (ex. @80%)";
				}
				if (result < 0f || result > 100f)
				{
					return "chance entre 0 et 100 %";
				}
				rule.Chance = result / 100f;
			}
			if (rule.Add)
			{
				rule.Min = rule.Min ?? 1;
				rule.Max = rule.Max ?? 1;
				rule.Chance = rule.Chance ?? 1f;
			}
			else if (text2 == null && text == null)
			{
				return "donner une quantité (=4, =8-10) ou une chance (@80%)";
			}
			return null;
		}

		private static string ParseAmount(string text, out int min, out int max)
		{
			min = (max = 0);
			int num = text.IndexOf('-', 1);
			string s = ((num < 0) ? text : text.Substring(0, num));
			string s2 = ((num < 0) ? text : text.Substring(num + 1));
			if (!int.TryParse(s, NumberStyles.Integer, CultureInfo.InvariantCulture, out min) || !int.TryParse(s2, NumberStyles.Integer, CultureInfo.InvariantCulture, out max))
			{
				return "quantité illisible (ex. =4 ou =8-10)";
			}
			if (min < 1)
			{
				return "quantité d'au moins 1 (pour couper un objet : @0%)";
			}
			if (max > 100)
			{
				return $"quantité d'au plus {100}";
			}
			if (min > max)
			{
				return "intervalle à l'envers";
			}
			return null;
		}

		public static string Describe(LootRule rule)
		{
			string text = (rule.Add ? "+" : "") + rule.Creature + ":" + rule.Item;
			if (rule.Min.HasValue)
			{
				text = text + "=" + ((rule.Max > rule.Min) ? $"{rule.Min}-{rule.Max}" : $"{rule.Min}");
			}
			bool flag = rule.Add && rule.Chance.GetValueOrDefault() == 1f;
			if (rule.Chance.HasValue && !flag)
			{
				text = text + "@" + (rule.Chance.Value * 100f).ToString("0.##", CultureInfo.InvariantCulture) + "%";
			}
			return text;
		}
	}
	internal static class LoxLooks
	{
		private static readonly string[] ColorProperties = new string[3] { "_Hue", "_Saturation", "_Value" };

		private const float OneStarScale = 1.1f;

		private const float TwoStarScale = 1.2f;

		private static List<LevelSetup> Setups(float baseScale)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			return new List<LevelSetup>
			{
				new LevelSetup
				{
					m_scale = baseScale * 1.1f,
					m_hue = 0f,
					m_saturation = 0.05f,
					m_value = -0.12f
				},
				new LevelSetup
				{
					m_scale = baseScale * 1.2f,
					m_hue = -0.03f,
					m_saturation = 0.1f,
					m_value = -0.28f
				}
			};
		}

		internal static void Apply()
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			LogReference("Wolf");
			GameObject prefab = PrefabManager.Instance.GetPrefab("Lox");
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				Plugin.Log.LogWarning((object)"Lox : prefab introuvable, pas de teinte");
				return;
			}
			if (Object.op_Implicit((Object)(object)prefab.GetComponentInChildren<LevelEffects>(true)))
			{
				Plugin.Log.LogInfo((object)"Lox : a déjà un LevelEffects, rien à ajouter");
				return;
			}
			SkinnedMeshRenderer val = (from r in prefab.GetComponentsInChildren<SkinnedMeshRenderer>(true)
				orderby Object.op_Implicit((Object)(object)r.sharedMesh) ? r.sharedMesh.vertexCount : 0 descending
				select r).FirstOrDefault();
			if (!Object.op_Implicit((Object)(object)val))
			{
				Plugin.Log.LogWarning((object)"Lox : aucun SkinnedMeshRenderer, pas de teinte");
				return;
			}
			Transform val2 = VisualRoot(prefab.transform, ((Component)val).transform);
			LevelEffects val3 = ((Component)val2).gameObject.AddComponent<LevelEffects>();
			val3.m_mainRender = (Renderer)(object)val;
			Vector3 localScale = val2.localScale;
			bool flag = Mathf.Approximately(localScale.x, localScale.y) && Mathf.Approximately(localScale.x, localScale.z);
			float x = localScale.x;
			if (!flag)
			{
				Plugin.Log.LogWarning((object)$"Lox : échelle de base de {PathOf(prefab.transform, val2)} non uniforme ({localScale.x:0.###}, {localScale.y:0.###}, {localScale.z:0.###}) : les lox étoilés perdront cette échelle");
			}
			val3.m_levelSetups = Setups(flag ? x : 1f);
			Plugin.Log.LogInfo((object)$"Lox : LevelEffects sur {PathOf(prefab.transform, val2)}, rendu {PathOf(prefab.transform, ((Component)val).transform)}, échelle de base {x:0.###}");
			LogMaterial((Renderer)(object)val);
		}

		private static void LogMaterial(Renderer renderer)
		{
			Material material = renderer.sharedMaterials.FirstOrDefault();
			if (!Object.op_Implicit((Object)(object)material))
			{
				Plugin.Log.LogWarning((object)"Lox : pas de matériau, seule la taille changera");
				return;
			}
			List<string> list = ColorProperties.Where((string p) => !material.HasProperty(p)).ToList();
			if (list.Count == 0)
			{
				Plugin.Log.LogInfo((object)("Lox : matériau " + ((Object)material).name + " (shader " + ((Object)material.shader).name + "), teinte possible"));
			}
			else
			{
				Plugin.Log.LogWarning((object)("Lox : matériau " + ((Object)material).name + " (shader " + ((Object)material.shader).name + ") sans " + string.Join(", ", list) + ", seule la taille changera"));
			}
		}

		private static void LogReference(string creature)
		{
			GameObject prefab = PrefabManager.Instance.GetPrefab(creature);
			LevelEffects val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponentInChildren<LevelEffects>(true) : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				string text = (Object.op_Implicit((Object)(object)val.m_mainRender) ? PathOf(prefab.transform, ((Component)val.m_mainRender).transform) : "aucun");
				Plugin.Log.LogInfo((object)(creature + " (référence) : LevelEffects sur " + PathOf(prefab.transform, ((Component)val).transform) + ", rendu " + text));
			}
		}

		private static Transform VisualRoot(Transform root, Transform t)
		{
			while (Object.op_Implicit((Object)(object)t.parent) && (Object)(object)t.parent != (Object)(object)root)
			{
				t = t.parent;
			}
			return t;
		}

		private static string PathOf(Transform root, Transform t)
		{
			List<string> list = new List<string>();
			while (Object.op_Implicit((Object)(object)t) && (Object)(object)t != (Object)(object)root)
			{
				list.Insert(0, ((Object)t).name);
				t = t.parent;
			}
			if (list.Count != 0)
			{
				return string.Join("/", list);
			}
			return "(racine)";
		}
	}
	[BepInPlugin("emeraude.faune", "Emeraude Faune", "1.2.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "emeraude.faune";

		public const string Name = "Emeraude Faune";

		public const string Version = "1.2.1";

		internal static ManualLogSource Log;

		internal static ConfigEntry<string> LootList;

		private const float CheckEverySeconds = 2f;

		private float nextCheck;

		private DateTime lastWrite;

		private void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			LootList = ((BaseUnityPlugin)this).Config.Bind<string>("Loot", "Rules", "Lox:LoxMeat=8-10, Lox:LoxPelt=4, Wolf:WolfMeat=4, Wolf:WolfPelt=2, Wolf:WolfFang@80%, Greydwarf:GreydwarfEye@100%, +Fenring_Cultist:WolfHairBundle=2-4, +Ulv:WolfHairBundle=1-2, +Fenring:WolfHairBundle=1-2", new ConfigDescription("Creature loot, comma separated. Creature:Item=4 or =8-10 sets the amount (both ends included), Creature:Item@80% sets the chance, Creature:Item=4@50% sets both, a leading + adds an item the creature does not drop (1 at 100% unless given). Prefab names. Stars still multiply amounts. Removing a rule gives back the base game value. The server's list is sent to every player. / Butin des créatures, séparé par des virgules. Créature:Objet=4 ou =8-10 règle la quantité (bornes incluses), Créature:Objet@80% la chance, Créature:Objet=4@50% les deux, un + devant ajoute un objet que la créature ne donne pas (1 à 100 % sauf indication). Noms de prefab. Les étoiles multiplient toujours les quantités. Retirer une règle rend la valeur du jeu de base. La liste du serveur est envoyée à tous les joueurs.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			LootList.SettingChanged += delegate
			{
				Drops.Apply(LootList.Value);
			};
			PrefabManager.OnVanillaPrefabsAvailable += Setup;
			new Harmony("emeraude.faune").PatchAll(typeof(Plugin).Assembly);
			lastWrite = LastWrite();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Emeraude Faune 1.2.1 loaded");
		}

		private static void Setup()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= Setup;
			Drops.Ready = true;
			Drops.Apply(LootList.Value);
			Breeding.RecordVanillaSatiety();
			LoxLooks.Apply();
		}

		private DateTime LastWrite()
		{
			if (!File.Exists(((BaseUnityPlugin)this).Config.ConfigFilePath))
			{
				return DateTime.MinValue;
			}
			return File.GetLastWriteTimeUtc(((BaseUnityPlugin)this).Config.ConfigFilePath);
		}

		private void Update()
		{
			if (Time.unscaledTime < nextCheck)
			{
				return;
			}
			nextCheck = Time.unscaledTime + 2f;
			DateTime dateTime = LastWrite();
			if (!(dateTime == lastWrite) && !(dateTime == DateTime.MinValue))
			{
				lastWrite = dateTime;
				if (!Object.op_Implicit((Object)(object)ZNet.instance) || ZNet.instance.IsServer())
				{
					Log.LogInfo((object)"Config modifiée, relecture");
					((BaseUnityPlugin)this).Config.Reload();
				}
			}
		}
	}
	public static class Rules
	{
		public const float TwoStarChance = 0.01f;

		public const float OneStarChance = 0.05f;

		public static int AmountMax(int inclusiveMax)
		{
			return inclusiveMax + 1;
		}

		public static int DisplayMax(int amountMin, int amountMax)
		{
			if (amountMax <= amountMin)
			{
				return amountMin;
			}
			return amountMax - 1;
		}

		public static int OffspringMinLevel(int motherLevel, float roll, int vanillaMin)
		{
			if (motherLevel > 1)
			{
				return vanillaMin;
			}
			return Math.Max((roll < 0.01f) ? 3 : ((roll < 0.060000002f) ? 2 : vanillaMin), vanillaMin);
		}
	}
}