Decompiled source of WigglesFlags v1.2.0

UserLibs/WigglesFlags.Fusion.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using LabFusion.Network;
using LabFusion.Network.Serialization;
using LabFusion.Player;
using LabFusion.SDK.Modules;
using MelonLoader;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: SecurityPermission((SecurityAction)8, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : System.Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(/*Could not decode attribute arguments.*/)]
	internal sealed class RefSafetyRulesAttribute : System.Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WigglesFlags
{
	public static class FlagNet
	{
		private static bool _warned;

		public static void Register()
		{
			ModuleMessageManager.RegisterHandler<FlagMessage>();
			Net.Online = () => NetworkInfo.HasServer;
			Net.LocalId = () => PlayerIDManager.LocalSmallID;
			Net.Send = Send;
		}

		private static void Send(byte kind, byte owner, int id, bool pole, string country, float[] p, bool reliable)
		{
			//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)
			if (!NetworkInfo.HasServer)
			{
				return;
			}
			FlagData flagData = new FlagData
			{
				Kind = kind,
				Owner = owner,
				Id = id,
				Pole = (pole ? ((byte)1) : ((byte)0)),
				Country = (country ?? "")
			};
			System.Array.Copy((System.Array)p, (System.Array)flagData.P, Math.Min(flagData.P.Length, p.Length));
			try
			{
				MessageRelay.RelayModule<FlagMessage, FlagData>(flagData, reliable ? CommonMessageRoutes.ReliableToOtherClients : CommonMessageRoutes.UnreliableToOtherClients);
			}
			catch (System.Exception ex)
			{
				if (!_warned)
				{
					_warned = true;
					FlagMod instance = FlagMod.Instance;
					if (instance != null)
					{
						((MelonBase)instance).LoggerInstance.Warning("Flag sync send failed (ignored): " + ex.Message);
					}
				}
			}
		}
	}
	public class FlagData : INetSerializable
	{
		public byte Kind;

		public byte Owner;

		public byte Pole;

		public int Id;

		public string Country = "";

		public float[] P = new float[12];

		public int? GetSize()
		{
			return null;
		}

		public void Serialize(INetSerializer s)
		{
			s.SerializeValue(ref Kind);
			s.SerializeValue(ref Owner);
			s.SerializeValue(ref Pole);
			s.SerializeValue(ref Id);
			s.SerializeValue(ref Country);
			for (int i = 0; i < P.Length; i++)
			{
				s.SerializeValue(ref P[i]);
			}
		}
	}
	public class FlagMessage : ModuleMessageHandler
	{
		protected override void OnHandleMessage(ReceivedMessage received)
		{
			FlagData flagData = ((ReceivedMessage)(ref received)).ReadData<FlagData>();
			if (flagData.Owner != PlayerIDManager.LocalSmallID)
			{
				FlagMod.OnNet(flagData.Kind, flagData.Owner, flagData.Id, flagData.Pole != 0, flagData.Country, flagData.P);
			}
		}
	}
}

UserLibs/WigglesFlags.Timeline.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using Microsoft.CodeAnalysis;
using Timeline;
using Timeline.Serialization.Binary;
using Timeline.Serialization.Registry;
using Timeline.WorldRecording;
using Timeline.WorldRecording.Recorders;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: SecurityPermission((SecurityAction)8, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : System.Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(/*Could not decode attribute arguments.*/)]
	internal sealed class RefSafetyRulesAttribute : System.Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WigglesFlags
{
	public static class FlagTimeline
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action <0>__Tick;

