Decompiled source of FragileValuables v0.1.3

REPO-FragileValuables.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using REPO_FragileValuables.Config;
using REPO_FragileValuables.UI;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("REPO-FragileValuables")]
[assembly: AssemblyDescription("Mod created by flipf17")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("REPO-FragileValuables")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a9c40ae3-d0a0-4848-aafc-54ca6693acb0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace REPO_FragileValuables
{
	[HarmonyPatch]
	public class IncreasedValuableObject : MonoBehaviour
	{
		internal static Random random = null;

		public static Dictionary<Durability, Durability> customDurabilities = new Dictionary<Durability, Durability>();

		public static Dictionary<Value, Value> customValues = new Dictionary<Value, Value>();

		public static HashSet<ValuableObject> currentFragileValuables = new HashSet<ValuableObject>();

		public ValuableObject valuableObject;

		public PhotonView photonView;

		public PhysGrabObjectImpactDetector impactDetector;

		public Durability customDurability;

		public Value customValue;

		public void Awake()
		{
			valuableObject = ((Component)this).GetComponent<ValuableObject>();
			photonView = ((Component)this).gameObject.GetComponent<PhotonView>();
			impactDetector = ((Component)this).gameObject.GetComponent<PhysGrabObjectImpactDetector>();
		}

		public void Start()
		{
			if (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient)
			{
				if (random == null)
				{
					random = new Random((int)Time.time);
				}
				if (Object.op_Implicit((Object)(object)valuableObject) && Object.op_Implicit((Object)(object)photonView) && Object.op_Implicit((Object)(object)impactDetector) && (Object)(object)valuableObject.durabilityPreset != (Object)null && (Object)(object)valuableObject.valuePreset != (Object)null && (Object)(object)valuableObject.physAttributePreset != (Object)null && (ConfigSettings.minFragilityThreshold.Value == -1 || valuableObject.durabilityPreset.fragility >= (float)ConfigSettings.minFragilityThreshold.Value) && (ConfigSettings.minValueThreshold.Value == -1 || valuableObject.valuePreset.valueMin >= (float)ConfigSettings.minValueThreshold.Value) && (ConfigSettings.maxValueThreshold.Value == -1 || valuableObject.valuePreset.valueMin <= (float)ConfigSettings.maxValueThreshold.Value) && (ConfigSettings.minMassThreshold.Value == -1 || valuableObject.physAttributePreset.mass >= (float)ConfigSettings.minMassThreshold.Value) && (ConfigSettings.maxMassThreshold.Value == -1 || valuableObject.physAttributePreset.mass <= (float)ConfigSettings.maxMassThreshold.Value))
				{
					float num = (float)random.NextDouble();
					if (num >= 1f - ConfigSettings.fragileValuableChance.Value)
					{
						photonView.RPC("IncreaseFragilityRPC", (RpcTarget)0, Array.Empty<object>());
						return;
					}
				}
			}
			if (!Object.op_Implicit((Object)(object)valuableObject) || !currentFragileValuables.Contains(valuableObject))
			{
				((Behaviour)this).enabled = false;
			}
		}

		public void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)valuableObject) && currentFragileValuables.Contains(valuableObject))
			{
				currentFragileValuables.Remove(valuableObject);
			}
		}

		[PunRPC]
		public void IncreaseFragilityRPC()
		{
			IncreaseFragility();
		}

		public void IncreaseFragility()
		{
			if (Object.op_Implicit((Object)(object)valuableObject) && Object.op_Implicit((Object)(object)impactDetector) && !currentFragileValuables.Contains(valuableObject))
			{
				string name = ((Object)valuableObject).name;
				name = ((!name.Contains("(Clone)")) ? (name + " - Fragile+") : name.Replace("(Clone)", " - Fragile+ (Clone)"));
				((Object)valuableObject).name = name;
				if (!customDurabilities.TryGetValue(valuableObject.durabilityPreset, out var value))
				{
					value = Object.Instantiate<Durability>(valuableObject.durabilityPreset);
					((Object)value).name = ((Object)valuableObject.durabilityPreset).name + " Fragile+";
					customDurabilities[valuableObject.durabilityPreset] = value;
				}
				if (!customValues.TryGetValue(valuableObject.valuePreset, out var value2))
				{
					value2 = Object.Instantiate<Value>(valuableObject.valuePreset);
					((Object)value2).name = ((Object)valuableObject.valuePreset).name + " Value+";
					customValues[valuableObject.valuePreset] = value2;
				}
				value.durability = valuableObject.durabilityPreset.durability * 0.01f;
				value.fragility = valuableObject.durabilityPreset.fragility * ConfigSettings.fragilityMultiplier.Value;
				value2.valueMin = valuableObject.valuePreset.valueMin * ConfigSettings.priceMultiplier.Value;
				value2.valueMax = valuableObject.valuePreset.valueMax * ConfigSettings.priceMultiplier.Value;
				if (ConfigSettings.verboseLogs.Value)
				{
					Plugin.LogVerbose("Increasing fragility and value of object: " + ((Object)valuableObject).name + " - Fragility: " + valuableObject.durabilityPreset.fragility + " => " + value.fragility + " Durability: " + valuableObject.durabilityPreset.durability + " => " + value.durability + " ValueMin: " + valuableObject.valuePreset.valueMin + " => " + value2.valueMin + " ValueMax: " + valuableObject.valuePreset.valueMax + " => " + value2.valueMax);
				}
				else
				{
					Plugin.Log("Increasing fragility and value of object: " + ((Object)valuableObject).name);
				}
				customDurability = value;
				customValue = value2;
				valuableObject.durabilityPreset = value;
				valuableObject.valuePreset = value2;
				impactDetector.fragility = valuableObject.durabilityPreset.fragility;
				impactDetector.durability = valuableObject.durabilityPreset.durability;
				currentFragileValuables.Add(valuableObject);
			}
		}

		[HarmonyPatch(typeof(LevelGenerator), "GenerateDone")]
		[HarmonyPostfix]
		public static void OnLevelGenerated()
		{
			if (!GameManager.Multiplayer() || PhotonNetwork.IsMasterClient)
			{
				Plugin.Log("Spawned " + currentFragileValuables.Count + " increased fragile valuables.");
			}
		}

		[HarmonyPatch(typeof(ValuableObject), "Awake")]
		[HarmonyPostfix]
		public static void OnAwake(ValuableObject __instance)
		{
			IncreasedValuableObject increasedValuableObject = ((Component)__instance).gameObject.AddComponent<IncreasedValuableObject>();
		}
	}
	[BepInPlugin("flipf17.FragileValuables", "FragileValuables", "0.1.3")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		public static Plugin instance;

		private static ManualLogSource logger;

		private void Awake()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			instance = this;
			CreateCustomLogger();
			ConfigSettings.BindConfigSettings();
			_harmony = new Harmony("FragileValuables");
			PatchAll();
			Log("FragileValuables loaded");
		}

		private void PatchAll()
		{
			IEnumerable<Type> enumerable;
			try
			{
				enumerable = Assembly.GetExecutingAssembly().GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				enumerable = ex.Types.Where((Type t) => t != null);
			}
			foreach (Type item in enumerable)
			{
				_harmony.PatchAll(item);
			}
		}

		private void CreateCustomLogger()
		{
			try
			{
				logger = Logger.CreateLogSource(string.Format("{0}-{1}", "FragileValuables", "0.1.3"));
			}
			catch
			{
				logger = ((BaseUnityPlugin)this).Logger;
			}
		}

		internal static void Log(string message)
		{
			logger.LogInfo((object)message);
		}

		internal static void LogError(string message)
		{
			logger.LogError((object)message);
		}

		internal static void LogWarning(string message)
		{
			logger.LogWarning((object)message);
		}

		internal static void LogVerbose(string message)
		{
			if (ConfigSettings.verboseLogs.Value)
			{
				logger.LogInfo((object)("[VERBOSE] " + message));
			}
		}

		internal static void LogErrorVerbose(string message)
		{
			if (ConfigSettings.verboseLogs.Value)
			{
				logger.LogError((object)("[VERBOSE] " + message));
			}
		}

		internal static void LogWarningVerbose(string message)
		{
			if (ConfigSettings.verboseLogs.Value)
			{
				logger.LogWarning((object)("[VERBOSE] " + message));
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "flipf17.FragileValuables";

		public const string PLUGIN_NAME = "FragileValuables";

		public const string PLUGIN_VERSION = "0.1.3";
	}
}
namespace REPO_FragileValuables.UI
{
	[HarmonyPatch]
	public static class ValuableUIPatcher
	{
		internal static readonly Color invalidColor = new Color(0f, 0f, 0f, 0f);

		internal static readonly Color defaultUIColor = new Color(0f, 0.8f, 1f, 1f);

		public static Color uiColorMiddle = defaultUIColor;

		public static Color uiColorCorner = defaultUIColor;

		public static Color uiColorPriceText = defaultUIColor;

		public static int displayTime = 2;

		public static float minAlpha = 0.05f;

		public static float maxAlpha = 0.5f;

		public static int flashSpeed = 1;

		private static Color previousTextUIColor;

		internal static Dictionary<ValuableDiscoverGraphic, Image> middleImages = new Dictionary<ValuableDiscoverGraphic, Image>();

		[HarmonyPatch(typeof(LevelGenerator), "Start")]
		[HarmonyPrefix]
		public static void OnLevelGenerationStart()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			middleImages.Clear();
			Color val = ConfigSettings.ParseUIColorString();
			Color val2;
			if (val == invalidColor)
			{
				val = defaultUIColor;
				val2 = val;
				Plugin.LogErrorVerbose("Failed to parse ui color. Reverting to default: " + ((object)(Color)(ref val2)).ToString());
			}
			else
			{
				val2 = val;
				Plugin.LogVerbose("Successfully parsed color: " + ((object)(Color)(ref val2)).ToString());
			}
			uiColorMiddle = new Color(val.r, val.g, val.b, 0.1f);
			uiColorCorner = new Color(val.r, val.g, val.b, 0.8f);
			uiColorPriceText = new Color(val.r, val.g, val.b, 1f);
		}

