Decompiled source of Offline Bots Training Data Recorder v0.1.6

StraftatTelemetry/StraftatTelemetry.dll

Decompiled 12 hours ago
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ComputerysModdingUtilities;
using HarmonyLib;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: StraftatMod(true)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("StraftatTelemetry")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.5.0")]
[assembly: AssemblyInformationalVersion("0.1.5")]
[assembly: AssemblyProduct("StraftatTelemetry")]
[assembly: AssemblyTitle("StraftatTelemetry")]
[assembly: AssemblyVersion("0.1.5.0")]
namespace StraftatTelemetry;

internal sealed class LineWriter : IDisposable
{
	private readonly ConcurrentQueue<string> _queue = new ConcurrentQueue<string>();

	private readonly AutoResetEvent _wake = new AutoResetEvent(initialState: false);

	private readonly StreamWriter _out;

	private readonly Thread _thread;

	private volatile bool _stop;

	public LineWriter(string path)
	{
		_out = new StreamWriter(path, append: false, new UTF8Encoding(encoderShouldEmitUTF8Identifier: false), 65536);
		_thread = new Thread(Run)
		{
			IsBackground = true,
			Name = "StraftatTelemetry writer",
			Priority = ThreadPriority.BelowNormal
		};
		_thread.Start();
	}

	public void WriteLine(string line)
	{
		_queue.Enqueue(line ?? "");
	}

	public void WriteLine()
	{
		_queue.Enqueue("");
	}

	private void Run()
	{
		while (!_stop)
		{
			_wake.WaitOne(250);
			Drain();
		}
		Drain();
	}

	private void Drain()
	{
		try
		{
			bool flag = false;
			string result;
			while (_queue.TryDequeue(out result))
			{
				_out.WriteLine(result);
				flag = true;
			}
			if (flag)
			{
				_out.Flush();
			}
		}
		catch (Exception ex)
		{
			ManualLogSource log = TelemetryPlugin.Log;
			if (log != null)
			{
				log.LogWarning((object)("Telemetry writer: " + ex.Message));
			}
		}
	}

	public void Dispose()
	{
		_stop = true;
		_wake.Set();
		if (!_thread.Join(3000))
		{
			Drain();
		}
		try
		{
			_out.Flush();
			_out.Dispose();
		}
		catch
		{
		}
		_wake.Close();
	}
}
internal class Sampler
{
	private class P
	{
		public FirstPersonController F;

		public PlayerHealth H;

		public PlayerPickup Pk;

		public int Id = -1;

		public string Label;

		public Vector3 PrevPos;

		public float PrevPosT;

		public Vector3 Vel;

		public float PrevHealth = -1f;

		public bool Visible;

		public float VisibleChangedAt;

		public float SeenAt = -1f;

		public float SeenErr;

		public bool ReactShot;

		public bool ReactAim;

		public float AimErr;

		public float AimErrChest;

		public float Dist;

		public float AimsAtMe;

		public string Item = "-";

		public GameObject ItemGo;

		public int ItemAmmo = int.MinValue;

		public int Shots;
	}

	private class Dropped
	{
		public GameObject Go;

		public string Name;

		public float At;

		public Vector3 Pos;

		public Vector3 DropPos;

		public float Height;
	}

	private class PendingAfter
	{
		public float At;

		public string Line;

		public float SpeedBefore;
	}

	public readonly string Map;

	public float SampledSeconds;

	private readonly int _index;

	private LineWriter _csv;

	private LineWriter _ev;

	private readonly float _t0;

	private float _nextRow;

	private float _lastRowAt = -1f;

	private int _rows;

	private int _frames;

	private int _events;

	private static readonly FieldRef<FirstPersonController, Vector3> WallNormalR = Ref<Vector3>("wallPointNormal");

	private static readonly FieldRef<FirstPersonController, bool> LadderR = Ref<bool>("onLadder");

	private static readonly FieldRef<FirstPersonController, float> SlideTimerR = Ref<float>("slideTimer");

	private static readonly FieldRef<FirstPersonController, float> SlideResetR = Ref<float>("slideResetTimer");

	private static readonly FieldRef<FirstPersonController, bool> FuncSprintR = Ref<bool>("funcSprint");

	private static readonly FieldInfo InteractF = AccessTools.Field(typeof(PlayerPickup), "interact");

	private static readonly FieldInfo DropF = AccessTools.Field(typeof(PlayerPickup), "drop");

	private static readonly FieldInfo ChangeF = AccessTools.Field(typeof(PlayerPickup), "change");

	private readonly List<P> _others = new List<P>();

	private readonly List<P> _slots = new List<P>();

	private static readonly Comparison<P> ByDist = (P a, P b) => a.Dist.CompareTo(b.Dist);

	private readonly StringBuilder _row = new StringBuilder(1024);

	private float _scanAt;

	private static readonly RaycastHit[] Hits = (RaycastHit[])(object)new RaycastHit[24];

	private FirstPersonController _self;

	private PlayerPickup _pk;

	private PlayerHealth _hp;

	private Transform _selfRoot;

	private int _bodies;

	private Vector3 _prevPos;

	private float _prevPosT;

	private Vector3 _vel;

	private bool _wasGrounded;

	private bool _wasSliding;

	private bool _wasSlope;

	private bool _wasCanWall;

	private bool _wasLadder;

	private bool _wasCrouch;

	private bool _wasJump;

	private bool _wasFire;

	private bool _wasZoom;

	private int _wasWallJumps;

	private float _prevSlideTimer;

	private float _slideEndAt = -10f;

	private float _airSince;

	private float _slideSince;

	private float _slopeSince;

	private float _canWallSince;

	private float _crouchAt = -1f;

	private float _jumpAt = -1f;

	private float _zoomAt;

	private float _groundedAt;

	private Vector3 _takeoffPos;

	private Vector3 _slideStartPos;

	private Vector3 _slopeStartPos;

	private float _takeoffSpeed;

	private float _slideStartSpeed;

	private float _slideMax;

	private float _slopeStartSpeed;

	private float _slopeMax;

	private float _slopeMax3;

	private bool _leftGroundPending;

	private float _leftGroundSpeed;

	private string _leftGroundInputs;

	private PendingAfter _pending;

	private int _slides;

	private int _slideJumps;

	private int _wallJumps;

	private int _jumps;

	private int _shots;

	private int _hitsDealt;

	private int _boosts;

	private int _pickups;

	private int _drops;

	private float _lastShotAt = -10f;

	private float _lastAttackAt = -10f;

	private float _lastBoostAt = -10f;

	private string _lastShotWeapon = "-";

	private float _lastShotErr = -1f;

	private readonly Queue<KeyValuePair<float, float>> _hsHist = new Queue<KeyValuePair<float, float>>();

	private float _prevHealth = -1f;

	private GameObject _right;

	private GameObject _left;

	private int _rightAmmo = int.MinValue;

	private int _leftAmmo = int.MinValue;

	private readonly List<Dropped> _dropped = new List<Dropped>();

	private readonly HashSet<string> _dumpedWeapons = new HashSet<string>();

	private InputAction _aInteract;

	private InputAction _aDrop;

	private InputAction _aChange;

	private Action<CallbackContext> _onInteract;

	private Action<CallbackContext> _onDrop;

	private Action<CallbackContext> _onChange;

	internal static readonly string[] StatNames = new string[20]
	{
		"headshotsAmount", "bodyshotsAmount", "killsAmount", "deathsAmount", "suicidesAmount", "noscope", "rocketJumps", "taserShots", "propKills", "windowsBroken",
		"potsBroken", "ragdollsThrownAway", "tauntsAmount", "roundsWon", "roundsLost", "gamesWon", "gamesLost", "timeSpentInAir", "timeSpentOnGround", "timeSpentInGame"
	};

	private float[] _stats;

	private float[] _statsNow;

	private int _headshots;

	private int _bodyshots;

	private int _oppShots;

	private string _lastGoneItem = "-";

	private float _warnAt;

	private float _findAt;

	private float _fullScanAt;

	private readonly List<FirstPersonController> _found = new List<FirstPersonController>();

	private static readonly Dictionary<int, string> NameCache = new Dictionary<int, string>();

	private float Now => Time.time - _t0;

	private static FieldRef<FirstPersonController, T> Ref<T>(string name)
	{
		try
		{
			return AccessTools.FieldRefAccess<FirstPersonController, T>(name);
		}
		catch
		{
			return null;
		}
	}

	private static T G<T>(FieldRef<FirstPersonController, T> r, FirstPersonController f, T fallback)
	{
		try
		{
			return (r != null && (Object)(object)f != (Object)null) ? r.Invoke(f) : fallback;
		}
		catch
		{
			return fallback;
		}
	}

	private static T Get<T>(FieldInfo f, object o, T fallback)
	{
		try
		{
			return (f != null && o != null && f.GetValue(o) is T val) ? val : fallback;
		}
		catch
		{
			return fallback;
		}
	}

	internal static float[] ReadStats()
	{
		float[] array = new float[StatNames.Length];
		return ReadStats(array) ? array : null;
	}

	internal static bool ReadStats(float[] a)
	{
		Settings instance = Settings.Instance;
		if ((Object)(object)instance == (Object)null)
		{
			return false;
		}
		a[0] = instance.headshotsAmount;
		a[1] = instance.bodyshotsAmount;
		a[2] = instance.killsAmount;
		a[3] = instance.deathsAmount;
		a[4] = instance.suicidesAmount;
		a[5] = instance.noscope;
		a[6] = instance.rocketJumps;
		a[7] = instance.taserShots;
		a[8] = instance.propKills;
		a[9] = instance.windowsBroken;
		a[10] = instance.potsBroken;
		a[11] = instance.ragdollsThrownAway;
		a[12] = instance.tauntsAmount;
		a[13] = instance.roundsWon;
		a[14] = instance.roundsLost;
		a[15] = instance.gamesWon;
		a[16] = instance.gamesLost;
		a[17] = instance.timeSpentInAir;
		a[18] = instance.timeSpentOnGround;
		a[19] = instance.timeSpentInGame;
		return true;
	}

	private static string F(float v)
	{
		return (float.IsNaN(v) || float.IsInfinity(v)) ? "" : v.ToString("0.###", CultureInfo.InvariantCulture);
	}

	private static string F1(float v)
	{
		return (float.IsNaN(v) || float.IsInfinity(v)) ? "?" : v.ToString("0.0", CultureInfo.InvariantCulture);
	}

	private static string F2(float v)
	{
		return v.ToString("0.00", CultureInfo.InvariantCulture);
	}

	private static float Read(InputAction a)
	{
		try
		{
			return (a != null) ? a.ReadValue<float>() : 0f;
		}
		catch
		{
			return 0f;
		}
	}

	public Sampler(string basePath, string map, int index)
	{
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		Map = map;
		_index = index;
		_t0 = Time.time;
		_csv = new LineWriter(basePath + "_samples.csv");
		_ev = new LineWriter(basePath + "_events.txt");
		_csv.WriteLine(Header());
		_ev.WriteLine(string.Format("STRAFTAT telemetry events, map {0} (#{1}), started {2:yyyy-MM-dd HH:mm:ss}, recorder {3}, game {4}", map, index, DateTime.Now, "0.1.6", Application.version));
		_ev.WriteLine("Times: seconds since this map started (same clock as the samples file). Angles in degrees. Speeds: horizontal m/s unless marked 3D.");
		_ev.WriteLine();
		Event("MAP " + map + ": gravity " + F1(Physics.gravity.y) + ", timeScale " + F2(Time.timeScale) + ", " + MapFeatures());
	}

