Decompiled source of DifferentStrokes v4.16.0

plugins/DifferentStrokes.dll

Decompiled 15 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyFileVersion("4.16.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace DifferentStrokes;

[BepInPlugin("com.differentstrokes.valheim", "DifferentStrokes", "4.16.0")]
public class DifferentStrokesPlugin : BaseUnityPlugin
{
	private struct GSample
	{
		public double t;

		public float v;

		public float a;
	}

	private struct KeyEv
	{
		public int cmd;

		public float t;
	}

	private struct HintRow
	{
		public string Key;

		public string Act;

		public bool Head;
	}

	public const string Guid = "com.differentstrokes.valheim";

	public const string PluginName = "DifferentStrokes";

	public const string Version = "4.16.0";

	internal static ManualLogSource Log;

	private bool _rowing;

	private CrewShip _rowShip;

	private CrewShip _aboardShip;

	private Vector3 _startLocal;

	private float _lastActivity;

	private float _nextStrokeOk;

	private float _boardedAt;

	private float _side = 1f;

	private int _streak;

	private readonly List<GSample> _g = new List<GSample>();

	private double _gLast;

	private Vector3 _gPos;

	private float _gSpeed;

	private float _gAcc;

	private bool _gHave;

	private GUIStyle _tiny;

	private GUIStyle _tinyR;

	private GUIStyle _tinyC;

	private float _txtNext;

	private float _gAmax = 1f;

	private float _gLo;

	private float _gHi = 1f;

	private string _tHint = "";

	private string _tHold = "";

	private string _tRhythm = "";

	private string _tPerfect = "";

	private string _tGA = "";

	private string _tGV = "";

	private string _tA1 = "";

	private string _tA2 = "";

	private string _tV1 = "";

	private string _tV2 = "";

	private string _tLegend = "";

	private string _tDebuff = "";

	private bool _keysPinned;

	private float _modeAt;

	private int _lastMode = -1;

	private float _nextEndLog;

	private bool _holding;

	private bool _failed;

	private bool _exhausted;

	private bool _haveYaw;

	private float _lastYaw;

	private float _holdStart;

	private float _catchQ;

	private float _oarPos;

	private bool _rev;

	private bool _pressRev;

	private bool _releaseRev;

	private int _heldCmd = -1;

	private float _strokeEndAt = -99f;

	private float _pressErrSec;

	private float _pressPath;

	private float _releasePath;

	private string _flashCatch = "";

	private string _flashFinish = "";

	private Color _colCatch = Color.white;

	private Color _colFinish = Color.white;

	private float _untilCatch;

	private float _untilFinish;

	private float _pressPhase;

	private float _releasePhase;

	private float _tickCatchUntil;

	private float _tickFinishUntil;

	private float _nextScan;

	private float _nextStatus;

	private float _nextHud;

	private Ship[] _fbShips;

	private float _fbAt;

	private bool _wasSeated;

	private float _sitAt = -99f;

	private int _strokesDone;

	private bool _hudOff;

	private string _exclRaw;

	private string[] _excl = new string[0];

	private int _blister;

	private int _sore;

	private float _blisterAt;

	private float _soreAt;

	private GUIStyle _left;

	private GUIStyle _right;

	private CrewStatus _status;

	private GUIStyle _label;

	private GUIStyle _small;

	private const float KeyBuffer = 0.3f;

	private readonly List<KeyEv> _kStack = new List<KeyEv>(4);

	private float _winScale = 1f;

	private float _winScaleP = 1f;

	private int _shBl = -1;

	private int _shSo = -1;

	private float _shBlAt;

	private float _shSoAt;

	private int _blisterEvt;

	private int _soreEvt;

	private int _shBlEvt;

	private int _shSoEvt;

	private GUIStyle _sigBig;

	private GUIStyle _sigLab;

	private float _th1;

	private float _th2;

	private float _th3;

	private float _thAt;

	private const float GuideSeconds = 9f;

	private readonly List<HintRow> _rows = new List<HintRow>(16);

	private float _hintA;

	private float _idleSince = -1f;

	private float _seBottom;

	private float _seAt;

	private RectTransform _seRoot;

	private GUIStyle _hKey;

	private GUIStyle _hAct;

	private GUIStyle _hHead;

	private bool _evtCatch;

	private bool _evtFinish;

	private bool _emberFailLogged;

	private float _paceVis;

	private static readonly GUIContent _measure;

	private static readonly Dictionary<long, Dictionary<string, float>> _widths;

	private static int _widthCount;

	private int _sigSeen = -1;

	private float _sigAt = -99f;

	private bool _sigUp = true;

	private static readonly Color[] SigCol;

	internal static bool IntroOpen;

	internal static int IntroDrawFrame;

	internal static float IntroClosedAt;

	internal static int IntroEscFrame;

	private static bool _patched;

	private static bool _guardsDead;

	private static Harmony _h;

	private int _introPage;

	private GUIStyle _introBody;

	private FieldInfo _fYaw;

	private FieldInfo _fPitch;

	private object _lockYaw;

	private float _lockPitch;

	private bool _lockOk;

	private const int IntroPages = 5;

	private int _pageSeen = -1;

	private float _pageAt;

	private static readonly KeyboardShortcut QL;

	private static readonly KeyboardShortcut QR;

	internal static bool InviteMode;

	private Vector2 _io;

	private float _is = 1f;

	private const float PW = 1120f;

	private const float PH = 760f;

	private static readonly Color Amber;

	private static readonly Color Hot;

	private static readonly Color Ink;

	private static readonly Color CardC;

	private static readonly Color Dim;

	private static readonly string[] TabNames;

	private GUIStyle _stH;

	private GUIStyle _stB;

	private float _dmU;

	private float _dmCatchAt = -9f;

	private float _dmFinAt = -9f;

	private int[] _dmT = new int[64];

	private int[] _dmR = new int[64];

	private long _dmCs = -999L;

	private int _dmEvt;

	private int _dmLevel = -1;

	private float _dmBase;

	private int _sigLvSeen = -1;

	private float _sigLvAt;

	private const float IW = 760f;

	private const float IH = 290f;

	private static bool _inputPatched;

	private static Harmony _hi;

	internal static bool _guardOff;

	private CrewShip _probeShipSeen;

	private PetProbeHold _probeHold;

	private static readonly HumanBodyBones[] ProbeBones;

	private static readonly string[][] ProbeNames;

	private static FieldInfo _fAnim;

	private static FieldInfo _fHealth;

	private bool _volOpen;

	private float _volTap;

	private GameObject _mmRoot;

	internal static DifferentStrokesPlugin Inst;

	private float _driveEnv;

	private float _driveFov;

	private float _accAvg;

	private float _windI;

	private float _dA;

	private readonly List<Vector2> _aHist = new List<Vector2>();

	private Vector3 _shiftDir = Vector3.forward;

	private Vector3 _shiftNow;

	private Camera _mainCam;

	private Camera _cam;

	private float _savedFov;

	private Vector3 _savedPos;

	private Quaternion _savedRot;

	private bool _camApplied;

	private float _appFov;

	private Vector3 _appPos;

	private Quaternion _appRot;

	private static readonly FieldInfo HudsF;

	private static FieldInfo _hdChar;

	private static FieldInfo _hdGui;

	private bool _tagFail;

	private bool _drumming;

	private CrewShip _drumShip;

	private float _drumCad;

	private float _drumLastAct;

	private float _drumFlashUntil;

	private float _drumTickUntil;

	private float _drumTickPhase;

	private long _drumJudged;

	private string _drumFlash = "";

	private Color _drumFlashCol = Color.white;

	private string _tDrumCad = "";

	private string _tDrumHold = "";

	private bool _drumFree;

	private float _freeEnergy;

	private float _freeNext;

	private readonly float[] _zoneFlash = new float[3];

	private static readonly int[][] PatA;

	private static readonly int[][] PatB;

	private int _gCode = -1;

	private int _drumStreak;

	private int _mMask = 85;

	private int _mPrev = 85;

	private long _mCycle = -1L;

	private long _nCycle = -99L;

	private int _nMask = 85;

	private float _drumHb;

	private int _drumEvt;

	private readonly Dictionary<long, int> _slotRes = new Dictionary<long, int>();

	private int[] _dTarget;

	private int[] _dRes;

	private static string StatePath => Path.Combine(Paths.ConfigPath, "sakima.differentstrokes.state");

	private double Per
	{
		get
		{
			if (!((Object)(object)_rowShip != (Object)null))
			{
				if (!((Object)(object)_aboardShip != (Object)null))
				{
					return 2.4;
				}
				return _aboardShip.Period;
			}
			return _rowShip.Period;
		}
	}

	private float Drv
	{
		get
		{
			if (!((Object)(object)_rowShip != (Object)null))
			{
				if (!((Object)(object)_aboardShip != (Object)null))
				{
					return 0.5f;
				}
				return _aboardShip.Drive;
			}
			return _rowShip.Drive;
		}
	}

	internal static bool RowingNow
	{
		get
		{
			if ((Object)(object)Inst != (Object)null)
			{
				return Inst._rowing;
			}
			return false;
		}
	}

	private float PerfWin => Mathf.Max(0.025f, Cfg.PerfectSeconds.Value * _winScaleP);

	private float GoodWin
	{
		get
		{
			float num = Mathf.Max(PerfWin + 0.03f, Cfg.GoodSeconds.Value * _winScale * (1f - Cfg.DebuffStrength.Value * (float)_blister));
			float t = Mathf.Clamp01(((float)_streak - 6f) / 4f);
			return Mathf.Lerp(num, PerfWin + 0.02f, Beat.Ease(t));
		}
	}

	private float Strength => 1f - Cfg.DebuffStrength.Value * (float)_sore;

	private float StoneAlpha => Mathf.Lerp(0.12f, 0.8f, Cfg.BoxOpacity.Value);

	internal static bool IntroActive
	{
		get
		{
			if (IntroOpen)
			{
				return Time.frameCount - IntroDrawFrame <= 6;
			}
			return false;
		}
	}

	internal static bool IntroSuppress
	{
		get
		{
			float num = Time.unscaledTime - IntroClosedAt;
			if (!IntroActive && !(num < 0.25f))
			{
				if (num < 3f)
				{
					return Input.GetMouseButton(0);
				}
				return false;
			}
			return true;
		}
	}

	private int GCode
	{
		get
		{
			if (!((Object)(object)_drumShip != (Object)null))
			{
				return 4;
			}
			return _drumShip.Code;
		}
	}

	private double GQ => 0.6 / (double)Beat.SubsOf(GCode);

	private double GA
	{
		get
		{
			if (!((Object)(object)_drumShip != (Object)null))
			{
				return 0.0;
			}
			return _drumShip.Anchor;
		}
	}

	private int GSlots => (int)Math.Round((((Object)(object)_drumShip != (Object)null) ? _drumShip.Period : 2.4) / GQ);

	private float DrumGroove => Mathf.Clamp01((float)_drumStreak / 16f);

	private float DrumGood => Mathf.Min(Cfg.DrumGoodSeconds.Value * _winScale, (float)GQ * 0.5f);

	private float DrumPerf => Mathf.Max(0.04f, Cfg.DrumPerfectSeconds.Value * _winScaleP);

	private static void CleanOldFiles(string cfgDir, string cfg, string keepBackup)
	{
		try
		{
			string[] files = Directory.GetFiles(cfgDir, Path.GetFileName(cfg) + ".bak-*");
			foreach (string text in files)
			{
				if (keepBackup == null || !string.Equals(text, keepBackup, StringComparison.OrdinalIgnoreCase))
				{
					try
					{
						File.Delete(text);
					}
					catch (Exception)
					{
					}
				}
			}
		}
		catch (Exception)
		{
		}
		try
		{
			string fullPath = Path.GetFullPath(typeof(DifferentStrokesPlugin).Assembly.Location);
			string directoryName = Path.GetDirectoryName(fullPath);
			string text2 = Path.GetFullPath(Paths.PluginPath).TrimEnd('\\', '/');
			try
			{
				string path = Path.Combine(directoryName, "sounds");
				if (Directory.Exists(path))
				{
					Directory.Delete(path, recursive: true);
				}
			}
			catch (Exception)
			{
			}
			Version version = ParseVer(FileVersionInfo.GetVersionInfo(fullPath).FileVersion);
			string[] files = Directory.GetFiles(text2, "DifferentStrokes.dll", SearchOption.AllDirectories);
			for (int i = 0; i < files.Length; i++)
			{
				string fullPath2 = Path.GetFullPath(files[i]);
				if (string.Equals(fullPath2, fullPath, StringComparison.OrdinalIgnoreCase))
				{
					continue;
				}
				Version version2 = ParseVer(FileVersionInfo.GetVersionInfo(fullPath2).FileVersion);
				if (version != null && version2 != null && version2 > version)
				{
					continue;
				}
				string directoryName2 = Path.GetDirectoryName(fullPath2);
				try
				{
					File.Delete(fullPath2);
				}
				catch (Exception)
				{
					continue;
				}
				if (string.Equals(directoryName2.TrimEnd('\\', '/'), text2, StringComparison.OrdinalIgnoreCase))
				{
					continue;
				}
				string[] array = new string[4] { "manifest.json", "README.md", "icon.png", "CHANGELOG.md" };
				foreach (string path2 in array)
				{
					try
					{
						File.Delete(Path.Combine(directoryName2, path2));
					}
					catch (Exception)
					{
					}
				}
				try
				{
					string path3 = Path.Combine(directoryName2, "sounds");
					if (Directory.Exists(path3))
					{
						Directory.Delete(path3, recursive: true);
					}
				}
				catch (Exception)
				{
				}
				try
				{
					if (Directory.GetFileSystemEntries(directoryName2).Length == 0)
					{
						Directory.Delete(directoryName2);
					}
				}
				catch (Exception)
				{
				}
			}
		}
		catch (Exception)
		{
		}
	}

	private static Version ParseVer(string s)
	{
		if (string.IsNullOrEmpty(s))
		{
			return null;
		}
		if (!System.Version.TryParse(s, out Version result))
		{
			return null;
		}
		return result;
	}

	private static Dictionary<string, string> ReadState()
	{
		Dictionary<string, string> dictionary = new Dictionary<string, string>();
		try
		{
			if (!File.Exists(StatePath))
			{
				return dictionary;
			}
			string[] array = File.ReadAllLines(StatePath);
			foreach (string text in array)
			{
				int num = text.IndexOf('=');
				if (num > 0)
				{
					dictionary[text.Substring(0, num).Trim()] = text.Substring(num + 1).Trim();
				}
			}
		}
		catch (Exception)
		{
		}
		return dictionary;
	}

	private static void WriteState(Dictionary<string, string> d)
	{
		try
		{
			List<string> list = new List<string>();
			foreach (KeyValuePair<string, string> item in d)
			{
				list.Add(item.Key + "=" + item.Value);
			}
			File.WriteAllLines(StatePath, list.ToArray());
		}
		catch (Exception)
		{
		}
	}

	private static void ApplyTutorialCarry()
	{
		try
		{
			Dictionary<string, string> dictionary = ReadState();
			bool flag = dictionary.Remove("IntroHidden");
			if (!dictionary.TryGetValue("TutorialCarry", out var value))
			{
				if (flag)
				{
					WriteState(dictionary);
				}
				return;
			}
			if (Cfg.TutorialChoice.Value == TutorialAnswer.NotAsked && Enum.TryParse<TutorialAnswer>(value, out var result))
			{
				Cfg.TutorialChoice.Value = result;
			}
			dictionary.Remove("TutorialCarry");
			WriteState(dictionary);
		}
		catch (Exception)
		{
		}
	}

	static DifferentStrokesPlugin()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Expected O, but got Unknown
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: 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_0066: 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_0081: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: 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)
		//IL_011d: 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)
		//IL_013b: 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_0159: Unknown result type (might be due to invalid IL or missing references)
		_measure = new GUIContent();
		_widths = new Dictionary<long, Dictionary<string, float>>();
		SigCol = (Color[])(object)new Color[4]
		{
			new Color(0.55f, 0.88f, 0.55f),
			new Color(1f, 0.82f, 0.3f),
			new Color(1f, 0.55f, 0.22f),
			new Color(0.55f, 0.82f, 1f)
		};
		IntroDrawFrame = -99;
		IntroClosedAt = -99f;
		IntroEscFrame = -99;
		QL = new KeyboardShortcut((KeyCode)47, (KeyCode[])(object)new KeyCode[1] { (KeyCode)304 });
		QR = new KeyboardShortcut((KeyCode)47, (KeyCode[])(object)new KeyCode[1] { (KeyCode)303 });
		Amber = new Color(1f, 0.58f, 0.18f);
		Hot = new Color(1f, 0.88f, 0.5f);
		Ink = new Color(0.04f, 0.03f, 0.025f);
		CardC = new Color(0.04f, 0.03f, 0.02f, 0.62f);
		Dim = new Color(1f, 0.97f, 0.9f, 0.55f);
		TabNames = new string[5] { "ROWING", "STEERING", "DEBUFFS", "DRUMMING", "SIGNATURES" };
		HumanBodyBones[] array = new HumanBodyBones[17];
		RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		ProbeBones = (HumanBodyBones[])(object)array;
		ProbeNames = new string[17][]
		{
			new string[1] { "Hips" },
			new string[1] { "Spine" },
			new string[1] { "Spine1" },
			new string[1] { "Neck" },
			new string[1] { "Head" },
			new string[2] { "LeftArm", "LeftUpperArm" },
			new string[2] { "LeftForeArm", "LeftLowerArm" },
			new string[1] { "LeftHand" },
			new string[2] { "RightArm", "RightUpperArm" },
			new string[2] { "RightForeArm", "RightLowerArm" },
			new string[1] { "RightHand" },
			new string[3] { "LeftUpLeg", "LeftUpperLeg", "LeftThigh" },
			new string[4] { "LeftLeg", "LeftLowerLeg", "LeftCalf", "LeftShin" },
			new string[1] { "LeftFoot" },
			new string[3] { "RightUpLeg", "RightUpperLeg", "RightThigh" },
			new string[4] { "RightLeg", "RightLowerLeg", "RightCalf", "RightShin" },
			new string[1] { "RightFoot" }
		};
		HudsF = AccessTools.Field(typeof(EnemyHud), "m_huds");
		PatA = new int[4][]
		{
			new int[3]
			{
				M(0, 3, 6, 9, 12),
				M(0, 3, 5, 6, 9, 11, 12),
				M(0, 2, 3, 5, 6, 8, 9, 11, 12, 14)
			},
			new int[3] { 85, 53, 89 },
			new int[3]
			{
				M(0, 3),
				M(0, 2, 3),
				M(0, 2, 3, 5)
			},
			new int[3]
			{
				M(0, 3),
				M(0, 2, 3),
				M(0, 2, 3, 5)
			}
		};
		PatB = new int[4][]
		{
			new int[3]
			{
				M(0, 3, 6, 9, 12, 13, 14),
				M(0, 3, 5, 6, 8, 9, 12, 13, 14),
				M(0, 2, 3, 5, 6, 8, 9, 11, 12, 13, 14)
			},
			new int[3] { 117, 245, 253 },
			new int[3]
			{
				M(0, 3, 4),
				M(0, 2, 3, 4, 5),
				M(0, 1, 2, 3, 4, 5)
			},
			new int[3]
			{
				M(0, 3, 4, 5),
				M(0, 2, 3, 4, 5),
				M(0, 1, 2, 3, 4, 5)
			}
		};
		try
		{
			string configPath = Paths.ConfigPath;
			string text = Path.Combine(configPath, "com.differentstrokes.valheim.cfg");
			string path = Path.Combine(configPath, "com.differentstrokes.valheim.version");
			string text2 = (File.Exists(path) ? File.ReadAllText(path).Trim() : null);
			if (!(text2 != "4.16.0"))
			{
				return;
			}
			string text3 = null;
			if (File.Exists(text))
			{
				try
				{
					Match match = Regex.Match(File.ReadAllText(text), "^\\s*TutorialChoice\\s*=\\s*(Accepted|Declined)\\s*$", RegexOptions.Multiline);
					if (match.Success)
					{
						Dictionary<string, string> dictionary = ReadState();
						dictionary["TutorialCarry"] = match.Groups[1].Value;
						WriteState(dictionary);
					}
				}
				catch (Exception)
				{
				}
				text3 = text + ".bak-" + (text2 ?? "old");
				File.Copy(text, text3, overwrite: true);
				File.Delete(text);
			}
			File.WriteAllText(path, "4.16.0");
			CleanOldFiles(configPath, text, text3);
		}
		catch (Exception)
		{
		}
	}

	private void RefreshTexts()
	{
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		if (Time.unscaledTime < _txtNext)
		{
			return;
		}
		_txtNext = Time.unscaledTime + 0.2f;
		if (Time.unscaledTime > _thAt)
		{
			_thAt = Time.unscaledTime + 0.5f;
			CrewShip crewShip = (((Object)(object)_rowShip != (Object)null) ? _rowShip : _aboardShip);
			if ((Object)(object)crewShip != (Object)null)
			{
				CrewShip.Thresholds(crewShip.RowerCount, out _th1, out _th2, out _th3);
			}
		}
		_tHint = "Press an arrow key to sit and row      [?] how to play      [" + KeyLabel(Cfg.HelpKey.Value) + "] key list";
		_tHold = "HOLD an arrow at the " + (_rev ? "FINISH end" : "CATCH") + ", RELEASE at the " + (_rev ? "CATCH end" : "FINISH") + "      up / down: forward / back      left / right: turn      [" + KeyLabel(Cfg.SwapKey.Value) + "] swaps side";
		_tRhythm = "PERFECT STROKES  " + _streak + "    +" + Mathf.RoundToInt(Cfg.RhythmFor(_streak) * 100f) + "% speed" + ((_streak >= 10) ? "  (MAX)" : "");
		_tPerfect = _tRhythm;
		_tGA = "acceleration";
		_tGV = "speed";
		_tDrumHold = (_drumFree ? ("FREESTYLE: play the three zones as you like      [" + KeyLabel(Cfg.DrumModeKey.Value) + "] back to the beat game") : ("TAP [" + KeyLabel(Cfg.DrumKey.Value) + "] as each glowing stone reaches the line      [" + KeyLabel(Cfg.DrumModeKey.Value) + "] freestyle      arrow key: back to rowing"));
		_tDrumCad = "CADENCE " + Mathf.RoundToInt(_drumCad * 100f) + "%   crew +" + Mathf.RoundToInt(_drumCad * Cfg.DrumBonusBase.Value * (1f + 0.5f * DrumGroove) * 100f) + "% thrust" + ((_drumStreak >= 3) ? ("    GROOVE x" + _drumStreak) : "");
		if (_drumFree)
		{
			_tDrumCad = "FREESTYLE   crew +" + Mathf.RoundToInt(_drumCad * Cfg.DrumBonusBase.Value * 100f) + "% thrust";
		}
		_tDebuff = ((_sore > 0) ? ("SORE BACK x" + _sore) : "") + ((_sore > 0 && _blister > 0) ? "     " : "") + ((_blister > 0) ? ("BLISTERED HANDS x" + _blister) : "");
	}

	private double PhaseNow()
	{
		CrewShip crewShip = (((Object)(object)_rowShip != (Object)null) ? _rowShip : _aboardShip);
		double num = Compat.NetTime();
		if (!((Object)(object)crewShip != (Object)null))
		{
			return Beat.Phase(num, 2.4);
		}
		return crewShip.PhaseAt(num);
	}

	private void FlashGuide(bool manual)
	{
		if (manual)
		{
			_sitAt = Time.time;
		}
	}

	private void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
		if (Application.isBatchMode)
		{
			Log.LogInfo((object)"DifferentStrokes is client-side only; disabled in headless mode.");
			((Behaviour)this).enabled = false;
			return;
		}
		Cfg.Bind(((BaseUnityPlugin)this).Config);
		ApplyTutorialCarry();
		Compat.SelfCheck(Log);
		Inst = this;
		((MonoBehaviour)this).useGUILayout = false;
		((Component)this).gameObject.AddComponent<CamApply>();
		Log.LogInfo((object)"DifferentStrokes 4.16.0 loaded (two optional, guarded Harmony patches are applied only when you open the pop-up / start rowing).");
	}

	private void Start()
	{
		if (Cfg.MusicEnabled.Value)
		{
			Synth.Build();
		}
	}

	private void OnDestroy()
	{
		RestoreCam();
		Player localPlayer = Player.m_localPlayer;
		if (_rowing && (Object)(object)localPlayer != (Object)null)
		{
			StopRowing(localPlayer, Compat.GetZdo(localPlayer));
		}
		if (_drumming && (Object)(object)localPlayer != (Object)null)
		{
			StopDrumming(Compat.GetZdo(localPlayer));
		}
	}

	private void Update()
	{
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: 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_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_028c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0400: Unknown result type (might be due to invalid IL or missing references)
		//IL_0405: Unknown result type (might be due to invalid IL or missing references)
		//IL_0410: Unknown result type (might be due to invalid IL or missing references)
		//IL_0415: Unknown result type (might be due to invalid IL or missing references)
		Synth.Pump();
		TickDebuffs();
		Player localPlayer = Player.m_localPlayer;
		UpdateWind(localPlayer);
		if ((Object)(object)localPlayer == (Object)null || !Cfg.Enabled.Value)
		{
			IntroOpen = false;
			ResetStroke();
			_drumming = false;
			_drumShip = null;
			if ((Object)(object)_rowShip != (Object)null)
			{
				_rowShip.LocalRowing = false;
			}
			_rowing = false;
			_rowShip = null;
			_aboardShip = null;
			return;
		}
		if (Time.time >= _nextScan)
		{
			_nextScan = Time.time + 2f;
			Scan();
		}
		CrewShip crewShip = FindShip(localPlayer);
		if ((Object)(object)crewShip != (Object)(object)_aboardShip)
		{
			_aboardShip = crewShip;
			_boardedAt = Time.time;
		}
		bool flag = (Object)(object)crewShip != (Object)null && Compat.IsSeated(localPlayer);
		if (flag && !_wasSeated)
		{
			OpenInvite();
		}
		_wasSeated = flag;
		UpdateHints(flag);
		TickIntro(localPlayer);
		TickPetProbe(localPlayer, crewShip);
		SampleGraph();
		UpdateWindows();
		if (KeyIn.Down(Cfg.GraphKey.Value) && Compat.InputAllowed())
		{
			Cfg.ShowGraph.Value = !Cfg.ShowGraph.Value;
		}
		if ((Object)(object)crewShip != (Object)null && KeyIn.Down(Cfg.UiKey.Value) && Compat.InputAllowed())
		{
			Cfg.MinimalUi.Value = !Cfg.MinimalUi.Value;
			((Character)localPlayer).Message((MessageType)1, Cfg.MinimalUi.Value ? ("Minimal UI (" + ((object)Cfg.UiKey.Value/*cast due to .constrained prefix*/).ToString() + " to bring the helpers back)") : "Full UI", 0, (Sprite)null, false);
		}
		ZDO zdo = Compat.GetZdo(localPlayer);
		if (zdo == null)
		{
			return;
		}
		SyncDebuffs(localPlayer, zdo);
		HandleDrum(localPlayer, crewShip, zdo);
		bool flag2 = false;
		if (_rowing)
		{
			bool flag3 = false;
			string text = null;
			if ((Object)(object)crewShip == (Object)null || (Object)(object)crewShip != (Object)(object)_rowShip || ((Character)localPlayer).IsDead() || !crewShip.OnDeck(localPlayer, 0.6f))
			{
				flag3 = true;
				text = "left the deck / ship changed";
			}
			else
			{
				Vector3 val = ((Component)localPlayer).transform.position - ((Component)_rowShip).transform.TransformPoint(_startLocal);
				if (((Vector3)(ref val)).sqrMagnitude > 0.80999994f)
				{
					flag3 = true;
					val = ((Component)localPlayer).transform.position - ((Component)_rowShip).transform.TransformPoint(_startLocal);
					text = "moved " + ((Vector3)(ref val)).magnitude.ToString("0.00") + " m from the seat";
				}
				else if (Time.time - _lastActivity > Cfg.IdleTimeout.Value)
				{
					flag3 = true;
					text = "idle";
				}
			}
			if (flag3)
			{
				Log.LogInfo((object)("DifferentStrokes: rowing stopped: " + text + " (seated=" + Compat.IsSeated(localPlayer) + ", attached=" + ((Character)localPlayer).IsAttached() + ")"));
				StopRowing(localPlayer, zdo);
			}
		}
		else if ((Object)(object)crewShip != (Object)null && !((Character)localPlayer).IsDead() && (!_drumming || !_drumFree) && ReadCmdDown() >= 0 && Compat.InputAllowed() && crewShip.OnDeck(localPlayer, 0f))
		{
			if (_drumming)
			{
				StopDrumming(zdo);
			}
			StartRowing(localPlayer, crewShip, zdo);
			flag2 = true;
		}
		if (_rowing && (Object)(object)_rowShip != (Object)null && !((Character)localPlayer).IsAttached())
		{
			float y = ((Component)_rowShip).transform.eulerAngles.y;
			if (_haveYaw)
			{
				float num = Mathf.DeltaAngle(_lastYaw, y);
				if (Mathf.Abs(num) > 0.001f)
				{
					((Component)localPlayer).transform.rotation = Quaternion.AngleAxis(num, Vector3.up) * ((Component)localPlayer).transform.rotation;
				}
			}
			_lastYaw = y;
			_haveYaw = true;
		}
		else
		{
			_haveYaw = false;
		}
		if (_rowing)
		{
			double num2 = PhaseNow();
			bool flag4 = Compat.InputAllowed();
			if (flag4 && !_holding && SwapPressed())
			{
				_side = 0f - _side;
				zdo.Set(Keys.Side, _side);
			}
			UpdateKeyStack(flag4, !flag2);
			if (!_holding)
			{
				int num3 = NextBufferedCmd();
				if (num3 >= 0 && !flag2 && flag4)
				{
					float num4 = -1f;
					for (int i = 0; i < _kStack.Count; i++)
					{
						if (_kStack[i].cmd == num3)
						{
							num4 = _kStack[i].t;
						}
					}
					if (num4 >= 0f && num4 < _strokeEndAt)
					{
						Classify(num3, _side, out var rev, out var _);
						if (Mathf.Abs((float)(Beat.Wrap(num2 - (rev ? ((double)Drv) : 0.0)) * Per)) > Cfg.GoodSeconds.Value + 0.05f)
						{
							_kStack.Clear();
							num3 = -1;
						}
					}
				}
				if (!flag2 && flag4 && Time.time >= _nextStrokeOk && num3 >= 0)
				{
					BeginStroke(localPlayer, zdo, num2, num3);
					_kStack.Clear();
				}
			}
			else
			{
				bool flag5 = !CmdPressed(_heldCmd) || !flag4;
				double num5 = FinishErrSec(num2);
				bool flag6 = (double)(Time.time - _holdStart) > Per || num5 > (double)Cfg.GoodSeconds.Value + 0.3;
				if (!flag4 && Time.time > _nextEndLog)
				{
					_nextEndLog = Time.time + 2f;
					Log.LogInfo((object)("DifferentStrokes: stroke ended because input is blocked (chat=" + ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) + ", menu=" + Menu.IsVisible() + ", inventory=" + InventoryGui.IsVisible() + ", map=" + Minimap.IsOpen() + ", popup=" + IntroOpen + ")"));
				}
				if (flag5 || flag6)
				{
					EndStroke(zdo, num2, flag6 && !flag5);
				}
			}
			if (_holding)
			{
				_oarPos = Mathf.MoveTowards(_oarPos, 1f, Time.deltaTime / (Drv * (float)Per));
			}
			else
			{
				_oarPos = Mathf.MoveTowards(_oarPos, 0f, Time.deltaTime / ((1f - Drv) * (float)Per));
			}
		}
		if ((Object)(object)_aboardShip != (Object)null && Time.time >= _nextStatus)
		{
			_nextStatus = Time.time + 0.1f;
			_status = _aboardShip.Evaluate();
		}
	}

	private static void Zone(Rect strip, float xc, float hw, Color col)
	{
		//IL_0036: 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)
		float num = Mathf.Max(((Rect)(ref strip)).x, xc - hw);
		float num2 = Mathf.Min(((Rect)(ref strip)).xMax, xc + hw);
		if (num2 > num)
		{
			Fill(new Rect(num, ((Rect)(ref strip)).y, num2 - num, ((Rect)(ref strip)).height), col);
		}
	}

	private void Scan()
	{
		string value = Cfg.ExcludedShips.Value;
		if (value != _exclRaw)
		{
			_exclRaw = value;
			_excl = value.Split(new char[1] { ',' });
			for (int i = 0; i < _excl.Length; i++)
			{
				_excl[i] = _excl[i].Trim();
			}
		}
		string[] excl = _excl;
		IList<Ship> list = Compat.CurrentShips();
		if (list == null)
		{
			if (Time.time > _fbAt)
			{
				_fbShips = Object.FindObjectsOfType<Ship>();
				_fbAt = Time.time + 3f;
			}
			list = _fbShips;
		}
		foreach (Ship item in list)
		{
			if ((Object)(object)item == (Object)null || (Object)(object)((Component)item).GetComponent<CrewShip>() != (Object)null)
			{
				continue;
			}
			string text = ((Object)item).name.Replace("(Clone)", "").Trim();
			bool flag = false;
			foreach (string text2 in excl)
			{
				if (text2.Length > 0 && text2 == text)
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				((Component)item).gameObject.AddComponent<CrewShip>();
			}
		}
		List<Player> allPlayers = Player.GetAllPlayers();
		for (int k = 0; k < allPlayers.Count; k++)
		{
			Player val = allPlayers[k];
			if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).GetComponent<CrewRig>() == (Object)null)
			{
				((Component)val).gameObject.AddComponent<CrewRig>();
			}
		}
	}

	private static CrewShip FindShip(Player p)
	{
		for (int i = 0; i < CrewShip.All.Count; i++)
		{
			CrewShip crewShip = CrewShip.All[i];
			if ((Object)(object)crewShip != (Object)null && crewShip.IsAboard(p))
			{
				return crewShip;
			}
		}
		return null;
	}

	private void ResetStroke()
	{
		_holding = false;
		_failed = false;
		_oarPos = 0f;
		_catchQ = 0f;
		_streak = 0;
		_rev = false;
		_heldCmd = -1;
		_kStack.Clear();
	}

	private double FinishErrSec(double c)
	{
		if (!_rev)
		{
			double num = _pressPhase;
			double num2 = c - num - Math.Floor(c - num);
			double num3 = (double)Drv - num - Math.Floor((double)Drv - num);
			return (num2 - num3) * Per;
		}
		double num4 = (1.0 - (double)Drv) * Per;
		return (double)(Time.time - _holdStart + _pressErrSec) - num4;
	}

	private static bool AltDown(ConfigEntry<KeyboardShortcut> e)
	{
		//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_000c: 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)
		if (e != null)
		{
			KeyboardShortcut value = e.Value;
			if ((int)((KeyboardShortcut)(ref value)).MainKey != 0)
			{
				return KeyIn.Down(e.Value);
			}
		}
		return false;
	}

	private static bool AltHeld(ConfigEntry<KeyboardShortcut> e)
	{
		//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_000c: 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)
		if (e != null)
		{
			KeyboardShortcut value = e.Value;
			if ((int)((KeyboardShortcut)(ref value)).MainKey != 0)
			{
				return KeyIn.Held(e.Value);
			}
		}
		return false;
	}

	private static bool SwapPressed()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: 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_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Invalid comparison between Unknown and I4
		KeyboardShortcut value = Cfg.SwapKey.Value;
		if (KeyIn.Down(value))
		{
			return true;
		}
		if ((int)((KeyboardShortcut)(ref value)).MainKey == 256)
		{
			return Input.GetKeyDown((KeyCode)277);
		}
		return false;
	}

	private static int ReadCmdDown()
	{
		//IL_0005: 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_0043: 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 (KeyIn.Down(Cfg.KeyFwd.Value) || AltDown(Cfg.PadFwd))
		{
			return 0;
		}
		if (KeyIn.Down(Cfg.KeyBack.Value) || AltDown(Cfg.PadBack))
		{
			return 1;
		}
		if (KeyIn.Down(Cfg.KeyLeft.Value) || AltDown(Cfg.PadLeft))
		{
			return 2;
		}
		if (KeyIn.Down(Cfg.KeyRight.Value) || AltDown(Cfg.PadRight))
		{
			return 3;
		}
		return -1;
	}

	private static bool CmdDownEvent(int cmd)
	{
		//IL_001d: 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_0059: 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)
		switch (cmd)
		{
		case 0:
			if (!KeyIn.Down(Cfg.KeyFwd.Value))
			{
				return AltDown(Cfg.PadFwd);
			}
			return true;
		case 1:
			if (!KeyIn.Down(Cfg.KeyBack.Value))
			{
				return AltDown(Cfg.PadBack);
			}
			return true;
		case 2:
			if (!KeyIn.Down(Cfg.KeyLeft.Value))
			{
				return AltDown(Cfg.PadLeft);
			}
			return true;
		case 3:
			if (!KeyIn.Down(Cfg.KeyRight.Value))
			{
				return AltDown(Cfg.PadRight);
			}
			return true;
		default:
			return false;
		}
	}

	private void UpdateKeyStack(bool allowed, bool addNew)
	{
		for (int num = _kStack.Count - 1; num >= 0; num--)
		{
			if (!allowed || !CmdPressed(_kStack[num].cmd) || (double)(Time.time - _kStack[num].t) > 0.6000000238418579 + Per)
			{
				_kStack.RemoveAt(num);
			}
		}
		if (!allowed || !addNew)
		{
			return;
		}
		KeyEv item = default(KeyEv);
		for (int i = 0; i < 4; i++)
		{
			if (!CmdDownEvent(i))
			{
				continue;
			}
			for (int num2 = _kStack.Count - 1; num2 >= 0; num2--)
			{
				if (_kStack[num2].cmd == i)
				{
					_kStack.RemoveAt(num2);
				}
			}
			item.cmd = i;
			item.t = Time.time;
			_kStack.Add(item);
		}
	}

	private int NextBufferedCmd()
	{
		int result = -1;
		float num = -1f;
		for (int i = 0; i < _kStack.Count; i++)
		{
			if (!(Time.time - _kStack[i].t > 0.3f + Cfg.PressCooldown.Value) && _kStack[i].t > num)
			{
				num = _kStack[i].t;
				result = _kStack[i].cmd;
			}
		}
		return result;
	}

	private static bool CmdPressed(int cmd)
	{
		//IL_001d: 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_0059: 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)
		switch (cmd)
		{
		case 0:
			if (!KeyIn.Held(Cfg.KeyFwd.Value))
			{
				return AltHeld(Cfg.PadFwd);
			}
			return true;
		case 1:
			if (!KeyIn.Held(Cfg.KeyBack.Value))
			{
				return AltHeld(Cfg.PadBack);
			}
			return true;
		case 2:
			if (!KeyIn.Held(Cfg.KeyLeft.Value))
			{
				return AltHeld(Cfg.PadLeft);
			}
			return true;
		case 3:
			if (!KeyIn.Held(Cfg.KeyRight.Value))
			{
				return AltHeld(Cfg.PadRight);
			}
			return true;
		default:
			return false;
		}
	}

	private static void Classify(int cmd, float oarSide, out bool rev, out float td)
	{
		td = cmd switch
		{
			3 => 1f, 
			2 => -1f, 
			_ => 0f, 
		};
		rev = cmd == 1 || (td != 0f && td == oarSide);
	}

	private void StartRowing(Player p, CrewShip ship, ZDO zdo)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		_rowing = true;
		_rowShip = ship;
		ship.LocalRowing = true;
		FlashGuide(manual: false);
		_startLocal = ((Component)ship).transform.InverseTransformPoint(((Component)p).transform.position);
		_lastActivity = Time.time;
		_nextStrokeOk = Time.time + 0.2f;
		ResetStroke();
		_side = DefaultSide(p, ship);
		zdo.Set(Keys.Side, _side);
		zdo.Set(Keys.Ver, "4.16.0");
		EnsureInputGuard();
		SetFlag(zdo, v: true);
		if (!((Character)p).IsAttached())
		{
			Compat.StartSitEmote(p);
		}
	}

	private void StopRowing(Player p, ZDO zdo)
	{
		_rowing = false;
		if ((Object)(object)_rowShip != (Object)null)
		{
			_rowShip.LocalRowing = false;
		}
		_rowShip = null;
		ResetStroke();
		if (zdo != null)
		{
			SetFlag(zdo, v: false);
			zdo.Set(Keys.Streak, 0, false);
			zdo.Set(Keys.Rev, false);
		}
		if ((Object)(object)p != (Object)null)
		{
			Compat.StopSitEmote(p);
		}
	}

	private void UpdateWindows()
	{
		float num = Mathf.Clamp01(Mathf.Max(0f, _gSpeed) / Cfg.WindowShrinkSpeed.Value);
		float num2 = 1f - Mathf.Exp((0f - Time.deltaTime) / 0.6f);
		float num3 = Mathf.Clamp01((float)(_drumming ? _drumStreak : _streak) / 10f);
		float num4 = Mathf.Max(Mathf.Lerp(1f, Cfg.WindowMinScale.Value, num), Mathf.Lerp(1f, Cfg.WindowMinScale.Value, num3));
		float num5 = Mathf.Max(Mathf.Lerp(1f, Cfg.PerfectMinScale.Value, num), Mathf.Lerp(1f, Cfg.PerfectMinScale.Value, num3));
		_winScale = Mathf.Lerp(_winScale, num4, num2);
		_winScaleP = Mathf.Lerp(_winScaleP, num5, num2);
	}

	private void SyncDebuffs(Player p, ZDO zdo)
	{
		if (_blisterEvt != _shBlEvt)
		{
			zdo.Set(Keys.BlisterEvt, _blisterEvt, false);
			_shBlEvt = _blisterEvt;
		}
		if (_soreEvt != _shSoEvt)
		{
			zdo.Set(Keys.SoreEvt, _soreEvt, false);
			_shSoEvt = _soreEvt;
		}
		bool num = _blister != _shBl || Mathf.Abs(_blisterAt - _shBlAt) > 0.5f;
		bool flag = _sore != _shSo || Mathf.Abs(_soreAt - _shSoAt) > 0.5f;
		if (num)
		{
			DebuffUi.Apply(p, 0, _blister, _blisterAt - Time.time, refresh: true);
			if (_blister != _shBl)
			{
				zdo.Set(Keys.Blister, _blister, false);
			}
			_shBl = _blister;
			_shBlAt = _blisterAt;
		}
		if (flag)
		{
			DebuffUi.Apply(p, 1, _sore, _soreAt - Time.time, refresh: true);
			if (_sore != _shSo)
			{
				zdo.Set(Keys.Sore, _sore, false);
			}
			_shSo = _sore;
			_shSoAt = _soreAt;
		}
	}

	private void TickDebuffs()
	{
		float value = Cfg.DebuffSeconds.Value;
		if (_blister > 0 && Time.time >= _blisterAt)
		{
			_blister--;
			_blisterAt = Time.time + value;
		}
		if (_sore > 0 && Time.time >= _soreAt)
		{
			_sore--;
			_soreAt = Time.time + value;
		}
	}

	private void AddDebuff(bool blisterHands)
	{
		if (!Cfg.Debuffs.Value)
		{
			return;
		}
		float num = Time.time + Cfg.DebuffSeconds.Value;
		if (blisterHands)
		{
			_blisterEvt++;
		}
		else
		{
			_soreEvt++;
		}
		if (blisterHands)
		{
			if (_blister < 3)
			{
				_blister++;
			}
			_blisterAt = num;
		}
		else
		{
			if (_sore < 3)
			{
				_sore++;
			}
			_soreAt = num;
		}
	}

	private float Grade(float errAbsSeconds)
	{
		errAbsSeconds = Mathf.Max(0f, errAbsSeconds - Cfg.LatencyGrace.Value);
		float perfWin = PerfWin;
		float num = Mathf.Max(GoodWin, perfWin + 0.02f);
		if (errAbsSeconds <= perfWin)
		{
			return 1f;
		}
		if (errAbsSeconds <= num)
		{
			return Mathf.Lerp(0.85f, 0.4f, (errAbsSeconds - perfWin) / (num - perfWin));
		}
		return 0f;
	}

	private static float DefaultSide(Player p, CrewShip ship)
	{
		//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_0035: 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_004b: Unknown result type (might be due to invalid IL or missing references)
		float x = ((Component)ship).transform.InverseTransformPoint(((Component)p).transform.position).x;
		if (Mathf.Abs(x) < 0.2f)
		{
			return 1f;
		}
		if (!(Vector3.Dot(((Component)ship).transform.right * Mathf.Sign(x), ((Component)p).transform.right) >= 0f))
		{
			return -1f;
		}
		return 1f;
	}

	private float OarShipSide(Player p)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: 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)
		if ((Object)(object)_rowShip == (Object)null)
		{
			return 0f;
		}
		float num = Vector3.Dot(((Component)p).transform.right * _side, ((Component)_rowShip).transform.right);
		if (!(Mathf.Abs(num) < 0.3f))
		{
			return Mathf.Sign(num);
		}
		return 0f;
	}

	private void BeginStroke(Player p, ZDO zdo, double c, int cmd)
	{
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_028d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		Classify(cmd, _side, out var rev, out var _);
		_rev = rev;
		_heldCmd = cmd;
		double num = Beat.Wrap(c - (rev ? ((double)Drv) : 0.0)) * Per;
		_pressErrSec = (float)num;
		float num2 = Mathf.Abs((float)num);
		float num3 = Grade(num2);
		float num4 = Cfg.StaminaPerStroke.Value * (1f + 0.15f * (float)_sore);
		bool flag = false;
		if (num4 > 0f)
		{
			flag = !((Character)p).HaveStamina(num4);
			if (flag)
			{
				num3 = 0f;
			}
			else
			{
				((Character)p).UseStamina(num4);
			}
		}
		_holding = true;
		_holdStart = Time.time;
		_lastActivity = Time.time;
		_catchQ = num3;
		_failed = num3 <= 0f;
		_exhausted = flag;
		if (num3 <= 0f)
		{
			_streak = 0;
		}
		zdo.Set(Keys.Streak, _streak, false);
		_untilCatch = Time.time + 1.2f;
		_untilFinish = 0f;
		_pressPhase = (float)c;
		_pressRev = rev;
		_pressPath = Beat.PathPhase(c, Drv, rev);
		_tickCatchUntil = Time.time + 2.5f;
		_tickFinishUntil = 0f;
		_evtCatch = true;
		float num5 = 0f;
		if (flag)
		{
			_flashCatch = "EXHAUSTED";
			_colCatch = Ui.Bad;
		}
		else if (_failed)
		{
			bool flag2 = num < 0.0;
			AddDebuff(blisterHands: true);
			float num6 = OarShipSide(p);
			if (Cfg.MissSteering.Value && num6 != 0f)
			{
				float num7 = Mathf.Lerp(0.5f, 1f, Mathf.Clamp01((num2 - Cfg.GoodSeconds.Value) / 0.5f));
				num5 = (flag2 ? num6 : (0f - num6)) * num7;
			}
			_flashCatch = (flag2 ? "TOO EARLY" : "TOO LATE");
			if (num5 != 0f)
			{
				_flashCatch += ((num5 > 0f) ? "  (veering starboard)" : "  (veering port)");
			}
			_colCatch = Ui.Bad;
		}
		else if (num3 >= 1f)
		{
			_flashCatch = "CATCH: PERFECT";
			_colCatch = Ui.Good;
		}
		else
		{
			_flashCatch = "CATCH: GOOD";
			_colCatch = Ui.Ok;
		}
		zdo.Set(Keys.Quality, _failed ? 0f : (num3 * 0.65f * Strength));
		zdo.Set(Keys.Turn, num5);
		zdo.Set(Keys.Rev, rev);
		zdo.Set(Keys.Cmd, cmd, false);
		zdo.Set(Keys.Err, Mathf.Clamp((float)num, -0.8f, 0.8f));
		zdo.Set(Keys.FinErr, 0f);
		zdo.Set(Keys.Time, (long)(Compat.NetTime() * 1000.0));
		zdo.Set(Keys.Stroke, zdo.GetInt(Keys.Stroke, 0) + 1, false);
	}

	private void EndStroke(ZDO zdo, double c, bool forced)
	{
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		_holding = false;
		_heldCmd = -1;
		_strokeEndAt = Time.time;
		_nextStrokeOk = Time.time + Cfg.PressCooldown.Value;
		_lastActivity = Time.time;
		double num = FinishErrSec(c);
		float num2 = (forced ? 0f : Grade(Mathf.Abs((float)num)));
		if ((forced || num2 <= 0f) && !_exhausted)
		{
			AddDebuff(blisterHands: false);
		}
		if (_failed)
		{
			_failed = false;
			return;
		}
		float num3 = (0.65f * _catchQ + 0.35f * num2) * Strength;
		if (!forced && num2 >= 1f && _catchQ >= 1f)
		{
			_streak++;
		}
		else if (!forced && num2 > 0f && _catchQ > 0f)
		{
			_streak = Mathf.Max(0, _streak - 2);
		}
		else
		{
			_streak = 0;
		}
		zdo.Set(Keys.Streak, _streak, false);
		if (!forced && ++_strokesDone >= 8 && !Cfg.TutorialDone.Value)
		{
			Cfg.TutorialDone.Value = true;
		}
		if (forced)
		{
			_flashFinish = "TOO LONG";
			_colFinish = Ui.Bad;
		}
		else if (num2 >= 1f)
		{
			_flashFinish = "FINISH: PERFECT";
			_colFinish = Ui.Good;
		}
		else if (num2 > 0f)
		{
			_flashFinish = "FINISH: GOOD";
			_colFinish = Ui.Ok;
		}
		else
		{
			_flashFinish = ((num < 0.0) ? "FINISH: TOO EARLY" : "FINISH: TOO LATE");
			_colFinish = Ui.Bad;
		}
		_untilFinish = Time.time + 1.2f;
		_releasePhase = (float)c;
		_releaseRev = _rev;
		_releasePath = Beat.PathPhase(c, Drv, _rev);
		_tickFinishUntil = Time.time + 2.5f;
		_evtFinish = true;
		zdo.Set(Keys.FinErr, forced ? 0.6f : Mathf.Clamp((float)num, -0.6f, 0.6f));
		zdo.Set(Keys.Quality, num3);
		zdo.Set(Keys.Time, (long)(Compat.NetTime() * 1000.0));
	}

	private static void SetFlag(ZDO zdo, bool v)
	{
		if (zdo.GetBool(Keys.Rowing, false) != v)
		{
			zdo.Set(Keys.Rowing, v);
		}
	}

	private void EnsureStyles()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Expected O, but got Unknown
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Expected O, but got Unknown
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Expected O, but got Unknown
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Expected O, but got Unknown
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Expected O, but got Unknown
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: 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_01a6: 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)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: 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_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: 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_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		if (_label == null)
		{
			_label = new GUIStyle(GUI.skin.label);
			_label.alignment = (TextAnchor)4;
			_small = new GUIStyle(_label);
			_left = new GUIStyle(_label);
			_left.alignment = (TextAnchor)3;
			_right = new GUIStyle(_label);
			_right.alignment = (TextAnchor)5;
			_tiny = new GUIStyle(_label);
			_tiny.alignment = (TextAnchor)3;
			_tinyR = new GUIStyle(_tiny);
			_tinyR.alignment = (TextAnchor)5;
			_tinyC = new GUIStyle(_tiny);
			_tinyC.alignment = (TextAnchor)4;
		}
		Font heading = Ui.Heading;
		Font body = Ui.Body;
		Font val = (((Object)(object)heading != (Object)null) ? heading : body);
		if ((Object)(object)_label.font != (Object)(object)val)
		{
			_label.font = val;
			GUIStyle small = _small;
			GUIStyle left = _left;
			Font val2 = (_right.font = val);
			Font font = (left.font = val2);
			small.font = font;
			GUIStyle tiny = _tiny;
			GUIStyle tinyR = _tinyR;
			val2 = (_tinyC.font = val);
			font = (tinyR.font = val2);
			tiny.font = font;
			FontStyle val7 = (FontStyle)(!((Object)(object)val != (Object)null));
			GUIStyle label = _label;
			GUIStyle small2 = _small;
			GUIStyle left2 = _left;
			GUIStyle right = _right;
			GUIStyle tiny2 = _tiny;
			GUIStyle tinyR2 = _tinyR;
			FontStyle val8 = (_tinyC.fontStyle = val7);
			FontStyle val10 = (tinyR2.fontStyle = val8);
			FontStyle val12 = (tiny2.fontStyle = val10);
			FontStyle val14 = (right.fontStyle = val12);
			FontStyle val16 = (left2.fontStyle = val14);
			FontStyle fontStyle = (small2.fontStyle = val16);
			label.fontStyle = fontStyle;
		}
		if (_sigBig != null)
		{
			_sigBig.font = (((Object)(object)heading != (Object)null) ? heading : body);
			_sigLab.font = (((Object)(object)body != (Object)null) ? body : heading);
		}
	}

	private bool HudOff()
	{
		if (Time.unscaledTime >= _nextHud)
		{
			_nextHud = Time.unscaledTime + 0.25f;
			_hudOff = Compat.HudHidden();
		}
		return _hudOff;
	}

	private void OnGUI()
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Invalid comparison between Unknown and I4
		//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0218: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Unknown result type (might be due to invalid IL or missing references)
		//IL_0322: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0430: Unknown result type (might be due to invalid IL or missing references)
		//IL_044f: Unknown result type (might be due to invalid IL or missing references)
		if (Cfg.Enabled.Value && Cfg.ShowVolumePanel.Value && Menu.IsVisible())
		{
			EnsureStyles();
			Ui.UseGlobal();
			DrawVolume();
			Ui.Done();
		}
		if (IntroOpen && Cfg.Enabled.Value && (Object)(object)Player.m_localPlayer != (Object)null)
		{
			EnsureStyles();
			Ui.Use(Cfg.PopupOpacity);
			DrawIntro(Ui.ScaleOf(Cfg.PopupScale));
			Ui.Done();
		}
		else
		{
			if ((int)Event.current.type != 7 || !Cfg.Enabled.Value || (Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)_aboardShip == (Object)null || HudOff())
			{
				return;
			}
			EnsureStyles();
			IntroCursor();
			RefreshTexts();
			float s = Ui.S * Cfg.UiScale.Value;
			int num = (_rowing ? 1 : (_drumming ? 2 : 0));
			if (num != _lastMode)
			{
				_lastMode = num;
				_modeAt = Time.time;
			}
			Ui.UseGlobal();
			DrawWindLines();
			Ui.Use(Cfg.MessagesOpacity);
			float num2 = Ui.ScaleOf(Cfg.MessagesScale);
			DrawSigCue(num2);
			Ui.Use(Cfg.MinigameOpacity);
			if (_rowing && _streak >= 10 && Cfg.MinigameStyle.Value != "Bar")
			{
				Carve.Vignette(new Color(0.3f, 0.6f, 1f), 0.1f + 0.04f * Mathf.Sin(Time.unscaledTime * 6f), s);
			}
			float num3 = Ui.ScaleOf(Cfg.MinigameScale) * 0.75f;
			_label.fontSize = Mathf.RoundToInt(36f * num3);
			_small.fontSize = Mathf.RoundToInt(28f * num3);
			float num4 = (float)Screen.width * 0.5f;
			Vector2 val = Ui.MinigameCentre();
			float num5 = Mathf.Max(700f, 780f) * num3 * 0.5f;
			float num6 = 350f * num3 * 0.5f;
			float num7 = Mathf.Clamp(val.x, Mathf.Min(num5 + 8f, num4), Mathf.Max((float)Screen.width - num5 - 8f, num4));
			float num8 = Mathf.Clamp(val.y, Mathf.Min(num6 + 8f, (float)Screen.height * 0.5f), Mathf.Max((float)Screen.height - num6 - 8f, (float)Screen.height * 0.5f));
			Matrix4x4 matrix = GUI.matrix;
			float num9 = (Cfg.CalmMode.Value ? 1f : Mathf.Clamp01((Time.time - _modeAt) / 0.3f));
			if (num9 < 1f && (_rowing || _drumming))
			{
				float num10 = 1f - Mathf.Pow(1f - num9, 3f);
				float num11 = Mathf.Lerp(0.86f, 1f, num10) + 0.03f * Mathf.Sin(num10 * (float)Math.PI);
				GUIUtility.ScaleAroundPivot(new Vector2(num11, num11), new Vector2(num7, num8));
			}
			if (_rowing)
			{
				if (Cfg.MinigameStyle.Value == "Bar")
				{
					DrawPov(num7, num8, num3);
				}
				else
				{
					DrawEmber(num7, num8, num3);
				}
			}
			else if (_drumming)
			{
				DrawDrum(num7, num8, num3);
			}
			GUI.matrix = matrix;
			Ui.Use(Cfg.MessagesOpacity);
			float num12 = num2 * 0.75f;
			DrawSitGuide(num2);
			if (_rowing && Cfg.TutorialChoice.Value != TutorialAnswer.Declined && !Cfg.TutorialDone.Value && !Cfg.MinimalUi.Value && Time.time - _sitAt > 9.3f)
			{
				string t = ((_strokesDone < 2) ? "HOLD an arrow key as the ember reaches the CATCH, RELEASE it at the FINISH. Up rows forward." : ((_strokesDone < 5) ? "Nice. Down rows backward, left and right turn. Green keys drive you on, red keys back you up." : "Stay on the beat and the boat speeds up. Perfect strokes in a row add a bonus."));
				Rect r = new Rect(num4 - 420f * num12, (float)Screen.height * 0.2f, 840f * num12, 40f * num12);
				_small.fontSize = Mathf.RoundToInt(22f * num12);
				Text(r, t, Ui.Gold, _small);
			}
			if (!_rowing && !_drumming && Cfg.ShowHint.Value && !Cfg.MinimalUi.Value && Time.time - _boardedAt < 8f)
			{
				Rect r2 = new Rect(num7 - 300f * num12, num8 - 26f * num12, 600f * num12, 52f * num12);
				_small.fontSize = Mathf.RoundToInt(28f * num12);
				Ui.PanelBox(r2, num12);
				Text(r2, _tHint, Ui.Gold, _small);
			}
			bool num13 = Cfg.ShowGraph.Value && !Cfg.MinimalUi.Value && _g.Count >= 4 && !Menu.IsVisible() && !InventoryGui.IsVisible() && !Minimap.IsOpen();
			float num14 = Ui.ScaleOf(Cfg.GraphScale);
			if (num13)
			{
				Ui.Use(Cfg.GraphOpacity);
				DrawGraph(num14 * 0.78f);
			}
			if (Cfg.ShowKeys.Value && !Menu.IsVisible() && !InventoryGui.IsVisible() && !Minimap.IsOpen())
			{
				Ui.Use(Cfg.KeyListOpacity);
				DrawKeys(Ui.ScaleOf(Cfg.KeyListScale));
			}
			float num15 = Ui.ScaleOf(Cfg.SpeedCardScale);
			_small.fontSize = Mathf.RoundToInt(22f * num15);
			float ty = (num13 ? (134f * num14) : (12f * num15));
			if (Cfg.ShowHud.Value && !Cfg.MinimalUi.Value)
			{
				Ui.Use(Cfg.SpeedCardOpacity);
				DrawSigPanel(num4, ty, num15);
			}
			Ui.Done();
		}
	}

	private void DrawSigPanel(float cx, float ty, float s)
	{
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: 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_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: 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_0235: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: 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_0271: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_028c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0312: Unknown result type (might be due to invalid IL or missing references)
		//IL_0363: Unknown result type (might be due to invalid IL or missing references)
		//IL_0397: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ad: 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_0051: Expected O, but got Unknown
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Expected O, but got Unknown
		CrewShip crewShip = (((Object)(object)_rowShip != (Object)null) ? _rowShip : _aboardShip);
		int num = Beat.Level(((Object)(object)crewShip != (Object)null) ? crewShip.Code : 4);
		if (_sigBig == null)
		{
			_sigBig = new GUIStyle(_label);
			_sigBig.font = (((Object)(object)Ui.Heading != (Object)null) ? Ui.Heading : _label.font);
			_sigBig.alignment = (TextAnchor)4;
			_sigLab = new GUIStyle(_label);
			_sigLab.font = (((Object)(object)Ui.Body != (Object)null) ? Ui.Body : _label.font);
			_sigLab.alignment = (TextAnchor)3;
		}
		float num2 = 560f * s;
		float num3 = 64f * s;
		Rect r = default(Rect);
		((Rect)(ref r))..ctor(cx - num2 * 0.5f, ty, num2, num3);
		Ui.PanelBox(r, s);
		Ui.Frame(new Rect(((Rect)(ref r)).x + 3f * s, ((Rect)(ref r)).y + 3f * s, ((Rect)(ref r)).width - 6f * s, ((Rect)(ref r)).height - 6f * s), new Color(Ui.Gold.r, Ui.Gold.g, Ui.Gold.b, 0.55f), Mathf.Max(1f, 1.5f * s));
		Color val = (new Color[4]
		{
			new Color(0.45f, 0.95f, 0.4f),
			new Color(1f, 0.86f, 0.24f),
			new Color(1f, 0.3f, 0.2f),
			new Color(0.78f, 0.92f, 1f)
		})[Mathf.Clamp(num, 0, 3)];
		float num4 = 190f * s;
		Rect r2 = new Rect(((Rect)(ref r)).x + 8f * s, ((Rect)(ref r)).y + 8f * s, num4, num3 - 16f * s);
		Ui.Fill(r2, new Color(val.r * 0.25f, val.g * 0.25f, val.b * 0.25f, 0.85f));
		Ui.Frame(r2, new Color(val.r, val.g, val.b, 0.9f), Mathf.Max(1.5f, 2f * s));
		_sigBig.fontSize = Mathf.RoundToInt(32f * s);
		Text(r2, Mathf.Max(0f, _gSpeed).ToString("0.0") + " m/s", val, _sigBig);
		float num5 = ((Rect)(ref r)).x + num4 + 24f * s;
		TextAnchor alignment = _small.alignment;
		_small.alignment = (TextAnchor)3;
		_small.fontSize = Mathf.RoundToInt(26f * s);
		Text(new Rect(num5, ((Rect)(ref r)).y + 4f * s, ((Rect)(ref r)).xMax - num5 - 10f * s, num3 - 8f * s), "Crew " + _status.Aboard + "   Rowing " + _status.Rowers, Ui.Parchment, _small);
		_small.alignment = alignment;
	}

	private void SampleGraph()
	{
		//IL_0056: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: 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_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_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: 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)
		if ((Object)(object)_aboardShip == (Object)null)
		{
			if (_g.Count > 0)
			{
				_g.Clear();
			}
			_gHave = false;
			return;
		}
		double timeAsDouble = Time.timeAsDouble;
		if (timeAsDouble - _gLast < 0.05)
		{
			return;
		}
		Transform transform = ((Component)_aboardShip).transform;
		Vector3 forward = transform.forward;
		forward.y = 0f;
		if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f)
		{
			return;
		}
		((Vector3)(ref forward)).Normalize();
		double num = timeAsDouble - _gLast;
		_gLast = timeAsDouble;
		if (!_gHave || num > 0.5 || num <= 0.0)
		{
			_gHave = true;
			_gPos = transform.position;
			_g.Clear();
			return;
		}
		float num2 = (_aboardShip.Owner ? Vector3.Dot(_aboardShip.Vel, forward) : Vector3.Dot((transform.position - _gPos) / (float)num, forward));
		_gPos = transform.position;
		_gSpeed += (num2 - _gSpeed) * 0.6f;
		double num3 = Compat.NetTime();
		float num4 = 0f;
		for (int num5 = _g.Count - 1; num5 >= 0; num5--)
		{
			if (num3 - _g[num5].t >= 0.2)
			{
				num4 = (_gSpeed - _g[num5].v) / (float)(num3 - _g[num5].t);
				break;
			}
		}
		_gAcc += (num4 - _gAcc) * 0.5f;
		GSample item = new GSample
		{
			t = num3,
			v = _gSpeed,
			a = _gAcc
		};
		_g.Add(item);
		while (_g.Count > 0 && num3 - _g[0].t > 14.0)
		{
			_g.RemoveAt(0);
		}
	}

	private void DrawGraph(float s)
	{
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: 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_0289: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_0294: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0480: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0509: Unknown result type (might be due to invalid IL or missing references)
		//IL_050e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0524: Unknown result type (might be due to invalid IL or missing references)
		//IL_0529: Unknown result type (might be due to invalid IL or missing references)
		//IL_053f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0544: Unknown result type (might be due to invalid IL or missing references)
		//IL_0453: Unknown result type (might be due to invalid IL or missing references)
		//IL_0455: Unknown result type (might be due to invalid IL or missing references)
		//IL_0375: Unknown result type (might be due to invalid IL or missing references)
		//IL_038e: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0902: Unknown result type (might be due to invalid IL or missing references)
		//IL_0926: Unknown result type (might be due to invalid IL or missing references)
		//IL_093a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0986: Unknown result type (might be due to invalid IL or missing references)
		//IL_099f: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_09e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0438: Unknown result type (might be due to invalid IL or missing references)
		//IL_0843: Unknown result type (might be due to invalid IL or missing references)
		//IL_0848: Unknown result type (might be due to invalid IL or missing references)
		//IL_086a: Unknown result type (might be due to invalid IL or missing references)
		//IL_086f: Unknown result type (might be due to invalid IL or missing references)
		//IL_07bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_07cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_07de: Unknown result type (might be due to invalid IL or missing references)
		//IL_080f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0814: Unknown result type (might be due to invalid IL or missing references)
		//IL_081b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0822: Unknown result type (might be due to invalid IL or missing references)
		//IL_082e: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
		if (_g.Count < 4)
		{
			return;
		}
		GUIStyle tiny = _tiny;
		int fontSize = (_tinyR.fontSize = Mathf.RoundToInt(26f * s));
		tiny.fontSize = fontSize;
		double num2 = Compat.NetTime();
		double num3 = num2 - 12.0;
		float num4 = (float)Per;
		float drv = Drv;
		float num5 = 1E+09f;
		float num6 = -1E+09f;
		float num7 = 1f;
		for (int i = 0; i < _g.Count; i++)
		{
			if (!(_g[i].t < num3))
			{
				num5 = Mathf.Min(num5, _g[i].v);
				num6 = Mathf.Max(num6, _g[i].v);
				num7 = Mathf.Max(num7, Mathf.Abs(_g[i].a));
			}
		}
		if (num6 < num5)
		{
			return;
		}
		float num8 = Mathf.Min(0f, num5 - 0.3f);
		float num9 = Mathf.Max(num6 + 0.3f, num8 + 2f);
		num7 = (_gAmax = Mathf.Ceil(num7 * 1.15f));
		_gLo = num8;
		_gHi = num9;
		float num10 = 270f * s;
		float num11 = 78f * s;
		float num12 = 52f * s;
		float num13 = 14f * s;
		float num14 = 12f * s;
		float num15 = num13 + num12 + num10 + num14 + num12 + num10 + num13;
		float num16 = (float)Screen.width * 0.5f - num15 * 0.5f;
		float num17 = 8f * s;
		Ui.PanelBox(new Rect(num16, num17, num15, 128f * s), s);
		Rect val = default(Rect);
		((Rect)(ref val))..ctor(num16 + num13 + num12, num17 + 40f * s, num10, num11);
		Rect val2 = default(Rect);
		((Rect)(ref val2))..ctor(((Rect)(ref val)).xMax + num14 + num12, ((Rect)(ref val)).y, num10, num11);
		Text(new Rect(((Rect)(ref val)).x - num12, num17 + 6f * s, num10 + num12, 32f * s), _tGA, Ui.Gold, _tiny);
		Text(new Rect(((Rect)(ref val2)).x - num12, num17 + 6f * s, num10 + num12, 32f * s), _tGV, Ui.Gold, _tiny);
		Rect[] array = (Rect[])(object)new Rect[2] { val, val2 };
		for (int j = 0; j < 2; j++)
		{
			Rect r = array[j];
			Ui.Fill(r, new Color(0.12f, 0.09f, 0.06f, 0.9f));
			long num18 = (long)Math.Floor(num3 / (double)num4) - 1;
			long num19 = (long)Math.Ceiling(num2 / (double)num4) + 1;
			for (long num20 = num18; num20 <= num19; num20++)
			{
				double num21 = (double)num20 * (double)num4;
				float num22 = ((Rect)(ref r)).x + (float)((num21 - num3) / 12.0) * num10;
				float num23 = num22 - 0.14f * num4 / 12f * num10;
				float num24 = 0.28f * num4 / 12f * num10;
				float num25 = Mathf.Max(num23, ((Rect)(ref r)).x);
				float num26 = Mathf.Min(num23 + num24, ((Rect)(ref r)).xMax);
				if (num26 > num25)
				{
					Ui.Fill(new Rect(num25, ((Rect)(ref r)).y, num26 - num25, ((Rect)(ref r)).height), new Color(0.95f, 0.45f, 0.45f, 0.22f));
				}
				float num27 = ((Rect)(ref r)).x + (float)((num21 + (double)(drv * num4) - num3) / 12.0) * num10;
				if (num22 >= ((Rect)(ref r)).x && num22 <= ((Rect)(ref r)).xMax)
				{
					VDash(num22, ((Rect)(ref r)).y, ((Rect)(ref r)).height, new Color(0.85f, 0.85f, 0.85f, 0.6f), s);
				}
				if (num27 >= ((Rect)(ref r)).x && num27 <= ((Rect)(ref r)).xMax)
				{
					VDash(num27, ((Rect)(ref r)).y, ((Rect)(ref r)).height, new Color(1f, 0.88f, 0.45f, 0.7f), s);
				}
			}
			Ui.Frame(r, Ui.Edge, Mathf.Max(1.5f, 2f * s));
		}
		float y = ((Rect)(ref val)).center.y;
		float num28 = Mathf.Lerp(((Rect)(ref val2)).yMax, ((Rect)(ref val2)).y, Mathf.InverseLerp(num8, num9, 0f));
		GraphGrid(val, 0f - num7, num7, num12, s);
		GraphGrid(val2, num8, num9, num12, s);
		if (_th1 > 0f)
		{
			float[] array2 = new float[3] { _th1, _th2, _th3 };
			Color[] array3 = (Color[])(object)new Color[3]
			{
				Ui.Gold,
				new Color(1f, 0.62f, 0.3f),
				new Color(1f, 0.38f, 0.32f)
			};
			float num29 = Mathf.Max(1.5f, 1.8f * s);
			for (int k = 0; k < 3; k++)
			{
				if (!(array2[k] < num8) && !(array2[k] > num9))
				{
					float num30 = Mathf.Lerp(((Rect)(ref val2)).yMax, ((Rect)(ref val2)).y, Mathf.InverseLerp(num8, num9, array2[k]));
					for (float num31 = 0f; num31 < num10; num31 += 10f * s)
					{
						Ui.Fill(new Rect(((Rect)(ref val2)).x + num31, num30 - num29 * 0.5f, 6f * s, num29), new Color(array3[k].r, array3[k].g, array3[k].b, 0.9f));
					}
				}
			}
		}
		float num32 = Mathf.Max(2f, 2.5f * s);
		Color val3 = default(Color);
		((Color)(ref val3))..ctor(1f, 0.52f, 0.42f);
		Color val4 = default(Color);
		((Color)(ref val4))..ctor(0.55f, 0.78f, 1f);
		float num33 = 0f;
		float num34 = 0f;
		float num35 = 0f;
		bool flag = false;
		for (int l = 0; l < _g.Count; l++)
		{
			if (_g[l].t < num3)
			{
				continue;
			}
			float num36 = ((Rect)(ref val)).x + (float)((_g[l].t - num3) / 12.0) * num10;
			float num37 = Mathf.Lerp(((Rect)(ref val)).yMax, ((Rect)(ref val)).y, Mathf.InverseLerp(0f - num7, num7, _g[l].a));
			float num38 = Mathf.Lerp(((Rect)(ref val2)).yMax, ((Rect)(ref val2)).y, Mathf.InverseLerp(num8, num9, _g[l].v));
			if (flag)
			{
				float num39 = Mathf.Max(num36 - num33, 1f) + 1f;
				float num40 = Mathf.Min(num34, num37) - num32 * 0.5f;
				float num41 = Mathf.Max(num34, num37) + num32 * 0.5f;
				float num42 = Mathf.Min(num35, num38) - num32 * 0.5f;
				float num43 = Mathf.Max(num35, num38) + num32 * 0.5f;
				if (Cfg.HudQuality.Value >= 1)
				{
					Ui.Fill(new Rect(num33, Mathf.Min(num37, y), num39, Mathf.Abs(num37 - y)), new Color(val3.r, val3.g, val3.b, 0.16f));
					Ui.Fill(new Rect(num33 + (((Rect)(ref val2)).x - ((Rect)(ref val)).x), Mathf.Min(num38, num28), num39, Mathf.Abs(num38 - num28)), new Color(val4.r, val4.g, val4.b, 0.16f));
				}
				Ui.Fill(new Rect(num33, num40, num39, num41 - num40), val3);
				Ui.Fill(new Rect(num33 + (((Rect)(ref val2)).x - ((Rect)(ref val)).x), num42, num39, num43 - num42), val4);
			}
			num33 = num36;
			num34 = num37;
			num35 = num38;
			flag = true;
		}
		if (flag)
		{
			float num44 = Mathf.Max(5f, 6f * s);
			Ui.Fill(new Rect(num33 - num44 * 0.5f - 1f, num34 - num44 * 0.5f - 1f, num44 + 2f, num44 + 2f), new Color(0f, 0f, 0f, 0.55f));
			Ui.Fill(new Rect(num33 - num44 * 0.5f, num34 - num44 * 0.5f, num44, num44), new Color(1f, 0.85f, 0.78f));
			Ui.Fill(new Rect(num33 + (((Rect)(ref val2)).x - ((Rect)(ref val)).x) - num44 * 0.5f - 1f, num35 - num44 * 0.5f - 1f, num44 + 2f, num44 + 2f), new Color(0f, 0f, 0f, 0.55f));
			Ui.Fill(new Rect(num33 + (((Rect)(ref val2)).x - ((Rect)(ref val)).x) - num44 * 0.5f, num35 - num44 * 0.5f, num44, num44), new Color(0.85f, 0.93f, 1f));
		}
	}

	private void GraphGrid(Rect r, float lo, float hi, float lab, float s)
	{
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: 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_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: 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_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: 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_0205: Unknown result type (might be due to invalid IL or missing references)
		float num = Mathf.Max(0.01f, hi - lo);
		float num2 = Mathf.Max(1f, Mathf.Ceil(num / 8f));
		int num3 = Mathf.CeilToInt(lo / num2 - 0.0001f);
		int num4 = Mathf.FloorToInt(hi / num2 + 0.0001f);
		float num5 = Mathf.Max(1.2f, 1.4f * s);
		float num6 = 26f * s;
		for (int i = num3; i <= num4; i++)
		{
			float num7 = (float)i * num2;
			float num8 = Mathf.Lerp(((Rect)(ref r)).yMax, ((Rect)(ref r)).y, Mathf.InverseLerp(lo, hi, num7));
			bool flag = i == 0;
			bool flag2 = Mathf.Abs(i) % 2 == 0;
			Color c = (flag ? new Color(1f, 0.97f, 0.85f, 0.7f) : new Color(1f, 1f, 1f, flag2 ? 0.2f : 0.16f));
			if (flag)
			{
				num5 = Mathf.Max(1.5f, 1.8f * s);
			}
			if (flag2)
			{
				Ui.Fill(new Rect(((Rect)(ref r)).x, num8 - num5 * 0.5f, ((Rect)(ref r)).width, num5), c);
			}
			else
			{
				float num9 = 7f * s;
				float num10 = 6f * s;
				for (float num11 = ((Rect)(ref r)).x; num11 < ((Rect)(ref r)).xMax; num11 += num9 + num10)
				{
					Ui.Fill(new Rect(num11, num8 - num5 * 0.5f, Mathf.Min(num9, ((Rect)(ref r)).xMax - num11), num5), c);
				}
			}
			float num12 = Mathf.Clamp01(Mathf.Min(num8 - ((Rect)(ref r)).y, ((Rect)(ref r)).yMax - num8) / num6);
			if (num12 > 0.03f)
			{
				Color c2 = (flag ? Ui.Gold : Ui.Parchment);
				c2.a = num12;
				Text(new Rect(((Rect)(ref r)).x - lab, num8 - 10f * s, lab - 6f * s, 20f * s), num7.ToString("0"), c2, _tinyR);
			}
		}
	}

	private void DrawSitGuide(float s)
	{
		//IL_007e: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: 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_021c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_029a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_031f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0329: Unknown result type (might be due to invalid IL or missing references)
		//IL_0362: Unknown result type (might be due to invalid IL or missing references)
		//IL_036c: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_03be: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0410: Unknown result type (might be due to invalid IL or missing references)
		//IL_042c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0436: Unknown result type (might be due to invalid IL or missing references)
		//IL_044e: Unknown result type (might be due to invalid IL or missing references)
		//IL_046a: Unknown result type (might be due to invalid IL or missing references)
		//IL_047a: Unknown result type (might be due to invalid IL or missing references)
		//IL_047f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0484: Unknown result type (might be due to invalid IL or missing references)
		//IL_0486: Unknown result type (might be due to invalid IL or missing references)
		//IL_049f: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0500: Unknown result type (might be due to invalid IL or missing references)
		//IL_0505: Unknown result type (might be due to invalid IL or missing references)
		//IL_0521: Unknown result type (might be due to invalid IL or missing references)
		//IL_0542: Unknown result type (might be due to invalid IL or missing references)
		//IL_056e: Unknown result type (might be due to invalid IL or missing references)
		//IL_058d: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0601: Unknown result type (might be due to invalid IL or missing references)
		//IL_0603: Unknown result type (might be due to invalid IL or missing references)
		//IL_060a: Unknown result type (might be due to invalid IL or missing references)
		//IL_060c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0613: Unknown result type (might be due to invalid IL or missing references)
		//IL_0615: Unknown result type (might be due to invalid IL or missing references)
		//IL_06dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0700: Unknown result type (might be due to invalid IL or missing references)
		//IL_071d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0727: Unknown result type (might be due to invalid IL or missing references)
		//IL_073a: Unknown result type (might be due to invalid IL or missing references)
		//IL_074d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0761: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_07bf: Unknown result type (might be due to invalid IL or missing references)
		float num = Time.time - _sitAt;
		Player localPlayer = Player.m_localPlayer;
		CrewShip crewShip = (((Object)(object)_rowShip != (Object)null) ? _rowShip : _aboardShip);
		if (!(num < 0f) && !(num > 9f) && !((Object)(object)localPlayer == (Object)null) && !((Object)(object)crewShip == (Object)null))
		{
			Carve.Init();
			float num2 = Mathf.Clamp01(num / 0.25f) * Mathf.Clamp01((9f - num) / 0.6f);
			bool flag = Vector3.Dot(((Component)localPlayer).transform.forward, ((Component)crewShip).transform.forward) >= -0.2f;
			bool flag2 = (_rowing ? _side : DefaultSide(localPlayer, crewShip)) > 0f;
			float num3 = 700f * s;
			float num4 = 232f * s;
			Rect r = default(Rect);
			((Rect)(ref r))..ctor((float)Screen.width * 0.5f - num3 * 0.5f, (float)Screen.height * 0.13f, num3, num4);
			Ui.PanelBox(r, s, Cfg.BoxOpacity.Value, num2);
			Color c = default(Color);
			((Color)(ref c))..ctor(Ui.Gold.r, Ui.Gold.g, Ui.Gold.b, num2);
			Color c2 = default(Color);
			((Color)(ref c2))..ctor(Ui.Parchment.r, Ui.Parchment.g, Ui.Parchment.b, num2);
			_small.fontSize = Mathf.RoundToInt(26f * s);
			Text(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + 8f * s, num3, 32f * s), "YOUR SEAT:  OAR ON THE " + (flag2 ? "RIGHT" : "LEFT") + "   -   FACING THE " + (flag ? "BOW" : "STERN"), c, _small);
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(((Rect)(ref r)).x + 128f * s, ((Rect)(ref r)).y + 112f * s);
			float num5 = 170f * s;
			float num6 = 46f * s;
			Rect r2 = default(Rect);
			((Rect)(ref r2))..ctor(val.x - num5 * 0.5f, val.y - num6 * 0.5f, num5, num6);
			Ui.Fill(r2, new Color(0.3f, 0.2f, 0.11f, 0.95f * num2));
			Ui.Frame(r2, new Color(Ui.Edge.r, Ui.Edge.g, Ui.Edge.b, num2), Mathf.Max(1.5f, 2f * s));
			Ui.Fill(new Rect(((Rect)(ref r2)).xMax, val.y - 7f * s, 12f * s, 14f * s), new Color(0.85f, 0.75f, 0.45f, 0.9f * num2));
			_tinyC.fontSize = Mathf.RoundToInt(22f * s);
			Text(new Rect(((Rect)(ref r2)).xMax - 36f * s, ((Rect)(ref r2)).y - 26f * s, 80f * s, 20f * s), "BOW", c2, _tinyC);
			Text(new Rect(((Rect)(ref r2)).x - 24f * s, ((Rect)(ref r2)).y - 26f * s, 80f * s, 20f * s), "STERN", c2, _tinyC);
			bool num7 = flag == flag2;
			float num8 = (num7 ? ((Rect)(ref r2)).yMax : ((Rect)(ref r2)).y);
			float num9 = (num7 ? 1f : (-1f));
			Vector2 val2 = new Vector2(val.x, val.y + num9 * num6 * 0.28f);
			Carve.Line(val2, new Vector2(val2.x, num8 + num9 * 34f * s), 3f * s, new Color(0.85f, 0.65f, 0.35f, num2));
			Carve.Hard(new Vector2(val2.x, num8 + num9 * 34f * s), 5f * s, new Color(0.85f, 0.65f, 0.35f, num2));
			Carve.Hard(val2, 8f * s, new Color(1f, 0.93f, 0.7f, num2));
			float num10 = (flag ? 1f : (-1f));
			Vector2 val3 = val2 + new Vector2(num10 * 30f * s, 0f);
			Carve.Line(val2, val3, 3f * s, new Color(1f, 0.93f, 0.7f, num2));
			Carve.Line(val3, val3 + new Vector2((0f - num10) * 8f * s, -7f * s), 3f * s, new Color(1f, 0.93f, 0.7f, num2));
			Carve.Line(val3, val3 + new Vector2((0f - num10) * 8f * s, 7f * s), 3f * s, new Color(1f, 0.93f, 0.7f, num2));
			_tinyC.fontSize = Mathf.RoundToInt(22f * s);
			Text(new Rect(val.x - 90f * s, ((Rect)(ref r2)).yMax + 40f * s, 180f * s, 22f * s), "you face " + (flag ? "ahead" : "astern"), c2, _tinyC);
			Color val4 = default(Color);
			((Color)(ref val4))..ctor(0.42f, 0.95f, 0.45f);
			Color val5 = default(Color);
			((Color)(ref val5))..ctor(1f, 0.36f, 0.32f);
			int num11 = (flag2 ? 3 : 2);
			int num12 = (flag2 ? 2 : 3);
			int[] array = new int[4] { 0, 1, num12, num11 };
			Color[] array2 = (Color[])(object)new Color[4] { val4, val5, val4, val5 };
			string[] array3 = new string[4]
			{
				flag ? "Row the boat AHEAD" : "Row the boat ASTERN",
				flag ? "Back-paddle: astern" : "Back-paddle: ahead",
				"Pull and turn away from your oar side",
				"Back-stroke and turn toward your oar side"
			};
			_left.fontSize = Mathf.RoundToInt(24f * s);
			Vector2 val6 = default(Vector2);
			Color val7 = default(Color);
			for (int i = 0; i < 4; i++)
			{
				((Vector2)(ref val6))..ctor(((Rect)(ref r)).x + 292f * s, ((Rect)(ref r)).y + 72f * s + (float)i * 34f * s);
				((Color)(ref val7))..ctor(array2[i].r, array2[i].g, array2[i].b, num2);
				EmberHud.GuideKey(val6, array[i], val7, s * 1.3f);
				Text(new Rect(val6.x + 24f * s, val6.y - 14f * s, 380f * s, 28f * s), array3[i], new Color(val7.r * 0.5f + 0.5f, val7.g * 0.5f + 0.5f, val7.b * 0.5f + 0.5f, num2), _left);
			}
			_tinyC.fontSize = Mathf.RoundToInt(23f * s);
			Text(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - 32f * s, num3, 24f * s), "HOLD a key as the ember reaches its CATCH, RELEASE at the FINISH", c2, _tinyC);
		}
	}

	private void UpdateHints(bool seated)
	{
		if (!seated || _rowing)
		{
			_idleSince = Time.time;
			_hintA = 0f;
			return;
		}
		if (_idleSince < 0f)
		{
			_idleSince = Time.time;
		}
		bool flag = Time.time - _idleSince > 10f || _keysPinned;
		_hintA = (flag ? Mathf.MoveTowards(_hintA, 1f, Time.unscaledDeltaTime / 0.6f) : 0f);
	}

	private float StatusIconsBottom()
	{
		//IL_0093: 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)
		if (Time.unscaledTime < _seAt)
		{
			return _seBottom;
		}
		_seAt = Time.unscaledTime + 0.25f;
		float num = 0f;
		try
		{
			if ((Object)(object)_seRoot == (Object)null && (Object)(object)Hud.instance != (Object)null)
			{
				_seRoot = Traverse.Create((object)Hud.instance).Field("m_statusEffectListRoot").GetValue<RectTransform>();
			}
			if ((Object)(object)_seRoot != (Object)null)
			{
				Vector3[] array = (Vector3[])(object)new Vector3[4];
				Canvas componentInParent = ((Component)_seRoot).GetComponentInParent<Canvas>();
				Camera val = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null);
				for (int i = 0; i < ((Transform)_seRoot).childCount; i++)
				{
					Transform child = ((Transform)_seRoot).GetChild(i);
					RectTransform val2 = (RectTransform)(object)((child is RectTransform) ? child : null);
					if (!((Object)(object)val2 == (Object)null) && ((Component)val2).gameObject.activeInHierarchy)
					{
						val2.GetWorldCorners(array);
						float num2 = (float)Screen.height - RectTransformUtility.WorldToScreenPoint(val, array[0]).y;
						if (num2 > num && num2 < (float)Screen.height)
						{
							num = num2;
						}
					}
				}
			}
		}
		catch (Exception)
		{
		}
		_seBottom = num;
		return num;
	}

	private static float TextW(GUIStyle st, int baseSize, string t)
	{
		int fontSize = st.fontSize;
		st.fontSize = Mathf.Max(13, Mathf.RoundToInt((float)baseSize * Cfg.UiTextSize.Value));
		float result = TextWidth(st, t);
		st.fontSize = fontSize;
		return result;
	}

	private void DrawKeys(float s)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Expected O, but got Unknown
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Expected O, but got Unknown
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: 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_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Invalid comparison between Unknown and I4
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_028c: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_045a: Unknown result type (might be due to invalid IL or missing references)
		//IL_045f: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0803: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0867: Unknown result type (might be due to invalid IL or missing references)
		//IL_0896: Unknown result type (might be due to invalid IL or missing references)
		if (_hintA <= 0.01f || _rowing)
		{
			return;
		}
		if (_hKey == null)
		{
			_hKey = new GUIStyle(_left);
			_hKey.fontStyle = (FontStyle)1;
			_hKey.alignment = (TextAnchor)3;
			_hKey.wordWrap = false;
			_hAct = new GUIStyle(_left);
			_hAct.wordWrap = false;
			_hHead = new GUIStyle(_left);
			_hHead.fontStyle = (FontStyle)1;
			_hHead.wordWrap = false;
		}
		GUIStyle hKey = _hKey;
		GUIStyle hAct = _hAct;
		Font val = (_hHead.font = _left.font);
		Font font2 = (hAct.font = val);
		hKey.font = font2;
		bool num = Compat.IsPilot(Player.m_localPlayer, ((Object)(object)_aboardShip != (Object)null) ? _aboardShip.ShipRef : null);
		_rows.Clear();
		HintRow item = default(HintRow);
		item.Head = true;
		item.Key = "?";
		item.Act = "How to play";
		_rows.Add(item);
		AddHint(KeyLabel(Cfg.KeyFwd.Value) + " / " + KeyLabel(Cfg.KeyBack.Value), "Hold at the catch, release at the finish");
		AddHint(KeyLabel(Cfg.KeyLeft.Value) + " / " + KeyLabel(Cfg.KeyRight.Value), "Turn: toward your oar slows, away speeds up");
		string text = KeyLabel(Cfg.SwapKey.Value);
		KeyboardShortcut value = Cfg.SwapKey.Value;
		AddHint(text + (((int)((KeyboardShortcut)(ref value)).MainKey == 256) ? " / Ins" : ""), "Swap your oar side");
		if (num)
		{
			AddHint(KeyLabel(Cfg.DrumKey.Value), "Drum (at the helm)");
			AddHint(KeyLabel(Cfg.DrumModeKey.Value), "Freestyle drumming on / off");
			AddHint(KeyLabel(Cfg.DrumEdgeKey.Value) + " " + KeyLabel(Cfg.DrumOuterKey.Value) + " " + KeyLabel(Cfg.DrumMiddleKey.Value), "Freestyle: edge, outer, middle");
		}
		AddHint(KeyLabel(Cfg.GraphKey.Value), "Speed graph");
		AddHint(KeyLabel(Cfg.UiKey.Value), "Minimal UI");
		AddHint(KeyLabel(Cfg.HelpKey.Value), _keysPinned ? "Unpin these hints" : "Pin these hints");
		float num2 = 1f;
		float num3 = 12f * s;
		float num4 = 16f * s;
		float num5 = 0f;
		float num6 = 0f;
		float num7 = 0f;
		float num8 = 0f;
		float num9 = (float)Screen.width * 0.34f;
		for (int i = 0; i < 3; i++)
		{
			float num10 = 0f;
			float num11 = 0f;
			num6 = num3 * 2f;
			for (int j = 0; j < _rows.Count; j++)
			{
				HintRow hintRow = _rows[j];
				int num12 = (hintRow.Head ? Mathf.RoundToInt(36f * s * num2) : Mathf.RoundToInt(21f * s * num2));
				float num13 = TextW(hintRow.Head ? _hHead : _hKey, num12, hintRow.Key);
				float num14 = TextW(hintRow.Head ? _hHead : _hAct, hintRow.Head ? num12 : num12, hintRow.Act);
				num10 = Mathf.Max(num10, num13);
				num11 = Mathf.Max(num11, num14);
				num6 += Mathf.Max(13f, (float)num12 * Cfg.UiTextSize.Value) * 1.3f + (hintRow.Head ? (6f * s) : 0f);
			}
			num5 = num3 * 2f + num10 + num4 + num11;
			num7 = (float)Screen.width - num5 - 16f * s;
			float[] array = new float[3];
			Rect val3 = MinimapRect(s);
			array[0] = ((Rect)(ref val3)).yMax + 8f * s;
			array[1] = StatusIconsBottom() + 8f * s;
			array[2] = (float)Screen.height * 0.18f;
			num8 = Mathf.Max(array);
			float num15 = (float)Screen.width * 0.5f;
			float num16 = Ui.ScaleOf(Cfg.GraphScale);
			float num17 = Ui.ScaleOf(Cfg.SpeedCardScale);
			bool flag = Cfg.ShowGraph.Value && !Cfg.MinimalUi.Value && _g.Count >= 4;
			if (flag && num7 < num15 + 280f * num16 * 0.78f + 8f * s)
			{
				num8 = Mathf.Max(num8, 112f * num16);
			}
			if (Cfg.ShowHud.Value && !Cfg.MinimalUi.Value && num7 < num15 + 290f * num17)
			{
				num8 = Mathf.Max(num8, (flag ? (134f * num16) : (12f * num17)) + 74f * num17 + 30f * s);
			}
			float num18 = (float)Screen.height - 12f * s - num8;
			float num19 = Mathf.Min(new float[3]
			{
				1f,
				num9 / num5,
				num18 / num6
			});
			if (num19 >= 0.995f)
			{
				break;
			}
			num2 *= Mathf.Max(0.5f, num19 * 0.97f);
		}
		Rect r = default(Rect);
		((Rect)(ref r))..ctor(num7, num8, num5, num6);
		Ui.PanelBox(r, s, Cfg.BoxOpacity.Value, _hintA);
		float num20 = ((Rect)(ref r)).y + num3;
		float num21 = ((Rect)(ref r)).x + num3;
		float num22 = 0f;
		for (int k = 0; k < _rows.Count; k++)
		{
			num22 = Mathf.Max(num22, TextW(_rows[k].Head ? _hHead : _hKey, _rows[k].Head ? Mathf.RoundToInt(36f * s * num2) : Mathf.RoundToInt(21f * s * num2), _rows[k].Key));
		}
		Color val4 = default(Color);
		((Color)(ref val4))..ctor(Ui.Parchment.r, Ui.Parchment.g, Ui.Parchment.b, _hintA);
		Color val5 = default(Color);
		((Color)(ref val5))..ctor(Ui.Gold.r, Ui.Gold.g, Ui.Gold.b, _hintA);
		for (int l = 0; l < _rows.Count; l++)
		{
			HintRow hintRow2 = _rows[l];
			int num23 = (hintRow2.Head ? Mathf.RoundToInt(36f * s * num2) : Mathf.RoundToInt(21f * s * num2));
			float num24 = Mathf.Max(13f, (float)num23 * Cfg.UiTextSize.Value) * 1.3f;
			GUIStyle val6 = (hintRow2.Head ? _hHead : _hKey);
			GUIStyle val7 = (hintRow2.Head ? _hHead : _hAct);
			int fontSize = (val7.fontSize = num23);
			val6.fontSize = fontSize;
			Text(new Rect(num21, num20, num22 + 4f, num24), hintRow2.Key, val5, val6);
			Text(new Rect(num21 + num22 + num4, num20, ((Rect)(ref r)).xMax - num3 - (num21 + num22 + num4), num24), hintRow2.Act, hintRow2.Head ? val5 : val4, val7);
			num20 += num24 + (hintRow2.Head ? (6f * s) : 0f);
			if (hintRow2.Head)
			{
				Ui.Fill(new Rect(((Rect)(ref r)).x + num3, num20 - 4f * s, ((Rect)(ref r)).width - num3 * 2f, Mathf.Max(1f, 1.5f * s)), new Color(Ui.Edge.r, Ui.Edge.g, Ui.Edge.b, 0.7f * _hintA));
			}
		}
	}

	private void AddHint(string key, string act)
	{
		HintRow item = default(HintRow);
		item.Head = false;
		item.Key = key;
		item.Act = act;
		_rows.Add(item);
	}

	private void PopText(Rect r, string t, Color c, GUIStyle st, float age, int baseSize)
	{
		//IL_003c: 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)
		int fontSize = st.fontSize;
		st.fontSize = Mathf.RoundToInt((float)baseSize * (1f + 0.45f * Mathf.Exp((0f - Mathf.Max(0f, age)) * 9f)));
		Text(r, t, c, st);
		st.fontSize = fontSize;
	}

	private static void VDash(float x, float y, float h, Color c, float s)
	{
		//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)
		float num = 6f * s;
		float num2 = 5f * s;
		float num3 = Mathf.Max(1.2f, 1.5f * s);
		for (float num4 = y; num4 < y + h; num4 += num + num2)
		{
			Ui.Fill(new Rect(x - num3 * 0.5f, num4, num3, Mathf.Min(num, y + h - num4)), c);
		}
	}

	private static float OarAngle(float pos)
	{
		return Mathf.Lerp(38f, -32f, Beat.Ease(pos));
	}

	private void DrawEmber(float cx, float y, float s)
	{
		try
		{
			DrawEmberInner(cx, y, s);
		}
		catch (Exception ex)
		{
			if (!_emberFailLogged)
			{
				_emberFailLogged = true;
				Log.LogError((object)("DifferentStrokes: minigame draw failed (logged once): " + ex));
			}
		}
	}

	private void DrawEmberInner(float cx, float y, float s)
	{
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: 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_02cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_035d: Unknown result type (might be due to invalid IL or missing references)
		//IL_037c: Unknown result type (might be due to invalid IL