		[HarmonyPatch(typeof(ValuableDiscoverGraphic), "Start")]
		[HarmonyPrefix]
		public static void OnStart(ref State ___state, ValuableDiscoverGraphic __instance)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			if (___state || !ConfigSettings.useCustomUIColor.Value)
			{
				return;
			}
			PhysGrabObject target = __instance.target;
			ValuableObject component = ((Component)target).GetComponent<ValuableObject>();
			if (!Object.op_Implicit((Object)(object)component) || !IncreasedValuableObject.currentFragileValuables.Contains(component))
			{
				return;
			}
			__instance.waitTime = displayTime;
			__instance.colorDiscoverMiddle = uiColorMiddle;
			__instance.colorDiscoverCorner = uiColorCorner;
			RectTransform middle = __instance.middle;
			Image val = ((middle != null) ? ((Component)middle).GetComponent<Image>() : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				((Graphic)val).color = uiColorMiddle;
				middleImages[__instance] = val;
			}
			else
			{
				Plugin.LogError("Failed to modify fragile valuable's ValuableDiscoverGraphic UI (middle) color.");
			}
			Image[] array = new Image[4];
			RectTransform topLeft = __instance.topLeft;
			array[0] = ((topLeft != null) ? ((Component)topLeft).GetComponent<Image>() : null);
			RectTransform topRight = __instance.topRight;
			array[1] = ((topRight != null) ? ((Component)topRight).GetComponent<Image>() : null);
			RectTransform botLeft = __instance.botLeft;
			array[2] = ((botLeft != null) ? ((Component)botLeft).GetComponent<Image>() : null);
			RectTransform botRight = __instance.botRight;
			array[3] = ((botRight != null) ? ((Component)botRight).GetComponent<Image>() : null);
			Image[] array2 = (Image[])(object)array;
			for (int i = 0; i < array2.Length; i++)
			{
				if (Object.op_Implicit((Object)(object)array2[i]))
				{
					((Graphic)array2[i]).color = uiColorCorner;
				}
				else
				{
					Plugin.LogError("Failed to modify fragile valuable's ValuableDiscoverGraphic UI (corner at index " + i + ") color.");
				}
			}
		}

		[HarmonyPatch(typeof(ValuableDiscoverGraphic), "Update")]
		[HarmonyPostfix]
		public static void UpdateAlpha(ref State ___state, ref float ___waitTimer, ValuableDiscoverGraphic __instance)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			if ((int)___state == 0 && middleImages.TryGetValue(__instance, out var value))
			{
				float num = __instance.waitTime - ___waitTimer;
				float num2 = Mathf.Sin(2f * (num - 1f / (4f * (float)flashSpeed)) * (float)Math.PI * (float)flashSpeed) / 2f * (maxAlpha - minAlpha) + (maxAlpha + minAlpha) / 2f;
				float num3 = Mathf.Lerp(((Graphic)value).color.a, num2, 15f * Time.deltaTime);
				((Graphic)value).color = new Color(((Graphic)value).color.r, ((Graphic)value).color.g, ((Graphic)value).color.b, num3);
			}
		}

		[HarmonyPatch(typeof(WorldSpaceUIValue), "Show")]
		[HarmonyPrefix]
		public static void OnShowValuePrefix(ref PhysGrabObject ___currentPhysGrabObject, PhysGrabObject _grabObject, int _value, bool _cost, Vector3 _offset, WorldSpaceUIValue __instance)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if (!ConfigSettings.useCustomUIColor.Value)
			{
				return;
			}
			previousTextUIColor = __instance.colorValue;
			if (!((Object.op_Implicit((Object)(object)___currentPhysGrabObject) && (Object)(object)___currentPhysGrabObject != (Object)(object)_grabObject) || _cost))
			{
				ValuableObject component = ((Component)_grabObject).GetComponent<ValuableObject>();
				if (Object.op_Implicit((Object)(object)component) && IncreasedValuableObject.currentFragileValuables.Contains(component))
				{
					__instance.colorValue = uiColorPriceText;
				}
			}
		}

		[HarmonyPatch(typeof(WorldSpaceUIValue), "Show")]
		[HarmonyPostfix]
		public static void OnShowValuePostfix(PhysGrabObject _grabObject, int _value, bool _cost, Vector3 _offset, WorldSpaceUIValue __instance)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (ConfigSettings.useCustomUIColor.Value)
			{
				__instance.colorValue = previousTextUIColor;
			}
		}
	}
}
namespace REPO_FragileValuables.Config
{
	[Serializable]
	public static class ConfigSettings
	{
		public static ConfigEntry<float> fragileValuableChance;