	private string Header()
	{
		StringBuilder stringBuilder = new StringBuilder("t,x,y,z,vx,vy,vz,speed3d,hspeed,grounded,yaw,pitch,moveX,moveY,jump,runKey,sprintMode,crouch,leanL,leanR,fire1,fire2,zoom,reload,isSprinting,isCrouching,isAiming,sliding,slideTimer,slideCooldown,slopeCrouchSlide,slopeSteepSlide,ice,canWallJump,wallJumps,maxWallJumps,wallNx,wallNz,ladder,forceFactor,groundAngle,downhill,headroom,wallAheadLow,wallAheadHigh,health,right,rightAmmo,left,leftAmmo,timeScale");
		for (int i = 1; i <= TelemetryPlugin.MaxOpponents.Value; i++)
		{
			stringBuilder.Append($",p{i},p{i}x,p{i}y,p{i}z,p{i}vx,p{i}vy,p{i}vz,p{i}yaw,p{i}pitch,p{i}height,p{i}health,p{i}item,p{i}visible,p{i}dist,p{i}aimErrHead,p{i}aimErrChest,p{i}aimsAtMe");
		}
		return stringBuilder.ToString();
	}

	public void Event(string text)
	{
		if (_ev != null)
		{
			_events++;
			_ev.WriteLine($"[{Now:000.00}] {text}");
		}
	}

	public void Tick()
	{
		if (_csv == null)
		{
			return;
		}
		long since = Session.Cost.Now();
		bool flag = EnsureSelf();
		since = Session.Cost.Section("finding you / spawn snapshot", since);
		if (!flag)
		{
			return;
		}
		_frames++;
		if (Time.time >= _scanAt)
		{
			_scanAt = Time.time + 1f;
			ScanPlayers();
			since = Session.Cost.Section("player scan", since);
		}
		try
		{
			Detect();
		}
		catch (Exception e)
		{
			Warn("detect", e);
		}
		since = Session.Cost.Section("movement/items/hits", since);
		if (!(Time.time >= _nextRow))
		{
			return;
		}
		float num = 1f / (float)Mathf.Max(10, TelemetryPlugin.SampleRate.Value);
		_nextRow = Mathf.Max(_nextRow + num, Time.time + num * 0.5f);
		try
		{
			UpdateOthers();
			since = Session.Cost.Section("other players + sight", since);
			WriteRow();
			Session.Cost.Section("samples row", since);
		}
		catch (Exception e2)
		{
			Warn("row", e2);
		}
	}

	private void Warn(string where, Exception e)
	{
		if (!(Time.time < _warnAt))
		{
			_warnAt = Time.time + 10f;
			TelemetryPlugin.Log.LogWarning((object)("Telemetry " + where + ": " + e.Message));
		}
	}