			public static Action <1>__Clear;
		}

		internal const byte RecorderId = 220;

		private static FlagsRecorder _current;

		private static bool _wasRecording;

		public static void Register()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			object obj = <>O.<0>__Tick;
			if (obj == null)
			{
				Action val = Tick;
				<>O.<0>__Tick = val;
				obj = (object)val;
			}
			Net.TimelineTick = (Action)obj;
			object obj2 = <>O.<1>__Clear;
			if (obj2 == null)
			{
				Action val2 = Clear;
				<>O.<1>__Clear = val2;
				obj2 = (object)val2;
			}
			Net.TimelineClear = (Action)obj2;
			RegisterType();
		}

		private static void RegisterType()
		{
			FieldInfo field = typeof(SerializableRegistry).GetField("recorderTypeRegistry", (BindingFlags)56);
			if (((field != null) ? field.GetValue((object)null) : null) is Dictionary<byte, System.Type> val)
			{
				val[(byte)220] = typeof(FlagsRecorder);
			}
		}

		private static void Clear()
		{
			_current = null;
		}

		private static void Tick()
		{
			if (!WorldPlayer.recording)
			{
				_current = null;
				_wasRecording = false;
				return;
			}
			if (!_wasRecording)
			{
				_current = null;
			}
			_wasRecording = true;
			if (_current == null && FlagMod.Count != 0)
			{
				WorldPlayer val = ((TimelineMainClass.timelineHolder != null) ? TimelineMainClass.timelineHolder.worldPlayer : WorldPlayer.Instance);
				if (val != null)
				{
					RegisterType();
					FlagsRecorder flagsRecorder = new FlagsRecorder();
					((ObjectRecorder)flagsRecorder).OnInitializedRecording((Object)null);
					((ObjectRecorder)flagsRecorder).recording = true;
					((ObjectRecorder)flagsRecorder).initTime = WorldPlayer.playHead;
					val.AddRecorderToRecord((ObjectRecorder)(object)flagsRecorder);
					_current = flagsRecorder;
				}
			}
		}
	}
	public class FlagsRecorder : ObjectRecorder
	{
		private sealed class Frame
		{
			public float T;

			public FlagSnap[] S;
		}

		private const int EntryBytes = 55;

		private readonly List<Frame> _frames = new List<Frame>();

		private readonly List<FlagSnap> _snap = new List<FlagSnap>();

		private readonly List<FlagSnap> _out = new List<FlagSnap>();

		private float _last = -1f;

		public override byte SerializeableID => 220;

		public override string GetName()
		{
			return "Wiggles Flags";
		}

		public override void OnInitializedRecording(Object obj)
		{
			_frames.Clear();
			_last = -1f;
		}

		public override void Capture(float time)
		{
			if (!(_last >= 0f) || !(time - _last < 0.05f))
			{
				_last = time;
				FlagMod.Snapshot(_snap);
				_frames.Add(new Frame
				{
					T = time,
					S = _snap.ToArray()
				});
			}
		}

		public override void OnRecordingCompleted()
		{
		}

		public override void OnInitializedPlayback()
		{
		}

		public override void Playback(float time)
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: 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_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			if (_frames.Count == 0)
			{
				return;
			}
			int num = 0;
			int num2 = _frames.Count - 1;
			while (num < num2)
			{
				int num3 = num + num2 + 1 >> 1;
				if (_frames[num3].T <= time)
				{
					num = num3;
				}
				else
				{
					num2 = num3 - 1;
				}
			}
			Frame frame = _frames[num];
			Frame frame2 = ((num + 1 < _frames.Count) ? _frames[num + 1] : frame);
			float num4 = ((frame2.T > frame.T) ? Mathf.Clamp01((time - frame.T) / (frame2.T - frame.T)) : 0f);
			_out.Clear();
			FlagSnap[] s = frame.S;
			foreach (FlagSnap val in s)
			{
				float[] array = (float[])((System.Array)val.P).Clone();
				FlagSnap[] s2 = frame2.S;
				foreach (FlagSnap val2 in s2)
				{
					if (val2.Id != val.Id)
					{
						continue;
					}
					if (val.Pole)
					{
						for (int k = 0; k < 3; k++)
						{
							array[k] += (val2.P[k] - array[k]) * num4;
						}
						Nlerp(array, val2.P, num4);
					}
					else
					{
						if ((int)val2.P[0] != (int)val.P[0])
						{
							break;
						}
						for (int l = 1; l < 12; l++)
						{
							if ((l - 1) % 4 != 0 || l >= 9)
							{
								array[l] += (val2.P[l] - array[l]) * num4;
							}
						}
					}
					break;
				}
				_out.Add(new FlagSnap
				{
					Id = val.Id,
					Country = val.Country,
					Pole = val.Pole,
					P = array
				});
			}
			FlagMod.ReplayFrame((object)this, _out);
		}

		private static void Nlerp(float[] p, float[] q, float k)
		{
			float num = ((p[3] * q[3] + p[4] * q[4] + p[5] * q[5] + p[6] * q[6] < 0f) ? (-1f) : 1f);
			for (int i = 3; i < 7; i++)
			{
				p[i] += (q[i] * num - p[i]) * k;
			}
		}

		public override void OnPlaybackCompleted()
		{
			FlagMod.ReplayEnd((object)this);
		}

		public override void OnHide(bool hide)
		{
			if (hide)
			{
				FlagMod.ReplayEnd((object)this);
			}
		}

		private List<string> Names()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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)
			List<string> val = new List<string>();
			Enumerator<Frame> enumerator = _frames.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					FlagSnap[] s = enumerator.Current.S;
					foreach (FlagSnap val2 in s)
					{
						if (!val.Contains(val2.Country))
						{
							val.Add(val2.Country);
						}
					}
				}
				return val;
			}
			finally
			{
				((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
		}

		public override int GetSize()
		{
			//IL_000f: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			int num = ((ObjectRecorder)this).GetSize() + 2;
			Enumerator<string> enumerator = Names().GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					string current = enumerator.Current;
					num += 2 + Encoding.UTF8.GetByteCount(current);
				}
			}
			finally
			{
				((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			num += 4;
			Enumerator<Frame> enumerator2 = _frames.GetEnumerator();
			try
			{
				while (enumerator2.MoveNext())
				{
					Frame current2 = enumerator2.Current;
					num += 5 + current2.S.Length * 55;
				}
				return num;
			}
			finally
			{
				((System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose();
			}
		}

		public override void WriteToStream(BinaryStream stream)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_009c: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			((ObjectRecorder)this).WriteToStream(stream);
			List<string> val = Names();
			stream.WriteUInt16((ushort)val.Count);
			Enumerator<string> enumerator = val.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					string current = enumerator.Current;
					byte[] bytes = Encoding.UTF8.GetBytes(current);
					stream.WriteUInt16((ushort)bytes.Length);
					byte[] array = bytes;
					foreach (byte b in array)
					{
						stream.WriteByte(b);
					}
				}
			}
			finally
			{
				((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			stream.WriteInt32(_frames.Count);
			Enumerator<Frame> enumerator2 = _frames.GetEnumerator();
			try
			{
				while (enumerator2.MoveNext())
				{
					Frame current2 = enumerator2.Current;
					stream.WriteSingle(current2.T);
					stream.WriteByte((byte)Math.Min(255, current2.S.Length));
					for (int j = 0; j < current2.S.Length && j < 255; j++)
					{
						FlagSnap val2 = current2.S[j];
						stream.WriteInt32(val2.Id);
						stream.WriteUInt16((ushort)val.IndexOf(val2.Country));
						stream.WriteByte(val2.Pole ? ((byte)1) : ((byte)0));
						for (int k = 0; k < 12; k++)
						{
							stream.WriteSingle(val2.P[k]);
						}
					}
				}
			}
			finally
			{
				((System.IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose();
			}
		}

		public override void ReadFromStream(BinaryStream stream)
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			((ObjectRecorder)this).ReadFromStream(stream);
			_frames.Clear();
			int num = stream.ReadUInt16();
			List<string> val = new List<string>(num);
			for (int i = 0; i < num; i++)
			{
				int num2 = stream.ReadUInt16();
				byte[] array = new byte[num2];
				for (int j = 0; j < num2; j++)
				{
					array[j] = stream.ReadByte();
				}
				val.Add(Encoding.UTF8.GetString(array));
			}
			int num3 = stream.ReadInt32();
			for (int k = 0; k < num3; k++)
			{
				Frame frame = new Frame
				{
					T = stream.ReadSingle()
				};
				int num4 = stream.ReadByte();
				frame.S = (FlagSnap[])(object)new FlagSnap[num4];
				for (int l = 0; l < num4; l++)
				{
					FlagSnap val2 = new FlagSnap
					{
						Id = stream.ReadInt32(),
						P = new float[12]
					};
					int num5 = stream.ReadUInt16();
					val2.Country = ((num5 < val.Count) ? val[num5] : "");
					val2.Pole = stream.ReadByte() != 0;
					for (int m = 0; m < 12; m++)
					{
						val2.P[m] = stream.ReadSingle();
					}
					frame.S[l] = val2;
				}
				_frames.Add(frame);
			}
		}
	}
}

Mods/WigglesFlags.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using BoneLib.BoneMenu;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using WigglesFlags;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: MelonInfo(typeof(FlagMod), "Wiggles Flags", "1.2.0", "adama", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: InternalsVisibleTo("WigglesFlags.Fusion")]
[assembly: InternalsVisibleTo("WigglesFlags.Timeline")]
[assembly: SecurityPermission((SecurityAction)8, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : System.Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(/*Could not decode attribute arguments.*/)]
	internal sealed class RefSafetyRulesAttribute : System.Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WigglesFlags
{
	internal struct V
	{
		public float x;

		public float y;

		public float z;

		public float Len => MathF.Sqrt(x * x + y * y + z * z);

		public Vector3 U => new Vector3
		{
			x = x,
			y = y,
			z = z
		};

		public V(float x, float y, float z)
		{
			this.x = x;
			this.y = y;
			this.z = z;
		}

		public static V operator +(V a, V b)
		{
			return new V(a.x + b.x, a.y + b.y, a.z + b.z);
		}

		public static V operator -(V a, V b)
		{
			return new V(a.x - b.x, a.y - b.y, a.z - b.z);
		}

		public static V operator *(V a, float s)
		{
			return new V(a.x * s, a.y * s, a.z * s);
		}

		public static float Dot(V a, V b)
		{
			return a.x * b.x + a.y * b.y + a.z * b.z;
		}

		public static V Cross(V a, V b)
		{
			return new V(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x);
		}

		public static V Lerp(V a, V b, float t)
		{
			return a + (b - a) * t;
		}

		public static V From(Vector3 v)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			return new V(v.x, v.y, v.z);
		}
	}
	internal sealed class Hold
	{
		public Hand Hand;

		public Vector3 LocalPos;

		public Quaternion LocalRot;

		public int Vertex = -1;
	}
	internal sealed class Flag
	{
		public const float PoleLen = 1.9f;

		public const float PoleR = 0.022f;

		private const float Top = 0.08f;

		private const float ClothW = 0.9f;

		private const float ClothH = 0.6f;

		private const float ClothMass = 0.16f;

		private const int NX = 22;

		private const int NY = 15;

		private const int N = 330;

		private const int Iters = 6;

		public readonly string Country;

		public readonly bool HasPole;

		public int Id;

		public byte Owner;

		public bool Remote;

		public bool Replay;

		public float LastHeard;

		public float NextSend;

		public GameObject Root;

		public Rigidbody Body;

		public readonly List<Collider> Colliders = new List<Collider>();

		public readonly List<Hold> Holds = new List<Hold>();

		private readonly Transform _t;

		private readonly Mesh _mesh;

		private readonly List<Material> _mats = new List<Material>();

		private readonly V[] _p = new V[330];

		private readonly V[] _o = new V[330];

		private readonly V[] _acc = new V[330];

		private readonly V[] _pin = new V[330];

		private readonly V[] _pinLast = new V[330];

		private readonly bool[] _pinned = new bool[330];

		private readonly bool[] _keep = new bool[330];

		private readonly Vector3[] _verts = (Vector3[])(object)new Vector3[660];

		private readonly int[] _ca;

		private readonly int[] _cb;

		private readonly float[] _cl;

		private readonly float _seed;

		private readonly float _aero;

		private V _lastTop;

		private V _lastAxis;

		private V _hungA;

		private V _hungB;

		private bool _first = true;

		private bool _hung;

		private float _groundY = -1000f;

		private float _nextGround;

		private Vector3 _netPos;

		private Quaternion _netRot;

		private bool _hasNet;

		private readonly int[] _netV = new int[2];

		private readonly V[] _netP = new V[2];

		private int _netN;

		private V _netCenter;

		private bool _hasCenter;

		private readonly Vector3[] _hp = (Vector3[])(object)new Vector3[6];

		private readonly Quaternion[] _hr = (Quaternion[])(object)new Quaternion[6];

		private readonly float[] _ht = new float[6];

		private int _hn;

		private int _hi;

		public bool Alive => (Object)(object)Root != (Object)null;

		public bool Local
		{
			get
			{
				if (!Remote)
				{
					return !Replay;
				}
				return false;
			}
		}

		public bool Held => Holds.Count > 0;

		public bool Moving
		{
			get
			{
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				if (!HasPole)
				{
					return (_p[165] - _o[165]).Len > 0.0005f;
				}
				if ((Object)(object)Body != (Object)null && !Body.isKinematic)
				{
					Vector3 val = Body.velocity;
					if (!(((Vector3)(ref val)).sqrMagnitude > 0.003f))
					{
						val = Body.angularVelocity;
						return ((Vector3)(ref val)).sqrMagnitude > 0.01f;
					}
					return true;
				}
				return false;
			}
		}

		public Flag(string country, FlagArt.Art art, Vector3 at, Quaternion facing, bool pole, bool remote = false, bool replay = false)
		{
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Expected O, but got Unknown
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: 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_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Expected O, but got Unknown
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			Country = country;
			HasPole = pole;
			Remote = remote;
			Replay = replay;
			_seed = (float)new Random().NextDouble() * 100f;
			_aero = 412.50003f;
			Root = new GameObject((replay ? "WigglesFlagReplay_" : (pole ? "WigglesFlag_" : "WigglesHandFlag_")) + country);
			_t = Root.transform;
			_t.SetPositionAndRotation(at, pole ? facing : Quaternion.identity);
			if (pole)
			{
				BuildPole();
				_netPos = at;
				_netRot = facing;
			}
			GameObject val = new GameObject("Cloth");
			val.transform.SetParent(_t, false);
			_mesh = new Mesh
			{
				name = "WigglesFlagCloth"
			};
			_mesh.MarkDynamic();
			val.AddComponent<MeshFilter>().sharedMesh = _mesh;
			Material val2 = FlagArt.MakeMaterial(Color.white, art.Albedo, art.Normal, 0f, 0.18f);
			_mats.Add(val2);
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = val2;
			float num = 0.04285714f;
			float num2 = 3f / 70f;
			Vector3 val3 = facing * Vector3.right;
			for (int i = 0; i < 15; i++)
			{
				for (int j = 0; j < 22; j++)
				{
					V v = (pole ? V.From(_t.TransformPoint(new Vector3(0.022f + (float)j * num, 1.8199999f - (float)i * num2, 0f))) : V.From(at + val3 * ((float)j * num - 0.45f) + Vector3.down * ((float)i * num2)));
					int num3 = i * 22 + j;
					_p[num3] = v;
					_o[num3] = v;
				}
			}
			if (pole)
			{
				for (int k = 0; k < 15; k++)
				{
					_pinned[k * 22] = true;
				}
			}
			else if (!remote && !replay)
			{
				_hung = true;
				_hungA = _p[0];
				_hungB = _p[21];
			}
			List<int> ca = new List<int>();
			List<int> cb = new List<int>();
			List<float> cl = new List<float>();
			for (int l = 0; l < 15; l++)
			{
				for (int m = 0; m < 22; m++)
				{
					Link(m, l, m + 1, l);
					Link(m, l, m, l + 1);
					Link(m, l, m + 1, l + 1);
					Link(m, l, m - 1, l + 1);
					Link(m, l, m + 2, l);
					Link(m, l, m, l + 2);
				}
			}
			_ca = ca.ToArray();
			_cb = cb.ToArray();
			_cl = cl.ToArray();
			Vector2[] array = (Vector2[])(object)new Vector2[660];
			Vector2 val4 = default(Vector2);
			for (int n = 0; n < 15; n++)
			{
				for (int num4 = 0; num4 < 22; num4++)
				{
					((Vector2)(ref val4))..ctor((float)num4 / 21f, 1f - (float)n / 14f);
					array[n * 22 + num4] = val4;
					array[330 + n * 22 + num4] = val4;
				}
			}
			int[] array2 = new int[3528];
			int num5 = 0;
			for (int num6 = 0; num6 < 14; num6++)
			{
				for (int num7 = 0; num7 < 21; num7++)
				{
					int num8 = num6 * 22 + num7;
					int num9 = num8 + 1;
					int num10 = num8 + 22;
					int num11 = num10 + 1;
					array2[num5++] = num8;
					array2[num5++] = num9;
					array2[num5++] = num10;
					array2[num5++] = num9;
					array2[num5++] = num11;
					array2[num5++] = num10;
					array2[num5++] = 330 + num8;
					array2[num5++] = 330 + num10;
					array2[num5++] = 330 + num9;
					array2[num5++] = 330 + num9;
					array2[num5++] = 330 + num10;
					array2[num5++] = 330 + num11;
				}
			}
			WriteVerts();
			_mesh.vertices = Il2CppStructArray<Vector3>.op_Implicit(_verts);
			_mesh.uv = Il2CppStructArray<Vector2>.op_Implicit(array);
			_mesh.triangles = Il2CppStructArray<int>.op_Implicit(array2);
			RefreshMesh();
			[CompilerGenerated]
			void Link(int num16, int num15, int num12, int num13)
			{
				if (num12 >= 0 && num12 < 22 && num13 < 15)
				{
					int num14 = num15 * 22 + num16;
					int num17 = num13 * 22 + num12;
					ca.Add(num14);
					cb.Add(num17);
					cl.Add((_p[num14] - _p[num17]).Len);
				}
			}
		}

		private void BuildPole()
		{
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: 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_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: 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_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: 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_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			Body = Root.AddComponent<Rigidbody>();
			Body.mass = 2.2f;
			Body.angularDrag = 0.6f;
			Body.maxAngularVelocity = 40f;
			Body.interpolation = (RigidbodyInterpolation)1;
			Body.collisionDetectionMode = (CollisionDetectionMode)3;
			Body.isKinematic = Remote || Replay;
			CapsuleCollider val = Root.AddComponent<CapsuleCollider>();
			val.direction = 1;
			val.radius = 0.028f;
			val.height = 1.9f;
			val.center = new Vector3(0f, 0.95f, 0f);
			SphereCollider val2 = Root.AddComponent<SphereCollider>();
			val2.radius = 0.045f;
			val2.center = new Vector3(0f, 1.9399999f, 0f);
			Colliders.Add((Collider)(object)val);
			Colliders.Add((Collider)(object)val2);
			if (Replay)
			{
				((Collider)val).enabled = false;
				((Collider)val2).enabled = false;
			}
			Color val3 = default(Color);
			((Color)(ref val3))..ctor(0.62f, 0.63f, 0.65f);
			Color color = default(Color);
			((Color)(ref color))..ctor(0.78f, 0.6f, 0.25f);
			Part((PrimitiveType)2, new Vector3(0f, 0.95f, 0f), new Vector3(0.044f, 0.95f, 0.044f), val3, 0.85f, 0.55f);
			Part((PrimitiveType)2, new Vector3(0f, 1.905f, 0f), new Vector3(0.05f, 0.012f, 0.05f), color, 1f, 0.65f);
			Part((PrimitiveType)0, new Vector3(0f, 1.9449999f, 0f), Vector3.one * 0.075f, color, 1f, 0.7f);
			Part((PrimitiveType)1, new Vector3(0f, 2f, 0f), new Vector3(0.018f, 0.035f, 0.018f), color, 1f, 0.7f);
			Part((PrimitiveType)2, new Vector3(0f, 0.02f, 0f), new Vector3(0.052800003f, 0.02f, 0.052800003f), new Color(0.06f, 0.06f, 0.07f), 0f, 0.3f);
			Part((PrimitiveType)2, new Vector3(0f, 1.8299999f, 0f), new Vector3(0.057199996f, 0.006f, 0.057199996f), val3 * 0.8f, 0.9f, 0.6f);
			Part((PrimitiveType)2, new Vector3(0f, 1.2199999f, 0f), new Vector3(0.057199996f, 0.006f, 0.057199996f), val3 * 0.8f, 0.9f, 0.6f);
		}

		private void Part(PrimitiveType type, Vector3 pos, Vector3 scale, Color color, float metallic, float smooth)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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)
			GameObject obj = GameObject.CreatePrimitive(type);
			Collider component = obj.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component);
			}
			obj.transform.SetParent(_t, false);
			obj.transform.localPosition = pos;
			obj.transform.localScale = scale;
			Material val = FlagArt.MakeMaterial(color, null, null, metallic, smooth);
			_mats.Add(val);
			((Renderer)obj.GetComponent<MeshRenderer>()).sharedMaterial = val;
		}

		public float Reach(Vector3 palm, out int vertex)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_003e: 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)
			//IL_0044: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			vertex = -1;
			if (HasPole)
			{
				Vector3 position = _t.position;
				Vector3 val = _t.TransformPoint(new Vector3(0f, 1.9f, 0f)) - position;
				float num = Mathf.Clamp01(Vector3.Dot(palm - position, val) / ((Vector3)(ref val)).sqrMagnitude);
				return Vector3.Distance(palm, position + val * num);
			}
			float num2 = 3.4028235E+38f;
			V v = V.From(palm);
			for (int i = 0; i < 15; i++)
			{
				for (int j = 0; j < 22; j++)
				{
					if (j != 0 && j != 21 && i != 0 && i != 14)
					{
						continue;
					}
					int idx = i * 22 + j;
					if (!Holds.Exists((Predicate<Hold>)((Hold h) => h.Vertex == idx)))
					{
						float len = (_p[idx] - v).Len;
						if (len < num2)
						{
							num2 = len;
							vertex = idx;
						}
					}
				}
			}
			return num2;
		}

		public void Take(Hand hand, Transform palm, int vertex)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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)
			Remote = false;
			Owner = Net.LocalId.Invoke();
			Hold hold = new Hold
			{
				Hand = hand
			};
			if (HasPole)
			{
				hold.LocalPos = _t.InverseTransformPoint(palm.position);
				hold.LocalRot = Quaternion.Inverse(_t.rotation) * palm.rotation;
				Body.isKinematic = true;
				Body.interpolation = (RigidbodyInterpolation)0;
				_hn = 0;
			}
			else
			{
				_hung = false;
				hold.Vertex = vertex;
			}
			Holds.Add(hold);
		}

		public void Let(Hand hand)
		{
			Hold hold = Holds.Find((Predicate<Hold>)((Hold x) => (Object)(object)x.Hand == (Object)(object)hand));
			if (hold != null)
			{
				Holds.Remove(hold);
				if (HasPole && Holds.Count == 0 && Local)
				{
					Body.isKinematic = false;
					Body.interpolation = (RigidbodyInterpolation)1;
					Throw();
				}
			}
		}

		private void Throw()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_008c: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: 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)
			if (_hn < 2)
			{
				return;
			}
			int num = (_hi + 5) % 6;
			int num2 = (_hi + 6 - _hn) % 6;
			float num3 = _ht[num] - _ht[num2];
			if (num3 < 0.005f)
			{
				return;
			}
			Vector3 velocity = (_hp[num] - _hp[num2]) / num3;
			if (((Vector3)(ref velocity)).magnitude > 20f)
			{
				velocity = ((Vector3)(ref velocity)).normalized * 20f;
			}
			Body.velocity = velocity;
			Quaternion val = _hr[num] * Quaternion.Inverse(_hr[num2]);
			float num4 = default(float);
			Vector3 val2 = default(Vector3);
			((Quaternion)(ref val)).ToAngleAxis(ref num4, ref val2);
			if (num4 > 180f)
			{
				num4 -= 360f;
			}
			if (!float.IsNaN(val2.x) && Mathf.Abs(num4) > 0.01f)
			{
				Vector3 angularVelocity = val2 * (num4 * ((float)Math.PI / 180f) / num3);
				if (((Vector3)(ref angularVelocity)).magnitude > 30f)
				{
					angularVelocity = ((Vector3)(ref angularVelocity)).normalized * 30f;
				}
				Body.angularVelocity = angularVelocity;
			}
		}

		public void Follow(float dt)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: 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_01a5: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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_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_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00b8: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			if (!HasPole)
			{
				return;
			}
			if (Local && Holds.Count > 0)
			{
				Hold hold = Holds[0];
				Transform val = FlagMod.Palm(hold.Hand);
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				Quaternion val2 = val.rotation * Quaternion.Inverse(hold.LocalRot);
				if (Holds.Count > 1)
				{
					Transform val3 = FlagMod.Palm(Holds[1].Hand);
					if ((Object)(object)val3 != (Object)null)
					{
						Vector3 val4 = val2 * (Holds[1].LocalPos - hold.LocalPos);
						Vector3 val5 = val3.position - val.position;
						if (((Vector3)(ref val4)).sqrMagnitude > 0.0001f && ((Vector3)(ref val5)).sqrMagnitude > 0.0001f)
						{
							val2 = Quaternion.FromToRotation(val4, val5) * val2;
						}
					}
				}
				Vector3 val6 = val.position - val2 * hold.LocalPos;
				_t.SetPositionAndRotation(val6, val2);
				_hp[_hi] = val6;
				_hr[_hi] = val2;
				_ht[_hi] = Time.time;
				_hi = (_hi + 1) % 6;
				if (_hn < 6)
				{
					_hn++;
				}
			}
			else if ((Remote || Replay) && _hasNet)
			{
				if (Replay || Vector3.Distance(_t.position, _netPos) > 3f)
				{
					_t.SetPositionAndRotation(_netPos, _netRot);
					return;
				}
				float num = 1f - Mathf.Exp(-18f * dt);
				_t.SetPositionAndRotation(Vector3.Lerp(_t.position, _netPos, num), Quaternion.Slerp(_t.rotation, _netRot, num));
			}
		}

		public void Pack(float[] p)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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)
			System.Array.Clear((System.Array)p, 0, p.Length);
			if (HasPole)
			{
				Vector3 position = _t.position;
				Quaternion rotation = _t.rotation;
				p[0] = position.x;
				p[1] = position.y;
				p[2] = position.z;
				p[3] = rotation.x;
				p[4] = rotation.y;
				p[5] = rotation.z;
				p[6] = rotation.w;
				return;
			}
			int num = 0;
			for (int i = 0; i < 330; i++)
			{
				if (num >= 2)
				{
					break;
				}
				if (_pinned[i])
				{
					p[1 + num * 4] = i;
					p[2 + num * 4] = _p[i].x;
					p[3 + num * 4] = _p[i].y;
					p[4 + num * 4] = _p[i].z;
					num++;
				}
			}
			p[0] = num;
			V v = _p[165];
			p[9] = v.x;
			p[10] = v.y;
			p[11] = v.z;
		}

		public void Apply(float[] p)
		{
			//IL_0015: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_00c6: 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)
			if (HasPole)
			{
				_netPos = new Vector3(p[0], p[1], p[2]);
				Quaternion val = new Quaternion
				{
					x = p[3],
					y = p[4],
					z = p[5],
					w = p[6]
				};
				float num = MathF.Sqrt(val.x * val.x + val.y * val.y + val.z * val.z + val.w * val.w);
				if (!(num < 0.0001f))
				{
					val.x /= num;
					val.y /= num;
					val.z /= num;
					val.w /= num;
					_netRot = val;
					_hasNet = true;
				}
			}
			else
			{
				_netN = Math.Clamp((int)p[0], 0, 2);
				for (int i = 0; i < _netN; i++)
				{
					_netV[i] = Math.Clamp((int)p[1 + i * 4], 0, 329);
					_netP[i] = new V(p[2 + i * 4], p[3 + i * 4], p[4 + i * 4]);
				}
				_netCenter = new V(p[9], p[10], p[11]);
				_hasCenter = true;
			}
		}

		private void SetPin(int v, V target)
		{
			if (!_pinned[v])
			{
				_pinned[v] = true;
				_pinLast[v] = _p[v];
			}
			_pin[v] = target;
		}

		private void UpdateClothPins()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			if (HasPole)
			{
				return;
			}
			System.Array.Clear((System.Array)_keep, 0, 330);
			if (Local)
			{
				if (_hung)
				{
					_keep[0] = true;
					_keep[21] = true;
				}
				Enumerator<Hold> enumerator = Holds.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						Hold current = enumerator.Current;
						if (current.Vertex >= 0)
						{
							_keep[current.Vertex] = true;
						}
					}
				}
				finally
				{
					((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
				}
				for (int i = 0; i < 330; i++)
				{
					if (_pinned[i] && !_keep[i])
					{
						_pinned[i] = false;
					}
				}
				if (_hung)
				{
					SetPin(0, _hungA);
					SetPin(21, _hungB);
				}
				enumerator = Holds.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						Hold current2 = enumerator.Current;
						if (current2.Vertex >= 0)
						{
							Transform val = FlagMod.Palm(current2.Hand);
							if ((Object)(object)val != (Object)null)
							{
								SetPin(current2.Vertex, V.From(val.position + val.forward * 0.03f));
							}
						}
					}
					return;
				}
				finally
				{
					((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
				}
			}
			for (int j = 0; j < _netN; j++)
			{
				_keep[_netV[j]] = true;
			}
			for (int k = 0; k < 330; k++)
			{
				if (_pinned[k] && !_keep[k])
				{
					_pinned[k] = false;
				}
			}
			for (int l = 0; l < _netN; l++)
			{
				SetPin(_netV[l], _netP[l]);
			}
			if (_netN != 0 || !_hasCenter)
			{
				return;
			}
			V v = _netCenter - _p[165];
			if (v.Len > 0.8f)
			{
				for (int m = 0; m < 330; m++)
				{
					_p[m] += v;
					_o[m] += v;
				}
			}
		}

		public void Tick(float dt, V wind, float time)
		{
			//IL_0045: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			if (dt <= 0f)
			{
				return;
			}
			if (dt > 1f / 30f)
			{
				dt = 1f / 30f;
			}
			V v = default(V);
			V v2 = default(V);
			if (HasPole)
			{
				v = V.From(_t.TransformPoint(new Vector3(0.022f, 1.8199999f, 0f)));
				v2 = V.From(_t.up);
				if (_first)
				{
					_lastTop = v;
					_lastAxis = v2;
				}
			}
			UpdateClothPins();
			if (_first)
			{
				System.Array.Copy((System.Array)_pin, (System.Array)_pinLast, 330);
				_first = false;
			}
			if (time >= _nextGround)
			{
				_nextGround = time + 0.2f;
				V v3 = _p[165];
				RaycastHit val = default(RaycastHit);
				_groundY = ((Physics.Raycast(v3.U + Vector3.up * 0.4f, Vector3.down, ref val, 6f, -1, (QueryTriggerInteraction)1) && !IsMine(((RaycastHit)(ref val)).collider)) ? ((RaycastHit)(ref val)).point.y : (-1000f));
			}
			float num = 0.55f + 0.9f * Mathf.PerlinNoise(time * 0.7f, _seed);
			V wind2 = wind * num;
			int num2 = Math.Max(1, (int)MathF.Ceiling(dt * 90f));
			float h = dt / (float)num2;
			for (int i = 1; i <= num2; i++)
			{
				float num3 = (float)i / (float)num2;
				Step(h, num3, V.Lerp(_lastTop, v, num3), V.Lerp(_lastAxis, v2, num3), wind2);
			}
			_lastTop = v;
			_lastAxis = v2;
			System.Array.Copy((System.Array)_pin, (System.Array)_pinLast, 330);
			WriteVerts();
			_mesh.vertices = Il2CppStructArray<Vector3>.op_Implicit(_verts);
			RefreshMesh();
		}

		private bool IsMine(Collider c)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Enumerator<Collider> enumerator = Colliders.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					if ((Object)(object)enumerator.Current == (Object)(object)c)
					{
						return true;
					}
				}
			}
			finally
			{
				((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			return false;
		}

		private void Step(float h, float f, V top, V axis, V wind)
		{
			for (int i = 0; i < 330; i++)
			{
				_acc[i] = new V(0f, -9.81f, 0f);
			}
			float invH = 1f / h;
			for (int j = 0; j < 14; j++)
			{
				for (int k = 0; k < 21; k++)
				{
					int num = j * 22 + k;
					int num2 = num + 1;
					int num3 = num + 22;
					int b = num3 + 1;
					Aero(num, num2, num3, wind, invH);
					Aero(num2, b, num3, wind, invH);
				}
			}
			float num4 = h * h;
			float num5 = _groundY + 0.012f;
			for (int l = 0; l < 330; l++)
			{
				if (!_pinned[l])
				{
					V v = _p[l];
					V v2 = (v - _o[l]) * 0.995f;
					_o[l] = v;
					v = v + v2 + _acc[l] * num4;
					if (v.y < num5)
					{
						v.y = num5;
						_o[l] = V.Lerp(_o[l], v, 0.6f);
						_o[l].y = num5;
					}
					_p[l] = v;
				}
			}
			Pin(f, top, axis);
			for (int m = 0; m < 6; m++)
			{
				for (int n = 0; n < _ca.Length; n++)
				{
					int num6 = _ca[n];
					int num7 = _cb[n];
					V v3 = _p[num7] - _p[num6];
					float len = v3.Len;
					if (len < 1E-06f)
					{
						continue;
					}
					float num8 = (len - _cl[n]) / len;
					bool flag = _pinned[num6];
					bool flag2 = _pinned[num7];
					if (!(flag && flag2))
					{
						if (flag)
						{
							_p[num7] -= v3 * num8;
							continue;
						}
						if (flag2)
						{
							_p[num6] += v3 * num8;
							continue;
						}
						V v4 = v3 * (0.5f * num8);
						_p[num6] += v4;
						_p[num7] -= v4;
					}
				}
				Pin(f, top, axis);
			}
		}

		private void Pin(float f, V top, V axis)
		{
			if (HasPole)
			{
				float num = 3f / 70f;
				for (int i = 0; i < 15; i++)
				{
					int num2 = i * 22;
					_p[num2] = top - axis * ((float)i * num);
					_o[num2] = _p[num2];
				}
				return;
			}
			for (int j = 0; j < 330; j++)
			{
				if (_pinned[j])
				{
					_p[j] = V.Lerp(_pinLast[j], _pin[j], f);
					_o[j] = _p[j];
				}
			}
		}

		private void Aero(int a, int b, int c, V wind, float invH)
		{
			V v = _p[a];
			V v2 = V.Cross(_p[b] - v, _p[c] - v);
			float len = v2.Len;
			if (!(len < 1E-09f))
			{
				float num = len * 0.5f;
				v2 *= 1f / len;
				V v3 = (v - _o[a] + (_p[b] - _o[b]) + (_p[c] - _o[c])) * (invH / 3f);
				V v4 = wind - v3;
				float num2 = V.Dot(v2, v4);
				V v5 = v4 - v2 * num2;
				V v6 = (v2 * (num2 * MathF.Abs(num2)) + v5 * (0.08f * v5.Len)) * (_aero * num);
				float len2 = v6.Len;
				if (len2 > 200f)
				{
					v6 *= 200f / len2;
				}
				_acc[a] += v6;
				_acc[b] += v6;
				_acc[c] += v6;
			}
		}

		private void WriteVerts()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0053: 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_006e: 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_008a: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			Matrix4x4 worldToLocalMatrix = _t.worldToLocalMatrix;
			for (int i = 0; i < 330; i++)
			{
				V v = _p[i];
				Vector3 val = new Vector3
				{
					x = worldToLocalMatrix.m00 * v.x + worldToLocalMatrix.m01 * v.y + worldToLocalMatrix.m02 * v.z + worldToLocalMatrix.m03,
					y = worldToLocalMatrix.m10 * v.x + worldToLocalMatrix.m11 * v.y + worldToLocalMatrix.m12 * v.z + worldToLocalMatrix.m13,
					z = worldToLocalMatrix.m20 * v.x + worldToLocalMatrix.m21 * v.y + worldToLocalMatrix.m22 * v.z + worldToLocalMatrix.m23
				};
				_verts[i] = val;
				_verts[330 + i] = val;
			}
		}

		private void RefreshMesh()
		{
			_mesh.RecalculateNormals();
			_mesh.RecalculateTangents();
			_mesh.RecalculateBounds();
		}

		public void Destroy()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			Holds.Clear();
			if ((Object)(object)Root != (Object)null)
			{
				Object.Destroy((Object)(object)Root);
			}
			Root = null;
			if ((Object)(object)_mesh != (Object)null)
			{
				Object.Destroy((Object)(object)_mesh);
			}
			Enumerator<Material> enumerator = _mats.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					Material current = enumerator.Current;
					if ((Object)(object)current != (Object)null)
					{
						Object.Destroy((Object)(object)current);
					}
				}
			}
			finally
			{
				((System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			_mats.Clear();
		}
	}
	internal sealed class FlagDef
	{
		public readonly string Name;

		public readonly string Region;

		public readonly Action<Painter> Draw;

		public FlagDef(string name, string region, Action<Painter> draw)
		{
			Name = name;
			Region = region;
			Draw = draw;
		}
	}
	internal sealed class Painter
	{
		public const int W = 1200;

		public const int H = 800;

		public const float A = 1.5f;

		public readonly Color32[] Px = (Color32[])(object)new Color32[960000];

		private int _x0;

		private int _y0;

		private int _x1 = 1200;

		private int _y1 = 800;

		public static Color32 C(uint hex)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			return new Color32((byte)(hex >> 16), (byte)(hex >> 8), (byte)hex, (byte)255);
		}

		public void Clip(float x0, float y0, float x1, float y1)
		{
			_x0 = (int)(x0 * 1200f);
			_y0 = (int)(y0 * 800f);
			_x1 = (int)MathF.Ceiling(x1 * 1200f);
			_y1 = (int)MathF.Ceiling(y1 * 800f);
		}

		public void NoClip()
		{
			_x0 = 0;
			_y0 = 0;
			_x1 = 1200;
			_y1 = 800;
		}

		public void Shape(Func<float, float, bool> f, uint hex, float u0 = 0f, float v0 = 0f, float u1 = 1.5f, float v1 = 1f)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			Color32 val = C(hex);
			int num = Math.Max(_x0, (int)(u0 * 800f));
			int num2 = Math.Min(_x1, (int)MathF.Ceiling(u1 * 800f));
			int num3 = Math.Max(_y0, (int)(v0 * 800f));
			int num4 = Math.Min(_y1, (int)MathF.Ceiling(v1 * 800f));
			for (int i = num3; i < num4; i++)
			{
				float num5 = ((float)i + 0.5f) / 800f;
				int num6 = (799 - i) * 1200;
				for (int j = num; j < num2; j++)
				{
					if (f.Invoke(((float)j + 0.5f) / 800f, num5))
					{
						Px[num6 + j] = val;
					}
				}
			}
		}

		public void Fill(uint c)
		{
			Shape((float u, float v) => true, c);
		}

		public void Rect(float x0, float y0, float x1, float y1, uint c)
		{
			Shape((float u, float v) => true, c, x0 * 1.5f, y0, x1 * 1.5f, y1);
		}

		public void HBands(int[] w, params uint[] cs)
		{
			float num = 0f;
			foreach (int num2 in w)
			{
				num += (float)num2;
			}
			float num3 = 0f;
			for (int j = 0; j < cs.Length; j++)
			{
				float num4 = (float)w[j] / num;
				Rect(0f, num3, 1f, num3 + num4, cs[j]);
				num3 += num4;
			}
		}

		public void VBands(int[] w, params uint[] cs)
		{
			float num = 0f;
			foreach (int num2 in w)
			{
				num += (float)num2;
			}
			float num3 = 0f;
			for (int j = 0; j < cs.Length; j++)
			{
				float num4 = (float)w[j] / num;
				Rect(num3, 0f, num3 + num4, 1f, cs[j]);
				num3 += num4;
			}
		}

		public void HStripes(params uint[] cs)
		{
			HBands(Ones(cs.Length), cs);
		}

		public void VStripes(params uint[] cs)
		{
			VBands(Ones(cs.Length), cs);
		}

		private static int[] Ones(int n)
		{
			int[] array = new int[n];
			for (int i = 0; i < n; i++)
			{
				array[i] = 1;
			}
			return array;
		}

		public void Circle(float x, float y, float r, uint c)
		{
			float cu = x * 1.5f;
			Shape((float u, float v) => (u - cu) * (u - cu) + (v - y) * (v - y) <= r * r, c, cu - r, y - r, cu + r, y + r);
		}

		public void Ring(float x, float y, float r0, float r1, uint c)
		{
			float cu = x * 1.5f;
			Shape(delegate(float u, float v)
			{
				float num = (u - cu) * (u - cu) + (v - y) * (v - y);
				return num >= r0 * r0 && num <= r1 * r1;
			}, c, cu - r1, y - r1, cu + r1, y + r1);
		}

		public void Crescent(float x, float y, float r, float du, float dv, float r2, uint c)
		{
			float cu = x * 1.5f;
			float iu = cu + du;
			float iv = y + dv;
			Shape((float u, float v) => (u - cu) * (u - cu) + (v - y) * (v - y) <= r * r && (u - iu) * (u - iu) + (v - iv) * (v - iv) > r2 * r2, c, cu - r, y - r, cu + r, y + r);
		}

		public void Ellipse(float x, float y, float rx, float ry, uint c)
		{
			float cu = x * 1.5f;
			Shape(delegate(float u, float v)
			{
				float num = (u - cu) / rx;
				float num2 = (v - y) / ry;
				return num * num + num2 * num2 <= 1f;
			}, c, cu - rx, y - ry, cu + rx, y + ry);
		}

		public void Poly(Vector2[] p, uint c)
		{
			float num = 3.4028235E+38f;
			float num2 = 3.4028235E+38f;
			float num3 = -3.4028235E+38f;
			float num4 = -3.4028235E+38f;
			float[] xs = new float[p.Length];
			float[] ys = new float[p.Length];
			for (int i = 0; i < p.Length; i++)
			{
				xs[i] = p[i].x;
				ys[i] = p[i].y;
				num = Math.Min(num, xs[i]);
				num3 = Math.Max(num3, xs[i]);
				num2 = Math.Min(num2, ys[i]);
				num4 = Math.Max(num4, ys[i]);
			}
			Shape((float u, float v) => Inside(xs, ys, u, v), c, num, num2, num3, num4);
		}

		public void PolyF(uint c, params float[] xy)
		{
			//IL_0023: 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)
			Vector2[] array = (Vector2[])(object)new Vector2[xy.Length / 2];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = new Vector2(xy[i * 2] * 1.5f, xy[i * 2 + 1]);
			}
			Poly(array, c);
		}

		public void Tri(float depth, uint c)
		{
			PolyF(c, 0f, 0f, depth, 0.5f, 0f, 1f);
		}

		public static Vector2[] StarPts(float cu, float cv, float r, float rotDeg, int n, float inner)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			Vector2[] array = (Vector2[])(object)new Vector2[n * 2];
			for (int i = 0; i < n * 2; i++)
			{
				float num = (90f + rotDeg + (float)i * 180f / (float)n) * ((float)Math.PI / 180f);
				float num2 = ((i % 2 == 0) ? r : (r * inner));
				array[i] = new Vector2(cu + MathF.Cos(num) * num2, cv - MathF.Sin(num) * num2);
			}
			return array;
		}

		public void Star(float x, float y, float r, uint c, float rot = 0f, int n = 5, float inner = 0.382f)
		{
			Poly(StarPts(x * 1.5f, y, r, rot, n, inner), c);
		}

		public void StarToward(float x, float y, float r, uint c, float tx, float ty)
		{
			float num = MathF.Atan2(0f - (ty - y), (tx - x) * 1.5f) * (180f / (float)Math.PI);
			Star(x, y, r, c, num - 90f);
		}

		public void LineU(float au, float av, float bu, float bv, float t, uint c)
		{
			float h = t * 0.5f;
			Shape((float u, float v) => SegD2(u, v, au, av, bu, bv) <= h * h, c, Math.Min(au, bu) - h, Math.Min(av, bv) - h, Math.Max(au, bu) + h, Math.Max(av, bv) + h);
		}

		public void Line(float x0, float y0, float x1, float y1, float t, uint c)
		{
			LineU(x0 * 1.5f, y0, x1 * 1.5f, y1, t, c);
		}

		public void Pentagram(float x, float y, float r, float t, uint c)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			Vector2[] array = StarPts(x * 1.5f, y, r, 0f, 5, 1f);
			for (int i = 0; i < 5; i++)
			{
				Vector2 val = array[i * 4 % 10];
				Vector2 val2 = array[(i + 1) * 4 % 10];
				LineU(val.x, val.y, val2.x, val2.y, t, c);
			}
		}

		public void TriOutline(float x, float y, float r, float rot, float t, uint c)
		{
			Vector2[] array = StarPts(x * 1.5f, y, r, rot, 3, 1f);
			LineU(array[0].x, array[0].y, array[2].x, array[2].y, t, c);
			LineU(array[2].x, array[2].y, array[4].x, array[4].y, t, c);
			LineU(array[4].x, array[4].y, array[0].x, array[0].y, t, c);
		}

		public void Bar(float cu, float cv, float len, float thick, float angDeg, uint c)
		{
			float num = angDeg * ((float)Math.PI / 180f);
			float ca = MathF.Cos(num);
			float sa = MathF.Sin(num);
			float hl = len * 0.5f;
			float ht = thick * 0.5f;
			float num2 = hl + ht;
			Shape(delegate(float u, float v)
			{
				float num3 = u - cu;
				float num4 = v - cv;
				return MathF.Abs(num3 * ca + num4 * sa) <= hl && MathF.Abs((0f - num3) * sa + num4 * ca) <= ht;
			}, c, cu - num2, cv - num2, cu + num2, cv + num2);
		}

		public void Nordic(float cx, float t, uint c)
		{
			Rect(cx - t * 0.5f / 1.5f, 0f, cx + t * 0.5f / 1.5f, 1f, c);
			Rect(0f, 0.5f - t * 0.5f, 1f, 0.5f + t * 0.5f, c);
		}

		public void UnionJack(float x0, float y0, float x1, float y1)
		{
			Clip(x0, y0, x1, y1);
			float num = y1 - y0;
			float num2 = (x0 + x1) * 0.5f;
			float num3 = (y0 + y1) * 0.5f;
			Rect(x0, y0, x1, y1, 74089u);
			Line(x0, y0, x1, y1, num * 0.2f, 16777215u);
			Line(x0, y1, x1, y0, num * 0.2f, 16777215u);
			Line(x0, y0, x1, y1, num * 0.067f, 13111342u);
			Line(x0, y1, x1, y0, num * 0.067f, 13111342u);
			Rect(num2 - num / 6f / 1.5f, y0, num2 + num / 6f / 1.5f, y1, 16777215u);
			Rect(x0, num3 - num / 6f, x1, num3 + num / 6f, 16777215u);
			Rect(num2 - num / 10f / 1.5f, y0, num2 + num / 10f / 1.5f, y1, 13111342u);
			Rect(x0, num3 - num / 10f, x1, num3 + num / 10f, 13111342u);
			NoClip();
		}

		public void Serrated(uint field, uint white, int teeth, float xa, float xb)
		{
			Fill(field);
			List<float> obj = new List<float>();
			obj.Add(0f);
			obj.Add(0f);
			obj.Add(xa);
			obj.Add(0f);
			List<float> val = obj;
			for (int i = 0; i < teeth; i++)
			{
				val.Add(xb);
				val.Add(((float)i + 0.5f) / (float)teeth);
				val.Add(xa);
				val.Add(((float)i + 1f) / (float)teeth);
			}
			val.Add(0f);
			val.Add(1f);
			PolyF(white, val.ToArray());
		}

		private static bool Inside(float[] xs, float[] ys, float u, float v)
		{
			bool flag = false;
			int num = 0;
			int num2 = xs.Length - 1;
			while (num < xs.Length)
			{
				if (ys[num] > v != ys[num2] > v && u < (xs[num2] - xs[num]) * (v - ys[num]) / (ys[num2] - ys[num]) + xs[num])
				{
					flag = !flag;
				}
				num2 = num++;
			}
			return flag;
		}

		private static float SegD2(float u, float v, float au, float av, float bu, float bv)
		{
			float num = bu - au;
			float num2 = bv - av;
			float num3 = num * num + num2 * num2;
			float num4 = ((num3 > 0f) ? Math.Clamp(((u - au) * num + (v - av) * num2) / num3, 0f, 1f) : 0f);
			float num5 = au + num4 * num - u;
			float num6 = av + num4 * num2 - v;
			return num5 * num5 + num6 * num6;
		}
	}
	internal static class FlagArt
	{
		public sealed class Art
		{
			public Texture2D Albedo;

			public Texture2D Normal;
		}

		public static string CustomDir;

		public static readonly string[] Regions = new string[5] { "Europe", "Americas", "Middle East", "Asia", "Africa & Oceania" };

		private static readonly Dictionary<string, Art> Cache = new Dictionary<string, Art>();

		private static Shader _shader;

		private const uint Wt = 16777215u;

		private const uint Bk = 0u;

		private const int OW = 600;

		private const int OH = 400;

		private static readonly string[] ShaderNames = new string[3] { "Universal Render Pipeline/Lit (PBR Workflow)", "Universal Render Pipeline/Lit", "Universal Render Pipeline/Simple Lit" };

		public static readonly List<FlagDef> All;

		public static Art Get(string name, bool pole)
		{
			string text = name + (pole ? "|pole" : "|hand");
			Art art = default(Art);
			if (Cache.TryGetValue(text, ref art) && (Object)(object)art.Albedo != (Object)null && (Object)(object)art.Normal != (Object)null)
			{
				return art;
			}
			float[] height = new float[240000];
			Texture2D albedo = LoadPng(name, pole, height) ?? Paint(name, pole, height);
			art = new Art
			{
				Albedo = albedo,
				Normal = NormalMap(height)
			};
			((Object)art.Albedo).hideFlags = (HideFlags)32;
			((Object)art.Normal).hideFlags = (HideFlags)32;
			Cache[text] = art;
			return art;
		}

		public static void ClearCache()
		{
			Cache.Clear();
		}

		private static Texture2D Paint(string name, bool pole, float[] height)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_00f5: 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_0108: 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_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			Painter painter = new Painter();
			painter.Fill(16777215u);
			All.Find((Predicate<FlagDef>)((FlagDef d) => d.Name == name))?.Draw.Invoke(painter);
			Color32[] array = (Color32[])(object)new Color32[240000];
			for (int num = 0; num < 400; num++)
			{
				for (int num2 = 0; num2 < 600; num2++)
				{
					int num3 = num * 2 * 1200 + num2 * 2;
					int num4 = num3 + 1200;
					Color32 val = painter.Px[num3];
					Color32 val2 = painter.Px[num3 + 1];
					Color32 val3 = painter.Px[num4];
					Color32 val4 = painter.Px[num4 + 1];
					array[num * 600 + num2] = new Color32((byte)(val.r + val2.r + val3.r + val4.r >> 2), (byte)(val.g + val2.g + val3.g + val4.g >> 2), (byte)(val.b + val2.b + val3.b + val4.b >> 2), (byte)255);
				}
			}
			Finish(array, 600, 400, pole, height);
			return ToTexture(array, 600, 400);
		}

		private static Texture2D ToTexture(Color32[] px, int w, int h)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			Texture2D val = new Texture2D(w, h, (TextureFormat)4, true);
			val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(px));
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Texture)val).filterMode = (FilterMode)2;
			((Texture)val).anisoLevel = 8;
			val.Apply(true);
			return val;
		}

		private static void Finish(Color32[] px, int w, int h, bool pole, float[] height)
		{
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: 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_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			int num = 7;
			int num2 = 4;
			int num3 = (pole ? 22 : 0);
			float[] array = new float[3];
			RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			float[] array2 = array;
			for (int i = 0; i < h; i++)
			{
				for (int j = 0; j < w; j++)
				{
					int num4 = i * w + j;
					float num5 = 1f;
					float num6 = 0f;
					bool flag = (((j >> 1) + (i >> 1)) & 1) == 0;
					num5 *= (flag ? 1.03f : 0.965f);
					num6 += (flag ? 0.35f : 0f);
					uint num7 = (uint)((j * 73856093) ^ (i * 19349663));
					num7 ^= num7 >> 13;
					num7 *= 1540483477;
					num7 ^= num7 >> 15;
					num5 *= 0.985f + (float)(num7 & 0xFF) / 255f * 0.03f;
					int num8 = Math.Min(Math.Min(j, w - 1 - j), Math.Min(i, h - 1 - i));
					if (num8 < num)
					{
						num5 *= 0.9f;
						num6 += 0.6f;
					}
					if (num8 == num2 && (j + i) / 3 % 2 == 0)
					{
						num5 *= 0.72f;
						num6 -= 0.4f;
					}
					Color32 val = px[num4];
					if (num3 > 0 && j < num3)
					{
						((Color32)(ref val))..ctor((byte)232, (byte)226, (byte)210, (byte)255);
						num5 *= ((j == num3 - 1 || j == num3 - 2) ? 0.75f : 1f);
						num6 += 0.8f;
						float[] array3 = array2;
						foreach (float num9 in array3)
						{
							float num10 = (float)j - (float)num3 * 0.5f;
							float num11 = (float)i - num9 * (float)(h - 1);
							float num12 = MathF.Sqrt(num10 * num10 + num11 * num11);
							if (num12 < 7.5f && num12 >= 4f)
							{
								((Color32)(ref val))..ctor((byte)196, (byte)160, (byte)84, (byte)255);
								num5 = 0.9f + ((num11 < 0f) ? 0.15f : 0f);
								num6 = 1.6f;
							}
							else if (num12 < 4f)
							{
								((Color32)(ref val))..ctor((byte)40, (byte)38, (byte)34, (byte)255);
								num5 = 1f;
								num6 = -0.5f;
							}
						}
					}
					float num13 = 0.299f * (float)(int)val.r + 0.587f * (float)(int)val.g + 0.114f * (float)(int)val.b;
					float num14 = ((float)(int)val.r + (num13 - (float)(int)val.r) * 0.12f) * 0.9f;
					float num15 = ((float)(int)val.g + (num13 - (float)(int)val.g) * 0.12f) * 0.9f;
					float num16 = ((float)(int)val.b + (num13 - (float)(int)val.b) * 0.12f) * 0.9f;
					px[num4] = new Color32(Mul((byte)num14, num5), Mul((byte)num15, num5), Mul((byte)num16, num5), (byte)255);
					height[num4] = num6;
				}
			}
		}

		private static byte Mul(byte v, float s)
		{
			int num = (int)((float)(int)v * s);
			return (byte)((num >= 0) ? ((num > 255) ? 255u : ((uint)num)) : 0u);
		}

		private static Texture2D NormalMap(float[] height)
		{
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			Color32[] array = (Color32[])(object)new Color32[240000];
			for (int i = 0; i < 400; i++)
			{
				for (int j = 0; j < 600; j++)
				{
					float num = height[i * 600 + Math.Max(0, j - 1)];
					float num2 = height[i * 600 + Math.Min(599, j + 1)];
					float num3 = height[Math.Max(0, i - 1) * 600 + j];
					float num4 = height[Math.Min(399, i + 1) * 600 + j];
					float num5 = (0f - (num2 - num)) * 1.6f;
					float num6 = (0f - (num4 - num3)) * 1.6f;
					float num7 = 1f;
					float num8 = MathF.Sqrt(num5 * num5 + num6 * num6 + num7 * num7);
					num5 /= num8;
					num6 /= num8;
					num7 /= num8;
					byte b = (byte)((num5 * 0.5f + 0.5f) * 255f);
					byte b2 = (byte)((num6 * 0.5f + 0.5f) * 255f);
					byte b3 = (byte)((num7 * 0.5f + 0.5f) * 255f);
					array[i * 600 + j] = new Color32(b, b2, b3, b);
				}
			}
			Texture2D val = new Texture2D(600, 400, (TextureFormat)4, true, true);
			val.SetPixels32(Il2CppStructArray<Color32>.op_Implicit(array));
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Texture)val).filterMode = (FilterMode)2;
			((Texture)val).anisoLevel = 8;
			val.Apply(true);
			return val;
		}

		private static Texture2D LoadPng(string name, bool pole, float[] height)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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)
			try
			{
				string text = Path.Combine(CustomDir, name + ".png");
				if (!File.Exists(text))
				{
					return null;
				}
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
				if (!ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(File.ReadAllBytes(text)), false))
				{
					return null;
				}
				Color32[] array = (Color32[])(object)new Color32[240000];
				for (int i = 0; i < 400; i++)
				{
					for (int j = 0; j < 600; j++)
					{
						array[i * 600 + j] = Color32.op_Implicit(val.GetPixelBilinear(((float)j + 0.5f) / 600f, ((float)i + 0.5f) / 400f));
					}
				}
				Object.Destroy((Object)(object)val);
				Finish(array, 600, 400, pole, height);
				return ToTexture(array, 600, 400);
			}
			catch (System.Exception ex)
			{
				FlagMod instance = FlagMod.Instance;
				if (instance != null)
				{
					((MelonBase)instance).LoggerInstance.Warning("Couldn't load " + name + ".png: " + ex.Message);
				}
				return null;
			}
		}

		public static Material MakeMaterial(Color color, Texture2D tex, Texture2D normal, float metallic, float smoothness)
		{
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Expected O, but got Unknown
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_shader == (Object)null)
			{
				string[] shaderNames = ShaderNames;
				for (int i = 0; i < shaderNames.Length; i++)
				{
					_shader = Shader.Find(shaderNames[i]);
					if ((Object)(object)_shader != (Object)null)
					{
						break;
					}
				}
				if ((Object)(object)_shader == (Object)null)
				{
					System.Collections.Generic.IEnumerator<Material> enumerator = Resources.FindObjectsOfTypeAll<Material>().GetEnumerator();
					try
					{
						while (((System.Collections.IEnumerator)enumerator).MoveNext())
						{
							Material current = enumerator.Current;
							if (!((Object)(object)current == (Object)null) && !((Object)(object)current.shader == (Object)null))
							{
								string name = ((Object)current.shader).name;
								if (name.Contains("Lit") && !name.Contains("Unlit") && !name.Contains("Particle") && current.HasProperty("_BaseMap"))
								{
									_shader = current.shader;
									break;
								}
							}
						}
					}
					finally
					{
						((System.IDisposable)enumerator)?.Dispose();
					}
				}
				FlagMod instance = FlagMod.Instance;
				if (instance != null)
				{
					((MelonBase)instance).LoggerInstance.Msg("Flag material: " + (((Object)(object)_shader != (Object)null) ? ((Object)_shader).name : "none found"));
				}
			}
			Material val = new Material(_shader)
			{
				hideFlags = (HideFlags)32,
				enableInstancing = true
			};
			val.renderQueue = 2000;
			if ((Object)(object)tex != (Object)null)
			{
				if (val.HasProperty("_BaseMap"))
				{
					val.SetTexture("_BaseMap", (Texture)(object)tex);
				}
				if (val.HasProperty("_MainTex"))
				{
					val.SetTexture("_MainTex", (Texture)(object)tex);
				}
			}
			if (val.HasProperty("_BaseColor"))
			{
				val.SetColor("_BaseColor", color);
			}
			if (val.HasProperty("_Color"))
			{
				val.SetColor("_Color", color);
			}
			if ((Object)(object)normal != (Object)null && val.HasProperty("_BumpMap"))
			{
				val.SetTexture("_BumpMap", (Texture)(object)normal);
				if (val.HasProperty("_BumpScale"))
				{
					val.SetFloat("_BumpScale", 0.8f);
				}
				val.EnableKeyword("_NORMALMAP");
			}
			if (val.HasProperty("_Smoothness"))
			{
				val.SetFloat("_Smoothness", smoothness);
			}
			if (val.HasProperty("_Glossiness"))
			{
				val.SetFloat("_Glossiness", smoothness);
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", metallic);
			}
			return val;
		}

		static FlagArt()
		{
			List<FlagDef> obj = new List<FlagDef>();
			obj.Add(new FlagDef("Ukraine", "Europe", delegate(Painter p)
			{
				p.HStripes(22455u, 16766720u);
			}));
			obj.Add(new FlagDef("United Kingdom", "Europe", delegate(Painter p)
			{
				p.UnionJack(0f, 0f, 1f, 1f);
			}));
			obj.Add(new FlagDef("France", "Europe", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.VStripes(array);
			}));
			obj.Add(new FlagDef("Germany", "Europe", delegate(Painter p)
			{
				p.HStripes(0u, 14483456u, 16764416u);
			}));
			obj.Add(new FlagDef("Italy", "Europe", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.VStripes(array);
			}));
			obj.Add(new FlagDef("Spain", "Europe", delegate(Painter p)
			{
				int[] array = new int[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				uint[] array2 = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HBands(array, array2);
			}));
			obj.Add(new FlagDef("Poland", "Europe", delegate(Painter p)
			{
				p.HStripes(16777215u, 14423100u);
			}));
			obj.Add(new FlagDef("Netherlands", "Europe", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HStripes(array);
			}));
			obj.Add(new FlagDef("Belgium", "Europe", delegate(Painter p)
			{
				p.VStripes(0u, 16636452u, 15676224u);
			}));
			obj.Add(new FlagDef("Ireland", "Europe", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.VStripes(array);
			}));
			obj.Add(new FlagDef("Sweden", "Europe", delegate(Painter p)
			{
				p.Fill(27303u);
				p.Nordic(0.375f, 0.2f, 16698368u);
			}));
			obj.Add(new FlagDef("Norway", "Europe", delegate(Painter p)
			{
				p.Fill(12192815u);
				p.Nordic(0.364f, 0.25f, 16777215u);
				p.Nordic(0.364f, 0.125f, 8283u);
			}));
			obj.Add(new FlagDef("Finland", "Europe", delegate(Painter p)
			{
				p.Nordic(0.361f, 0.273f, 12140u);
			}));
			obj.Add(new FlagDef("Denmark", "Europe", delegate(Painter p)
			{
				p.Fill(13111342u);
				p.Nordic(0.378f, 0.143f, 16777215u);
			}));
			obj.Add(new FlagDef("Iceland", "Europe", delegate(Painter p)
			{
				p.Fill(152220u);
				p.Nordic(0.36f, 0.222f, 16777215u);
				p.Nordic(0.36f, 0.111f, 14425653u);
			}));
			obj.Add(new FlagDef("Switzerland", "Europe", delegate(Painter p)
			{
				p.Fill(14297372u);
				p.Rect(13f / 30f, 0.2f, 17f / 30f, 0.8f, 16777215u);
				p.Rect(0.3f, 0.4f, 0.7f, 0.6f, 16777215u);
			}));
			obj.Add(new FlagDef("Austria", "Europe", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HStripes(array);
			}));
			obj.Add(new FlagDef("Greece", "Europe", delegate(Painter p)
			{
				uint[] array = new uint[9];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HStripes(array);
				float num = 5f / 9f;
				float num2 = 1f / 9f;
				p.Rect(0f, 0f, num / 1.5f, num, 876207u);
				p.Rect(0f, 2f * num2, num / 1.5f, 3f * num2, 16777215u);
				p.Rect(2f * num2 / 1.5f, 0f, 3f * num2 / 1.5f, num, 16777215u);
			}));
			obj.Add(new FlagDef("Portugal", "Europe", delegate(Painter p)
			{
				p.Rect(0f, 0f, 0.4f, 1f, 26112u);
				p.Rect(0.4f, 0f, 1f, 1f, 16711680u);
				p.Ring(0.4f, 0.5f, 0.15f, 0.2f, 16769024u);
				float cu = 0.6f;
				p.Bar(cu, 0.5f, 0.2f, 0.16f, 90f, 16711680u);
				p.Bar(cu, 0.5f, 0.13f, 0.1f, 90f, 16777215u);
			}));
			obj.Add(new FlagDef("Russia", "Europe", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HStripes(array);
			}));
			obj.Add(new FlagDef("Czechia", "Europe", delegate(Painter p)
			{
				p.HStripes(16777215u, 14095386u);
				p.Tri(0.5f, 1131902u);
			}));
			obj.Add(new FlagDef("Estonia", "Europe", delegate(Painter p)
			{
				p.HStripes(29390u, 0u, 16777215u);
			}));
			obj.Add(new FlagDef("Latvia", "Europe", delegate(Painter p)
			{
				int[] array = new int[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				uint[] array2 = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HBands(array, array2);
			}));
			obj.Add(new FlagDef("Lithuania", "Europe", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HStripes(array);
			}));
			obj.Add(new FlagDef("Romania", "Europe", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.VStripes(array);
			}));
			obj.Add(new FlagDef("Hungary", "Europe", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HStripes(array);
			}));
			obj.Add(new FlagDef("Bulgaria", "Europe", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HStripes(array);
			}));
			obj.Add(new FlagDef("Georgia", "Europe", delegate(Painter p)
			{
				p.Nordic(0.5f, 0.2f, 16711680u);
				float num = 13f / 60f;
				float[] array = new float[2]
				{
					num,
					1f - num
				};
				foreach (float num2 in array)
				{
					float[] array2 = new float[2] { 0.2f, 0.8f };
					foreach (float num3 in array2)
					{
						p.Rect(num2 - 0.02f, num3 - 0.1f, num2 + 0.02f, num3 + 0.1f, 16711680u);
						p.Rect(num2 - 1f / 15f, num3 - 0.03f, num2 + 1f / 15f, num3 + 0.03f, 16711680u);
					}
				}
			}));
			obj.Add(new FlagDef("United States", "Americas", delegate(Painter p)
			{
				for (int i = 0; i < 13; i++)
				{
					p.Rect(0f, (float)i / 13f, 1f, (float)(i + 1) / 13f, (i % 2 == 0) ? 11674164u : 16777215u);
				}
				float num = 0.4f;
				float num2 = 0.53846157f;
				p.Rect(0f, 0f, num, num2, 3947374u);
				for (int j = 0; j < 9; j++)
				{
					int num3 = ((j % 2 == 0) ? 6 : 5);
					for (int k = 0; k < num3; k++)
					{
						float x = (float)((j % 2 == 0) ? (2 * k + 1) : (2 * k + 2)) * num / 12f;
						p.Star(x, (float)(j + 1) * num2 / 10f, 0.031f, 16777215u);
					}
				}
			}));
			obj.Add(new FlagDef("Canada", "Americas", delegate(Painter p)
			{
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				int[] array = new int[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				uint[] array2 = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.VBands(array, array2);
				float[] array3 = new float[42];
				RuntimeHelpers.InitializeArray((System.Array)array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				float[] array4 = array3;
				Vector2[] array5 = (Vector2[])(object)new Vector2[array4.Length / 2];
				for (int i = 0; i < array5.Length; i++)
				{
					array5[i] = new Vector2(0.75f + array4[i * 2] * 0.62f, 0.5f - array4[i * 2 + 1] * 0.62f);
				}
				p.Poly(array5, 14157345u);
			}));
			obj.Add(new FlagDef("Mexico", "Americas", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.VStripes(array);
				p.Ring(0.5f, 0.52f, 0.11f, 0.13f, 26695u);
				p.Circle(0.5f, 0.5f, 0.1f, 9198123u);
			}));
			obj.Add(new FlagDef("Brazil", "Americas", delegate(Painter p)
			{
				p.Fill(39995u);
				float[] array = new float[8];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.PolyF(16768768u, array);
				p.Circle(0.5f, 0.5f, 0.245f, 10102u);
				float cu = 0.75f;
				float ou = cu - 0.2f;
				float ov = 1.05f;
				p.Shape(delegate(float u, float v)
				{
					float num = (u - cu) * (u - cu) + (v - 0.5f) * (v - 0.5f);
					float num2 = MathF.Sqrt((u - ou) * (u - ou) + (v - ov) * (v - ov));
					return num <= 0.060025003f && num2 >= 0.56f && num2 <= 0.61f;
				}, 16777215u, cu - 0.25f, 0.25f, cu + 0.25f, 0.75f);
			}));
			obj.Add(new FlagDef("Argentina", "Americas", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HStripes(array);
				p.Star(0.5f, 0.5f, 0.14f, 16167950u, 0f, 16, 0.6f);
				p.Circle(0.5f, 0.5f, 0.07f, 16167950u);
			}));
			obj.Add(new FlagDef("Colombia", "Americas", delegate(Painter p)
			{
				int[] array = new int[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				uint[] array2 = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HBands(array, array2);
			}));
			obj.Add(new FlagDef("Chile", "Americas", delegate(Painter p)
			{
				p.Rect(0f, 0.5f, 1f, 1f, 13970206u);
				p.Rect(0f, 0f, 1f / 3f, 0.5f, 14758u);
				p.Star(1f / 6f, 0.25f, 0.1f, 16777215u);
			}));
			obj.Add(new FlagDef("Cuba", "Americas", delegate(Painter p)
			{
				uint[] array = new uint[5];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HStripes(array);
				p.Tri(0.577f, 13571115u);
				p.Star(0.19233334f, 0.5f, 0.13f, 16777215u);
			}));
			obj.Add(new FlagDef("Puerto Rico", "Americas", delegate(Painter p)
			{
				uint[] array = new uint[5];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HStripes(array);
				p.Tri(0.577f, 20720u);
				p.Star(0.19233334f, 0.5f, 0.13f, 16777215u);
			}));
			obj.Add(new FlagDef("Jamaica", "Americas", delegate(Painter p)
			{
				p.Fill(39738u);
				float[] array = new float[6];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.PolyF(0u, array);
				float[] array2 = new float[6];
				RuntimeHelpers.InitializeArray((System.Array)array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.PolyF(0u, array2);
				p.Line(0f, 0f, 1f, 1f, 0.16f, 16699648u);
				p.Line(0f, 1f, 1f, 0f, 0.16f, 16699648u);
			}));
			obj.Add(new FlagDef("Iraq", "Middle East", delegate(Painter p)
			{
				p.HStripes(13504806u, 16777215u, 0u);
				float bx0 = 0.3f;
				float bx1 = 0.7f;
				float by0 = 0.375f;
				float by1 = 0.625f;
				B(0.93f, 0.02f, 0.98f, 0.84f);
				B(0.82f, 0.02f, 0.87f, 0.84f);
				B(0.71f, 0.02f, 0.76f, 0.84f);
				B(0.53f, 0.72f, 0.87f, 0.84f);
				B(0.53f, 0.4f, 0.58f, 0.84f);
				B(0.63f, 0.4f, 0.68f, 0.84f);
				B(0.53f, 0.4f, 0.68f, 0.5f);
				B(0.44f, 0.02f, 0.49f, 0.84f);
				B(0.33f, 0.1f, 0.38000003f, 0.84f);
				B(0.24f, 0.1f, 0.38000003f, 0.2f);
				B(0.1f, 0.72f, 0.38000003f, 0.84f);
				B(0.2f, 0.5f, 0.25f, 0.84f);
				B(0.2f, 0.92f, 0.25f, 1f);
				p.PolyF(31293u, bx0 + 0.1f * (bx1 - bx0), by0 + 0.72f * (by1 - by0), bx0 + 0.15f * (bx1 - bx0), by0 + 0.72f * (by1 - by0), bx0 + 0.07f * (bx1 - bx0), by0 + 1.02f * (by1 - by0), bx0 + 0.02f * (bx1 - bx0), by0 + 1.02f * (by1 - by0));
				[CompilerGenerated]
				void B(float x0, float y0, float x1, float y1)
				{
					p.Rect(bx0 + x0 * (bx1 - bx0), by0 + y0 * (by1 - by0), bx0 + x1 * (bx1 - bx0), by0 + y1 * (by1 - by0), 31293u);
				}
			}));
			obj.Add(new FlagDef("Iran", "Middle East", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HStripes(array);
				p.Crescent(0.5f, 0.5f, 0.11f, 0.035f, 0f, 0.1f, 14286848u);
				p.Crescent(0.5f, 0.5f, 0.11f, -0.035f, 0f, 0.1f, 14286848u);
				p.Bar(0.75f, 0.49f, 0.2f, 0.018f, 90f, 14286848u);
			}));
			obj.Add(new FlagDef("Syria", "Middle East", delegate(Painter p)
			{
				p.HStripes(31293u, 16777215u, 0u);
				float[] array = new float[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				float[] array2 = array;
				foreach (float x in array2)
				{
					p.Star(x, 0.5f, 0.11f, 13504806u);
				}
			}));
			obj.Add(new FlagDef("Palestine", "Middle East", delegate(Painter p)
			{
				p.HStripes(0u, 16777215u, 31293u);
				p.Tri(1f / 3f, 13504806u);
			}));
			obj.Add(new FlagDef("Israel", "Middle East", delegate(Painter p)
			{
				p.Rect(0f, 0.1f, 1f, 0.25f, 14520u);
				p.Rect(0f, 0.75f, 1f, 0.9f, 14520u);
				p.TriOutline(0.5f, 0.5f, 0.17f, 0f, 0.028f, 14520u);
				p.TriOutline(0.5f, 0.5f, 0.17f, 180f, 0.028f, 14520u);
			}));
			obj.Add(new FlagDef("Jordan", "Middle East", delegate(Painter p)
			{
				p.HStripes(0u, 16777215u, 31293u);
				p.Tri(0.5f, 13504806u);
				p.Star(0.17f, 0.5f, 0.07f, 16777215u, 0f, 7, 0.5f);
			}));
			obj.Add(new FlagDef("Lebanon", "Middle East", delegate(Painter p)
			{
				int[] array = new int[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				uint[] array2 = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HBands(array, array2);
				for (int i = 0; i < 4; i++)
				{
					float num = 0.29f + (float)i * 0.08f;
					float num2 = num + 0.12f;
					float num3 = (0.06f + (float)i * 0.03f) / 1.5f;
					p.PolyF(42577u, 0.5f, num, 0.5f + num3, num2, 0.5f - num3, num2);
				}
				p.Rect(0.49f, 0.65f, 0.51f, 0.72f, 42577u);
			}));
			obj.Add(new FlagDef("Kuwait", "Middle East", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HStripes(array);
				float[] array2 = new float[8];
				RuntimeHelpers.InitializeArray((System.Array)array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.PolyF(0u, array2);
			}));
			obj.Add(new FlagDef("UAE", "Middle East", delegate(Painter p)
			{
				p.Rect(0.25f, 0f, 1f, 1f / 3f, 29487u);
				p.Rect(0.25f, 2f / 3f, 1f, 1f, 0u);
				p.Rect(0f, 0f, 0.25f, 1f, 16711680u);
			}));
			obj.Add(new FlagDef("Qatar", "Middle East", delegate(Painter p)
			{
				p.Serrated(9247549u, 16777215u, 9, 0.27f, 0.35f);
			}));
			obj.Add(new FlagDef("Bahrain", "Middle East", delegate(Painter p)
			{
				p.Serrated(13504806u, 16777215u, 5, 0.25f, 0.34f);
			}));
			obj.Add(new FlagDef("Turkey", "Middle East", delegate(Painter p)
			{
				p.Fill(14879255u);
				p.Crescent(1f / 3f, 0.5f, 0.25f, 0.0625f, 0f, 0.2f, 16777215u);
				p.Star(83f / 150f, 0.5f, 0.125f, 16777215u, 90f);
			}));
			obj.Add(new FlagDef("Egypt", "Middle East", delegate(Painter p)
			{
				p.HStripes(13504806u, 16777215u, 0u);
				p.Ellipse(0.5f, 0.5f, 0.06f, 0.11f, 12620544u);
			}));
			obj.Add(new FlagDef("Yemen", "Middle East", delegate(Painter p)
			{
				p.HStripes(13504806u, 16777215u, 0u);
			}));
			obj.Add(new FlagDef("Kurdistan", "Middle East", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HStripes(array);
				p.Star(0.5f, 0.5f, 0.15f, 16694545u, 0f, 21, 0.65f);
				p.Circle(0.5f, 0.5f, 0.09f, 16694545u);
			}));
			obj.Add(new FlagDef("Japan", "Asia", delegate(Painter p)
			{
				p.Circle(0.5f, 0.5f, 0.3f, 12320813u);
			}));
			obj.Add(new FlagDef("China", "Asia", delegate(Painter p)
			{
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: 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)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: 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_009a: Unknown result type (might be due to invalid IL or missing references)
				p.Fill(15604773u);
				p.Star(1f / 6f, 0.25f, 0.15f, 16768512u);
				ValueTuple<float, float>[] array = new ValueTuple<float, float>[4]
				{
					new ValueTuple<float, float>(10f, 2f),
					new ValueTuple<float, float>(12f, 4f),
					new ValueTuple<float, float>(12f, 7f),
					new ValueTuple<float, float>(10f, 9f)
				};
				for (int i = 0; i < array.Length; i++)
				{
					ValueTuple<float, float> val = array[i];
					float item = val.Item1;
					float item2 = val.Item2;
					p.StarToward(item / 30f, item2 / 20f, 0.05f, 16768512u, 1f / 6f, 0.25f);
				}
			}));
			obj.Add(new FlagDef("South Korea", "Asia", delegate(Painter p)
			{
				float cu = 0.75f;
				float r = 0.25f;
				float num = MathF.Atan2(0.5f, 0.75f);
				float ca = MathF.Cos(num);
				float sa = MathF.Sin(num);
				p.Shape(delegate(float u, float v)
				{
					float num4 = u - cu;
					float num5 = v - 0.5f;
					if (num4 * num4 + num5 * num5 > r * r)
					{
						return false;
					}
					float num6 = num4 * ca + num5 * sa;
					float num7 = (0f - num4) * sa + num5 * ca;
					if ((num6 + r / 2f) * (num6 + r / 2f) + num7 * num7 <= r * r / 4f)
					{
						return true;
					}
					return !((num6 - r / 2f) * (num6 - r / 2f) + num7 * num7 <= r * r / 4f) && num7 < 0f;
				}, 13446714u, cu - r, 0.5f - r, cu + r, 0.5f + r);
				p.Shape(delegate(float u, float v)
				{
					float num4 = u - cu;
					float num5 = v - 0.5f;
					if (num4 * num4 + num5 * num5 > r * r)
					{
						return false;
					}
					float num6 = num4 * ca + num5 * sa;
					float num7 = (0f - num4) * sa + num5 * ca;
					if ((num6 + r / 2f) * (num6 + r / 2f) + num7 * num7 <= r * r / 4f)
					{
						return false;
					}
					return (num6 - r / 2f) * (num6 - r / 2f) + num7 * num7 <= r * r / 4f || num7 >= 0f;
				}, 18336u, cu - r, 0.5f - r, cu + r, 0.5f + r);
				float num2 = 0.8324084f;
				float num3 = 0.554939f;
				float dirU = 0f - num2;
				float dirV = 0f - num3;
				bool[] array = new bool[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				Trigram(dirU, dirV, array);
				Trigram(num2, num3, new bool[3]);
				Trigram(num2, 0f - num3, new bool[3] { false, true, false });
				Trigram(0f - num2, num3, new bool[3] { true, false, true });
				void Trigram(float num9, float num11, bool[] solid)
				{
					float num4 = 0.458f;
					float num5 = 0.25f;
					float thick = 1f / 24f;
					float num6 = 0.0625f;
					float num7 = 1f / 48f;
					float num8 = cu + num9 * num4;
					float num10 = 0.5f + num11 * num4;
					float angDeg = MathF.Atan2(num11, num9) * 180f / (float)Math.PI + 90f;
					float num12 = 0f - num11;
					for (int i = 0; i < 3; i++)
					{
						float num13 = (float)(i - 1) * num6;
						float num14 = num8 + num9 * num13;
						float num15 = num10 + num11 * num13;
						if (solid[i])
						{
							p.Bar(num14, num15, num5, thick, angDeg, 0u);
						}
						else
						{
							float num16 = (num5 - num7) / 2f;
							float num17 = num7 / 2f + num16 / 2f;
							p.Bar(num14 + num12 * num17, num15 + num9 * num17, num16, thick, angDeg, 0u);
							p.Bar(num14 - num12 * num17, num15 - num9 * num17, num16, thick, angDeg, 0u);
						}
					}
				}
			}));
			obj.Add(new FlagDef("India", "Asia", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HStripes(array);
				float num = 0.75f;
				p.Ring(0.5f, 0.5f, 0.12f, 0.14f, 128u);
				for (int i = 0; i < 24; i++)
				{
					float num2 = (float)i * (float)Math.PI / 12f;
					p.LineU(num, 0.5f, num + MathF.Cos(num2) * 0.125f, 0.5f + MathF.Sin(num2) * 0.125f, 0.009f, 128u);
				}
				p.Circle(0.5f, 0.5f, 0.025f, 128u);
			}));
			obj.Add(new FlagDef("Pakistan", "Asia", delegate(Painter p)
			{
				p.Rect(0.25f, 0f, 1f, 1f, 82204u);
				p.Crescent(0.625f, 0.5f, 0.3f, 0.07f, -0.07f, 0.27f, 16777215u);
				p.Star(0.7316667f, 0.37f, 0.1f, 16777215u, -45f);
			}));
			obj.Add(new FlagDef("Bangladesh", "Asia", delegate(Painter p)
			{
				p.Fill(27214u);
				p.Circle(0.45f, 0.5f, 0.2f, 16001601u);
			}));
			obj.Add(new FlagDef("Vietnam", "Asia", delegate(Painter p)
			{
				p.Fill(14296349u);
				p.Star(0.5f, 0.5f, 0.3f, 16776960u);
			}));
			obj.Add(new FlagDef("Philippines", "Asia", delegate(Painter p)
			{
				p.HStripes(14504u, 13504806u);
				p.Tri(0.577f, 16777215u);
				p.Star(0.19233334f, 0.5f, 0.12f, 16568598u, 0f, 8, 0.45f);
				p.Circle(0.19233334f, 0.5f, 0.06f, 16568598u);
				p.Star(0.045f, 0.1f, 0.04f, 16568598u);
				p.Star(0.045f, 0.9f, 0.04f, 16568598u);
				p.Star(0.5f, 0.5f, 0.04f, 16568598u, 90f);
			}));
			obj.Add(new FlagDef("Indonesia", "Asia", delegate(Painter p)
			{
				p.HStripes(16711680u, 16777215u);
			}));
			obj.Add(new FlagDef("Thailand", "Asia", delegate(Painter p)
			{
				int[] array = new int[5];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				uint[] array2 = new uint[5];
				RuntimeHelpers.InitializeArray((System.Array)array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HBands(array, array2);
			}));
			obj.Add(new FlagDef("Nigeria", "Africa & Oceania", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.VStripes(array);
			}));
			obj.Add(new FlagDef("South Africa", "Africa & Oceania", delegate(Painter p)
			{
				p.Rect(0f, 0f, 1f, 0.5f, 14695473u);
				p.Rect(0f, 0.5f, 1f, 1f, 5257u);
				p.Line(0f, 0f, 0.36f, 0.5f, 0.333f, 16777215u);
				p.Line(0f, 1f, 0.36f, 0.5f, 0.333f, 16777215u);
				p.Rect(0.36f, 0.333f, 1f, 0.667f, 16777215u);
				p.Line(0f, 0f, 0.36f, 0.5f, 0.2f, 30537u);
				p.Line(0f, 1f, 0.36f, 0.5f, 0.2f, 30537u);
				p.Rect(0.36f, 0.4f, 1f, 0.6f, 30537u);
				float[] array = new float[6];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.PolyF(16758812u, array);
				float[] array2 = new float[6];
				RuntimeHelpers.InitializeArray((System.Array)array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.PolyF(0u, array2);
			}));
			obj.Add(new FlagDef("Kenya", "Africa & Oceania", delegate(Painter p)
			{
				int[] array = new int[5];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				uint[] array2 = new uint[5];
				RuntimeHelpers.InitializeArray((System.Array)array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HBands(array, array2);
				p.Line(0.43f, 0.15f, 0.57f, 0.85f, 0.015f, 16777215u);
				p.Line(0.57f, 0.15f, 0.43f, 0.85f, 0.015f, 16777215u);
				p.Ellipse(0.5f, 0.5f, 0.11f, 0.32f, 16777215u);
				p.Ellipse(0.5f, 0.5f, 0.09f, 0.3f, 12255232u);
				float cu = 0.75f;
				p.Shape(delegate(float u, float v)
				{
					float num = (u - cu) / 0.09f;
					float num2 = (v - 0.5f) / 0.3f;
					return num * num + num2 * num2 <= 1f && MathF.Abs(v - 0.5f) > 0.16f;
				}, 0u, cu - 0.1f, 0.2f, cu + 0.1f, 0.8f);
			}));
			obj.Add(new FlagDef("Ghana", "Africa & Oceania", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HStripes(array);
				p.Star(0.5f, 0.5f, 0.16f, 0u);
			}));
			obj.Add(new FlagDef("Ethiopia", "Africa & Oceania", delegate(Painter p)
			{
				uint[] array = new uint[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HStripes(array);
				p.Circle(0.5f, 0.5f, 0.2f, 1001391u);
				p.Pentagram(0.5f, 0.5f, 0.16f, 0.022f, 16571657u);
			}));
			obj.Add(new FlagDef("Morocco", "Africa & Oceania", delegate(Painter p)
			{
				p.Fill(12658477u);
				p.Pentagram(0.5f, 0.5f, 0.22f, 0.035f, 25139u);
			}));
			obj.Add(new FlagDef("Algeria", "Africa & Oceania", delegate(Painter p)
			{
				p.VStripes(26163u, 16777215u);
				p.Crescent(0.5f, 0.5f, 0.25f, 0.0625f, 0f, 0.2f, 13766708u);
				p.Star(44f / 75f, 0.5f, 0.12f, 13766708u, 90f);
			}));
			obj.Add(new FlagDef("Tunisia", "Africa & Oceania", delegate(Painter p)
			{
				p.Fill(15138835u);
				p.Circle(0.5f, 0.5f, 0.25f, 16777215u);
				p.Crescent(0.5f, 0.5f, 0.19f, 0.05f, 0f, 0.15f, 15138835u);
				p.Star(0.54f, 0.5f, 0.1f, 15138835u, 90f);
			}));
			obj.Add(new FlagDef("Libya", "Africa & Oceania", delegate(Painter p)
			{
				int[] array = new int[3];
				RuntimeHelpers.InitializeArray((System.Array)array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				p.HBands(array, 15138835u, 0u, 2334278u);
				p.Crescent(0.47f, 0.5f, 0.15f, 0.04f, 0f, 0.12f, 16777215u);
				p.Star(0.55f, 0.5f, 0.07f, 16777215u, 90f);
			}));
			obj.Add(new FlagDef("Somalia", "Africa & Oceania", delegate(Painter p)
			{
				p.Fill(4295133u);
				p.Star(0.5f, 0.5f, 0.2f, 16777215u);
			}));
			obj.Add(new FlagDef("Sudan", "Africa & Oceania", delegate(Painter p)
			{
				p.HStripes(13766708u, 16777215u, 0u);
				p.Tri(1f / 3f, 29225u);
			}));
			obj.Add(new FlagDef("Australia", "Africa & Oceania", delegate(Painter p)
			{
				p.Fill(74089u);
				p.UnionJack(0f, 0f, 0.5f, 0.5f);
				p.Star(0.25f, 0.76f, 0.14f, 16777215u, 0f, 7, 0.44f);
				p.Star(0.75f, 0.17f, 0.065f, 16777215u, 0f, 7, 0.44f);
				p.Star(0.625f, 0.45f, 0.065f, 16777215u, 0f, 7, 0.44f);
				p.Star(0.865f, 0.39f, 0.065f, 16777215u, 0f, 7, 0.44f);
				p.Star(0.75f, 0.82f, 0.065f, 16777215u, 0f, 7, 0.44f);
				p.Star(0.8f, 0.56f, 0.035f, 16777215u);
			}));
			obj.Add(new FlagDef("New Zealand", "Africa & Oceania", delegate(Painter p)
			{
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: 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_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				p.Fill(74089u);
				p.UnionJack(0f, 0f, 0.5f, 0.5f);
				ValueTuple<float, float, float>[] array = new ValueTuple<float, float, float>[4]
				{
					new ValueTuple<float, float, float>(0.75f, 0.2f, 0.07f),
					new ValueTuple<float, float, float>(0.635f, 0.45f, 0.075f),
					new ValueTuple<float, float, float>(0.86f, 0.4f, 0.065f),
					new ValueTuple<float, float, float>(0.75f, 0.8f, 0.08f)
				};
				for (int i = 0; i < array.Length; i++)
				{
					ValueTuple<float, float, float> val = array[i];
					float item = val.Item1;
					float item2 = val.Item2;
					float item3 = val.Item3;
					p.Star(item, item2, item3 + 0.015f, 16777215u);
					p.Star(item, item2, item3, 13111342u);
				}
			}));
			All = obj;
		}
	}
	public struct FlagSnap
	{
		public int Id;

		public string Country;

		public bool Pole;

		public float[] P;
	}
	public class FlagMod : MelonMod
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action <0>__ClearAll;

			public static Action <1>__ClearCache;

			public static Action <2>__DeleteAll;
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<MelonMod, bool> <>9__15_0;

			public static Func<MelonMod, bool> <>9__15_1;

			public static Action<bool> <>9__16_0;

			public static Action<float> <>9__16_1;

			public static Action <>9__22_0;

			internal bool <OnLateInitializeMelon>b__15_0(MelonMod m)
			{
				return ((MelonBase)m).Info.Name == "LabFusion";
			}

			internal bool <OnLateInitializeMelon>b__15_1(MelonMod m)
			{
				return ((MelonBase)m).Info.Name == "Timeline";
			}

			internal void <BuildMenu>b__16_0(bool v)
			{
				_pole.Value = v;
			}

			internal void <BuildMenu>b__16_1(float v)
			{
				_wind.Value = v;
			}

			internal void <OnUpdate>b__22_0()
			{
			}
		}

		internal static FlagMod Instance;

		private static readonly List<Flag> Flags = new List<Flag>();

		private static readonly Dictionary<object, Dictionary<int, Flag>> Replays = new Dictionary<object, Dictionary<int, Flag>>();

		private static MelonPreferences_Entry<float> _wind;

		private static MelonPreferences_Entry<bool> _pole;

		private static float _seed;

		private static readonly float[] _buf = new float[12];

		private static readonly Random _rng = new Random();

		private static readonly bool[] _gripDown = new bool[2];

		private static readonly Flag[] _holding = new Flag[2];

		private const float GrabReachPole = 0.09f;

		private const float GrabReachCloth = 0.14f;

		public static int Count => Flags.Count;

		public override void OnInitializeMelon()
		{
			//IL_0094: 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_009f: Expected O, but got Unknown
			Instance = this;
			MelonPreferences_Category obj = MelonPreferences.CreateCategory("WigglesFlags");
			_wind = obj.CreateEntry<float>("Wind", 4f, "Wind strength (m/s)", (string)null, false, false, (ValueValidator)null, (string)null);
			_pole = obj.CreateEntry<bool>("OnPole", true, "Spawn flags on a pole (off: a bare flag you hold by its corners and edges)", (string)null, false, false, (ValueValidator)null, (string)null);
			_seed = (float)_rng.NextDouble() * 100f;
			FlagArt.CustomDir = Path.Combine(MelonEnvironment.UserDataDirectory, "WigglesFlags");
			Directory.CreateDirectory(FlagArt.CustomDir);
			BuildMenu();
			object obj2 = <>O.<0>__ClearAll;
			if (obj2 == null)
			{
				Action val = ClearAll;
				<>O.<0>__ClearAll = val;
				obj2 = (object)val;
			}
			Hooking.OnLevelUnloaded += (Action)obj2;
		}

		public override void OnLateInitializeMelon()
		{
			if (Enumerable.Any<MelonMod>((System.Collections.Generic.IEnumerable<MelonMod>)MelonTypeBase<MelonMod>.RegisteredMelons, (Func<MelonMod, bool>)((MelonMod m) => ((MelonBase)m).Info.Name == "LabFusion")) && Net.Load("WigglesFlags.Fusion", "WigglesFlags.FlagNet", ((MelonBase)this).LoggerInstance))
			{
				((MelonBase)this).LoggerInstance.Msg("Fusion sync on");
			}
			if (Enumerable.Any<MelonMod>((System.Collections.Generic.IEnumerable<MelonMod>)MelonTypeBase<MelonMod>.RegisteredMelons, (Func<MelonMod, bool>)((MelonMod m) => ((MelonBase)m).Info.Name == "Timeline")) && Net.Load("WigglesFlags.Timeline", "WigglesFlags.FlagTimeline", ((MelonBase)this).LoggerInstance))
			{
				((MelonBase)this).LoggerInstance.Msg("Timeline recording on");
			}
		}

		private void BuildMenu()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: