Decompiled source of DrainTarPit v1.0.0

DrainTarPit/DrainTarPit.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DrainTarPit.Building;
using DrainTarPit.Debug;
using DrainTarPit.Drain;
using DrainTarPit.Effects;
using DrainTarPit.Logging;
using DrainTarPit.Pump;
using DrainTarPit.TextLocal;
using DrainTarPit.Ui;
using DrainTarPit.Visuals;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.Audio;
using UnityEngine.Playables;
using UnityEngine.Rendering;
using UnityEngine.TextCore.Text;
using UnityEngine.UIElements;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: InternalsVisibleTo("WaterAndTarPools")]
[assembly: InternalsVisibleTo("KydlTools")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.0.0.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 DrainTarPit
{
	internal static class ModSettings
	{
		public static ConfigEntry<bool> EnableAll;

		public static ConfigEntry<bool> DebugLog;

		public static ConfigEntry<WorldHoseStyleOption> WorldHoseStyle;

		public static ConfigEntry<float> WorldHoseOpacity;

		public static ConfigEntry<HoseStyleOption> BuildHoseStyle;

		public static ConfigEntry<float> BuildHoseOpacity;

		public static ConfigEntry<KeyCode> TiltKey;

		public static ConfigEntry<KeyCode> RollKey;

		public static ConfigEntry<KeyCode> TiltResetKey;

		public static ConfigEntry<float> TiltStep;

		public static ConfigEntry<bool> SoundEffects;

		public static ConfigEntry<float> EffectsVolume;

		public static ConfigEntry<bool> ScratchSounds;

		public static ConfigEntry<bool> TarSplashSound;

		public static ConfigEntry<bool> TarSlugFlow;

		public static ConfigEntry<float> LiquidFlowSpeed;

		public static ConfigEntry<float> NozzleFlowAmount;

		public static ConfigEntry<bool> NozzlePuddle;

		public static ConfigEntry<float> NozzlePressure;

		public static ConfigEntry<float> NozzleFlowSeconds;

		public static ConfigEntry<float> PourSoundOffset;

		public static ConfigEntry<float> VolumePerStroke;

		public static ConfigEntry<float> DrainRadius;

		public static ConfigEntry<float> StrainerSearchRadius;

		public static ConfigEntry<float> StrainerReach;

		public static ConfigEntry<float> MinTarDepth;

		public static ConfigEntry<int> MaxChainPieces;

		public static ConfigEntry<float> SnapTolerance;

		public static ConfigEntry<float> RefillMinutes;

		public static ConfigEntry<bool> AutoReach;

		public static readonly Tunable<string> TestOutDir = new Tunable<string>("DebugLog", "TestOutDir", "", "Folder where the console tests (dtp ptest ...) write their report DrainTarPit.PoolTests.txt. Empty = the BepInEx config folder.");

		public static readonly Tunable<string> ShaderName = new Tunable<string>("Visuals", "ShaderName", "Custom/Piece", "Valheim shader the pump / hose materials are swapped to; falls back to Custom/Piece, then Standard.");

		public static readonly Tunable<bool> UseMaskMap = new Tunable<bool>("Visuals", "UseMaskMap", value: true, "Use the packed mask textures for metallic / smoothness (off = scalar values).");

		public static readonly Tunable<float> AlbedoBrightness = new Tunable<float>("Visuals", "AlbedoBrightness", 1.5f, "Brightens the colour textures of all pump / hose pieces (gamma lift). Read when the pieces are prepared (game start).");

		public static readonly Tunable<float> PieceHealth = new Tunable<float>("Building", "PieceHealth", 400f, "Health of the hoses, strainer, nozzle and pool sign; the pump has twice this. Structural support is not changed.");

		public static readonly Tunable<float> SoundTailSeconds = new Tunable<float>("Effects", "SoundTailSeconds", 0.3f, "The lever sound (pump_up) is faded out this many seconds after its loudest moment.");

		public static readonly Tunable<bool> DrySound = new Tunable<bool>("Effects", "DrySound", value: true, "Pump sounds go to the game's Effects mixer group (no outdoor reverb), with the game's sound-effects volume.");

		public static readonly Tunable<bool> PumpDroplets = new Tunable<bool>("Effects", "PumpDroplets", value: false, "Puff of droplets at the pump's outlet on every stroke.");

		public static readonly Tunable<bool> SyncPour = new Tunable<bool>("Effects", "SyncPour", value: true, "Stream, splashes, puddle, pour sound and deposit happen when the slug of that stroke reaches the nozzle.");

		public static readonly Tunable<float> TarSlugLength = new Tunable<float>("Effects", "TarSlugLength", 2f, "Length (m) of the liquid slug in the hoses.");

		public static readonly Tunable<float> PitFlowBoost = new Tunable<float>("Drain", "PitFlowBoost", 9f, "While a pit is pumped its tar flows towards the hole faster: multiplies the pit's viscosity value (9 = about 3x faster).");

		public static readonly Tunable<float> PitFlowBoostSeconds = new Tunable<float>("Drain", "PitFlowBoostSeconds", 20f, "How long (s) after the last stroke a pit keeps PitFlowBoost.");

		public static readonly Tunable<bool> AllowWater = new Tunable<bool>("Pools", "AllowWater", value: false, "Strainers built in water pump water (sea / lake / a pump pool). On while WaterAndTarPools is installed.").SetFromConfigOf("WaterAndTarPools");

		public static readonly Tunable<float> MinWaterDepth = new Tunable<float>("Pools", "MinWaterDepth", 0.3f, "Minimum water depth (m) at the strainer tip for it to count as 'in water' (WaterAndTarPools config).").SetFromConfigOf("WaterAndTarPools");

		public static readonly Tunable<bool> WaterSplashSound = new Tunable<bool>("Effects", "WaterSplashSound", value: true, "Water splash where the pumped water comes down (WaterAndTarPools config).").SetFromConfigOf("WaterAndTarPools");

		public static readonly Tunable<float> WaterSplashVolume = new Tunable<float>("Effects", "WaterSplashVolume", 0.6f, "Volume of the water splash (WaterAndTarPools config).").SetFromConfigOf("WaterAndTarPools");

		public static readonly Tunable<float> WaterSplashOffset = new Tunable<float>("Effects", "WaterSplashOffset", -0.3f, "Seconds added to the moment the water splash plays (negative = earlier).");

		public static readonly Tunable<bool> WaterSlugFlow = new Tunable<bool>("Effects", "WaterSlugFlow", value: true, "Slug of water travelling through see-through hoses (WaterAndTarPools config).").SetFromConfigOf("WaterAndTarPools");

		public static readonly Tunable<float> StaminaPerStroke = new Tunable<float>("Pump", "StaminaPerStroke", 3f, "Stamina used per pump stroke.");

		public static readonly Tunable<float> HoldToCycleSeconds = new Tunable<float>("Pump", "HoldToCycleSeconds", 0.4f, "Hold the use button (E) this long to switch from single strokes to continuous pumping. Release to stop.");

		public static readonly Tunable<float> CycleStrokeSeconds = new Tunable<float>("Pump", "CycleStrokeSeconds", 1.2f, "Fallback seconds per loop while pumping continuously; the real Cycle clip length is used when the clip is found.");

		public static readonly Tunable<bool> FacePump = new Tunable<bool>("Pump", "FacePump", value: true, "Turn the player towards the lever when mounting the pump (the stand point is rotated at runtime). Turn off to use the stand_point's own rotation.");

		public static readonly Tunable<float> StandYawOffset = new Tunable<float>("Pump", "StandYawOffset", 0f, "Extra yaw (degrees) added to the facing direction when mounting. Use 90 / -90 / 180 if the player stands sideways or backwards at the pump.");

		public static readonly Tunable<string> AttachBool = new Tunable<string>("Pump", "AttachBool", "attach_chair", "Vanilla player animator bool used to pin the player in place while pumping. Its clip is replaced by the pump clips.");

		public static readonly Tunable<float> MaxPumpDistance = new Tunable<float>("Pump", "MaxPumpDistance", 3f, "If the mounted player ends up further than this (m) from the stand point (pushed, teleported, ...) they are released at once.");

		public static readonly Tunable<bool> HandIK = new Tunable<bool>("Pump", "HandIK", value: true, "Pin the player's hands to the lever handle with IK while pumping (stops the hands clipping through the lever).");

		public static readonly Tunable<float> HandIKBlendSeconds = new Tunable<float>("Pump", "HandIKBlendSeconds", 0.35f, "Seconds to blend the hands onto / off the handle when mounting / stepping away.");

		public static readonly Tunable<float> GripSpread = new Tunable<float>("Pump", "GripSpread", 0.17f, "Half the distance (m) between the two hands on the handle.");

		public static readonly Tunable<float> GripUp = new Tunable<float>("Pump", "GripUp", 0f, "Move the grip point up (+) / down (-) from the lever's interact_point (m). Tweak if the hands sit above/below the handle. The arms can only reach so far: to get the whole player higher use StandHeight.");

		public static readonly Tunable<float> GripForward = new Tunable<float>("Pump", "GripForward", -0.025f, "Move the grip point along the lever (+ = away from you, towards the pump column, m).");

		public static readonly Tunable<bool> HandRotate = new Tunable<bool>("Pump", "HandRotate", value: true, "Turn the hands palm-down onto the handle bar (overhand grip) instead of leaving them in the animation's orientation. Turn off to compare / if the hands twist wrongly on a modded player model.");

		public static readonly Tunable<float> FingerCurl = new Tunable<float>("Pump", "FingerCurl", 0.79f, "How far the fingers curl around the handle bar (0 = open hand, 1 = tight wrap). Needs a player rig with finger bones.");

		public static readonly Tunable<float> GripPalmOffset = new Tunable<float>("Pump", "GripPalmOffset", -0.002f, "Gap (m) between the palm and the top of the handle bar. Lower = hands sink into the bar, higher = hands float above it.");

		public static readonly Tunable<float> ThumbCurl = new Tunable<float>("Pump", "ThumbCurl", 0.8f, "How far the thumb curls down and under the handle bar (0 = thumb keeps the animation pose, 1 = tight wrap). Needs finger bones.");

		public static readonly Tunable<float> ThumbSpread = new Tunable<float>("Pump", "ThumbSpread", 25f, "Degrees the thumb is swung away from the fist (sideways, before it curls under the bar). Raise it if the thumb still sits against the index finger, lower it if it sticks out.");

		public static readonly Tunable<float> ClipBlendSeconds = new Tunable<float>("Pump", "ClipBlendSeconds", 0.12f, "Seconds to cross-fade between the pump clips (Enter / Idle / Push / Pull / Cycle / Exit). 0 = hard cuts like before. Removes the pose popping at every phase change.");

		public static readonly Tunable<bool> BendToReach = new Tunable<bool>("Pump", "BendToReach", value: true, "When the hands cannot reach the lever handle (typically at the bottom of the stroke), bend the player to get there: first forward from the back (spine), then down at the knees. The bend follows the lever, so it is deepest when the lever is down. Turn off for the plain clips.");

		public static readonly Tunable<float> MaxBackBend = new Tunable<float>("Pump", "MaxBackBend", 45f, "Most (degrees, spread over spine / chest / upper chest) the player may bend forward from the back to reach the handle.");

		public static readonly Tunable<float> MaxKneeBend = new Tunable<float>("Pump", "MaxKneeBend", 0.08f, "Most (m) the hips may sink with bent knees (feet stay on the ground) when the back bend alone is not enough.");

		public static readonly Tunable<float> HipLock = new Tunable<float>("Pump", "HipLock", 0.85f, "How much the hips are held still while pumping (0 = they follow the clips like before, 1 = fixed at their calm position; the feet stay planted by leg IK). The stroke then comes from the upper body: the back bends towards the lever and the arms push. Needs BendToReach.");

		public static readonly Tunable<float> BendSmooth = new Tunable<float>("Pump", "BendSmooth", 8f, "How fast (1/s) the back bend follows the lever. Lower = softer, more rounded movement; higher = snappier.");

		public static readonly Tunable<bool> FreezeIdle = new Tunable<bool>("Pump", "FreezeIdle", value: true, "Hold the Idle pose still instead of looping the Idle clip. The Idle clip makes the left leg twitch every loop; with this on the legs stay calm (the arms follow the lever IK anyway).");

		public static readonly Tunable<float> StandHeight = new Tunable<float>("Pump", "StandHeight", 0f, "Lifts (+) or lowers (-) the player at the pump (m). Raise it if the hands cannot reach the handle (arms stretched, hands below the lever). Applied when you step onto the pump.");

		public static readonly Tunable<float> StandForward = new Tunable<float>("Pump", "StandForward", -0.28f, "Moves the player towards (+) or away from (-) the lever (m).");

		public static readonly Tunable<float> StandSide = new Tunable<float>("Pump", "StandSide", 0f, "Moves the player sideways (m). + = to the player's right when facing the lever.");

		public static readonly Tunable<float> MaxAutoStep = new Tunable<float>("Pump", "MaxAutoStep", 0.25f, "Most (m) AutoReach may step the player towards the lever.");

		public static readonly Tunable<float> MaxAutoRaise = new Tunable<float>("Pump", "MaxAutoRaise", 0.15f, "Most (m) AutoReach may then lift the player (a standing player should barely float).");

		public static bool On => EnableAll == null || EnableAll.Value;

		public static void Bind(ConfigFile c)
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected O, but got Unknown
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Expected O, but got Unknown
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Expected O, but got Unknown
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Expected O, but got Unknown
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Expected O, but got Unknown
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Expected O, but got Unknown
			string[] lines = ModSettingsCommaFix.Capture(c);
			EnableAll = c.Bind<bool>("General", "EnableAll", true, "Switches the whole mod on / off while playing. Off: no pumping, no liquid moving, no sounds or effects from this mod; pieces already built stay in the world and can still be built.");
			DebugLog = c.Bind<bool>("DebugLog", "Enable", false, "Writes detailed lines about everything the mod does to the BepInEx log (for bug reports). Leave off while playing normally.");
			ModSettingsHose.Bind(c);
			TiltKey = c.Bind<KeyCode>("Building", "TiltKey", (KeyCode)308, "Hold while scrolling to tilt the held piece up/down (pitch) instead of turning it. Keyboard/mouse only.");
			RollKey = c.Bind<KeyCode>("Building", "RollKey", (KeyCode)306, "Hold together with TiltKey while scrolling to roll the piece around its own axis instead of pitching it.");
			TiltResetKey = c.Bind<KeyCode>("Building", "TiltResetKey", (KeyCode)8, "Resets pitch and roll of the held piece to flat.");
			TiltStep = c.Bind<float>("Building", "TiltStep", 45f, new ConfigDescription("Degrees per scroll step for pitch/roll.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 90f), Array.Empty<object>()));
			SoundEffects = c.Bind<bool>("Effects", "SoundEffects", true, "All sounds of this mod (pump strokes, the liquid coming out of the nozzle). Off = the mod makes no sound at all.");
			EffectsVolume = c.Bind<float>("Effects", "EffectsVolume", 0.6f, new ConfigDescription("Volume of the pump sounds and of the tar coming out of the nozzle (0 = silent).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			ScratchSounds = c.Bind<bool>("Effects", "ScratchSounds", true, "Pump stroke sound in three parts: a scratch while the piston rises, a scratch while it falls, and the lever hit when it reaches the bottom. Off = only the lever hit.");
			TarSplashSound = c.Bind<bool>("Effects", "TarSplashSound", true, "Play the sound of tar pouring out of the nozzle. Off = tar pours silently.");
			TarSlugFlow = c.Bind<bool>("Effects", "TarSlugFlow", true, "Show a slug of tar travelling through the hoses on every pump stroke (strainer -> pump -> nozzle; see-through hoses).");
			LiquidFlowSpeed = c.Bind<float>("Effects", "LiquidFlowSpeed", 3.5f, new ConfigDescription("Speed (m/s) of the liquid slug through the hoses (tar and water).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 10f), Array.Empty<object>()));
			NozzleFlowAmount = c.Bind<float>("Effects", "NozzleFlowAmount", 1f, new ConfigDescription("How much liquid visibly pours out of the nozzle on every stroke (a falling stream, splashes where it lands and a puddle that fades). 0 = off, 1 = default, 4 = a lot. Shown to every player near the pump.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 4f), Array.Empty<object>()));
			NozzlePuddle = c.Bind<bool>("Effects", "NozzlePuddle", true, "Show a small puddle on the ground where the stream lands (it spreads and fades after a few seconds). Off = just the stream and splashes.");
			NozzlePressure = c.Bind<float>("Effects", "NozzlePressure", 4.5f, new ConfigDescription("Speed (m/s) the liquid leaves the nozzle with. Higher = the stream shoots further away from the nozzle before it falls (a nozzle pointing sideways throws it in an arc). 0.5 = it just drips out.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 12f), Array.Empty<object>()));
			NozzleFlowSeconds = c.Bind<float>("Effects", "NozzleFlowSeconds", 0.45f, new ConfigDescription("How long (seconds) the stream keeps running after each press (a short, strong spurt that fades out). Lower = it stops sooner after the last press.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 3f), Array.Empty<object>()));
			PourSoundOffset = c.Bind<float>("Effects", "PourSoundOffset", 0f, new ConfigDescription("Fine tuning (seconds) of the pour sound against the stream at the nozzle. Negative = the sound comes earlier, positive = later. Use it if your audio output has a delay (Bluetooth, large buffers).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.5f, 0.5f), Array.Empty<object>()));
			BindDrain(c);
			BindPump(c);
			ModSettingsCommaFix.Apply(c, lines);
			DropRemoved(c);
			ModSettingsHose.Hook();
			EnableAll.SettingChanged += delegate
			{
				ModLog.Info("Config: EnableAll = " + EnableAll.Value + (EnableAll.Value ? ", the mod is on" : ", the mod is inert (no pumping, effects or menus)"));
			};
			ModLog.Verbose("Config: bound (EnableAll " + EnableAll.Value + ", debug log " + DebugLog.Value + ")");
		}

		private static int DropRemoved(ConfigFile c)
		{
			int num = 0;
			try
			{
				PropertyInfo property = typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				IDictionary dictionary = ((property != null) ? (property.GetValue(c, null) as IDictionary) : null);
				if (dictionary != null)
				{
					num = dictionary.Count;
					dictionary.Clear();
				}
				c.Save();
				if (num > 0)
				{
					ModLog.Info("Config: " + num + " entry(ies) that are no longer settings were removed from the file");
				}
			}
			catch (TargetInvocationException ex)
			{
				ModLog.Warn("Config: old entries could not be removed: " + ex.InnerException?.Message);
			}
			catch (IOException ex2)
			{
				ModLog.Warn("Config: the file could not be saved after removing old entries: " + ex2.Message);
			}
			return num;
		}

		private static void BindDrain(ConfigFile c)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Expected O, but got Unknown
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Expected O, but got Unknown
			VolumePerStroke = c.Bind<float>("Drain", "VolumePerStroke", 6f, new ConfigDescription("Cubic meters of liquid moved per pump stroke. Use the console command `dtp pits` to see how big the pits are.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 30f), Array.Empty<object>()));
			DrainRadius = c.Bind<float>("Drain", "DrainRadius", 4f, new ConfigDescription("Meters around the strainer that tar is pulled from. The pull is strongest at the strainer and fades towards the edge, so the pit gets a funnel instead of a flat hole; tar outside the radius flows in.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 8f), Array.Empty<object>()));
			StrainerSearchRadius = c.Bind<float>("Drain", "StrainerSearchRadius", 1f, new ConfigDescription("The strainer counts as 'in tar' if there is tar this close (m, sideways) to its tip, and pulls from the deepest tar around it. 0 = only straight under the tip.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>()));
			StrainerReach = c.Bind<float>("Drain", "StrainerReach", 0.5f, new ConfigDescription("How far (m) the strainer tip may hang ABOVE the liquid surface and still pump.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			MinTarDepth = c.Bind<float>("Drain", "MinTarDepth", 0.1f, new ConfigDescription("Minimum tar depth (m) under the strainer tip for it to count as 'in tar'.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 2f), Array.Empty<object>()));
			MaxChainPieces = c.Bind<int>("Drain", "MaxChainPieces", 40, new ConfigDescription("Longest hose chain (pieces) that is followed from the pump to a strainer / nozzle.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 100), Array.Empty<object>()));
			SnapTolerance = c.Bind<float>("Drain", "SnapTolerance", 0.3f, new ConfigDescription("Max distance (m) between two snap points for two pieces to count as connected.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 1f), Array.Empty<object>()));
			RefillMinutes = c.Bind<float>("Drain", "RefillMinutes", 60f, new ConfigDescription("Minutes (world time) for a drained tar pit to seep back to its original volume. Restarts with every pump stroke.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 120f), Array.Empty<object>()));
		}

		private static void BindPump(ConfigFile c)
		{
			AutoReach = c.Bind<bool>("Pump", "AutoReach", true, "While pumping, move the player just far enough towards the lever (and, only if that is not enough, up) for both hands to reach the handle at the top of the stroke. Turn off to use StandHeight / StandForward only.");
		}
	}
	internal enum HoseStyleOption
	{
		Transparent,
		Solid
	}
	internal enum WorldHoseStyleOption
	{
		Default,
		Transparent,
		Solid
	}
	internal enum WaterStyleOption
	{
		Game,
		Tropical,
		Lake,
		Ashlands
	}
	internal static class ModSettingsCommaFix
	{
		private static readonly Regex Section = new Regex("^\\s*\\[(?<s>[^\\]]+)\\]\\s*$");

		private static readonly Regex CommaNumber = new Regex("^\\s*(?<k>[^=#]+?)\\s*=\\s*(?<v>-?\\d+,\\d+)\\s*$");

		internal static string[] Capture(ConfigFile c)
		{
			try
			{
				return (c != null && !string.IsNullOrEmpty(c.ConfigFilePath) && File.Exists(c.ConfigFilePath)) ? File.ReadAllLines(c.ConfigFilePath) : null;
			}
			catch (Exception ex)
			{
				ModLog.Warn("Config comma check skipped: " + ex.Message);
				return null;
			}
		}

		internal static void Apply(ConfigFile c, string[] lines)
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			try
			{
				if (c == null || lines == null)
				{
					return;
				}
				string text = "";
				foreach (string input in lines)
				{
					Match match = Section.Match(input);
					if (match.Success)
					{
						text = match.Groups["s"].Value.Trim();
						continue;
					}
					Match match2 = CommaNumber.Match(input);
					if (!match2.Success)
					{
						continue;
					}
					ConfigDefinition val = new ConfigDefinition(text, match2.Groups["k"].Value);
					if (c.ContainsKey(val))
					{
						ConfigEntryBase val2 = c[val];
						if ((!(val2.SettingType != typeof(float)) || !(val2.SettingType != typeof(double))) && double.TryParse(match2.Groups["v"].Value.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
						{
							object boxedValue = val2.BoxedValue;
							val2.BoxedValue = ((val2.SettingType == typeof(float)) ? ((object)(float)result) : ((object)result));
							ModLog.Warn("Config [" + text + "] " + val.Key + " = " + match2.Groups["v"].Value + ": a comma is read as the decimal point -> " + Convert.ToString(val2.BoxedValue, CultureInfo.InvariantCulture) + " (BepInEx had read " + Convert.ToString(boxedValue, CultureInfo.InvariantCulture) + "). Please use a dot in the config file.");
						}
					}
				}
			}
			catch (Exception ex)
			{
				ModLog.Warn("Config comma check skipped: " + ex.Message);
			}
		}
	}
	internal static class ModSettingsHose
	{
		internal const string WorldSection = "World Hose Visuals";

		internal const string BuildSection = "Build Time Hose Visuals";

		public static void Bind(ConfigFile c)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			ModSettings.WorldHoseStyle = c.Bind<WorldHoseStyleOption>("World Hose Visuals", "World Hose Style", WorldHoseStyleOption.Default, "How all hoses (straight + elbow) already built in the world are shown. Default = each hose shows the style and opacity it was built with (its own Build Hose Style / Build Hose Opacity). Transparent = every hose see-through with World Hose Opacity. Solid = every hose opaque. Applies right away to all loaded hoses and on every world load; it never changes what a hose has stored, so going back to Default restores each hose's own look.");
			ModSettings.WorldHoseOpacity = c.Bind<float>("World Hose Visuals", "World Hose Opacity", 0.45f, new ConfigDescription("Opacity of all hoses in the world while World Hose Style = Transparent (0 = invisible, 1 = solid). Applies right away.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			ModSettings.BuildHoseStyle = c.Bind<HoseStyleOption>("Build Time Hose Visuals", "Build Hose Style", HoseStyleOption.Solid, "Style of a hose at the moment you build it: Transparent (the tar / water can be seen moving through it) or Solid. Stored on that hose for good. A change only affects hoses built from then on; hoses already built keep the style they were built with.");
			ModSettings.BuildHoseOpacity = c.Bind<float>("Build Time Hose Visuals", "Build Hose Opacity", 0.45f, new ConfigDescription("Opacity of a hose built with Build Hose Style = Transparent (0 = invisible, 1 = solid). Stored on that hose for good; a change only affects hoses built from then on.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		}

		public static void Hook()
		{
			ModSettings.WorldHoseStyle.SettingChanged += delegate
			{
				ModLog.Verbose("Config: World Hose Style = " + ModSettings.WorldHoseStyle.Value.ToString() + ", all loaded hoses are shown again");
				MaterialFixer.RequestWorldRefresh();
			};
			ModSettings.WorldHoseOpacity.SettingChanged += delegate
			{
				ModLog.Verbose("Config: World Hose Opacity = " + ModSettings.WorldHoseOpacity.Value.ToString("0.00") + ", all loaded hoses are shown again");
				MaterialFixer.RequestWorldRefresh();
			};
			ModSettings.BuildHoseStyle.SettingChanged += delegate
			{
				ModLog.Verbose("Config: Build Hose Style = " + ModSettings.BuildHoseStyle.Value.ToString() + ", for hoses built from now on");
				MaterialFixer.RequestRefresh();
			};
			ModSettings.BuildHoseOpacity.SettingChanged += delegate
			{
				ModLog.Verbose("Config: Build Hose Opacity = " + ModSettings.BuildHoseOpacity.Value.ToString("0.00") + ", for hoses built from now on");
				MaterialFixer.RequestRefresh();
			};
		}
	}
	[BepInPlugin("com.kydldev.DrainTarPit", "DrainTarPit", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGuid = "com.kydldev.DrainTarPit";

		public const string ModName = "DrainTarPit";

		public const string ModVersion = "1.0.0";

		public const string BundleName = "draintarpit";

		internal static Plugin Instance;

		internal static AssetBundle Bundle;

		private FileSystemWatcher _cfgWatcher;

		private volatile bool _cfgFileChanged;

		private float _cfgReloadAt;

		private int _cfgRetries;

		private void Awake()
		{
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			ModLog.Init(((BaseUnityPlugin)this).Logger);
			ModLog.Info("DrainTarPit 1.0.0 loaded (dll built " + File.GetLastWriteTime(Assembly.GetExecutingAssembly().Location).ToString("yyyy-MM-dd HH:mm:ss") + ")");
			ModSettings.Bind(((BaseUnityPlugin)this).Config);
			WatchConfigFile();
			Loc.Register();
			Bundle = LoadBundle();
			if ((Object)(object)Bundle == (Object)null)
			{
				ModLog.Error("Could not load asset bundle 'draintarpit'.");
				return;
			}
			string[] allAssetNames = Bundle.GetAllAssetNames();
			foreach (string text in allAssetNames)
			{
				ModLog.Verbose("bundle asset: " + text);
			}
			PumpFx.Preload();
			PrefabManager.OnVanillaPrefabsAvailable += PieceRegistrar.RegisterAll;
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new DtpCommands());
			new Harmony("com.kydldev.DrainTarPit").PatchAll(Assembly.GetExecutingAssembly());
			UiLog.VerboseSink = delegate(string s)
			{
				ModLog.Verbose(s);
			};
			UiLog.WarnSink = delegate(string s)
			{
				ModLog.Warn(s);
			};
			UiLog.ErrorSink = delegate(string s)
			{
				ModLog.Error(s);
			};
			UiInputLock.Install();
			ModLog.Info("WaterAndTarPools " + (PoolHooks.PoolsInstalled ? ("is loaded (" + PoolHooks.PoolsMod + ")") : "is loaded after this mod or not installed (pools / water come with it)"));
		}

		private static AssetBundle LoadBundle()
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
			foreach (string text in manifestResourceNames)
			{
				if (text != "draintarpit" && !text.EndsWith(".draintarpit"))
				{
					continue;
				}
				using Stream stream = executingAssembly.GetManifestResourceStream(text);
				using MemoryStream memoryStream = new MemoryStream();
				stream?.CopyTo(memoryStream);
				AssetBundle val = AssetBundle.LoadFromMemory(memoryStream.ToArray());
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			string text2 = Path.Combine(Path.GetDirectoryName(executingAssembly.Location), "draintarpit");
			return File.Exists(text2) ? AssetBundle.LoadFromFile(text2) : null;
		}

		private void WatchConfigFile()
		{
			try
			{
				string configFilePath = ((BaseUnityPlugin)this).Config.ConfigFilePath;
				_cfgWatcher = new FileSystemWatcher(Path.GetDirectoryName(configFilePath), Path.GetFileName(configFilePath))
				{
					NotifyFilter = (NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite)
				};
				_cfgWatcher.Changed += delegate
				{
					_cfgFileChanged = true;
				};
				_cfgWatcher.Created += delegate
				{
					_cfgFileChanged = true;
				};
				_cfgWatcher.Renamed += delegate
				{
					_cfgFileChanged = true;
				};
				_cfgWatcher.EnableRaisingEvents = true;
			}
			catch (Exception ex)
			{
				ModLog.Warn("Config file watcher not started (edits to the .cfg need a restart): " + ex.Message);
			}
		}

		private void TickConfigReload()
		{
			if (_cfgFileChanged)
			{
				_cfgFileChanged = false;
				_cfgReloadAt = Time.realtimeSinceStartup + 0.5f;
				_cfgRetries = 0;
			}
			if (_cfgReloadAt <= 0f || Time.realtimeSinceStartup < _cfgReloadAt)
			{
				return;
			}
			_cfgReloadAt = 0f;
			try
			{
				if (File.Exists(((BaseUnityPlugin)this).Config.ConfigFilePath))
				{
					((BaseUnityPlugin)this).Config.Reload();
					ModLog.Info("Config file changed on disk - reloaded.");
				}
			}
			catch (Exception ex)
			{
				if (++_cfgRetries <= 3)
				{
					_cfgReloadAt = Time.realtimeSinceStartup + 1f;
				}
				else
				{
					ModLog.Warn("Config reload failed: " + ex.Message);
				}
			}
		}

		private void OnDestroy()
		{
			if (_cfgWatcher != null)
			{
				_cfgWatcher.EnableRaisingEvents = false;
				_cfgWatcher.Dispose();
				_cfgWatcher = null;
			}
		}

		private void Update()
		{
			TickConfigReload();
			MaterialFixer.Tick();
		}

		internal void RunCoroutine(IEnumerator routine)
		{
			((MonoBehaviour)this).StartCoroutine(routine);
		}
	}
	internal struct WaterColour
	{
		public string Key;

		public Color Body;

		public Color Glow;

		public static readonly Color GameBody = new Color(0.3f, 0.55f, 0.72f, 1f);

		public static WaterColour Game => new WaterColour
		{
			Key = "Game",
			Body = GameBody,
			Glow = Color.black
		};

		public unsafe override string ToString()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			string[] obj = new string[6] { Key, " (body ", null, null, null, null };
			Color body = Body;
			obj[2] = ((object)(*(Color*)(&body))/*cast due to .constrained prefix*/).ToString();
			obj[3] = ", glow ";
			body = Glow;
			obj[4] = ((object)(*(Color*)(&body))/*cast due to .constrained prefix*/).ToString();
			obj[5] = ")";
			return string.Concat(obj);
		}
	}
	internal static class PoolHooks
	{
		internal static string PoolsMod = "";

		internal static Action<Vector3, Vector3, float, PumpLiquid> Deposit;

		internal static Func<DtpPiece, Vector3?, Vector3?, WaterColour> WaterColourFor;

		internal static readonly Dictionary<string, AudioClip> Clips = new Dictionary<string, AudioClip>(StringComparer.OrdinalIgnoreCase);

		internal static readonly Dictionary<string, Action<string[]>> Commands = new Dictionary<string, Action<string[]>>(StringComparer.OrdinalIgnoreCase);

		internal static bool PoolsInstalled => PoolsMod.Length > 0;

		internal static event Action<LiquidVolume, ZNetView> VolumeRegister;

		internal static event Action<LiquidVolume> VolumeUpdate;

		internal static event Action<LiquidVolume> VolumeDestroyed;

		internal static WaterColour ColourFor(DtpPiece pump, Vector3? source, Vector3? dest)
		{
			//IL_0034: Expected O, but got Unknown
			if (WaterColourFor == null)
			{
				ModLog.Verbose("PoolHooks: water colour = the fixed blue (WaterAndTarPools not installed)");
				return WaterColour.Game;
			}
			try
			{
				return WaterColourFor(pump, source, dest);
			}
			catch (MissingReferenceException ex)
			{
				MissingReferenceException ex2 = ex;
				ModLog.VerboseWarn("PoolHooks: water colour lookup hit a removed object (" + ((Exception)(object)ex2).Message + "), fixed blue used");
				return WaterColour.Game;
			}
		}

		internal static int RaiseRegister(LiquidVolume v, ZNetView nv)
		{
			Action<LiquidVolume, ZNetView> volumeRegister = PoolHooks.VolumeRegister;
			if (volumeRegister == null)
			{
				return 0;
			}
			volumeRegister(v, nv);
			return volumeRegister.GetInvocationList().Length;
		}

		internal static int RaiseUpdate(LiquidVolume v)
		{
			Action<LiquidVolume> volumeUpdate = PoolHooks.VolumeUpdate;
			if (volumeUpdate == null)
			{
				return 0;
			}
			volumeUpdate(v);
			return 1;
		}

		internal static int RaiseDestroyed(LiquidVolume v)
		{
			Action<LiquidVolume> volumeDestroyed = PoolHooks.VolumeDestroyed;
			if (volumeDestroyed == null)
			{
				return 0;
			}
			volumeDestroyed(v);
			return 1;
		}
	}
	public sealed class Tunable<T>
	{
		private readonly T _fixed;

		private T _value;

		public string Name { get; }

		public string Section { get; }

		public string Description { get; }

		public T Default => _fixed;

		public bool External { get; private set; }

		public T Value
		{
			get
			{
				return _value;
			}
			set
			{
				if (!object.Equals(_value, value))
				{
					T value2 = _value;
					_value = value;
					string[] obj = new string[11]
					{
						"Tunable: ", Section, ".", Name, " = ", null, null, null, null, null,
						null
					};
					T val = value;
					obj[5] = val?.ToString();
					obj[6] = " (was ";
					val = value2;
					obj[7] = val?.ToString();
					obj[8] = ", fixed value ";
					obj[9] = _fixed?.ToString();
					obj[10] = ")";
					ModLog.Verbose(string.Concat(obj));
					this.SettingChanged?.Invoke(this, EventArgs.Empty);
				}
			}
		}

		public event EventHandler SettingChanged;

		public Tunable(string section, string name, T value, string description = "")
		{
			Section = section;
			Name = name;
			Description = description ?? "";
			_fixed = value;
			_value = value;
		}

		public Tunable<T> SetFromConfigOf(string mod)
		{
			External = true;
			ModLog.Verbose("Tunable: " + Section + "." + Name + " is set from the config of " + mod);
			return this;
		}

		public T Reset()
		{
			Value = _fixed;
			return _value;
		}

		public override string ToString()
		{
			string[] obj = new string[5] { Section, ".", Name, " = ", null };
			T value = _value;
			obj[4] = value?.ToString();
			return string.Concat(obj);
		}
	}
}
namespace DrainTarPit.Visuals
{
	internal static class MaterialFixer
	{
		private static readonly HashSet<Material> Done = new HashSet<Material>();

		private static Shader _shader;

		private static bool _resolved;

		private static readonly Dictionary<Texture, Texture> BrightCache = new Dictionary<Texture, Texture>();

		private static volatile bool _worldRefreshPending;

		private static bool _noStandardLogged;

		private static readonly Dictionary<string, Material> ClearCache = new Dictionary<string, Material>();

		private static readonly Dictionary<Material, Material> ClearOrigin = new Dictionary<Material, Material>();

		private static readonly List<GameObject> HosePrefabs = new List<GameObject>();

		private static volatile bool _refreshPending;

		private static readonly Dictionary<string, Material> SolidByName = new Dictionary<string, Material>();

		private static Shader _clearShader;

		private static bool _clearResolved;

		private static bool WantsClear => ModSettings.BuildHoseStyle.Value == HoseStyleOption.Transparent && (int)SystemInfo.graphicsDeviceType != 4;

		public static Shader ResolveShader()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			if (_resolved)
			{
				return _shader;
			}
			_resolved = true;
			if ((int)SystemInfo.graphicsDeviceType == 4)
			{
				ModLog.Info("No graphics device (dedicated server?) - skipping material fix.");
				return null;
			}
			string value = ModSettings.ShaderName.Value;
			_shader = FindShader(value);
			if ((Object)(object)_shader == (Object)null)
			{
				ModLog.Warn("Shader '" + value + "' not found, trying Custom/Piece, then Standard.");
				_shader = FindShader("Custom/Piece") ?? FindShader("Standard");
			}
			if ((Object)(object)_shader == (Object)null)
			{
				ModLog.Error("No usable replacement shader found; materials will render pink.");
			}
			else
			{
				ModLog.Info("Material shader: " + ((Object)_shader).name);
				LogShaderProperties(_shader);
			}
			return _shader;
		}

		private static Shader FindShader(string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				return null;
			}
			Shader val = Shader.Find(name);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			try
			{
				return Cache.GetPrefab<Shader>(name);
			}
			catch
			{
				return null;
			}
		}

		private static void LogShaderProperties(Shader s)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			if (ModSettings.DebugLog.Value)
			{
				StringBuilder stringBuilder = new StringBuilder();
				int propertyCount = s.GetPropertyCount();
				for (int i = 0; i < propertyCount; i++)
				{
					stringBuilder.Append(s.GetPropertyName(i)).Append(':').Append(s.GetPropertyType(i))
						.Append("  ");
				}
				ModLog.Info("Shader properties: " + stringBuilder);
			}
		}

		public static void Apply(GameObject prefab)
		{
			Shader val = ResolveShader();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val2 in componentsInChildren)
			{
				Material[] sharedMaterials = val2.sharedMaterials;
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					if ((Object)(object)sharedMaterials[j] != (Object)null)
					{
						Fix(sharedMaterials[j], val);
					}
				}
				val2.sharedMaterials = sharedMaterials;
			}
		}

		private static void Fix(Material m, Shader shader)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			if (!Done.Add(m) || (Object)(object)m.shader == (Object)(object)shader)
			{
				return;
			}
			Texture val = GetTex(m, "_BaseColorMap") ?? GetTex(m, "_MainTex");
			Texture tex = GetTex(m, "_NormalMap");
			Texture tex2 = GetTex(m, "_MaskMap");
			Color val2 = (m.HasProperty("_BaseColor") ? m.GetColor("_BaseColor") : Color.white);
			float num = (m.HasProperty("_Metallic") ? m.GetFloat("_Metallic") : 0f);
			float num2 = (m.HasProperty("_Smoothness") ? m.GetFloat("_Smoothness") : 0.3f);
			float num3 = (m.HasProperty("_NormalScale") ? m.GetFloat("_NormalScale") : 1f);
			m.shader = shader;
			m.shaderKeywords = new string[0];
			Set(m, "_MainTex", Brighten(val, ModSettings.AlbedoBrightness.Value));
			if (m.HasProperty("_Color"))
			{
				m.SetColor("_Color", val2);
			}
			if ((Object)(object)tex != (Object)null && m.HasProperty("_BumpMap"))
			{
				m.SetTexture("_BumpMap", tex);
				if (m.HasProperty("_BumpScale"))
				{
					m.SetFloat("_BumpScale", num3);
				}
				m.EnableKeyword("_NORMALMAP");
			}
			if (m.HasProperty("_EmissionColor"))
			{
				m.SetColor("_EmissionColor", Color.black);
			}
			if (m.HasProperty("_EmissionMap"))
			{
				m.SetTexture("_EmissionMap", (Texture)null);
			}
			m.DisableKeyword("_EMISSION");
			if (m.HasProperty("_MetalColor"))
			{
				m.SetColor("_MetalColor", Color.white);
			}
			bool flag = (Object)(object)tex2 != (Object)null && ModSettings.UseMaskMap.Value;
			if (flag && m.HasProperty("_MetallicTex"))
			{
				m.SetTexture("_MetallicTex", tex2);
				if (m.HasProperty("_Metallic"))
				{
					m.SetFloat("_Metallic", 1f);
				}
				if (m.HasProperty("_MetallicAlphaGloss"))
				{
					m.SetFloat("_MetallicAlphaGloss", 1f);
				}
				if (m.HasProperty("_Glossiness"))
				{
					m.SetFloat("_Glossiness", 1f);
				}
			}
			else if (flag && m.HasProperty("_MetallicGlossMap"))
			{
				m.SetTexture("_MetallicGlossMap", tex2);
				m.EnableKeyword("_METALLICGLOSSMAP");
				if (m.HasProperty("_GlossMapScale"))
				{
					m.SetFloat("_GlossMapScale", 1f);
				}
				if (m.HasProperty("_OcclusionMap"))
				{
					m.SetTexture("_OcclusionMap", tex2);
				}
			}
			else
			{
				if (m.HasProperty("_Metallic"))
				{
					m.SetFloat("_Metallic", num);
				}
				if (m.HasProperty("_Glossiness"))
				{
					m.SetFloat("_Glossiness", num2);
				}
			}
			if (ModSettings.DebugLog.Value)
			{
				ModLog.Info("Fixed material " + ((Object)m).name + " (albedo=" + Name((Object)(object)val) + ", normal=" + Name((Object)(object)tex) + ", mask=" + Name((Object)(object)tex2) + ")");
			}
		}

		private static Texture Brighten(Texture src, float b)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)src == (Object)null || b <= 1.001f)
			{
				return src;
			}
			if (BrightCache.TryGetValue(src, out var value))
			{
				return value;
			}
			RenderTexture val = null;
			RenderTexture active = RenderTexture.active;
			try
			{
				val = RenderTexture.GetTemporary(src.width, src.height, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2);
				Graphics.Blit(src, val);
				RenderTexture.active = val;
				Texture2D val2 = new Texture2D(src.width, src.height, (TextureFormat)4, true, false);
				val2.ReadPixels(new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), 0, 0);
				byte[] array = new byte[256];
				for (int i = 0; i < 256; i++)
				{
					array[i] = (byte)Mathf.Clamp(Mathf.RoundToInt(Mathf.Pow((float)i / 255f, 1f / b) * 255f), 0, 255);
				}
				Color32[] pixels = val2.GetPixels32();
				for (int j = 0; j < pixels.Length; j++)
				{
					pixels[j].r = array[pixels[j].r];
					pixels[j].g = array[pixels[j].g];
					pixels[j].b = array[pixels[j].b];
				}
				val2.SetPixels32(pixels);
				val2.Apply(true);
				((Object)val2).name = ((Object)src).name + "_bright";
				((Texture)val2).wrapMode = src.wrapMode;
				((Texture)val2).filterMode = src.filterMode;
				BrightCache[src] = (Texture)(object)val2;
				return (Texture)(object)val2;
			}
			catch (Exception ex)
			{
				ModLog.Warn("Could not brighten texture " + ((Object)src).name + ": " + ex.Message);
				BrightCache[src] = src;
				return src;
			}
			finally
			{
				RenderTexture.active = active;
				if ((Object)(object)val != (Object)null)
				{
					RenderTexture.ReleaseTemporary(val);
				}
			}
		}

		internal static bool IsClearCopy(Material m)
		{
			return (Object)(object)m != (Object)null && ClearOrigin.ContainsKey(m);
		}

		public static void RequestWorldRefresh()
		{
			_worldRefreshPending = true;
			ModLog.Verbose("Hoses: world look refresh queued for the next frame");
		}

		private static bool IsHose(string n)
		{
			return n.Contains("Hose_Straight") || n.Contains("Elbow");
		}

		public static void MakeHosesClear(GameObject prefab)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)SystemInfo.graphicsDeviceType == 4 || !IsHose(((Object)prefab).name))
			{
				return;
			}
			if (!HosePrefabs.Contains(prefab))
			{
				HosePrefabs.Add(prefab);
			}
			Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				Material[] sharedMaterials = val.sharedMaterials;
				int num = WallSlot(sharedMaterials);
				if (num >= 0 && !LooksClear(sharedMaterials[num]))
				{
					SolidByName[BaseName(sharedMaterials[num])] = sharedMaterials[num];
					ModLog.Verbose("Hoses: solid wall material of " + ((Object)prefab).name + " = " + ((Object)sharedMaterials[num]).name);
				}
			}
			ApplyHoseStyle(prefab);
		}

		private static string BaseName(Material m)
		{
			string text = (((Object)(object)m != (Object)null) ? ((Object)m).name : "");
			bool flag = true;
			while (flag)
			{
				flag = false;
				if (text.EndsWith(" (Instance)"))
				{
					text = text.Substring(0, text.Length - " (Instance)".Length);
					flag = true;
				}
				if (text.EndsWith("_clear"))
				{
					text = text.Substring(0, text.Length - "_clear".Length);
					flag = true;
				}
			}
			return text;
		}

		private static bool LooksClear(Material m)
		{
			return (Object)(object)m != (Object)null && (ClearOrigin.ContainsKey(m) || ((Object)m).name.Contains("_clear") || m.renderQueue >= 3000);
		}

		private static Material SolidOf(Material current, string who)
		{
			if ((Object)(object)current == (Object)null)
			{
				return current;
			}
			if (ClearOrigin.TryGetValue(current, out var value) && !LooksClear(value))
			{
				return value;
			}
			if (!LooksClear(current))
			{
				SolidByName[BaseName(current)] = current;
				return current;
			}
			if (SolidByName.TryGetValue(BaseName(current), out value) && (Object)(object)value != (Object)null)
			{
				ModLog.Verbose("Hoses: " + who + " had a see-through wall material that was not ours (" + ((Object)current).name + "): its solid one is " + ((Object)value).name);
				return value;
			}
			ModLog.Warn("Hoses: no solid wall material known for " + ((Object)current).name + " on " + who + " - it stays see-through");
			return current;
		}

		public static void RequestRefresh()
		{
			_refreshPending = true;
			ModLog.Verbose("Hoses: build look refresh of the hose prefabs queued for the next frame");
		}

		public static void Tick()
		{
			if (_worldRefreshPending)
			{
				_worldRefreshPending = false;
				int num = DtpPiece.ShowAllHoseLooks();
				ModLog.Info("World Hose Style " + ModSettings.WorldHoseStyle.Value.ToString() + ((ModSettings.WorldHoseStyle.Value == WorldHoseStyleOption.Transparent) ? (" (opacity " + ModSettings.WorldHoseOpacity.Value.ToString("0.00") + ")") : "") + ": " + num + " loaded hose(s) shown again");
			}
			if (_refreshPending)
			{
				_refreshPending = false;
				RefreshHoses();
			}
		}

		private static void RefreshHoses()
		{
			try
			{
				if (HosePrefabs.Count == 0)
				{
					return;
				}
				int num = 0;
				foreach (GameObject hosePrefab in HosePrefabs)
				{
					if ((Object)(object)hosePrefab != (Object)null)
					{
						num += ApplyHoseStyle(hosePrefab);
					}
				}
				ModLog.Info("Build Hose Style " + ModSettings.BuildHoseStyle.Value.ToString() + (WantsClear ? (" (opacity " + ModSettings.BuildHoseOpacity.Value.ToString("0.00") + ")") : "") + " will be used for hoses built from now on (" + num + " prefab renderer(s) changed); hoses already built keep the look they were built with.");
			}
			catch (Exception ex)
			{
				ModLog.Warn("Could not refresh the hose look: " + ex.Message);
			}
		}

		private static int WallSlot(Material[] mats)
		{
			for (int i = 0; i < mats.Length; i++)
			{
				if ((Object)(object)mats[i] != (Object)null && ((Object)mats[i]).name.ToLowerInvariant().Contains("leather"))
				{
					return i;
				}
			}
			return (mats.Length == 0 || !((Object)(object)mats[0] != (Object)null)) ? (-1) : 0;
		}

		private static int ApplyHoseStyle(GameObject root)
		{
			return ApplyLook(root, ModSettings.BuildHoseStyle.Value, ModSettings.BuildHoseOpacity.Value);
		}

		public static int ApplyLook(GameObject root, HoseStyleOption style, float opacity)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			bool flag = style == HoseStyleOption.Transparent && (int)SystemInfo.graphicsDeviceType != 4;
			Shader val = (flag ? ResolveClearShader() : null);
			if (flag && (Object)(object)val == (Object)null)
			{
				if (!_noStandardLogged)
				{
					_noStandardLogged = true;
					ModLog.Warn("ClearHoses: no transparent-capable shader found (tried Standard, Sprites/Default, Hidden/Internal-Colored) - hoses stay solid.");
				}
				flag = false;
			}
			int num = 0;
			Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val2 in componentsInChildren)
			{
				Material[] sharedMaterials = val2.sharedMaterials;
				int num2 = WallSlot(sharedMaterials);
				if (num2 >= 0)
				{
					Material val3 = sharedMaterials[num2];
					Material val4 = SolidOf(val3, ((Object)root).name);
					Material val5 = (flag ? Clear(val4, val, opacity) : val4);
					if (!((Object)(object)val5 == (Object)(object)val3))
					{
						sharedMaterials[num2] = val5;
						val2.sharedMaterials = sharedMaterials;
						num++;
					}
				}
			}
			return num;
		}

		private static Shader ResolveClearShader()
		{
			if (_clearResolved)
			{
				return _clearShader;
			}
			_clearResolved = true;
			string[] array = new string[3] { "Standard", "Sprites/Default", "Hidden/Internal-Colored" };
			foreach (string name in array)
			{
				Shader val = FindShader(name);
				if ((Object)(object)val != (Object)null)
				{
					_clearShader = val;
					ModLog.Info("ClearHoses shader: " + ((Object)val).name);
					break;
				}
			}
			return _clearShader;
		}

		private static void SetOpacity(Material c, float a)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			string text = (((Object)(object)c.shader != (Object)null) ? ((Object)c.shader).name : "");
			if (text == "Standard")
			{
				c.color = new Color(1f, 1f, 1f, a);
			}
			else if (c.HasProperty("_Color"))
			{
				c.SetColor("_Color", (text == "Sprites/Default") ? new Color(1f, 1f, 1f, a) : new Color(0.55f, 0.5f, 0.4f, a));
			}
		}

		private static Material Clear(Material src, Shader std, float opacity)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			opacity = Mathf.Clamp(Mathf.Round(opacity * 100f) / 100f, 0.01f, 1f);
			string key = ((Object)src).GetInstanceID() + "|" + Mathf.RoundToInt(opacity * 100f);
			if (ClearCache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			value = new Material(std)
			{
				name = ((Object)src).name + "_clear"
			};
			Texture val = (src.HasProperty("_MainTex") ? src.GetTexture("_MainTex") : null);
			if ((Object)(object)val != (Object)null && value.HasProperty("_MainTex"))
			{
				value.mainTexture = val;
			}
			if (((Object)std).name != "Standard")
			{
				if (value.HasProperty("_SrcBlend"))
				{
					value.SetInt("_SrcBlend", 5);
				}
				if (value.HasProperty("_DstBlend"))
				{
					value.SetInt("_DstBlend", 10);
				}
				if (value.HasProperty("_ZWrite"))
				{
					value.SetInt("_ZWrite", 0);
				}
				if (value.HasProperty("_Cull"))
				{
					value.SetInt("_Cull", 0);
				}
				value.renderQueue = 3000;
			}
			else
			{
				if (value.HasProperty("_Metallic"))
				{
					value.SetFloat("_Metallic", 0f);
				}
				if (value.HasProperty("_Glossiness"))
				{
					value.SetFloat("_Glossiness", 0.4f);
				}
				value.SetFloat("_Mode", 2f);
				value.SetInt("_SrcBlend", 5);
				value.SetInt("_DstBlend", 10);
				value.SetInt("_ZWrite", 0);
				value.DisableKeyword("_ALPHATEST_ON");
				value.DisableKeyword("_ALPHAPREMULTIPLY_ON");
				value.EnableKeyword("_ALPHABLEND_ON");
				value.renderQueue = 3000;
			}
			SetOpacity(value, opacity);
			ClearCache[key] = value;
			ClearOrigin[value] = src;
			return value;
		}

		private static Texture GetTex(Material m, string prop)
		{
			return m.HasProperty(prop) ? m.GetTexture(prop) : null;
		}

		private static string Name(Object o)
		{
			return (o == (Object)null) ? "none" : o.name;
		}

		private static void Set(Material m, string prop, Texture t)
		{
			if ((Object)(object)t != (Object)null && m.HasProperty(prop))
			{
				m.SetTexture(prop, t);
			}
		}
	}
}
namespace DrainTarPit.Ui
{
	internal static class UiInputLock
	{
		private static readonly HashSet<string> Holders = new HashSet<string>();

		private static Harmony _harmony;

		private static int _patched;

		internal static int Count => Holders.Count;

		internal static void Install()
		{
			//IL_013e: Expected O, but got Unknown
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			try
			{
				_harmony = new Harmony("com.kydldev.DrainTarPit.uilock");
				MethodInfo methodInfo = AccessTools.Method(typeof(TextInput), "IsVisible", (Type[])null, (Type[])null);
				if (methodInfo != null)
				{
					_harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(UiInputLock), "VisiblePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					_patched++;
				}
				else
				{
					ModLog.Warn("UiInputLock: TextInput.IsVisible not found - the player can still move while a DrainTarPit menu is open");
				}
				foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(typeof(ZInput)))
				{
					if (!(declaredMethod.Name != "GetMouseScrollWheel") && !(declaredMethod.ReturnType != typeof(float)) && !declaredMethod.IsGenericMethod)
					{
						_harmony.Patch((MethodBase)declaredMethod, (HarmonyMethod)null, new HarmonyMethod(typeof(UiInputLock), "ScrollPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
						_patched++;
					}
				}
				ModLog.Verbose("UiInputLock: " + _patched + " game method(s) patched (TextInput.IsVisible + ZInput.GetMouseScrollWheel)");
			}
			catch (HarmonyException ex)
			{
				HarmonyException ex2 = ex;
				ModLog.Warn("UiInputLock: patching failed: " + ((Exception)(object)ex2).Message);
			}
			catch (Exception ex3)
			{
				ModLog.Warn("UiInputLock: install failed: " + ex3.Message);
			}
		}

		internal static int Hold(string who)
		{
			Holders.Add(who);
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
			ModLog.Verbose("UiInputLock: held by '" + who + "' (" + Holders.Count + " holder(s))");
			return Holders.Count;
		}

		internal static int Release(string who)
		{
			int count = Holders.Count;
			Holders.Remove(who);
			if (count != Holders.Count)
			{
				ModLog.Verbose("UiInputLock: released by '" + who + "' (" + Holders.Count + " holder(s) left)");
			}
			return Holders.Count;
		}

		private static void VisiblePostfix(ref bool __result)
		{
			if (Holders.Count > 0)
			{
				__result = true;
			}
		}

		private static void ScrollPostfix(ref float __result)
		{
			if (Holders.Count > 0)
			{
				__result = 0f;
			}
		}
	}
	internal static class UiControls
	{
		private const float ItemHeight = 40f;

		private const float ListMax = 400f;

		private static readonly string[] Palette = new string[14]
		{
			"#FFFFFF", "#000000", "#E8D5A9", "#FFB85C", "#C0392B", "#E67E22", "#F1C40F", "#2ECC71", "#1ABC9C", "#00FFFF",
			"#3498DB", "#9B59B6", "#FF33FF", "#7F8C8D"
		};

		internal static Button Button(string text, Action onClick, bool primary = false)
		{
			//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_0039: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			Button b = new Button((Action)delegate
			{
				UiLog.Verbose("Ui: button '" + text + "' pressed");
				onClick?.Invoke();
			})
			{
				text = text
			};
			Color bg = (primary ? UiKit.GoldDim : UiKit.PanelLight);
			Color hot = (primary ? UiKit.Gold : UiKit.PanelHover);
			((VisualElement)b).style.backgroundColor = StyleColor.op_Implicit(bg);
			((VisualElement)b).style.color = StyleColor.op_Implicit(primary ? UiKit.OnDark : UiKit.Text);
			((VisualElement)b).style.fontSize = StyleLength.op_Implicit(21f);
			UiKit.Borders((VisualElement)(object)b, 1f, UiKit.Border);
			UiKit.Radius((VisualElement)(object)b, 4f);
			UiKit.Pad((VisualElement)(object)b, 6f, 14f);
			((VisualElement)b).style.flexShrink = StyleFloat.op_Implicit(0f);
			((VisualElement)b).style.marginLeft = StyleLength.op_Implicit(3f);
			((VisualElement)b).style.marginRight = StyleLength.op_Implicit(3f);
			((VisualElement)b).style.marginTop = StyleLength.op_Implicit(3f);
			((VisualElement)b).style.marginBottom = StyleLength.op_Implicit(3f);
			UiKit.Fade((VisualElement)(object)b, "background-color");
			((CallbackEventHandler)b).RegisterCallback<PointerEnterEvent>((EventCallback<PointerEnterEvent>)delegate
			{
				//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)
				((VisualElement)b).style.backgroundColor = StyleColor.op_Implicit(hot);
			}, (TrickleDown)0);
			((CallbackEventHandler)b).RegisterCallback<PointerLeaveEvent>((EventCallback<PointerLeaveEvent>)delegate
			{
				//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)
				((VisualElement)b).style.backgroundColor = StyleColor.op_Implicit(bg);
			}, (TrickleDown)0);
			return b;
		}

		internal static Button Field(string text, Action onClick)
		{
			//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_0039: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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)
			//IL_007f: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			Button b = new Button((Action)delegate
			{
				UiLog.Verbose("Ui: field '" + text + "' opened");
				onClick?.Invoke();
			})
			{
				text = text
			};
			((VisualElement)b).style.backgroundColor = StyleColor.op_Implicit(UiKit.Track);
			((VisualElement)b).style.color = StyleColor.op_Implicit(UiKit.Gold);
			((VisualElement)b).style.fontSize = StyleLength.op_Implicit(22f);
			UiKit.Borders((VisualElement)(object)b, 1f, UiKit.Border);
			UiKit.Radius((VisualElement)(object)b, 4f);
			UiKit.Pad((VisualElement)(object)b, 5f, 10f);
			((VisualElement)b).style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)3);
			((VisualElement)b).style.flexShrink = StyleFloat.op_Implicit(0f);
			((VisualElement)b).style.marginLeft = StyleLength.op_Implicit(0f);
			((VisualElement)b).style.marginRight = StyleLength.op_Implicit(0f);
			UiKit.Fade((VisualElement)(object)b, "border-top-color", "border-bottom-color", "border-left-color", "border-right-color");
			((CallbackEventHandler)b).RegisterCallback<PointerEnterEvent>((EventCallback<PointerEnterEvent>)delegate
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				UiKit.Borders((VisualElement)(object)b, 1f, UiKit.Gold);
			}, (TrickleDown)0);
			((CallbackEventHandler)b).RegisterCallback<PointerLeaveEvent>((EventCallback<PointerLeaveEvent>)delegate
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				UiKit.Borders((VisualElement)(object)b, 1f, UiKit.Border);
			}, (TrickleDown)0);
			return b;
		}

		internal static VisualElement Heading(string text)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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)
			VisualElement val = new VisualElement();
			val.style.flexShrink = StyleFloat.op_Implicit(0f);
			val.style.marginTop = StyleLength.op_Implicit(16f);
			val.style.marginBottom = StyleLength.op_Implicit(6f);
			Label val2 = UiKit.Label(text.ToUpperInvariant(), 24f, UiKit.Gold, title: true);
			((VisualElement)val2).style.letterSpacing = StyleLength.op_Implicit(1.5f);
			val.Add((VisualElement)(object)val2);
			VisualElement val3 = new VisualElement();
			val3.style.height = StyleLength.op_Implicit(1f);
			val3.style.backgroundColor = StyleColor.op_Implicit(UiKit.Border);
			val3.style.marginTop = StyleLength.op_Implicit(4f);
			val.Add(val3);
			return val;
		}

		internal static Label Note(string text)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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)
			Label val = UiKit.Label(text, 18f, UiKit.TextDim);
			((VisualElement)val).style.whiteSpace = StyleEnum<WhiteSpace>.op_Implicit((WhiteSpace)0);
			((VisualElement)val).style.flexShrink = StyleFloat.op_Implicit(0f);
			((VisualElement)val).style.marginTop = StyleLength.op_Implicit(2f);
			((VisualElement)val).style.marginBottom = StyleLength.op_Implicit(2f);
			return val;
		}

		internal static VisualElement Row(string label, VisualElement control)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_0073: 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_00a0: 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)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			VisualElement val = new VisualElement();
			val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			val.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
			val.style.flexShrink = StyleFloat.op_Implicit(0f);
			val.style.marginTop = StyleLength.op_Implicit(4f);
			val.style.marginBottom = StyleLength.op_Implicit(4f);
			Label val2 = UiKit.Label(label, 22f, UiKit.Text);
			((VisualElement)val2).style.width = StyleLength.op_Implicit(170f);
			((VisualElement)val2).style.flexShrink = StyleFloat.op_Implicit(0f);
			val.Add((VisualElement)(object)val2);
			control.style.flexGrow = StyleFloat.op_Implicit(1f);
			control.style.flexShrink = StyleFloat.op_Implicit(1f);
			val.Add(control);
			return val;
		}

		internal static VisualElement Line(params VisualElement[] items)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			VisualElement val = new VisualElement();
			val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			val.style.flexWrap = StyleEnum<Wrap>.op_Implicit((Wrap)1);
			val.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
			val.style.flexShrink = StyleFloat.op_Implicit(0f);
			foreach (VisualElement val2 in items)
			{
				val.Add(val2);
			}
			return val;
		}

		internal static TextField TextField(string value, int maxLength, Action<string> changed)
		{
			//IL_000e: 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_0023: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_002d: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_007a: 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)
			TextField val = new TextField();
			((BaseField<string>)val).value = value ?? "";
			((TextInputBaseField<string>)val).maxLength = maxLength;
			TextField val2 = val;
			((VisualElement)val2).style.marginLeft = StyleLength.op_Implicit(0f);
			((VisualElement)val2).style.marginRight = StyleLength.op_Implicit(0f);
			((VisualElement)val2).style.marginTop = StyleLength.op_Implicit(0f);
			((VisualElement)val2).style.marginBottom = StyleLength.op_Implicit(0f);
			((VisualElement)val2).style.flexShrink = StyleFloat.op_Implicit(0f);
			StyleInput(val2, 22);
			INotifyValueChangedExtensions.RegisterValueChangedCallback<string>((INotifyValueChanged<string>)(object)val2, (EventCallback<ChangeEvent<string>>)delegate(ChangeEvent<string> e)
			{
				changed?.Invoke(e.newValue);
			});
			return val2;
		}

		private static void StyleInput(TextField f, int size)
		{
			//IL_0029: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			VisualElement input = (VisualElement)(((object)UQueryExtensions.Q((VisualElement)(object)f, (string)null, TextField.inputUssClassName)) ?? ((object)f));
			input.style.backgroundColor = StyleColor.op_Implicit(UiKit.Track);
			input.style.color = StyleColor.op_Implicit(UiKit.Gold);
			input.style.fontSize = StyleLength.op_Implicit((float)size);
			UiKit.Borders(input, 1f, UiKit.Border);
			UiKit.Radius(input, 4f);
			UiKit.Pad(input, 5f, 8f);
			input.style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)3);
			((CallbackEventHandler)f).RegisterCallback<FocusInEvent>((EventCallback<FocusInEvent>)delegate
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				UiKit.Borders(input, 1f, UiKit.Gold);
			}, (TrickleDown)0);
			((CallbackEventHandler)f).RegisterCallback<FocusOutEvent>((EventCallback<FocusOutEvent>)delegate
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				UiKit.Borders(input, 1f, UiKit.Border);
			}, (TrickleDown)0);
		}

		internal static VisualElement Toggle(string text, bool on, Action<bool> changed)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_00d7: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Expected O, but got Unknown
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			VisualElement row = new VisualElement();
			row.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			row.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
			row.style.flexShrink = StyleFloat.op_Implicit(0f);
			UiKit.Pad(row, 5f, 8f);
			UiKit.Radius(row, 4f);
			row.style.marginRight = StyleLength.op_Implicit(6f);
			UiKit.Fade(row, "background-color");
			VisualElement sw = new VisualElement();
			sw.pickingMode = (PickingMode)1;
			sw.style.width = StyleLength.op_Implicit(44f);
			sw.style.height = StyleLength.op_Implicit(22f);
			sw.style.flexShrink = StyleFloat.op_Implicit(0f);
			sw.style.marginRight = StyleLength.op_Implicit(8f);
			UiKit.Radius(sw, 11f);
			UiKit.Borders(sw, 1f, UiKit.Border);
			UiKit.Fade(sw, "background-color");
			VisualElement knob = new VisualElement();
			knob.pickingMode = (PickingMode)1;
			knob.style.position = StyleEnum<Position>.op_Implicit((Position)1);
			knob.style.top = StyleLength.op_Implicit(2f);
			knob.style.width = StyleLength.op_Implicit(16f);
			knob.style.height = StyleLength.op_Implicit(16f);
			UiKit.Radius(knob, 8f);
			UiKit.Fade(knob, "left", "background-color");
			sw.Add(knob);
			row.Add(sw);
			row.Add((VisualElement)(object)UiKit.Label(text, 22f, UiKit.Text));
			((CallbackEventHandler)row).RegisterCallback<PointerEnterEvent>((EventCallback<PointerEnterEvent>)delegate
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				row.style.backgroundColor = StyleColor.op_Implicit(UiKit.PanelLight);
			}, (TrickleDown)0);
			((CallbackEventHandler)row).RegisterCallback<PointerLeaveEvent>((EventCallback<PointerLeaveEvent>)delegate
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				row.style.backgroundColor = StyleColor.op_Implicit(Color.clear);
			}, (TrickleDown)0);
			((CallbackEventHandler)row).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e)
			{
				if (((PointerEventBase<PointerDownEvent>)(object)e).button == 0)
				{
					on = !on;
					Show();
					UiLog.Verbose("Ui: switch '" + text + "' " + (on ? "on" : "off"));
					changed?.Invoke(on);
				}
			}, (TrickleDown)0);
			Show();
			return row;
			void Show()
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: 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_0069: 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_006e: Unknown result type (might be due to invalid IL or missing references)
				sw.style.backgroundColor = StyleColor.op_Implicit(on ? UiKit.GoldDim : UiKit.Track);
				knob.style.left = StyleLength.op_Implicit((float)(on ? 24 : 2));
				knob.style.backgroundColor = StyleColor.op_Implicit(on ? UiKit.Gold : UiKit.TextDim);
			}
		}

		internal static VisualElement Slider(float min, float max, float value, string format, Action<float> changed)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Expected O, but got Unknown
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Expected O, but got Unknown
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Expected O, but got Unknown
			//IL_0319: Expected O, but got Unknown
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			VisualElement val = new VisualElement();
			val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			val.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
			val.style.flexShrink = StyleFloat.op_Implicit(0f);
			val.style.minHeight = StyleLength.op_Implicit(34f);
			VisualElement hit = new VisualElement();
			hit.style.flexGrow = StyleFloat.op_Implicit(1f);
			hit.style.height = StyleLength.op_Implicit(24f);
			hit.style.justifyContent = StyleEnum<Justify>.op_Implicit((Justify)1);
			hit.style.marginRight = StyleLength.op_Implicit(10f);
			VisualElement val2 = new VisualElement();
			val2.pickingMode = (PickingMode)1;
			val2.style.height = StyleLength.op_Implicit(6f);
			UiKit.Radius(val2, 3f);
			val2.style.backgroundColor = StyleColor.op_Implicit(UiKit.Track);
			UiKit.Borders(val2, 1f, UiKit.Border);
			hit.Add(val2);
			VisualElement fill = new VisualElement();
			fill.pickingMode = (PickingMode)1;
			fill.style.position = StyleEnum<Position>.op_Implicit((Position)1);
			fill.style.left = StyleLength.op_Implicit(0f);
			fill.style.top = StyleLength.op_Implicit(0f);
			fill.style.bottom = StyleLength.op_Implicit(0f);
			fill.style.backgroundColor = StyleColor.op_Implicit(UiKit.GoldDim);
			UiKit.Radius(fill, 3f);
			val2.Add(fill);
			VisualElement handle = new VisualElement();
			handle.pickingMode = (PickingMode)1;
			handle.style.position = StyleEnum<Position>.op_Implicit((Position)1);
			handle.style.top = StyleLength.op_Implicit(4f);
			handle.style.width = StyleLength.op_Implicit(16f);
			handle.style.height = StyleLength.op_Implicit(16f);
			handle.style.marginLeft = StyleLength.op_Implicit(-8f);
			UiKit.Radius(handle, 8f);
			handle.style.backgroundColor = StyleColor.op_Implicit(UiKit.Gold);
			UiKit.Borders(handle, 1f, UiKit.OnDark);
			hit.Add(handle);
			val.Add(hit);
			TextField val3 = new TextField();
			((TextInputBaseField<string>)val3).maxLength = 8;
			TextField input = val3;
			((VisualElement)input).style.width = StyleLength.op_Implicit(80f);
			((VisualElement)input).style.flexShrink = StyleFloat.op_Implicit(0f);
			((VisualElement)input).style.marginLeft = StyleLength.op_Implicit(0f);
			((VisualElement)input).style.marginRight = StyleLength.op_Implicit(0f);
			((VisualElement)input).style.marginTop = StyleLength.op_Implicit(0f);
			((VisualElement)input).style.marginBottom = StyleLength.op_Implicit(0f);
			StyleInput(input, 19);
			val.Add((VisualElement)(object)input);
			float v = Mathf.Clamp(value, min, max);
			bool editing = false;
			((CallbackEventHandler)hit).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e)
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				PointerCaptureHelper.CapturePointer((IEventHandler)(object)hit, ((PointerEventBase<PointerDownEvent>)(object)e).pointerId);
				FromX(((PointerEventBase<PointerDownEvent>)(object)e).localPosition.x);
				((EventBase)e).StopPropagation();
			}, (TrickleDown)0);
			((CallbackEventHandler)hit).RegisterCallback<PointerMoveEvent>((EventCallback<PointerMoveEvent>)delegate(PointerMoveEvent e)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				if (PointerCaptureHelper.HasPointerCapture((IEventHandler)(object)hit, ((PointerEventBase<PointerMoveEvent>)(object)e).pointerId))
				{
					FromX(((PointerEventBase<PointerMoveEvent>)(object)e).localPosition.x);
				}
			}, (TrickleDown)0);
			((CallbackEventHandler)hit).RegisterCallback<PointerUpEvent>((EventCallback<PointerUpEvent>)delegate(PointerUpEvent e)
			{
				if (PointerCaptureHelper.HasPointerCapture((IEventHandler)(object)hit, ((PointerEventBase<PointerUpEvent>)(object)e).pointerId))
				{
					PointerCaptureHelper.ReleasePointer((IEventHandler)(object)hit, ((PointerEventBase<PointerUpEvent>)(object)e).pointerId);
					UiLog.Verbose("Ui: slider set to " + v.ToString(format));
				}
			}, (TrickleDown)0);
			((CallbackEventHandler)input).RegisterCallback<FocusInEvent>((EventCallback<FocusInEvent>)delegate
			{
				editing = true;
			}, (TrickleDown)0);
			((CallbackEventHandler)input).RegisterCallback<FocusOutEvent>((EventCallback<FocusOutEvent>)delegate
			{
				editing = false;
				Commit();
			}, (TrickleDown)0);
			((CallbackEventHandler)input).RegisterCallback<KeyDownEvent>((EventCallback<KeyDownEvent>)delegate(KeyDownEvent e)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Invalid comparison between Unknown and I4
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Invalid comparison between Unknown and I4
				if ((int)((KeyboardEventBase<KeyDownEvent>)(object)e).keyCode == 13 || (int)((KeyboardEventBase<KeyDownEvent>)(object)e).keyCode == 271)
				{
					((EventBase)e).StopPropagation();
					editing = false;
					Commit();
					((Focusable)input).Blur();
				}
			}, (TrickleDown)0);
			Show();
			return val;
			void Commit()
			{
				string s = (((BaseField<string>)(object)input).value ?? "").Trim().Replace(',', '.');
				if (float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
				{
					Set(result, "typed");
					UiLog.Verbose("Ui: slider typed " + v.ToString(format));
				}
				else
				{
					UiLog.Verbose("Ui: slider input '" + ((BaseField<string>)(object)input).value + "' is not a number, kept " + v.ToString(format));
					Show();
				}
			}
			void FromX(float x)
			{
				float width = hit.resolvedStyle.width;
				if (width > 1f)
				{
					Set(Mathf.Lerp(min, max, Mathf.Clamp01(x / width)), "drag");
				}
			}
			void Set(float nv, string how)
			{
				v = Mathf.Clamp(nv, min, max);
				Show();
				changed?.Invoke(v);
			}
			void Show()
			{
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: 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_0067: Unknown result type (might be due to invalid IL or missing references)
				float num = ((max > min) ? Mathf.InverseLerp(min, max, v) : 0f);
				fill.style.width = StyleLength.op_Implicit(Length.Percent(num * 100f));
				handle.style.left = StyleLength.op_Implicit(Length.Percent(num * 100f));
				if (!editing)
				{
					((BaseField<string>)(object)input).SetValueWithoutNotify(v.ToString(format));
				}
			}
		}

		internal static Button Dropdown(IList<string> options, string current, Func<string, string> label, Action<string> chosen)
		{
			Button b = null;
			string cur = current;
			b = Field(label(current) + "  ▾", delegate
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Expected O, but got Unknown
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Expected O, but got Unknown
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_012d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0132: Unknown result type (might be due to invalid IL or missing references)
				//IL_0169: Unknown result type (might be due to invalid IL or missing references)
				//IL_0181: Unknown result type (might be due to invalid IL or missing references)
				//IL_0194: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0202: Unknown result type (might be due to invalid IL or missing references)
				//IL_0213: Unknown result type (might be due to invalid IL or missing references)
				//IL_02be: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_0305: Unknown result type (might be due to invalid IL or missing references)
				//IL_0321: Unknown result type (might be due to invalid IL or missing references)
				VisualElement root = UiKit.Root;
				if (root != null)
				{
					VisualElement shade = new VisualElement
					{
						name = "dtp-dropdown"
					};
					shade.style.position = StyleEnum<Position>.op_Implicit((Position)1);
					shade.style.left = StyleLength.op_Implicit(0f);
					shade.style.top = StyleLength.op_Implicit(0f);
					shade.style.right = StyleLength.op_Implicit(0f);
					shade.style.bottom = StyleLength.op_Implicit(0f);
					shade.style.backgroundColor = StyleColor.op_Implicit(new Color(0f, 0f, 0f, 0.35f));
					VisualElement val = new VisualElement();
					Rect worldBound = ((VisualElement)b).worldBound;
					float num = Mathf.Min(400f, (float)options.Count * 40f + 12f);
					float num2 = ((Rect)(ref worldBound)).yMax + num;
					Rect layout = root.layout;
					float num3 = ((num2 > ((Rect)(ref layout)).height) ? Mathf.Max(0f, ((Rect)(ref worldBound)).yMin - num) : (((Rect)(ref worldBound)).yMax + 2f));
					val.style.position = StyleEnum<Position>.op_Implicit((Position)1);
					val.style.left = StyleLength.op_Implicit(((Rect)(ref worldBound)).xMin);
					val.style.top = StyleLength.op_Implicit(num3);
					val.style.width = StyleLength.op_Implicit(Mathf.Max(((Rect)(ref worldBound)).width, 260f));
					val.style.height = StyleLength.op_Implicit(num);
					val.style.backgroundColor = StyleColor.op_Implicit(new Color(UiKit.Panel.r, UiKit.Panel.g, UiKit.Panel.b, 1f));
					UiKit.Borders(val, 1f, UiKit.Gold);
					UiKit.Radius(val, 6f);
					UiKit.Pad(val, 4f, 4f);
					UiScroll uiScroll = new UiScroll("drop-down");
					val.Add(uiScroll.Root);
					foreach (string option in options)
					{
						string opt = option;
						Label item = UiKit.Label(label(opt), 22f, (opt == cur) ? UiKit.Gold : UiKit.Text);
						((VisualElement)item).pickingMode = (PickingMode)0;
						((VisualElement)item).style.height = StyleLength.op_Implicit(36f);
						((VisualElement)item).style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)3);
						((VisualElement)item).style.flexShrink = StyleFloat.op_Implicit(0f);
						UiKit.Pad((VisualElement)(object)item, 0f, 10f);
						UiKit.Radius((VisualElement)(object)item, 4f);
						UiKit.Fade((VisualElement)(object)item, "background-color");
						((CallbackEventHandler)item).RegisterCallback<PointerEnterEvent>((EventCallback<PointerEnterEvent>)delegate
						{
							//IL_000b: Unknown result type (might be due to invalid IL or missing references)
							//IL_0010: Unknown result type (might be due to invalid IL or missing references)
							((VisualElement)item).style.backgroundColor = StyleColor.op_Implicit(UiKit.PanelHover);
						}, (TrickleDown)0);
						((CallbackEventHandler)item).RegisterCallback<PointerLeaveEvent>((EventCallback<PointerLeaveEvent>)delegate
						{
							//IL_000b: Unknown result type (might be due to invalid IL or missing references)
							//IL_0010: Unknown result type (might be due to invalid IL or missing references)
							((VisualElement)item).style.backgroundColor = StyleColor.op_Implicit(Color.clear);
						}, (TrickleDown)0);
						((CallbackEventHandler)item).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e)
						{
							if (((PointerEventBase<PointerDownEvent>)(object)e).button == 0)
							{
								cur = opt;
								((TextElement)b).text = label(opt) + "  ▾";
								shade.RemoveFromHierarchy();
								UiLog.Verbose("Ui: drop-down chose '" + opt + "'");
								chosen?.Invoke(opt);
							}
						}, (TrickleDown)0);
						uiScroll.Content.Add((VisualElement)(object)item);
					}
					((CallbackEventHandler)shade).RegisterCallback<PointerDownEvent>((EventCallback<PointerDownEvent>)delegate(PointerDownEvent e)
					{
						if ((object)((EventBase)e).target == shade)
						{
							shade.RemoveFromHierarchy();
							UiLog.Verbose("Ui: drop-down closed without a choice");
						}
					}, (TrickleDown)0);
					shade.Add(val);
					root.Add(shade);
					int num4 = options.IndexOf(cur);
					if (num4 > 3)
					{
						uiScroll.ScrollTo((float)(num4 - 3) * 40f);
					}
					UiLog.Verbose("Ui: drop-down opened with " + options.Count + " option(s), current '" + cur + "'");
				}
			});
			return b;
		}

		internal static VisualElement ColorPicker(string hex, Action<string> changed, out Action<string> set)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_006e: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Expected O, but got Unknown
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			VisualElement val = new VisualElement();
			val.style.flexShrink = StyleFloat.op_Implicit(0f);
			Color c = default(Color);
			if (!ColorUtility.TryParseHtmlString(hex ?? "#FFFFFF", ref c))
			{
				c = Color.white;
			}
			VisualElement preview = new VisualElement();
			preview.style.height = StyleLength.op_Implicit(26f);
			UiKit.Radius(preview, 4f);
			UiKit.Borders(preview, 1f, UiKit.Border);
			val.Add(preview);
			VisualElement val2 = new VisualElement();
			val2.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			val2.style.flexWrap = StyleEnum<Wrap>.op_Implicit((Wrap)1);
			val2.style.flexShrink = StyleFloat.op_Implicit(0f);
			val2.style.marginTop = StyleLength.op_Implicit(8f);
			val2.style.marginBottom = StyleLength.op_Implicit(4f);
			val.Add(val2);
			VisualElement sliders = new VisualElement();
			sliders.style.flexShrink = StyleFloat.op_Implicit(0f);
			val.Add(sliders);
			TextField field = null;
			string[] palette = Palette;
			Color pc = default(Color);
			foreach (string text in palette)
			{
				ColorUtility.TryParseHtmlString(text, ref pc);
				VisualElement s = new VisualElement();
				s.style.w