	private bool EnsureSelf()
	{
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: 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)
		FirstPersonController val = (((Object)(object)Settings.Instance != (Object)null) ? Settings.Instance.localPlayer : null);
		if ((Object)(object)val == (Object)null || !((Component)val).gameObject.activeInHierarchy)
		{
			val = FindOwnBody();
		}
		if ((Object)(object)val == (Object)null || !((Component)val).gameObject.activeInHierarchy)
		{
			return false;
		}
		if ((Object)(object)val != (Object)(object)_self)
		{
			Unsubscribe();
			_self = val;
			_selfRoot = ((Component)val).transform.root;
			_pk = (((Object)(object)val.playerPickupScript != (Object)null) ? val.playerPickupScript : ((Component)val).GetComponentInChildren<PlayerPickup>());
			_hp = ((Component)val).GetComponent<PlayerHealth>() ?? ((Component)val).GetComponentInParent<PlayerHealth>();
			_bodies++;
			ResetSelf();
			Subscribe();
			_scanAt = 0f;
			Event($"SPAWN #{_bodies} at ({F1(((Component)val).transform.position.x)},{F1(((Component)val).transform.position.y)},{F1(((Component)val).transform.position.z)}), yaw {F1(((Component)val).transform.eulerAngles.y)}");
			if (_bodies == 1)
			{
				Event("PLAYER PARAMS: " + Fields(val, 80));
			}
			Event("MAP ITEMS: " + WorldItems());
		}
		return true;
	}

	private FirstPersonController FindOwnBody()
	{
		if (Time.time < _findAt)
		{
			return null;
		}
		_findAt = Time.time + 2f;
		ClientInstance instance = ClientInstance.Instance;
		FirstPersonController[] array = Object.FindObjectsOfType<FirstPersonController>();
		foreach (FirstPersonController val in array)
		{
			if (!((Object)(object)val == (Object)null) && ((Component)val).gameObject.activeInHierarchy && !Session.IsBot(val))
			{
				PlayerValues component = ((Component)val).GetComponent<PlayerValues>();
				if ((Object)(object)component != (Object)null && (Object)(object)instance != (Object)null && (Object)(object)component.sync___get_value_playerClient() == (Object)(object)instance)
				{
					return val;
				}
			}
		}
		return null;
	}

	private void ResetSelf()
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: 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_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		FirstPersonController self = _self;
		_wasGrounded = self.isGrounded;
		_wasSliding = false;
		_wasSlope = false;
		_wasCanWall = self.CanWallJump;
		_wasWallJumps = self.wallJumpsCount;
		_wasLadder = G(LadderR, self, fallback: false);
		_airSince = (_slideSince = (_canWallSince = (_groundedAt = Time.time)));
		_takeoffPos = (_prevPos = ((Component)self).transform.position);
		_prevPosT = Time.time;
		_vel = Vector3.zero;
		_pending = null;
		_leftGroundPending = false;
		_right = (_left = null);
		_rightAmmo = (_leftAmmo = int.MinValue);
		_prevHealth = -1f;
		_hsHist.Clear();
	}

	private void Subscribe()
	{
		if ((Object)(object)_pk == (Object)null)
		{
			return;
		}
		try
		{
			_aInteract = Get<InputAction>(InteractF, _pk, null);
			_aDrop = Get<InputAction>(DropF, _pk, null);
			_aChange = Get<InputAction>(ChangeF, _pk, null);
			_onInteract = delegate
			{
				KeyEvent("interact");
			};
			_onDrop = delegate
			{
				KeyEvent("drop");
			};
			_onChange = delegate
			{
				KeyEvent("switch");
			};
			if (_aInteract != null)
			{
				_aInteract.performed += _onInteract;
			}
			if (_aDrop != null)
			{
				_aDrop.performed += _onDrop;
			}
			if (_aChange != null)
			{
				_aChange.performed += _onChange;
			}
		}
		catch (Exception e)
		{
			Warn("subscribe", e);
		}
	}

	private void Unsubscribe()
	{
		try
		{
			if (_aInteract != null && _onInteract != null)
			{
				_aInteract.performed -= _onInteract;
			}
			if (_aDrop != null && _onDrop != null)
			{
				_aDrop.performed -= _onDrop;
			}
			if (_aChange != null && _onChange != null)
			{
				_aChange.performed -= _onChange;
			}
		}
		catch
		{
		}
		_aInteract = (_aDrop = (_aChange = null));
	}

	private void KeyEvent(string key)
	{
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		if (Session.Paused || _ev == null || (Object)(object)_self == (Object)null)
		{
			return;
		}
		try
		{
			Transform val = Cam();
			string text = "";
			if ((Object)(object)val != (Object)null && Ray(val.position, val.forward, 6f, out var best))
			{
				ItemBehaviour componentInParent = ((Component)((RaycastHit)(ref best)).collider).GetComponentInParent<ItemBehaviour>();
				text = (((Object)(object)componentInParent != (Object)null) ? (", looking at " + ItemName(((Component)componentInParent).gameObject) + " " + F1(((RaycastHit)(ref best)).distance) + " m away") : (", looking at " + ((Object)((RaycastHit)(ref best)).collider).name + " " + F1(((RaycastHit)(ref best)).distance) + " m away"));
			}
			Event("KEY " + key + ": holding " + ItemName(_right) + "/" + ItemName(_left) + ", speed " + F1(HSpeed()) + ", " + (_self.isGrounded ? "grounded" : ("airborne " + F2(Time.time - _airSince) + " s")) + text);
		}
		catch
		{
		}
	}

	private float HSpeed()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		Vector2 val = new Vector2(_vel.x, _vel.z);
		return ((Vector2)(ref val)).magnitude;
	}

	private void Detect()
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0484: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_075d: Unknown result type (might be due to invalid IL or missing references)
		//IL_075f: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_06be: Unknown result type (might be due to invalid IL or missing references)
		//IL_06bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_07fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_07fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0821: Unknown result type (might be due to invalid IL or missing references)
		//IL_096e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0970: Unknown result type (might be due to invalid IL or missing references)
		//IL_098a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a71: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a76: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a7b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a7f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a8b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aac: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ab0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ab5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cba: Unknown result type (might be due to invalid IL or missing references)
		//IL_0af9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0afb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0afd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b02: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b07: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ae4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ae8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cfa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cfb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c1f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c43: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f47: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f59: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f6b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f70: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f84: Unknown result type (might be due to invalid IL or missing references)
		//IL_10df: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ff7: Unknown result type (might be due to invalid IL or missing references)
		//IL_1126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e47: Unknown result type (might be due to invalid IL or missing references)
		//IL_1253: Unknown result type (might be due to invalid IL or missing references)
		//IL_120e: Unknown result type (might be due to invalid IL or missing references)
		FirstPersonController f = _self;
		CharacterController characterController = f.characterController;
		Vector3 position = ((Component)f).transform.position;
		float num = Time.time - _prevPosT;
		if (num > 0.0001f)
		{
			Vector3 val = (position - _prevPos) / num;
			_vel = (((Object)(object)characterController != (Object)null && ((Collider)characterController).enabled) ? characterController.velocity : val);
		}
		_prevPos = position;
		_prevPosT = Time.time;
		Vector3 vel = _vel;
		Vector2 val2 = new Vector2(vel.x, vel.z);
		float magnitude = ((Vector2)(ref val2)).magnitude;
		float y = ((Component)f).transform.eulerAngles.y;
		Transform val3 = Cam();
		float num2 = (((Object)(object)val3 != (Object)null) ? val3.eulerAngles.x : 0f);
		if (num2 > 180f)
		{
			num2 -= 360f;
		}
		Vector2 mv = Vector2.zero;
		try
		{
			if (f.move != null)
			{
				mv = f.move.ReadValue<Vector2>();
			}
		}
		catch
		{
		}
		float num3 = Read(f.jump);
		float num4 = Read(f.crouch);
		float num5 = Read(f.fire1);
		float num6 = Read(f.zoom);
		bool isGrounded = f.isGrounded;
		bool canWallJump = f.CanWallJump;
		int wallJumpsCount = f.wallJumpsCount;
		bool flag = G(LadderR, f, fallback: false);
		float num7 = G(SlideTimerR, f, 0f);
		SlopeSlide slopeSlideScript = f.slopeSlideScript;
		bool flag2 = (Object)(object)slopeSlideScript != (Object)null && (slopeSlideScript.isCrouchSlopeSliding || slopeSlideScript.isSteepSlopeSliding);
		bool crouchDown = num4 > 0.1f;
		bool flag3 = num3 > 0.1f;
		if (crouchDown && !_wasCrouch)
		{
			_crouchAt = Time.time;
		}
		if (flag3 && !_wasJump)
		{
			_jumpAt = Time.time;
		}
		Vector3 val4 = default(Vector3);
		((Vector3)(ref val4))..ctor(vel.x, 0f, vel.z);
		Vector3 val5 = Quaternion.Euler(0f, y, 0f) * Vector3.forward;
		if (_pending != null && Time.time >= _pending.At)
		{
			Event(_pending.Line + "; speed " + F1(_pending.SpeedBefore) + " -> " + F1(magnitude) + " m/s 0.15 s later");
			_pending = null;
		}
		_hsHist.Enqueue(new KeyValuePair<float, float>(Time.time, magnitude));
		while (_hsHist.Count > 0 && Time.time - _hsHist.Peek().Key > 0.12f)
		{
			_hsHist.Dequeue();
		}
		float num8 = magnitude;
		foreach (KeyValuePair<float, float> item in _hsHist)
		{
			if (item.Value < num8)
			{
				num8 = item.Value;
			}
		}
		if (magnitude - num8 > 7f && magnitude > 10f && Time.time - _slideSince > 0.15f && Time.time - _lastBoostAt > 0.5f)
		{
			_lastBoostAt = Time.time;
			_boosts++;
			Event($"BOOST {F1(num8)} -> {F1(magnitude)} m/s (3D {F1(((Vector3)(ref vel)).magnitude)}), vy {F1(vel.y)}, {Held()}, fire1={((num5 > 0.1f) ? 1 : 0)} aimStance={((num6 > 0.1f) ? 1 : 0)}, " + (isGrounded ? "grounded" : ("airborne " + F2(Time.time - _airSince) + " s")) + ", pitch " + F1(num2) + ", forceFactor " + F2(f.forceFactor) + ", last attack " + F2(Time.time - _lastAttackAt) + " s ago");
		}
		bool flag4 = num7 > _prevSlideTimer + 0.4f;
		_prevSlideTimer = num7;
		bool flag5 = f.IsSliding || (num7 > 0f && f.isCrouching);
		if (flag4 || (flag5 && !_wasSliding))
		{
			_slides++;
			_slideSince = Time.time;
			_slideStartPos = position;
			_slideStartSpeed = magnitude;
			_slideMax = magnitude;
			Event("SLIDE start: speed " + F1(magnitude) + ", " + (isGrounded ? "on the ground" : "airborne") + ", crouch pressed " + F2((_crouchAt >= 0f) ? (Time.time - _crouchAt) : (-1f)) + " s before, " + ((isGrounded && Time.time - _groundedAt < 0.3f) ? ("landed " + F2(Time.time - _groundedAt) + " s before, ") : "") + "headroom " + F1(Headroom(position)) + " m, wall ahead " + F1(Ahead(position, val5, 0.4f)) + " m, " + Inputs());
		}
		if (flag5)
		{
			_slideMax = Mathf.Max(_slideMax, magnitude);
		}
		if (!flag5 && _wasSliding)
		{
			_slideEndAt = Time.time;
			Event("SLIDE end: " + F2(Time.time - _slideSince) + " s, " + F1(Vector3.Distance(position, _slideStartPos)) + " m, speed " + F1(_slideStartSpeed) + " -> " + F1(magnitude) + " (max " + F1(_slideMax) + "), " + (isGrounded ? "still grounded" : "left the ground"));
		}
		if (flag2 && !_wasSlope)
		{
			_slopeSince = Time.time;
			_slopeStartPos = position;
			_slopeStartSpeed = magnitude;
			_slopeMax = magnitude;
			_slopeMax3 = ((Vector3)(ref vel)).magnitude;
			Ground(position, out var angle, out var downhill);
			Event("SLOPE SLIDE start (" + (slopeSlideScript.isSteepSlopeSliding ? "steep, no crouch needed" : "crouch") + "): speed " + F1(magnitude) + " (3D " + F1(((Vector3)(ref vel)).magnitude) + "), ground " + F1(angle) + " deg, " + ((downhill > 0.3f) ? "going downhill" : ((downhill < -0.3f) ? "going UPHILL" : "across the slope")) + " (" + F2(downhill) + "), " + Inputs());
		}
		if (flag2)
		{
			_slopeMax = Mathf.Max(_slopeMax, magnitude);
			_slopeMax3 = Mathf.Max(_slopeMax3, ((Vector3)(ref vel)).magnitude);
		}
		if (!flag2 && _wasSlope)
		{
			Event("SLOPE SLIDE end: " + F2(Time.time - _slopeSince) + " s, " + F1(Vector3.Distance(position, _slopeStartPos)) + " m, dy " + F1(position.y - _slopeStartPos.y) + ", speed " + F1(_slopeStartSpeed) + " -> " + F1(magnitude) + " (max " + F1(_slopeMax) + ", 3D max " + F1(_slopeMax3) + "), " + (isGrounded ? "still grounded" : "left the ground"));
		}
		if (canWallJump && !_wasCanWall)
		{
			_canWallSince = Time.time;
		}
		if (wallJumpsCount > _wasWallJumps)
		{
			_wallJumps++;
			Vector3 val6 = G<Vector3>(WallNormalR, f, Vector3.zero);
			Vector3 val7 = default(Vector3);
			((Vector3)(ref val7))..ctor(val6.x, 0f, val6.z);
			float num9 = ((((Vector3)(ref val7)).sqrMagnitude > 0.001f) ? Vector3.Angle(val5, -((Vector3)(ref val7)).normalized) : (-1f));
			float num10 = ((((Vector3)(ref val7)).sqrMagnitude > 0.001f && ((Vector3)(ref val4)).sqrMagnitude > 0.25f) ? Vector3.Angle(val4, -((Vector3)(ref val7)).normalized) : (-1f));
			float num11 = Vector3.Dot(Vector3.Cross(val5, -val7), Vector3.up);
			_pending = new PendingAfter
			{
				At = Time.time + 0.15f,
				SpeedBefore = magnitude,
				Line = string.Format("WALLJUMP #{0} of max {1}: view vs wall {2} deg ({3}), ", wallJumpsCount, f.maxWallJumps, F1(num9), (num9 < 0f) ? "?" : ((num9 < 15f) ? "facing the wall: climb" : ((num11 >= 0f) ? "wall on the left" : "wall on the right"))) + "velocity vs wall " + ((num10 < 0f) ? "n/a (not moving)" : (F1(num10) + " deg")) + ", wall touched " + F2(Time.time - _canWallSince) + " s before, airborne " + F2(Time.time - _airSince) + " s, " + F1(position.y - _takeoffPos.y) + " m above take-off, vy " + F1(vel.y) + ", " + Held() + ", " + Inputs()
			};
		}
		if (!isGrounded && _wasGrounded)
		{
			bool flag6 = (flag3 && Time.time - _jumpAt < 0.25f) || vel.y > 2f;
			if (flag6 || Time.time - _groundedAt > 0.1f)
			{
				_airSince = Time.time;
				_takeoffPos = position;
				_takeoffSpeed = magnitude;
			}
			if (flag6)
			{
				bool flag7 = _wasSliding || flag5 || _wasSlope || Time.time - _slideEndAt < 0.2f;
				if (flag7)
				{
					_slideJumps++;
				}
				else
				{
					_jumps++;
				}
				string text = (flag7 ? ("SLIDE JUMP " + F2(Time.time - (_wasSlope ? _slopeSince : _slideSince)) + " s into the " + (_wasSlope ? "slope slide" : "slide") + " (slide entry speed " + F1(_wasSlope ? _slopeStartSpeed : _slideStartSpeed) + ")") : "JUMP");
				_pending = new PendingAfter
				{
					At = Time.time + 0.15f,
					SpeedBefore = magnitude,
					Line = text + ": speed " + F1(magnitude) + ", vy " + F1(vel.y) + ", " + Held() + ", " + Inputs()
				};
				_leftGroundPending = false;
			}
			else
			{
				_leftGroundPending = true;
				_leftGroundSpeed = magnitude;
				_leftGroundInputs = Inputs();
			}
		}
		if (_leftGroundPending && !isGrounded && Time.time - _airSince > 0.12f)
		{
			_leftGroundPending = false;
			Event("LEFT GROUND (walked/slid off a ledge): speed " + F1(_leftGroundSpeed) + ", " + _leftGroundInputs);
		}
		if (isGrounded && !_wasGrounded)
		{
			_leftGroundPending = false;
			float num12 = Time.time - _airSince;
			_groundedAt = Time.time;
			val2 = new Vector2(position.x - _takeoffPos.x, position.z - _takeoffPos.z);
			float magnitude2 = ((Vector2)(ref val2)).magnitude;
			bool flag8 = magnitude2 < 0.3f && Mathf.Abs(position.y - _takeoffPos.y) < 0.3f && _takeoffSpeed < 0.5f && magnitude < 0.5f;
			if (num12 > 0.12f && !flag8)
			{
				Event($"LAND: {F2(num12)} s in the air, {F1(magnitude2)} m covered, dy {F1(position.y - _takeoffPos.y)}, take-off speed {F1(_takeoffSpeed)} -> landing speed {F1(magnitude)}, crouch={(crouchDown ? 1 : 0)}");
			}
		}
		bool flag9 = num5 > 0.1f;
		if (flag9 && !_wasFire)
		{
			_lastAttackAt = Time.time;
			P t = Nearest();
			Event("ATTACK with " + ItemName(_right) + ((f.isAiming || num6 > 0.1f) ? " (aim stance held: lunge / aimed shot)" : "") + ": speed " + F1(magnitude) + ", vy " + F1(vel.y) + ", " + (isGrounded ? "on the ground" : ("airborne " + F2(Time.time - _airSince) + " s, " + F1(position.y - _takeoffPos.y) + " m above take-off")) + ", pitch " + F1(num2) + ", stance held " + ((num6 > 0.1f) ? (F2(Time.time - _zoomAt) + " s") : "no") + TargetInfo(t));
			Reacted(t, "attack");
		}
		bool flag10 = num6 > 0.1f;
		if (flag10 && !_wasZoom)
		{
			_zoomAt = Time.time;
		}
		if (flag != _wasLadder)
		{
			Event(flag ? ("LADDER on: speed " + F1(magnitude) + ", " + Inputs()) : ("LADDER off: vy " + F1(vel.y) + ", " + Inputs()));
		}
		Items(position);
		Health();
		Stats();
		_wasGrounded = isGrounded;
		_wasSliding = flag5;
		_wasSlope = flag2;
		_wasCanWall = canWallJump;
		_wasWallJumps = wallJumpsCount;
		_wasLadder = flag;
		_wasCrouch = crouchDown;
		_wasJump = flag3;
		_wasFire = flag9;
		_wasZoom = flag10;
		string Held()
		{
			return "holding " + ItemName(_right);
		}
		string Inputs()
		{
			return $"input move=({F1(mv.x)},{F1(mv.y)}) sprintMode={(G(FuncSprintR, f, fallback: false) ? 1 : 0)} crouch={(crouchDown ? 1 : 0)}";
		}
	}

	private void Items(Vector3 pos)
	{
		//IL_0774: Unknown result type (might be due to invalid IL or missing references)
		//IL_0779: 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_027e: 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_0290: 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_04f1: 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_0371: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_pk == (Object)null)
		{
			return;
		}
		GameObject val = null;
		GameObject val2 = null;
		try
		{
			val = _pk.sync___get_value_objInHand();
			val2 = _pk.sync___get_value_objInLeftHand();
		}
		catch
		{
		}
		if ((Object)(object)val != (Object)null && !Object.op_Implicit((Object)(object)val))
		{
			val = null;
		}
		if ((Object)(object)val2 != (Object)null && !Object.op_Implicit((Object)(object)val2))
		{
			val2 = null;
		}
		int num = Ammo(val);
		int num2 = Ammo(val2);
		if ((Object)(object)val != (Object)null && (Object)(object)val == (Object)(object)_right && _rightAmmo != int.MinValue && num >= 0 && num < _rightAmmo)
		{
			Shot(val, "right", _rightAmmo - num, num);
		}
		if ((Object)(object)val2 != (Object)null && (Object)(object)val2 == (Object)(object)_left && _leftAmmo != int.MinValue && num2 >= 0 && num2 < _leftAmmo)
		{
			Shot(val2, "left", _leftAmmo - num2, num2);
		}
		if ((Object)(object)val != (Object)(object)_right || (Object)(object)val2 != (Object)(object)_left)
		{
			GameObject[] array = (GameObject[])(object)new GameObject[2] { _right, _left };
			GameObject[] array2 = (GameObject[])(object)new GameObject[2] { val, val2 };
			if ((Object)(object)val != (Object)null && (Object)(object)val == (Object)(object)_left && (Object)(object)val2 == (Object)(object)_right)
			{
				Event("SWITCH hands: right now " + ItemName(val) + ", left now " + ItemName(val2));
			}
			else
			{
				GameObject[] array3 = array;
				foreach (GameObject val3 in array3)
				{
					if (!((Object)(object)val3 == (Object)null) && !array2.Contains(val3))
					{
						bool flag = Object.op_Implicit((Object)(object)val3) && val3.activeInHierarchy && (Object)(object)((Component)val3.transform.root).GetComponentInChildren<FirstPersonController>() == (Object)null;
						if (flag)
						{
							_drops++;
							Dropped dropped = new Dropped
							{
								Go = val3,
								Name = ItemName(val3),
								At = Time.time,
								Pos = val3.transform.position,
								DropPos = val3.transform.position,
								Height = HeightAboveGround(val3)
							};
							_dropped.Add(dropped);
							Event(string.Format("DROP {0} (ammo {1}) from the {2} hand: speed {3}, {4}, ", dropped.Name, Ammo(val3), ((Object)(object)val3 == (Object)(object)_right) ? "right" : "left", F1(HSpeed()), _self.isGrounded ? "grounded" : ("airborne " + F2(Time.time - _airSince) + " s")) + "item " + F1(dropped.Height) + " m above the ground, " + F1(Vector3.Distance(dropped.Pos, pos)) + " m from you");
						}
						else
						{
							_lastGoneItem = ItemName(val3);
						}
						if (!flag)
						{
							Event("GONE " + ItemName(val3) + " from the " + (((Object)(object)val3 == (Object)(object)_right) ? "right" : "left") + " hand (thrown, used up, placed or broken)");
						}
					}
				}
				GameObject[] array4 = array2;
				foreach (GameObject nw in array4)
				{
					if (!((Object)(object)nw == (Object)null) && !array.Contains(nw))
					{
						_pickups++;
						Weapon component = nw.GetComponent<Weapon>();
						string text = "";
						Dropped dropped2 = _dropped.FirstOrDefault((Dropped x) => (Object)(object)x.Go == (Object)(object)nw);
						if (dropped2 != null)
						{
							text = ", RE-GRABBED own drop " + F2(Time.time - dropped2.At) + " s after dropping it (it was " + F1(dropped2.Height) + " m above the ground, moved " + F1(Vector3.Distance(dropped2.Pos, dropped2.DropPos)) + " m)";
							_dropped.Remove(dropped2);
						}
						Event(string.Format("PICKUP {0} into the {1} hand: ammo {2}", ItemName(nw), ((Object)(object)nw == (Object)(object)val) ? "right" : "left", Ammo(nw)) + (((Object)(object)component != (Object)null) ? $", maxWallJumps {component.maxWallJumps}, moveFactor {F2(component.movementFactor)}, jumpFactor {F2(component.jumpFactor)}, wallJumpFactor {F2(component.wallJumpFactor)}" : "") + ", speed " + F1(HSpeed()) + ", " + (_self.isGrounded ? "grounded" : "airborne") + text);
						string item = Map + "|" + ItemName(nw);
						if ((Object)(object)component != (Object)null && _dumpedWeapons.Add(item))
						{
							Event("WEAPON PARAMS " + ItemName(nw) + " (" + ((object)component).GetType().Name + "): " + Fields(component, 60));
						}
					}
				}
			}
			_right = val;
			_left = val2;
		}
		_rightAmmo = (((Object)(object)val != (Object)null) ? num : int.MinValue);
		_leftAmmo = (((Object)(object)val2 != (Object)null) ? num2 : int.MinValue);
		for (int num3 = _dropped.Count - 1; num3 >= 0; num3--)
		{
			Dropped dropped3 = _dropped[num3];
			if ((Object)(object)dropped3.Go == (Object)null || !Object.op_Implicit((Object)(object)dropped3.Go) || Time.time - dropped3.At > 4f)
			{
				_dropped.RemoveAt(num3);
			}
			else
			{
				dropped3.Pos = dropped3.Go.transform.position;
				dropped3.Height = HeightAboveGround(dropped3.Go);
			}
		}
	}

	private void Shot(GameObject go, string hand, int count, int left)
	{
		_shots += count;
		_lastShotAt = Time.time;
		_lastShotWeapon = ItemName(go);
		P p = Nearest();
		_lastShotErr = p?.AimErr ?? (-1f);
		Event(string.Format("SHOT {0} ({1}{2}, {3} left): speed {4}, {5}", ItemName(go), hand, (count > 1) ? $", {count} ammo" : "", left, F1(HSpeed()), _self.isGrounded ? "grounded" : ("airborne " + F2(Time.time - _airSince) + " s")) + string.Format("{0}, aiming={1}{2}", (_wasSliding || _wasSlope) ? ", sliding" : "", _self.isAiming ? 1 : 0, TargetInfo(p)));
		Reacted(p, "shot");
	}

	private void Stats()
	{
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		if (_statsNow == null)
		{
			_statsNow = new float[StatNames.Length];
		}
		if (!ReadStats(_statsNow))
		{
			return;
		}
		float[] statsNow = _statsNow;
		if (_stats == null)
		{
			_stats = (float[])statsNow.Clone();
			return;
		}
		for (int i = 0; i < 17; i++)
		{
			int num = Mathf.RoundToInt(statsNow[i] - _stats[i]);
			if (num > 0)
			{
				P p = NearestVisible() ?? Nearest();
				object obj;
				if (p == null)
				{
					obj = "";
				}
				else
				{
					string[] obj2 = new string[11]
					{
						", nearest ",
						p.Label,
						" ",
						F1(p.Dist),
						" m, aim ",
						F1(p.AimErr),
						" deg off head / ",
						F1(p.AimErrChest),
						" off chest, they move ",
						null,
						null
					};
					Vector2 val = new Vector2(p.Vel.x, p.Vel.z);
					obj2[9] = F1(((Vector2)(ref val)).magnitude);
					obj2[10] = " m/s";
					obj = string.Concat(obj2);
				}
				string text = (string)obj;
				float v = Mathf.Min(Time.time - _lastShotAt, Time.time - _lastAttackAt);
				string text2 = (((Object)(object)_right != (Object)null) ? ItemName(_right) : (_lastGoneItem + " (thrown/placed)"));
				string text3 = (_others.Any((P o) => o.Label != null && o.Label.StartsWith("bot")) ? " [offline bots run on your PC, so this counter may be the bot's]" : "");
				string text4 = "you " + F1(HSpeed()) + " m/s " + (_self.isGrounded ? "grounded" : ("airborne " + F2(Time.time - _airSince) + " s")) + ((_wasSliding || _wasSlope) ? " sliding" : "");
				switch (StatNames[i])
				{
				case "headshotsAmount":
					_headshots += num;
					Event($"HIT HEAD x{num} with {text2} ({F2(v)} s after your last shot/attack): {text4}{text}");
					break;
				case "bodyshotsAmount":
					_bodyshots += num;
					Event($"HIT BODY x{num} with {text2} ({F2(v)} s after your last shot/attack): {text4}{text}");
					break;
				case "killsAmount":
					Event("KILL (game counter) with " + text2 + ": " + text4 + text + text3);
					break;
				case "deathsAmount":
					Event("DEATH (game counter)" + text3);
					break;
				case "suicidesAmount":
					Event("SUICIDE (game counter: fall, own explosive...)" + text3);
					break;
				case "noscope":
					Event("NOSCOPE (game counter)");
					break;
				case "rocketJumps":
					Event("ROCKET JUMP (game counter): " + text4 + ", vy " + F1(_vel.y));
					break;
				default:
					Event($"COUNTER {StatNames[i]} +{num}");
					break;
				}
			}
		}
		_statsNow = _stats;
		_stats = statsNow;
	}

	private void Health()
	{
		float num = HealthOf(_hp);
		if (_prevHealth >= 0f && num >= 0f && num < _prevHealth - 0.01f)
		{
			P p = NearestVisible() ?? Nearest();
			Event("DAMAGE TAKEN " + F1(_prevHealth - num) + " (" + F1(num) + " left): you " + F1(HSpeed()) + " m/s " + (_self.isGrounded ? "grounded" : "airborne") + ((_wasSliding || _wasSlope) ? " sliding" : "") + ((p != null) ? (", nearest " + p.Label + " " + F1(p.Dist) + " m holding " + p.Item + ", " + (p.Visible ? "in view" : "not in view") + ", their aim " + F1(p.AimsAtMe) + " deg off you") : ", nobody around (fall/hazard)"));
			if (num <= 0f)
			{
				Event("DIED");
			}
		}
		_prevHealth = num;
	}

	private static float HealthOf(PlayerHealth ph)
	{
		if ((Object)(object)ph == (Object)null)
		{
			return -1f;
		}
		try
		{
			return ph.sync___get_value_health();
		}
		catch
		{
			return ph.health;
		}
	}

	private void ScanPlayers()
	{
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		_found.Clear();
		try
		{
			foreach (ClientInstance value in ClientInstance.playerInstances.Values)
			{
				FirstPersonController val = (((Object)(object)value != (Object)null && (Object)(object)value.PlayerSpawner != (Object)null) ? value.PlayerSpawner.player : null);
				if ((Object)(object)val != (Object)null && Object.op_Implicit((Object)(object)val))
				{
					_found.Add(val);
				}
			}
		}
		catch
		{
		}
		if (_found.Count == 0 || Time.time >= _fullScanAt)
		{
			_fullScanAt = Time.time + 20f;
			FirstPersonController[] array = Object.FindObjectsOfType<FirstPersonController>();
			foreach (FirstPersonController item in array)
			{
				if (!_found.Contains(item))
				{
					_found.Add(item);
				}
			}
		}
		_others.RemoveAll((P p2) => (Object)(object)p2.F == (Object)null || !Object.op_Implicit((Object)(object)p2.F) || (Object)(object)p2.F == (Object)(object)_self);
		foreach (FirstPersonController f in _found)
		{
			if (!((Object)(object)f == (Object)null) && !((Object)(object)f == (Object)(object)_self) && !_others.Any((P p2) => (Object)(object)p2.F == (Object)(object)f))
			{
				PlayerValues component = ((Component)f).GetComponent<PlayerValues>();
				ClientInstance val2 = null;
				try
				{
					val2 = (((Object)(object)component != (Object)null) ? component.sync___get_value_playerClient() : null);
				}
				catch
				{
				}
				if (!((Object)(object)val2 == (Object)null) && (!((Object)(object)ClientInstance.Instance != (Object)null) || !((Object)(object)val2 == (Object)(object)ClientInstance.Instance)))
				{
					P p = new P
					{
						F = f,
						Id = val2.PlayerId,
						H = ((Component)f).GetComponent<PlayerHealth>(),
						Pk = (((Object)(object)f.playerPickupScript != (Object)null) ? f.playerPickupScript : ((Component)f).GetComponentInChildren<PlayerPickup>()),
						PrevPos = ((Component)f).transform.position,
						PrevPosT = Time.time
					};
					p.Label = Session.Label(p.Id, f);
					_others.Add(p);
				}
			}
		}
	}

	private void UpdateOthers()
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0335: 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)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: 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_03fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0545: Unknown result type (might be due to invalid IL or missing references)
		//IL_054a: Unknown result type (might be due to invalid IL or missing references)
		//IL_080c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0811: Unknown result type (might be due to invalid IL or missing references)
		Transform val = Cam();
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		Vector3 position = val.position;
		Vector3 val2 = position;
		foreach (P other in _others)
		{
			if ((Object)(object)other.F == (Object)null || !Object.op_Implicit((Object)(object)other.F))
			{
				continue;
			}
			Vector3 position2 = ((Component)other.F).transform.position;
			float num = Time.time - other.PrevPosT;
			if (num > 0.0001f)
			{
				other.Vel = Vector3.Lerp(other.Vel, (position2 - other.PrevPos) / num, 0.6f);
			}
			other.PrevPos = position2;
			other.PrevPosT = Time.time;
			bool flag = ((Component)other.F).gameObject.activeInHierarchy && HealthOf(other.H) > 0f;
			Vector3 val3 = Head(other.F);
			Vector3 val4 = Chest(other.F);
			other.Dist = Vector3.Distance(position, val4);
			other.AimErr = Vector3.Angle(val.forward, val3 - position);
			other.AimErrChest = Vector3.Angle(val.forward, val4 - position);
			Transform val5 = (((Object)(object)other.F.playerCamera != (Object)null) ? ((Component)other.F.playerCamera).transform : ((Component)other.F).transform);
			other.AimsAtMe = Vector3.Angle(val5.forward, val2 - val5.position);
			other.Item = "-";
			GameObject val6 = null;
			try
			{
				if ((Object)(object)other.Pk != (Object)null)
				{
					val6 = other.Pk.sync___get_value_objInHand();
				}
			}
			catch
			{
			}
			if ((Object)(object)val6 != (Object)null && !Object.op_Implicit((Object)(object)val6))
			{
				val6 = null;
			}
			other.Item = ItemName(val6);
			int num2 = Ammo(val6);
			Vector2 val7;
			if ((Object)(object)val6 != (Object)null && (Object)(object)val6 == (Object)(object)other.ItemGo && other.ItemAmmo != int.MinValue && num2 >= 0 && num2 < other.ItemAmmo)
			{
				other.Shots += other.ItemAmmo - num2;
				_oppShots += other.ItemAmmo - num2;
				string[] obj2 = new string[8]
				{
					string.Format("OPP SHOT {0} {1} ({2} left): their aim {3} deg off your head, {4} m, {5}, ", other.Label, other.Item, num2, F1(other.AimsAtMe), F1(other.Dist), other.Visible ? "in your view" : "out of your view"),
					"them ",
					null,
					null,
					null,
					null,
					null,
					null
				};
				val7 = new Vector2(other.Vel.x, other.Vel.z);
				obj2[2] = F1(((Vector2)(ref val7)).magnitude);
				obj2[3] = " m/s, you ";
				obj2[4] = F1(HSpeed());
				obj2[5] = " m/s ";
				obj2[6] = (_self.isGrounded ? "grounded" : "airborne");
				obj2[7] = ((_wasSliding || _wasSlope) ? " sliding" : "");
				Event(string.Concat(obj2));
			}
			other.ItemGo = val6;
			other.ItemAmmo = (((Object)(object)val6 != (Object)null) ? num2 : int.MinValue);
			bool flag2 = flag && Mathf.Min(other.AimErr, other.AimErrChest) < 55f && (LineOfSight(position, val3, other.F) || LineOfSight(position, val4, other.F));
			if (flag2 != other.Visible)
			{
				if (flag2 && Time.time - other.VisibleChangedAt > 0.6f)
				{
					other.SeenAt = Time.time;
					other.SeenErr = other.AimErr;
					other.ReactShot = (other.ReactAim = false);
					string[] obj3 = new string[17]
					{
						"SEEN ",
						other.Label,
						": ",
						F1(other.Dist),
						" m, your aim ",
						F1(other.AimErr),
						" deg off their head, they hold ",
						other.Item,
						", their aim ",
						F1(other.AimsAtMe),
						" deg off you, you hold ",
						ItemName(_right),
						", you ",
						F1(HSpeed()),
						" m/s, them ",
						null,
						null
					};
					val7 = new Vector2(other.Vel.x, other.Vel.z);
					obj3[15] = F1(((Vector2)(ref val7)).magnitude);
					obj3[16] = " m/s";
					Event(string.Concat(obj3));
				}
				other.Visible = flag2;
				other.VisibleChangedAt = Time.time;
			}
			if (other.Visible && other.SeenAt > 0f && !other.ReactAim && Mathf.Min(other.AimErr, other.AimErrChest) < 4f && Time.time - other.SeenAt < 3f)
			{
				other.ReactAim = true;
				Event("ON TARGET " + other.Label + ": crosshair within 4 deg " + F2(Time.time - other.SeenAt) + " s after seeing them (started " + F1(other.SeenErr) + " deg off, " + F1(other.Dist) + " m)");
			}
			float num3 = HealthOf(other.H);
			if (other.PrevHealth >= 0f && num3 >= 0f && num3 < other.PrevHealth - 0.01f)
			{
				float num4 = Mathf.Min(Time.time - _lastShotAt, Time.time - _lastAttackAt);
				bool flag3 = num4 < 0.6f;
				if (flag3)
				{
					_hitsDealt++;
				}
				string[] obj4 = new string[18]
				{
					"DAMAGE ",
					other.Label,
					" ",
					F1(other.PrevHealth - num3),
					" (",
					F1(num3),
					" left)",
					flag3 ? (" after your " + ((Time.time - _lastShotAt <= Time.time - _lastAttackAt) ? (_lastShotWeapon + " shot") : "attack") + " " + F2(num4) + " s earlier") : " (not right after your shot: someone else / hazard / fall)",
					", ",
					F1(other.Dist),
					" m, your aim was ",
					F1(_lastShotErr),
					" deg off their head at the shot, you ",
					F1(HSpeed()),
					" m/s, them ",
					null,
					null,
					null
				};
				val7 = new Vector2(other.Vel.x, other.Vel.z);
				obj4[15] = F1(((Vector2)(ref val7)).magnitude);
				obj4[16] = " m/s";
				obj4[17] = ((num3 <= 0f) ? ", KILLED" : "");
				Event(string.Concat(obj4));
			}
			other.PrevHealth = num3;
		}
	}

	private void Reacted(P t, string what)
	{
		if (t != null && t.Visible && !(t.SeenAt < 0f) && !t.ReactShot && !(Time.time - t.SeenAt > 3f))
		{
			t.ReactShot = true;
			Event("REACTION " + t.Label + ": first " + what + " " + F2(Time.time - t.SeenAt) + " s after seeing them, aim " + F1(t.AimErr) + " deg off (started " + F1(t.SeenErr) + "), " + F1(t.Dist) + " m");
		}
	}

	private P Nearest()
	{
		P p = null;
		foreach (P other in _others)
		{
			if ((Object)(object)other.F != (Object)null && Object.op_Implicit((Object)(object)other.F) && ((Component)other.F).gameObject.activeInHierarchy && HealthOf(other.H) > 0f && (p == null || other.Dist < p.Dist))
			{
				p = other;
			}
		}
		return p;
	}

	private P NearestVisible()
	{
		P p = null;
		foreach (P other in _others)
		{
			if (other.Visible && (p == null || other.Dist < p.Dist))
			{
				p = other;
			}
		}
		return p;
	}

	private string TargetInfo(P t)
	{
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		if (t == null)
		{
			return ", nobody around";
		}
		string[] obj = new string[13]
		{
			", nearest ",
			t.Label,
			" ",
			F1(t.Dist),
			" m ",
			t.Visible ? "in view" : "out of view",
			", aim ",
			F1(t.AimErr),
			" deg off head / ",
			F1(t.AimErrChest),
			" off chest, they move ",
			null,
			null
		};
		Vector2 val = new Vector2(t.Vel.x, t.Vel.z);
		obj[11] = F1(((Vector2)(ref val)).magnitude);
		obj[12] = " m/s";
		return string.Concat(obj);
	}

	private static Vector3 Head(FirstPersonController p)
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		return ((Object)(object)p.playerCamera != (Object)null) ? ((Component)p.playerCamera).transform.position : (((Component)p).transform.position + Vector3.up * (Height(p) * 0.9f));
	}

	private static Vector3 Chest(FirstPersonController p)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		return ((Component)p).transform.position + Vector3.up * (Height(p) * 0.62f);
	}

	private static float Height(FirstPersonController p)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		CharacterController characterController = p.characterController;
		return ((Object)(object)characterController != (Object)null) ? (characterController.height * ((Component)characterController).transform.lossyScale.y) : 2f;
	}

	private bool LineOfSight(Vector3 from, Vector3 to, FirstPersonController target)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: 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_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = to - from;
		float magnitude = ((Vector3)(ref val)).magnitude;
		if (magnitude < 0.01f)
		{
			return true;
		}
		int num = Physics.RaycastNonAlloc(from, val / magnitude, Hits, magnitude, -5, (QueryTriggerInteraction)1);
		for (int i = 0; i < num; i++)
		{
			Transform root = ((Component)((RaycastHit)(ref Hits[i])).collider).transform.root;
			if (!((Object)(object)root == (Object)(object)_selfRoot) && !((Object)(object)root == (Object)(object)((Component)target).transform.root) && !((Object)(object)((Component)((RaycastHit)(ref Hits[i])).collider).GetComponentInParent<ItemBehaviour>() != (Object)null))
			{
				return false;
			}
		}
		return true;
	}

	private Transform Cam()
	{
		return ((Object)(object)_self != (Object)null && (Object)(object)_self.playerCamera != (Object)null) ? ((Component)_self.playerCamera).transform : null;
	}

	private bool Ray(Vector3 o, Vector3 d, float len, out RaycastHit best)
	{
		//IL_0003: 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_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		best = default(RaycastHit);
		int num = Physics.RaycastNonAlloc(o, d, Hits, len, -5, (QueryTriggerInteraction)1);
		float num2 = float.MaxValue;
		bool result = false;
		for (int i = 0; i < num; i++)
		{
			if (!((Object)(object)((Component)((RaycastHit)(ref Hits[i])).collider).transform.root == (Object)(object)_selfRoot) && ((RaycastHit)(ref Hits[i])).distance < num2)
			{
				num2 = ((RaycastHit)(ref Hits[i])).distance;
				best = Hits[i];
				result = true;
			}
		}
		return result;
	}

	private float Headroom(Vector3 pos)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: 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_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		RaycastHit best;
		return Ray(pos + Vector3.up * 0.3f, Vector3.up, 4f, out best) ? (((RaycastHit)(ref best)).distance + 0.3f) : 9f;
	}

	private float Ahead(Vector3 pos, Vector3 fwd, float height)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		RaycastHit best;
		return Ray(pos + Vector3.up * height, fwd, 6f, out best) ? ((RaycastHit)(ref best)).distance : 9f;
	}

	private void Ground(Vector3 pos, out float angle, out float downhill)
	{
		//IL_0010: 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_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		angle = -1f;
		downhill = 0f;
		if (Ray(pos + Vector3.up * 0.5f, Vector3.down, 3f, out var best))
		{
			angle = Vector3.Angle(((RaycastHit)(ref best)).normal, Vector3.up);
			Vector3 val = Vector3.ProjectOnPlane(Vector3.down, ((RaycastHit)(ref best)).normal);
			val.y = 0f;
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(_vel.x, 0f, _vel.z);
			if (angle > 2f && ((Vector3)(ref val)).sqrMagnitude > 0.0001f && ((Vector3)(ref val2)).sqrMagnitude > 0.25f)
			{
				downhill = Vector3.Dot(((Vector3)(ref val)).normalized, ((Vector3)(ref val2)).normalized);
			}
		}
	}

	private float HeightAboveGround(GameObject item)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		Transform transform = item.transform;
		int num = Physics.RaycastNonAlloc(transform.position + Vector3.up * 0.05f, Vector3.down, Hits, 50f, -5, (QueryTriggerInteraction)1);
		float num2 = 99f;
		for (int i = 0; i < num; i++)
		{
			Collider collider = ((RaycastHit)(ref Hits[i])).collider;
			if (!((Component)collider).transform.IsChildOf(transform) && !((Object)(object)((Component)collider).transform.root == (Object)(object)_selfRoot))
			{
				num2 = Mathf.Min(num2, ((RaycastHit)(ref Hits[i])).distance - 0.05f);
			}
		}
		return num2;
	}

	private void WriteRow()
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: 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_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0472: Unknown result type (might be due to invalid IL or missing references)
		//IL_0491: Unknown result type (might be due to invalid IL or missing references)
		//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ff: 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_051a: Unknown result type (might be due to invalid IL or missing references)
		//IL_051b: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0738: Unknown result type (might be due to invalid IL or missing references)
		//IL_0784: Unknown result type (might be due to invalid IL or missing references)
		//IL_079c: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_083d: Unknown result type (might be due to invalid IL or missing references)
		FirstPersonController self = _self;
		Vector3 vel = _vel;
		Vector3 position = ((Component)self).transform.position;
		float now = Now;
		if (_lastRowAt >= 0f)
		{
			SampledSeconds += Mathf.Min(now - _lastRowAt, 0.5f);
		}
		_lastRowAt = now;
		_rows++;
		Transform val = Cam();
		float num = (((Object)(object)val != (Object)null) ? val.eulerAngles.x : 0f);
		if (num > 180f)
		{
			num -= 360f;
		}
		Vector2 val2 = Vector2.zero;
		try
		{
			if (self.move != null)
			{
				val2 = self.move.ReadValue<Vector2>();
			}
		}
		catch
		{
		}
		SlopeSlide slopeSlideScript = self.slopeSlideScript;
		bool canWallJump = self.CanWallJump;
		Vector3 val3 = (canWallJump ? G<Vector3>(WallNormalR, self, Vector3.zero) : Vector3.zero);
		Vector3 fwd = Quaternion.Euler(0f, ((Component)self).transform.eulerAngles.y, 0f) * Vector3.forward;
		Ground(position, out var angle, out var downhill);
		StringBuilder sb = _row;
		sb.Length = 0;
		A(F(now));
		A(F(position.x));
		A(F(position.y));
		A(F(position.z));
		A(F(vel.x));
		A(F(vel.y));
		A(F(vel.z));
		A(F(((Vector3)(ref vel)).magnitude));
		Vector2 val4 = new Vector2(vel.x, vel.z);
		A(F(((Vector2)(ref val4)).magnitude));
		B(self.isGrounded);
		A(F1(((Component)self).transform.eulerAngles.y));
		A(F1(num));
		A(F(val2.x));
		A(F(val2.y));
		A(F(Read(self.jump)));
		A(F(Read(self.run)));
		B(G(FuncSprintR, self, fallback: false));
		A(F(Read(self.crouch)));
		A(F(Read(self.leanLeft)));
		A(F(Read(self.leanRight)));
		A(F(Read(self.fire1)));
		A(F(Read(self.fire2)));
		A(F(Read(self.zoom)));
		A(F(Read(self.reload)));
		B(self.isSprinting);
		B(self.isCrouching);
		B(self.isAiming);
		B(self.IsSliding);
		A(F(G(SlideTimerR, self, 0f)));
		A(F(G(SlideResetR, self, 0f)));
		B((Object)(object)slopeSlideScript != (Object)null && slopeSlideScript.isCrouchSlopeSliding);
		B((Object)(object)slopeSlideScript != (Object)null && slopeSlideScript.isSteepSlopeSliding);
		B((Object)(object)slopeSlideScript != (Object)null && (slopeSlideScript.onIce || slopeSlideScript.onSuperIce));
		B(canWallJump);
		A(self.wallJumpsCount.ToString());
		A(self.maxWallJumps.ToString());
		A(canWallJump ? F(val3.x) : "");
		A(canWallJump ? F(val3.z) : "");
		B(G(LadderR, self, fallback: false));
		A(F(self.forceFactor));
		A(F1(angle));
		A(F2(downhill));
		A(F1(Headroom(position)));
		A(F1(Ahead(position, fwd, 0.4f)));
		A(F1(Ahead(position, fwd, 1.5f)));
		A(F1(HealthOf(_hp)));
		A(ItemName(_right));
		A(((Object)(object)_right != (Object)null) ? Ammo(_right).ToString() : "");
		A(ItemName(_left));
		A(((Object)(object)_left != (Object)null) ? Ammo(_left).ToString() : "");
		sb.Append(F2(Time.timeScale));
		List<P> slots = _slots;
		slots.Clear();
		foreach (P other in _others)
		{
			if ((Object)(object)other.F != (Object)null && Object.op_Implicit((Object)(object)other.F))
			{
				slots.Add(other);
			}
		}
		slots.Sort(ByDist);
		if (slots.Count > TelemetryPlugin.MaxOpponents.Value)
		{
			slots.RemoveRange(TelemetryPlugin.MaxOpponents.Value, slots.Count - TelemetryPlugin.MaxOpponents.Value);
		}
		for (int i = 0; i < TelemetryPlugin.MaxOpponents.Value; i++)
		{
			if (i >= slots.Count)
			{
				sb.Append(new string(',', 17));
				continue;
			}
			P p = slots[i];
			Vector3 position2 = ((Component)p.F).transform.position;
			Transform val5 = (((Object)(object)p.F.playerCamera != (Object)null) ? ((Component)p.F.playerCamera).transform : null);
			float num2 = (((Object)(object)val5 != (Object)null) ? val5.eulerAngles.x : 0f);
			if (num2 > 180f)
			{
				num2 -= 360f;
			}
			sb.Append(',').Append(p.Label);
			sb.Append(',').Append(F(position2.x)).Append(',')
				.Append(F(position2.y))
				.Append(',')
				.Append(F(position2.z));
			sb.Append(',').Append(F(p.Vel.x)).Append(',')
				.Append(F(p.Vel.y))
				.Append(',')
				.Append(F(p.Vel.z));
			sb.Append(',').Append(F1(((Component)p.F).transform.eulerAngles.y)).Append(',')
				.Append(F1(num2))
				.Append(',')
				.Append(F2(Height(p.F)));
			sb.Append(',').Append(F1(HealthOf(p.H))).Append(',')
				.Append(p.Item)
				.Append(',')
				.Append(p.Visible ? '1' : '0');
			sb.Append(',').Append(F1(p.Dist)).Append(',')
				.Append(F1(p.AimErr))
				.Append(',')
				.Append(F1(p.AimErrChest))
				.Append(',')
				.Append(F1(p.AimsAtMe));
		}
		_csv.WriteLine(sb.ToString());
		void A(string s)
		{
			sb.Append(s).Append(',');
		}
		void B(bool b)
		{
			sb.Append(b ? '1' : '0').Append(',');
		}
	}

	private static string ItemName(GameObject go)
	{
		if ((Object)(object)go == (Object)null || !Object.op_Implicit((Object)(object)go))
		{
			return "-";
		}
		int instanceID = ((Object)go).GetInstanceID();
		if (NameCache.TryGetValue(instanceID, out var value))
		{
			return value;
		}
		if (NameCache.Count > 2000)
		{
			NameCache.Clear();
		}
		string text = ItemNameRaw(go);
		NameCache[instanceID] = text;
		return text;
	}

	private static string ItemNameRaw(GameObject go)
	{
		string text = null;
		try
		{
			ItemBehaviour component = go.GetComponent<ItemBehaviour>();
			if ((Object)(object)component != (Object)null)
			{
				text = component.weaponName;
			}
		}
		catch
		{
		}
		if (string.IsNullOrEmpty(text))
		{
			text = ((Object)go).name.Replace("(Clone)", "");
		}
		return text.Trim().Replace(',', ' ').Replace(' ', '_');
	}

	private static int Ammo(GameObject go)
	{
		if ((Object)(object)go == (Object)null || !Object.op_Implicit((Object)(object)go))
		{
			return -1;
		}
		try
		{
			Weapon component = go.GetComponent<Weapon>();
			return ((Object)(object)component != (Object)null) ? component.sync___get_value_currentAmmo() : (-1);
		}
		catch
		{
			return -1;
		}
	}

	private static bool IsPersonalSetting(string name)
	{
		string text = name.ToLowerInvariant();
		return text.Contains("lookspeed") || text.Contains("sensitiv") || text.Contains("fov") || text.Contains("mouse");
	}

	private static string Fields(object o, int max)
	{
		StringBuilder stringBuilder = new StringBuilder();
		int num = 0;
		FieldInfo[] fields = o.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public);
		foreach (FieldInfo fieldInfo in fields)
		{
			if (num >= max)
			{
				break;
			}
			if ((!(fieldInfo.FieldType != typeof(float)) || !(fieldInfo.FieldType != typeof(int)) || !(fieldInfo.FieldType != typeof(bool))) && !fieldInfo.Name.StartsWith("syncVar", StringComparison.Ordinal) && !fieldInfo.Name.Contains("<") && !IsPersonalSetting(fieldInfo.Name))
			{
				object value;
				try
				{
					value = fieldInfo.GetValue(o);
				}
				catch
				{
					continue;
				}
				stringBuilder.Append(fieldInfo.Name).Append('=').Append((value is float v) ? F(v) : ((!(value is bool)) ? value.ToString() : (((bool)value) ? "1" : "0")))
					.Append(' ');
				num++;
			}
		}
		return stringBuilder.ToString().TrimEnd(Array.Empty<char>());
	}

	private string WorldItems()
	{
		try
		{
			List<string> list = (from w in (from w in Object.FindObjectsOfType<Weapon>()
					where (Object)(object)w != (Object)null && ((Component)w).gameObject.activeInHierarchy && (Object)(object)((Component)((Component)w).transform.root).GetComponentInChildren<FirstPersonController>() == (Object)null
					select w).Take(80)
				select ItemName(((Component)w).gameObject) + "@(" + F1(((Component)w).transform.position.x) + "," + F1(((Component)w).transform.position.y) + "," + F1(((Component)w).transform.position.z) + ")").ToList();
			return (list.Count == 0) ? "none" : ($"{list.Count}: " + string.Join(" ", list));
		}
		catch (Exception ex)
		{
			return "? (" + ex.Message + ")";
		}
	}

	private static string MapFeatures()
	{
		List<string> parts = new List<string>();
		Count<GravityZone>("gravity zones");
		Count<ForceZone>("force zones");
		Count<ImpulseZone>("impulse zones");
		Count<WallJumpZone>("walljump zones");
		Count<FlingTrigger>("fling triggers");
		Count<Teleporter>("teleporters");
		Count<MovingPlatform>("moving platforms");
		Count<ShatterableGlass>("breakable glass");
		Count<PhysicsProp>("physics props");
		Count<ItemSpawner>("item spawners");
		Count<ItemDispenser>("dispensers");
		Count<DamageZone>("damage zones");
		Count<Door>("doors");
		return (parts.Count == 0) ? "no special zones" : string.Join(", ", parts);
		void Count<T>(string label) where T : Object
		{
			try
			{
				int num = Object.FindObjectsOfType<T>().Length;
				if (num > 0)
				{
					parts.Add($"{label} {num}");
				}
			}
			catch
			{
			}
		}
	}

	public string SummaryLine()
	{
		return $"#{_index} {Map}: {SampledSeconds:F0} s, {_rows} rows, {_events} events, {_bodies} spawns, {_slides} slides, {_slideJumps} slide jumps, {_wallJumps} walljumps, {_jumps} jumps, " + $"{_boosts} boosts, {_shots} shots, {_headshots} head hits + {_bodyshots} body hits (game counters), {_hitsDealt} damage events right after a shot, {_oppShots} shots by others, {_pickups} pickups, {_drops} drops";
	}

	public void Close(string why)
	{
		Unsubscribe();
		try
		{
			_ev?.WriteLine();
			_ev?.WriteLine("Summary (" + why + "): " + SummaryLine());
		}
		catch
		{
		}
		try
		{
			_csv?.Dispose();
		}
		catch
		{
		}
		try
		{
			_ev?.Dispose();
		}
		catch
		{
		}
		_csv = (_ev = null);
	}
}
internal static class Session
{
	internal static class Cost
	{
		private class Sec
		{
			public double Sum;