		public static ConfigEntry<float> fragilityMultiplier;

		public static ConfigEntry<float> priceMultiplier;

		public static ConfigEntry<int> minFragilityThreshold;

		public static ConfigEntry<int> minValueThreshold;

		public static ConfigEntry<int> maxValueThreshold;

		public static ConfigEntry<int> minMassThreshold;

		public static ConfigEntry<int> maxMassThreshold;

		public static ConfigEntry<bool> useCustomUIColor;

		public static ConfigEntry<string> fragileUIColor;

		public static ConfigEntry<bool> verboseLogs;

		public static Dictionary<string, ConfigEntryBase> currentConfigEntries = new Dictionary<string, ConfigEntryBase>();

		internal static void BindConfigSettings()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Expected O, but got Unknown
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Expected O, but got Unknown
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Expected O, but got Unknown
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Expected O, but got Unknown
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Expected O, but got Unknown
			Plugin.Log("Binding Configs");
			fragilityMultiplier = AddConfigEntry<float>(((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("General", "Increased Fragility Multiplier", 3f, new ConfigDescription("[Host only] Higher value = More fragile. The more fragile an object, the easier it is to damage it. A value of 1 would not modify the fragility. (lighter hits may cause damage)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())));
			priceMultiplier = AddConfigEntry<float>(((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("General", "Increased Price Multiplier", 2f, new ConfigDescription("[Host only] Price multiplier for fragile valuables. This only affects the objects randomly spawned with increased fragility. A value of 1 would not modify the price.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>())));
			fragileValuableChance = AddConfigEntry<float>(((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Spawn Rules", "Increased Fragility Chance", 0.1f, new ConfigDescription("[Host only] Chance for a fragile valuable to spawn with more value, but higher fragility.\nValues will be clamped between 0.01 and 1.0", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 1f), Array.Empty<object>())));
			minFragilityThreshold = AddConfigEntry<int>(((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Spawn Rules", "Min Fragility Threshold", 90, new ConfigDescription("[Host only] Only objects with a default fragility of this number and ABOVE will have a chance to increase in fragility and value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())));
			minValueThreshold = AddConfigEntry<int>(((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Spawn Rules", "Min Value Threshold", 1000, new ConfigDescription("[Host only] Only objects with a default min value of this number and ABOVE will have a chance to increase in fragility and value.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100000), Array.Empty<object>())));
			maxValueThreshold = AddConfigEntry<int>(((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Spawn Rules", "Max Value Threshold", 5000, new ConfigDescription("[Host only] Only objects with a default min value of this number and BELOW will have a chance to increase in fragility and value.\nSet to -1 to ignore this criteria.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 100000), Array.Empty<object>())));
			minMassThreshold = AddConfigEntry<int>(((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Spawn Rules", "Min Mass Threshold", 0, new ConfigDescription("[Host only] Only objects with a default mass of this number and ABOVE will have a chance to increase in fragility and value. (for reference a small vase has a mass of 2)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10), Array.Empty<object>())));
			maxMassThreshold = AddConfigEntry<int>(((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Spawn Rules", "Max Mass Threshold", 2, new ConfigDescription("[Host only] Only objects with a default mass of this number and BELOW will have a chance to increase in fragility and value. (for reference a small vase has a mass of 2)\nSet to -1 to ignore this criteria.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(-1, 10), Array.Empty<object>())));
			useCustomUIColor = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("UI", "Use Custom UI Color", true, new ConfigDescription("[Client-side] If true, the custom ui color for increased fragile object will apply.\nThese colors are used when discovering an increased fragile object, or for the value color while holding the object.", (AcceptableValueBase)null, Array.Empty<object>())));
			fragileUIColor = AddConfigEntry<string>(((BaseUnityPlugin)Plugin.instance).Config.Bind<string>("UI", "Discovered Object UI Color", "0,0.8,1", new ConfigDescription("[Client-side] Enter 3 values for RGB, separated by a comma. Example: \"0,0.8,1\"\nValues must be within 0 and 1", (AcceptableValueBase)null, Array.Empty<object>())));
			verboseLogs = AddConfigEntry<bool>(((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("General", "Verbose Logs", false, new ConfigDescription("Enables verbose logs. Useful for debugging.", (AcceptableValueBase)null, Array.Empty<object>())));
			fragilityMultiplier.Value = Mathf.Clamp(fragilityMultiplier.Value, 0.1f, 5f);
			priceMultiplier.Value = Mathf.Max(priceMultiplier.Value, 0.1f);
			fragileValuableChance.Value = Mathf.Clamp(fragileValuableChance.Value, 0f, 1f);
			minFragilityThreshold.Value = Mathf.Clamp(minFragilityThreshold.Value, 0, 100);
			minValueThreshold.Value = Mathf.Clamp(minValueThreshold.Value, -1, 100000);
			maxValueThreshold.Value = Mathf.Clamp(maxValueThreshold.Value, minValueThreshold.Value, 100000);
			minMassThreshold.Value = Mathf.Clamp(minMassThreshold.Value, -1, 10);
			maxMassThreshold.Value = Mathf.Clamp(maxMassThreshold.Value, minMassThreshold.Value, 10);
		}

		internal static Color ParseUIColorString()
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string[] array = fragileUIColor.Value.Split(new char[1] { ',' });
				if (array == null || array.Length != 3)
				{
					throw new Exception("Must specify 3 color values");
				}
				float num = float.Parse(array[0]);
				float num2 = float.Parse(array[1]);
				float num3 = float.Parse(array[2]);
				Color result = default(Color);
				((Color)(ref result))..ctor(num, num2, num3);
				return result;
			}
			catch (Exception ex)
			{
				Plugin.LogError("Error parsing fragile object ui color string: " + fragileUIColor.Value + "\n" + ex);
				fragileUIColor.Value = (string)((ConfigEntryBase)fragileUIColor).DefaultValue;
				return ValuableUIPatcher.invalidColor;
			}
		}

		internal static ConfigEntry<T> AddConfigEntry<T>(ConfigEntry<T> configEntry)
		{
			currentConfigEntries.Add(((ConfigEntryBase)configEntry).Definition.Key, (ConfigEntryBase)(object)configEntry);
			return configEntry;
		}
	}
}