			public double Max;

			public long N;

			public long Over1;
		}

		private static readonly double TickMs = 1000.0 / (double)Stopwatch.Frequency;

		private static long _frames;

		private static long _over05;

		private static long _over1;

		private static long _over2;

		private static double _sum;

		private static double _max;

		private static int _gc0;

		private static readonly Dictionary<string, Sec> Sections = new Dictionary<string, Sec>();

		public static void Reset()
		{
			_frames = (_over05 = (_over1 = (_over2 = 0L)));
			_sum = (_max = 0.0);
			_gc0 = GC.CollectionCount(0);
			Sections.Clear();
		}

		public static long Now()
		{
			return Stopwatch.GetTimestamp();
		}

		public static long Section(string name, long since)
		{
			long num = Now();
			double num2 = (double)(num - since) * TickMs;
			if (!Sections.TryGetValue(name, out var value))
			{
				value = (Sections[name] = new Sec());
			}
			value.Sum += num2;
			value.N++;
			if (num2 > value.Max)
			{
				value.Max = num2;
			}
			if (num2 > 1.0)
			{
				value.Over1++;
			}
			return num;
		}

		public static void Add(long ticks)
		{
			double num = (double)ticks * TickMs;
			_frames++;
			_sum += num;
			if (num > _max)
			{
				_max = num;
			}
			if (num > 0.5)
			{
				_over05++;
			}
			if (num > 1.0)
			{
				_over1++;
			}
			if (num > 2.0)
			{
				_over2++;
			}
		}

		public static string Summary()
		{
			if (_frames == 0)
			{
				return "recorder cost: no frames";
			}
			return string.Format(CultureInfo.InvariantCulture, "recorder cost per frame: avg {0:0.000} ms, max {1:0.00} ms, frames over 0.5/1/2 ms: {2}/{3}/{4} of {5}; garbage collections in the whole game during the match: {6}", _sum / (double)_frames, _max, _over05, _over1, _over2, _frames, GC.CollectionCount(0) - _gc0) + "\n  by part: " + string.Join("; ", from k in Sections
				orderby k.Value.Sum descending
				select string.Format(CultureInfo.InvariantCulture, "{0} avg {1:0.000} ms (max {2:0.00}, {3} over 1 ms, {4} runs)", k.Key, k.Value.Sum / (double)Math.Max(1L, k.Value.N), k.Value.Max, k.Value.Over1, k.Value.N));
		}
	}

	private static string _folder;

	private static string _stamp;

	private static Sampler _seg;

	private static int _segIndex;

	private static int _marks;

	private static readonly List<string> SegmentLines = new List<string>();

	private static readonly List<string> Maps = new List<string>();

	private static float _sampledSeconds;

	private static DateTime _startedAt;

	private static readonly Dictionary<int, string> Labels = new Dictionary<int, string>();

	private static int _opps;

	private static int _mates;

	private static int _bots;

	private static int _kills;

	private static int _deaths;

	private static int _roundsWon;

	private static readonly List<string> PendingKillFeed = new List<string>();

	private static float[] _statsAtStart;

	private static readonly HashSet<string> NonGameplay = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "MainMenu", "VictoryScene", "DontDestroyOnLoad", "EmptyScene", "LoadingScene", "Loading" };

	public static bool InMatch => _folder != null;

	public static bool Paused { get; private set; }

	public static void OnScene(string scene)
	{
		if (string.Equals(scene, "MainMenu", StringComparison.OrdinalIgnoreCase))
		{
			EndMatch("back in the menu");
		}
		else if (NonGameplay.Contains(scene))
		{
			CloseSegment("left the map (" + scene + ")");
		}
		else if (TelemetryPlugin.AutoRecord.Value || InMatch)
		{
			if (!InMatch)
			{
				StartMatch();
			}
			OpenSegment(scene);
		}
	}

	public static void TogglePause()
	{
		if (!InMatch)
		{
			string text = CurrentGameplayScene();
			if (text == null)
			{
				TelemetryRunner.Notify("Telemetry: not in a match yet. Recording starts with the next map.");
				return;
			}
			StartMatch();
			OpenSegment(text);
			Paused = false;
			TelemetryRunner.Notify("Telemetry: recording.", 3f);
		}
		else
		{
			Paused = !Paused;
			_seg?.Event(Paused ? "PAUSED (F4)" : "RESUMED (F4)");
			TelemetryRunner.Notify(Paused ? "Telemetry: paused. Nothing is recorded until you resume." : "Telemetry: recording.", 3f);
		}
	}

	public static void Mark()
	{
		if (_seg != null && !Paused)
		{
			_marks++;
			_seg.Event($"MARK #{_marks} (the player flagged the few seconds before this as worth a look)");
			TelemetryRunner.Notify($"Telemetry: moment #{_marks} marked.", 2f);
		}
	}

	public static void Tick()
	{
		if (_seg != null && !Paused)
		{
			long timestamp = Stopwatch.GetTimestamp();
			_seg.Tick();
			Cost.Add(Stopwatch.GetTimestamp() - timestamp);
		}
	}

	private static string CurrentGameplayScene()
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		string result = null;
		for (int i = 0; i < SceneManager.sceneCount; i++)
		{
			Scene sceneAt = SceneManager.GetSceneAt(i);
			string name = ((Scene)(ref sceneAt)).name;
			if (!NonGameplay.Contains(name))
			{
				result = name;
			}
		}
		return result;
	}

	private static void StartMatch()
	{
		_startedAt = DateTime.Now;
		_stamp = _startedAt.ToString("yyyyMMdd_HHmmss");
		_folder = Path.Combine(TelemetryPlugin.RecordingsDir, "_recording_" + _stamp);
		Directory.CreateDirectory(_folder);
		_segIndex = 0;
		_marks = 0;
		_sampledSeconds = 0f;
		_kills = (_deaths = (_roundsWon = 0));
		Cost.Reset();
		Paused = false;
		SegmentLines.Clear();
		Maps.Clear();
		Labels.Clear();
		PendingKillFeed.Clear();
		_opps = (_mates = (_bots = 0));
		_statsAtStart = Sampler.ReadStats();
		WriteMeta(final: false);
		TelemetryPlugin.Log.LogInfo((object)("Recording match to " + _folder));
	}

	private static void OpenSegment(string map)
	{
		if (_seg != null && _seg.Map == map)
		{
			return;
		}
		CloseSegment("next map");
		_segIndex++;
		Maps.Add(map);
		string text = map;
		char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
		foreach (char oldChar in invalidFileNameChars)
		{
			text = text.Replace(oldChar, '_');
		}
		_seg = new Sampler(Path.Combine(_folder, $"{_segIndex:00}_{text}"), map, _segIndex);
		foreach (string item in PendingKillFeed)
		{
			_seg.Event(item);
		}
		PendingKillFeed.Clear();
	}

	private static void CloseSegment(string why)
	{
		if (_seg != null)
		{
			try
			{
				_seg.Close(why);
				_sampledSeconds += _seg.SampledSeconds;
				SegmentLines.Add(_seg.SummaryLine());
			}
			catch (Exception ex)
			{
				TelemetryPlugin.Log.LogWarning((object)("Closing segment: " + ex.Message));
			}
			_seg = null;
		}
	}

	public static void EndMatch(string why, bool synchronous = false)
	{
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		if (!InMatch)
		{
			return;
		}
		CloseSegment(why);
		string folder = _folder;
		_folder = null;
		Paused = false;
		if (_sampledSeconds < TelemetryPlugin.MinMatchSeconds.Value)
		{
			TelemetryPlugin.Log.LogInfo((object)$"Recording only {_sampledSeconds:F0} s long: discarded.");
			try
			{
				Directory.Delete(folder, recursive: true);
				return;
			}
			catch
			{
				return;
			}
		}
		try
		{
			WriteMeta(final: true, folder, why);
		}
		catch (Exception ex)
		{
			TelemetryPlugin.Log.LogWarning((object)("match.txt: " + ex.Message));
		}
		string text = string.Join("+", from m in Maps.Distinct().Take(3)
			select (m.Length > 18) ? m.Substring(0, 18) : m);
		if (Maps.Distinct().Count() > 3)
		{
			text += $"+{Maps.Distinct().Count() - 3}more";
		}
		char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
		foreach (char oldChar in invalidFileNameChars)
		{
			text = text.Replace(oldChar, '_');
		}
		string zip = Path.Combine(TelemetryPlugin.RecordingsDir, "STRAFTAT_" + _stamp + "_" + text + ".zip");
		if (synchronous)
		{
			Zip(folder, zip);
		}
		else
		{
			ThreadPool.QueueUserWorkItem(delegate
			{
				Zip(folder, zip);
			});
		}
		TelemetryRunner.Notify($"Telemetry: saved {Path.GetFileName(zip)} ({_sampledSeconds / 60f:F1} min). {TelemetryPlugin.FolderKey.Value} opens the folder.");
	}

	private static void Zip(string folder, string zip)
	{
		try
		{
			if (File.Exists(zip))
			{
				File.Delete(zip);
			}
			ZipFile.CreateFromDirectory(folder, zip, CompressionLevel.Optimal, includeBaseDirectory: false);
			Directory.Delete(folder, recursive: true);
			TelemetryPlugin.Log.LogInfo((object)("Saved " + zip));
		}
		catch (Exception ex)
		{
			TelemetryPlugin.Log.LogWarning((object)("Zipping failed (" + ex.Message + "); the raw folder is kept: " + folder));
		}
	}

	public static void RecoverLeftovers()
	{
		try
		{
			string[] directories = Directory.GetDirectories(TelemetryPlugin.RecordingsDir, "_recording_*");
			foreach (string text in directories)
			{
				if (!Directory.GetFiles(text).Any((string f) => f.EndsWith("_samples.csv")))
				{
					Directory.Delete(text, recursive: true);
					continue;
				}
				string text2 = Path.GetFileName(text).Substring("_recording_".Length);
				Zip(text, Path.Combine(TelemetryPlugin.RecordingsDir, "STRAFTAT_" + text2 + "_recovered.zip"));
			}
		}
		catch (Exception ex)
		{
			TelemetryPlugin.Log.LogWarning((object)("Recovering old recordings: " + ex.Message));
		}
	}

	public static string Label(int playerId, FirstPersonController body = null)
	{
		ClientInstance instance = ClientInstance.Instance;
		if ((Object)(object)instance != (Object)null && playerId == instance.PlayerId)
		{
			return "self";
		}
		if (Labels.TryGetValue(playerId, out var value))
		{
			return value;
		}
		if (!TelemetryPlugin.Anonymize.Value && ClientInstance.playerInstances.TryGetValue(playerId, out var value2) && (Object)(object)value2 != (Object)null && !string.IsNullOrEmpty(value2.PlayerName))
		{
			value = Regex.Replace(value2.PlayerName, "<[^>]*>", "").Replace(',', ' ').Trim();
		}
		else if ((Object)(object)body != (Object)null && IsBot(body))
		{
			value = "bot" + ++_bots;
		}
		else if (SameTeam(playerId))
		{
			int num = ++_mates;
			value = "mate" + num;
		}
		else
		{
			int num = ++_opps;
			value = "opp" + num;
		}
		Labels[playerId] = value;
		return value;
	}

	public static bool IsBot(FirstPersonController f)
	{
		try
		{
			return (Object)(object)f != (Object)null && (Object)(object)((Component)((Component)f).transform.root).GetComponent("BotMarker") != (Object)null;
		}
		catch
		{
			return false;
		}
	}

	public static bool SameTeam(int playerId)
	{
		try
		{
			GameManager instance = GameManager.Instance;
			ScoreManager instance2 = ScoreManager.Instance;
			ClientInstance instance3 = ClientInstance.Instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null || (Object)(object)instance3 == (Object)null || !instance.playingTeams)
			{
				return false;
			}
			return instance2.GetTeamId(playerId) == instance2.GetTeamId(instance3.PlayerId);
		}
		catch
		{
			return false;
		}
	}

	public static void OnKillFeed(string text)
	{
		if (!InMatch || Paused || string.IsNullOrEmpty(text) || text.IndexOf("{PLAYER_NAME}", StringComparison.Ordinal) < 0)
		{
			return;
		}
		string text2 = Regex.Replace(text, "<[^>]*>", "");
		int num = (((Object)(object)ClientInstance.Instance != (Object)null) ? ClientInstance.Instance.PlayerId : (-999));
		MatchCollection matchCollection = Regex.Matches(text2, "\\{PLAYER_NAME\\}:\\{(\\d+)\\}");
		if (matchCollection.Count > 0 && text2.IndexOf(" won the ", StringComparison.Ordinal) < 0)
		{
			int num2 = int.Parse(matchCollection[0].Groups[1].Value);
			int num3 = ((matchCollection.Count > 1) ? int.Parse(matchCollection[matchCollection.Count - 1].Groups[1].Value) : (-1));
			if (num2 == num)
			{
				_deaths++;
			}
			else if (num3 == num)
			{
				_kills++;
			}
		}
		else if (matchCollection.Count > 0 && int.Parse(matchCollection[0].Groups[1].Value) == num && text2.IndexOf(" won the round", StringComparison.Ordinal) >= 0)
		{
			_roundsWon++;
		}
		string text3 = "KILLFEED: " + Regex.Replace(text2, "\\{PLAYER_NAME\\}:\\{(\\d+)\\}", (Match m) => Label(int.Parse(m.Groups[1].Value)));
		if (_seg != null)
		{
			_seg.Event(text3);
		}
		else
		{
			PendingKillFeed.Add(text3);
		}
	}

	private static void WriteMeta(bool final, string folderOverride = null, string why = null)
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine(string.Format("STRAFTAT Telemetry recording, recorder {0}, game {1}, started {2:yyyy-MM-dd HH:mm:ss}", "0.1.6", Application.version, _startedAt));
		stringBuilder.AppendLine($"anonymized={(TelemetryPlugin.Anonymize.Value ? 1 : 0)} sampleRate={TelemetryPlugin.SampleRate.Value} role={Net.Role()}");
		if (Chainloader.PluginInfos.ContainsKey("com.straftatbots.offlinebots"))
		{
			stringBuilder.AppendLine("NOTE: the Offline Bots mod is installed (opponents named botN are bots).");
		}
		if (final)
		{
			stringBuilder.AppendLine();
			stringBuilder.AppendLine($"ended {DateTime.Now:yyyy-MM-dd HH:mm:ss} ({why}), {_sampledSeconds / 60f:F1} min recorded, {_marks} marks");
			stringBuilder.AppendLine(Cost.Summary());
			stringBuilder.AppendLine($"your kill feed: {_kills} kills, {_deaths} deaths, {_roundsWon} round wins");
			float[] end = Sampler.ReadStats();
			if (Labels.Values.Any((string l) => l.StartsWith("bot")))
			{
				stringBuilder.AppendLine("NOTE: offline bots run on your PC, so the game's kill/death/suicide/air-time counters below include the bots' too (hit counters are yours).");
			}
			if (_statsAtStart != null && end != null)
			{
				stringBuilder.AppendLine("game stat counters this match: " + string.Join(" ", Sampler.StatNames.Select((string n, int i) => n.StartsWith("time") ? $"{n}={end[i] - _statsAtStart[i]:F1}s" : $"{n}={Mathf.RoundToInt(end[i] - _statsAtStart[i])}")));
			}
			stringBuilder.AppendLine("players: " + ((Labels.Count == 0) ? "none seen" : string.Join(", ", Labels.Values)));
			stringBuilder.AppendLine("maps:");
			foreach (string segmentLine in SegmentLines)
			{
				stringBuilder.AppendLine("  " + segmentLine);
			}
		}
		File.WriteAllText(Path.Combine(folderOverride ?? _folder, "match.txt"), stringBuilder.ToString());
	}
}
internal static class Net
{
	private static Type _finder;

	private static readonly Dictionary<string, PropertyInfo> Props = new Dictionary<string, PropertyInfo>();

	private static Type Finder => _finder ?? (_finder = AccessFinder());

	private static Type AccessFinder()
	{
		try
		{
			return AccessTools.TypeByName("FishNet.InstanceFinder");
		}
		catch
		{
			return null;
		}
	}

	private static object Prop(object o, Type t, string name)
	{
		try
		{
			Type type = t ?? o.GetType();
			string key = type.FullName + "." + name;
			if (!Props.TryGetValue(key, out var value))
			{
				value = (Props[key] = AccessTools.Property(type, name));
			}
			return (value != null) ? value.GetValue(o, null) : null;
		}
		catch
		{
			return null;
		}
	}

	public static string Role()
	{
		object obj = Prop(null, Finder, "IsHostStarted") ?? Prop(null, Finder, "IsHost");
		bool flag = default(bool);
		int num;
		if (obj is bool)
		{
			flag = (bool)obj;
			num = 1;
		}
		else
		{
			num = 0;
		}
		if (((uint)num & (flag ? 1u : 0u)) != 0)
		{
			return "host";
		}
		object obj2 = Prop(null, Finder, "IsServerStarted") ?? Prop(null, Finder, "IsServer");
		bool flag2 = default(bool);
		int num2;
		if (obj2 is bool)
		{
			flag2 = (bool)obj2;
			num2 = 1;
		}
		else
		{
			num2 = 0;
		}
		if (((uint)num2 & (flag2 ? 1u : 0u)) != 0)
		{
			return "server";
		}
		return "client";
	}

	public static long PingMs()
	{
		object obj = Prop(null, Finder, "TimeManager");
		if (obj == null)
		{
			return -1L;
		}
		object obj2 = Prop(obj, null, "RoundTripTime");
		try
		{
			return (obj2 != null) ? Convert.ToInt64(obj2) : (-1);
		}
		catch
		{
			return -1L;
		}
	}
}
[BepInPlugin("com.straftatbots.telemetry", "STRAFTAT Telemetry Recorder", "0.1.6")]
public class TelemetryPlugin : BaseUnityPlugin
{
	public const string Guid = "com.straftatbots.telemetry";

	public const string Version = "0.1.6";

	internal static ManualLogSource Log;

	internal static ConfigEntry<bool> AutoRecord;

	internal static ConfigEntry<bool> ShowIndicator;

	internal static ConfigEntry<bool> Anonymize;

	internal static ConfigEntry<KeyboardShortcut> PauseKey;

	internal static ConfigEntry<KeyboardShortcut> MarkKey;

	internal static ConfigEntry<KeyboardShortcut> FolderKey;

	internal static ConfigEntry<int> SampleRate;

	internal static ConfigEntry<int> MaxOpponents;

	internal static ConfigEntry<float> MinMatchSeconds;

	internal static string RootDir;

	internal static string RecordingsDir;

	private void Awake()
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Expected O, but got Unknown
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Expected O, but got Unknown
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		AutoRecord = ((BaseUnityPlugin)this).Config.Bind<bool>("Recording", "AutoRecord", true, "Record every match automatically (one zip per match, from the first map until you're back in the menu). Off = only record after pressing the pause/resume key.");
		SampleRate = ((BaseUnityPlugin)this).Config.Bind<int>("Recording", "SampleRate", 60, new ConfigDescription("Rows per second in the samples file. Events (jumps, slides, shots, pickups...) are always timed per frame.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 120), Array.Empty<object>()));
		MaxOpponents = ((BaseUnityPlugin)this).Config.Bind<int>("Recording", "MaxOtherPlayers", 3, new ConfigDescription("How many other players get columns in the samples file (nearest first).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 7), Array.Empty<object>()));
		MinMatchSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Recording", "MinMatchSeconds", 20f, "Recordings shorter than this are thrown away (menu blips, instant leaves).");
		Anonymize = ((BaseUnityPlugin)this).Config.Bind<bool>("Privacy", "Anonymize", true, "Write 'self', 'opp1', 'mate1'... instead of player names. No Steam names or IDs are ever written when this is on.");
		ShowIndicator = ((BaseUnityPlugin)this).Config.Bind<bool>("Display", "ShowIndicator", true, "Small REC marker in the top-right corner while recording.");
		PauseKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "PauseResume", new KeyboardShortcut((KeyCode)285, Array.Empty<KeyCode>()), "Pause / resume recording.");
		MarkKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "MarkMoment", new KeyboardShortcut((KeyCode)284, Array.Empty<KeyCode>()), "Mark a moment worth a look (a clever play, a weird bug, a botched trick). The few seconds before the mark get flagged.");
		FolderKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "OpenFolder", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Open the recordings folder.");
		RootDir = Path.Combine(Paths.BepInExRootPath, "StraftatTelemetry");
		RecordingsDir = Path.Combine(RootDir, "recordings");
		try
		{
			Directory.CreateDirectory(RecordingsDir);
		}
		catch (Exception ex)
		{
			Log.LogError((object)("Can't create " + RecordingsDir + ": " + ex.Message));
		}
		try
		{
			Harmony val = new Harmony("com.straftatbots.telemetry");
			MethodInfo methodInfo = AccessTools.Method(typeof(PauseManager), "WriteLog", new Type[1] { typeof(string) }, (Type[])null);
			if (methodInfo != null)
			{
				val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(TelemetryPlugin), "WriteLog_Post", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			else
			{
				Log.LogWarning((object)"PauseManager.WriteLog not found: kill feed won't be recorded.");
			}
		}
		catch (Exception ex2)
		{
			Log.LogWarning((object)("Kill feed hook failed (recording still works): " + ex2.Message));
		}
		Session.RecoverLeftovers();
		TelemetryRunner.Create();
		SceneManager.sceneLoaded += delegate(Scene s, LoadSceneMode mode)
		{
			try
			{
				Session.OnScene(((Scene)(ref s)).name);
			}
			catch (Exception ex3)
			{
				Log.LogError((object)("OnScene: " + ex3));
			}
		};
		Log.LogInfo((object)("STRAFTAT Telemetry 0.1.6 ready. Recordings: " + RecordingsDir));
	}

	private static void WriteLog_Post(string text)
	{
		try
		{
			Session.OnKillFeed(text);
		}
		catch
		{
		}
	}
}
internal class TelemetryRunner : MonoBehaviour
{
	private static TelemetryRunner _instance;

	private float _noticeUntil;

	private string _notice;

	private GUIStyle _style;

	private GUIStyle _small;

	public static void Create()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Expected O, but got Unknown
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)_instance != (Object)null))
		{
			GameObject val = new GameObject("StraftatTelemetryRunner")
			{
				hideFlags = (HideFlags)61
			};
			Object.DontDestroyOnLoad((Object)(object)val);
			_instance = val.AddComponent<TelemetryRunner>();
			_instance.Notice("STRAFTAT Telemetry 0.1.6: " + (TelemetryPlugin.AutoRecord.Value ? "recording your matches automatically" : ("press " + ((object)TelemetryPlugin.PauseKey.Value/*cast due to .constrained prefix*/).ToString() + " to record")) + ".  " + $"{TelemetryPlugin.PauseKey.Value} pause/resume   {TelemetryPlugin.MarkKey.Value} mark a moment   {TelemetryPlugin.FolderKey.Value} open recordings", 14f);
		}
	}

	public static void Notify(string text, float seconds = 8f)
	{
		if ((Object)(object)_instance != (Object)null)
		{
			_instance.Notice(text, seconds);
		}
	}

	private void Notice(string text, float seconds)
	{
		_notice = text;
		_noticeUntil = Time.unscaledTime + seconds;
	}

	private void Update()
	{
		//IL_0007: 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_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to inva