using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ComputerysModdingUtilities;
using FishNet.Object.Synchronizing;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("MatchStats")]
[assembly: AssemblyDescription("Kills, deaths and damage of every player, between rounds and after the match.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: StraftatMod(true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MatchStats;
[BepInPlugin("dorsth.straftat.matchstats", "MatchStats", "1.0.0")]
public sealed class MatchStatsPlugin : BaseUnityPlugin
{
public const string Guid = "dorsth.straftat.matchstats";
public const string Name = "MatchStats";
public const string Version = "1.0.0";
internal static ManualLogSource Log;
private void Awake()
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"MatchStats 1.0.0 loaded. Dorsth was here.");
bool flag = !File.Exists(((BaseUnityPlugin)this).Config.ConfigFilePath);
try
{
Stats.Bind(((BaseUnityPlugin)this).Config, new Harmony("dorsth.straftat.matchstats"));
}
catch (Exception ex)
{
Log.LogWarning((object)("Match stats are off: " + ex.Message));
return;
}
if (flag)
{
try
{
Carry();
}
catch
{
}
}
}
private void Carry()
{
string path = Path.Combine(Paths.ConfigPath, "dorsth.straftat.monolith.cfg");
if (!File.Exists(path))
{
return;
}
bool flag = false;
string[] array = File.ReadAllLines(path);
for (int i = 0; i < array.Length; i++)
{
string text = array[i].Trim();
if (text.StartsWith("[", StringComparison.Ordinal))
{
flag = text == "[Match Stats]";
}
else if (flag && text.StartsWith("Enabled", StringComparison.Ordinal))
{
int num = text.IndexOf('=');
if (num > 0 && text.Substring(num + 1).Trim().Equals("false", StringComparison.OrdinalIgnoreCase))
{
Stats.On.Value = false;
}
break;
}
}
}
}
internal static class Stats
{
internal sealed class P
{
public string Name = "";
public int Kills;
public int Deaths;
public int Takes;
public int Survived;
public int OpenK;
public int OpenD;
public int Trades;
public int Multi;
public int Clutch;
public float Dmg;
public int RoundKills;
public bool Alive = true;
public bool LastAlive;
public int RK;
public int RD;
public float RDmg;
}
private struct Hit
{
public int Victim;
public int Frame;
public float Dmg;
public bool Lethal;
public PlayerHealth Ph;
}
private struct Death
{
public int Victim;
public int Killer;
public float At;
}
internal sealed class KillTag : MonoBehaviour
{
private static readonly FieldRef<TabScreen, TextMeshProUGUI> MapText = AccessTools.FieldRefAccess<TabScreen, TextMeshProUGUI>("mapText");
private static Color _mint = Color32.op_Implicit(new Color32((byte)168, (byte)230, (byte)180, byte.MaxValue));
private TMP_Text _name;
private TextMeshProUGUI _t;
private int _id = -1;
private int _k = -1;
private int _d = -1;
private int _dmg = -1;
internal static void Put(TMP_Text name, int id)
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Expected O, but got Unknown
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: 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_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)name == (Object)null)
{
return;
}
try
{
TabScreen componentInParent = ((Component)name).GetComponentInParent<TabScreen>(true);
if ((Object)(object)componentInParent != (Object)null && (Object)(object)MapText.Invoke(componentInParent) != (Object)null)
{
_mint = ((Graphic)MapText.Invoke(componentInParent)).color;
}
}
catch
{
}
KillTag killTag = ((Component)name).GetComponentInChildren<KillTag>(true);
if ((Object)(object)killTag == (Object)null)
{
GameObject val = new GameObject("MONOLITH kills");
val.transform.SetParent(name.transform, false);
killTag = val.AddComponent<KillTag>();
killTag._name = name;
TextMeshProUGUI obj2 = (killTag._t = val.AddComponent<TextMeshProUGUI>());
((Graphic)obj2).raycastTarget = false;
((TMP_Text)obj2).enableWordWrapping = false;
((TMP_Text)obj2).overflowMode = (TextOverflowModes)0;
((TMP_Text)obj2).richText = false;
((TMP_Text)obj2).font = name.font;
((TMP_Text)obj2).fontSharedMaterial = name.fontSharedMaterial;
((TMP_Text)obj2).alignment = (TextAlignmentOptions)1025;
RectTransform rectTransform = ((TMP_Text)obj2).rectTransform;
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(0.5f, 0.5f);
rectTransform.anchorMax = val2;
rectTransform.anchorMin = val2;
rectTransform.pivot = Vector2.zero;
rectTransform.sizeDelta = new Vector2(400f, 40f);
}
killTag._id = id;
killTag._k = (killTag._d = (killTag._dmg = -1));
}
private void LateUpdate()
{
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Invalid comparison between Unknown and I4
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Invalid comparison between Unknown and I4
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: Unknown result type (might be due to invalid IL or missing references)
//IL_0290: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
if (_id < 0 || !((Object)(object)_name != (Object)null) || !On.Value || !ClientInstance.playerInstances.ContainsKey(_id))
{
if (((TMP_Text)_t).text.Length > 0)
{
((TMP_Text)_t).text = "";
}
_k = (_d = (_dmg = -1));
return;
}
All.TryGetValue(_id, out var value);
int num = value?.Kills ?? 0;
int num2 = value?.Deaths ?? 0;
int num3 = ((value != null) ? Mathf.RoundToInt(value.Dmg) : 0);
if (num != _k || num2 != _d || num3 != _dmg)
{
_k = num;
_d = num2;
_dmg = num3;
((TMP_Text)_t).text = "kills " + num.ToString(CultureInfo.InvariantCulture) + " deaths " + num2.ToString(CultureInfo.InvariantCulture) + " damage " + num3.ToString(CultureInfo.InvariantCulture);
}
((TMP_Text)_t).fontSize = Mathf.Max(16f, _name.fontSize * 0.5f);
((Graphic)_t).color = _mint;
Bounds textBounds = _name.textBounds;
Vector3 val = default(Vector3);
if (_name.text.Length > 0 && ((Bounds)(ref textBounds)).size.x > 0f)
{
((Vector3)(ref val))..ctor(((Bounds)(ref textBounds)).min.x, ((Bounds)(ref textBounds)).max.y + ((TMP_Text)_t).fontSize * 0.2f, 0f);
}
else
{
Rect rect = _name.rectTransform.rect;
float preferredWidth = ((TMP_Text)_t).preferredWidth;
HorizontalAlignmentOptions horizontalAlignment = _name.horizontalAlignment;
float num4 = (((int)horizontalAlignment == 4) ? (((Rect)(ref rect)).xMax - preferredWidth) : (((int)horizontalAlignment == 2) ? (((Rect)(ref rect)).center.x - preferredWidth * 0.5f) : ((Rect)(ref rect)).xMin));
((Vector3)(ref val))..ctor(num4, ((Rect)(ref rect)).center.y - ((TMP_Text)_t).fontSize * 0.35f, 0f);
}
Transform transform = ((TMP_Text)_t).transform;
Vector3 val2 = transform.localPosition - val;
if (((Vector3)(ref val2)).sqrMagnitude > 0.01f)
{
transform.localPosition = val;
}
}
}
internal sealed class Board : MonoBehaviour
{
internal static Board Me;
private bool _full;
private bool _waitOnly;
private float _hideAt = -1f;
private GameObject _canvas;
private RectTransform _root;
private RectTransform _back;
private const float Pad = 14f;
private const float Edge = 24f;
private TMP_FontAsset _font;
private Material _mat;
private readonly List<TextMeshProUGUI> _cells = new List<TextMeshProUGUI>();
private static readonly string[] FullHead = new string[9] { "player", "kills", "deaths", "adr", "first k-d", "trade", "2k", "clutch", "survived" };
private static readonly string[] RoundHead = new string[4] { "player", "kills", "deaths", "damage" };
private const float Gap = 28f;
private static readonly Color Mint = Color32.op_Implicit(new Color32((byte)180, (byte)242, (byte)180, byte.MaxValue));
private static readonly Color White = Color32.op_Implicit(new Color32((byte)248, (byte)248, (byte)248, byte.MaxValue));
private Vector2 _to;
private float _flyAt = -1f;
private const float Fly = 0.55f;
private Canvas _cv;
private CanvasScaler _sc;
private Image _backImage;
private bool _world;
private float _worldUntil = -1f;
private string _whyFlat;
private const float Turn = 85f;
private const float Wide = 6.5f;
private const float Clear = 2.6f;
private const float Out = 0f;
private string _digit;
private static readonly char[] Separators = new char[2] { '-', '/' };
private readonly StringBuilder _sb = new StringBuilder();
private TextMeshProUGUI _ruler;
private readonly List<Behaviour> _counters = new List<Behaviour>();
internal void Show(bool full)
{
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_0332: 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_04d2: Unknown result type (might be due to invalid IL or missing references)
//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
//IL_04db: Unknown result type (might be due to invalid IL or missing references)
//IL_0587: Unknown result type (might be due to invalid IL or missing references)
//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
//IL_05bb: Unknown result type (might be due to invalid IL or missing references)
//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
//IL_071d: Unknown result type (might be due to invalid IL or missing references)
//IL_0724: Unknown result type (might be due to invalid IL or missing references)
//IL_0726: Unknown result type (might be due to invalid IL or missing references)
//IL_0727: Unknown result type (might be due to invalid IL or missing references)
//IL_072e: Unknown result type (might be due to invalid IL or missing references)
//IL_0745: Unknown result type (might be due to invalid IL or missing references)
//IL_05fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0605: Unknown result type (might be due to invalid IL or missing references)
//IL_0607: Unknown result type (might be due to invalid IL or missing references)
//IL_0608: Unknown result type (might be due to invalid IL or missing references)
//IL_060f: Unknown result type (might be due to invalid IL or missing references)
//IL_0621: Unknown result type (might be due to invalid IL or missing references)
//IL_0626: Unknown result type (might be due to invalid IL or missing references)
//IL_062b: Unknown result type (might be due to invalid IL or missing references)
//IL_0683: Unknown result type (might be due to invalid IL or missing references)
//IL_06af: Unknown result type (might be due to invalid IL or missing references)
//IL_06b4: Unknown result type (might be due to invalid IL or missing references)
//IL_06d1: Unknown result type (might be due to invalid IL or missing references)
//IL_06e9: Unknown result type (might be due to invalid IL or missing references)
//IL_06ee: Unknown result type (might be due to invalid IL or missing references)
_full = full;
_waitOnly = false;
_hideAt = -1f;
if ((Object)(object)_canvas == (Object)null)
{
Make();
}
if ((Object)(object)_root == (Object)null)
{
return;
}
Flat();
_worldUntil = (full ? (Time.unscaledTime + 10f) : (-1f));
_whyFlat = null;
int num = -1;
try
{
if ((Object)(object)LobbyController.Instance != (Object)null && (Object)(object)LobbyController.Instance.LocalPlayerController != (Object)null)
{
num = LobbyController.Instance.LocalPlayerController.PlayerId;
}
}
catch
{
}
Color val = Color32.op_Implicit(new Color32((byte)172, (byte)188, (byte)252, byte.MaxValue));
Color val2 = Color32.op_Implicit(new Color32((byte)232, (byte)128, (byte)104, byte.MaxValue));
try
{
PauseManager instance = PauseManager.Instance;
Color val3 = default(Color);
if ((Object)(object)instance != (Object)null && ColorUtility.TryParseHtmlString("#" + (instance.selfNameLogColor ?? "").TrimStart('#'), ref val3))
{
val = val3;
}
if ((Object)(object)instance != (Object)null && ColorUtility.TryParseHtmlString("#" + (instance.enemyNameLogColor ?? "").TrimStart('#'), ref val3))
{
val2 = val3;
}
}
catch
{
}
string[] array = (full ? FullHead : RoundHead);
float num2 = (full ? 22f : 20f);
float num3 = (full ? 32f : 22f);
float pad = 0f;
List<KeyValuePair<int, P>> list = Sorted();
if (!full)
{
list.Sort((KeyValuePair<int, P> a, KeyValuePair<int, P> b) => (Team(a.Key) == Team(b.Key)) ? ((b.Value.RK == a.Value.RK) ? b.Value.RDmg.CompareTo(a.Value.RDmg) : b.Value.RK.CompareTo(a.Value.RK)) : Team(a.Key).CompareTo(Team(b.Key)));
}
List<string[]> list2 = new List<string[]> { array };
List<Color> list3 = new List<Color> { Mint };
foreach (KeyValuePair<int, P> item in list)
{
P value = item.Value;
int num4 = Math.Max(1, value.Takes);
list2.Add(full ? new string[9]
{
Drawable(value.Name),
value.Kills.ToString(),
value.Deaths.ToString(),
Num(value.Dmg / (float)num4),
value.OpenK + "-" + value.OpenD,
value.Trades.ToString(),
value.Multi.ToString(),
value.Clutch.ToString(),
value.Survived + "/" + value.Takes
} : new string[4]
{
Drawable(value.Name),
value.RK.ToString(),
value.RD.ToString(),
Num(value.RDmg)
});
list3.Add((num >= 0 && Team(item.Key) == Team(num)) ? val : val2);
}
int num5 = array.Length;
int cell = 0;
float[] array2 = new float[num5];
_canvas.SetActive(true);
float num6 = Measure("0", num2);
_digit = ((num6 > 0f) ? ("<mspace=" + (num6 / num2).ToString("0.###", CultureInfo.InvariantCulture) + "em>") : null);
for (int num7 = 0; num7 < num5; num7++)
{
float num8 = 0f;
int num9 = 0;
for (int num10 = 0; num10 < list2.Count; num10++)
{
string[] array3 = list2[num10];
if (num7 < array3.Length && array3[num7] != null)
{
num9 = Math.Max(num9, array3[num7].Length);
num8 = Math.Max(num8, (num7 == 0) ? Ink(array3[num7], num2) : Measure(Shown(num10, num7, array3[num7]), num2));
}
}
if (num8 < (float)num9 * num2 * 0.3f)
{
num8 = (float)num9 * num2 * 0.6f;
}
if (num7 == 0)
{
num8 = Mathf.Min(num8, full ? 260f : 220f);
}
array2[num7] = num8 + ((num7 > 0) ? 28f : 0f);
}
_canvas.SetActive(true);
for (int num11 = 0; num11 < list2.Count; num11++)
{
Row(ref cell, num11, list2[num11], array2, num2, num3, pad, list3[num11], (num11 == 0) ? Mint : White);
}
for (int num12 = cell; num12 < _cells.Count; num12++)
{
((Component)_cells[num12]).gameObject.SetActive(false);
}
float num13 = 0f;
float[] array4 = array2;
foreach (float num15 in array4)
{
num13 += num15;
}
float num16 = (float)(list.Count + 1) * (num3 + 4f) - 4f;
_back.anchoredPosition = new Vector2(-14f, 14f);
_back.sizeDelta = new Vector2(num13 + 28f, num16 + 28f);
_root.sizeDelta = new Vector2(num13, num16);
((Transform)_root).localScale = Vector3.one;
Vector2 val4 = default(Vector2);
if (full)
{
RectTransform root = _root;
RectTransform root2 = _root;
RectTransform root3 = _root;
((Vector2)(ref val4))..ctor(0.5f, 0.5f);
root3.pivot = val4;
Vector2 anchorMin = (root2.anchorMax = val4);
root.anchorMin = anchorMin;
Rect rect = ((RectTransform)_canvas.transform).rect;
float num17 = Mathf.Min(new float[3]
{
1f,
((Rect)(ref rect)).width * 0.8f / (num13 + 28f),
((Rect)(ref rect)).height * 0.36f / (num16 + 28f)
});
((Transform)_root).localScale = new Vector3(num17, num17, 1f);
_to = new Vector2(0f, (0f - ((Rect)(ref rect)).height) * 0.5f + ((Rect)(ref rect)).height * 0.225f);
_flyAt = Time.unscaledTime + 0.5f;
_root.anchoredPosition = _to + new Vector2(0f, (0f - ((Rect)(ref rect)).height) * 0.6f);
}
else
{
RectTransform root4 = _root;
RectTransform root5 = _root;
RectTransform root6 = _root;
((Vector2)(ref val4))..ctor(0f, 1f);
root6.pivot = val4;
Vector2 anchorMin = (root5.anchorMax = val4);
root4.anchorMin = anchorMin;
_root.anchoredPosition = new Vector2(38f, -38f);
_flyAt = -1f;
}
_canvas.SetActive(true);
Counters(back: false);
((Behaviour)this).enabled = true;
}
private void Flat()
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
_world = false;
if ((Object)(object)_cv != (Object)null)
{
_cv.renderMode = (RenderMode)0;
}
if ((Object)(object)_sc != (Object)null)
{
((Behaviour)_sc).enabled = true;
}
if ((Object)(object)_backImage != (Object)null)
{
((Graphic)_backImage).color = new Color(0f, 0f, 0f, 0.45f);
}
}
private bool InRoom()
{
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: 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_00cd: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: 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_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_0281: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_0293: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
VictoryMenu val = null;
VictoryMenu[] array = Object.FindObjectsOfType<VictoryMenu>();
foreach (VictoryMenu val2 in array)
{
if (Traverse.Create((object)val2).Field("restartGame").GetValue<bool>())
{
val = val2;
break;
}
}
if ((Object)(object)val == (Object)null)
{
_whyFlat = "no rematch sign";
return false;
}
GameObject value = Traverse.Create((object)val).Field("textObject").GetValue<GameObject>();
TMP_Text val3 = (((Object)(object)value != (Object)null) ? value.GetComponentInChildren<TMP_Text>() : null);
if ((Object)(object)val3 == (Object)null)
{
val3 = ((Component)val).GetComponentInChildren<TMP_Text>();
}
if (!((Object)(object)val3 == (Object)null))
{
Bounds bounds = val3.bounds;
if (!(((Bounds)(ref bounds)).size.x <= 0f))
{
Transform transform = val3.transform;
Bounds bounds2 = val3.bounds;
float num = ((Bounds)(ref bounds2)).size.x * Mathf.Abs(transform.lossyScale.x);
float num2 = ((Bounds)(ref bounds2)).size.y * Mathf.Abs(transform.lossyScale.y);
Vector3 val4 = transform.TransformPoint(new Vector3(((Bounds)(ref bounds2)).min.x, ((Bounds)(ref bounds2)).max.y, ((Bounds)(ref bounds2)).center.z));
_cv.renderMode = (RenderMode)2;
((Behaviour)_sc).enabled = false;
if ((Object)(object)_backImage != (Object)null)
{
((Graphic)_backImage).color = new Color(0.05f, 0.06f, 0.07f, 0.6f);
}
RectTransform val5 = (RectTransform)_canvas.transform;
val5.sizeDelta = _back.sizeDelta;
float num3 = 6.5f * num / Mathf.Max(1f, _back.sizeDelta.x);
float num4 = _back.sizeDelta.x * num3;
float num5 = _back.sizeDelta.y * num3;
((Transform)val5).localScale = new Vector3(num3, num3, num3);
Quaternion val6 = transform.rotation * Quaternion.Euler(0f, -85f, 0f);
Vector3 val7 = val4 + transform.up * num2 - transform.right * (2.6f * num) - transform.forward * (0f * num);
((Transform)val5).rotation = val6;
((Transform)val5).position = val7 - val6 * Vector3.right * (num4 * 0.5f) + transform.up * (num5 * 0.5f);
((Transform)_root).localScale = Vector3.one;
_to = Vector2.zero;
_world = true;
_flyAt = Time.unscaledTime;
if (MatchStatsPlugin.Log != null)
{
MatchStatsPlugin.Log.LogInfo((object)"Match stats: the victory board stands in the room.");
}
return true;
}
}
_whyFlat = "rematch sign has no text";
return false;
}
private string Shown(int r, int i, string v)
{
if (r == 0 || i == 0 || _digit == null)
{
return v;
}
int num = v.IndexOfAny(Separators);
if (num < 0)
{
return _digit + v + "</mspace>";
}
return _digit + v.Substring(0, num) + "</mspace>" + v[num] + _digit + v.Substring(num + 1) + "</mspace>";
}
private void Row(ref int cell, int r, string[] v, float[] w, float size, float rowH, float pad, Color name, Color num)
{
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
float num2 = (float)(-r) * (rowH + 4f);
float num3 = pad;
for (int i = 0; i < v.Length && i < w.Length; i++)
{
TextMeshProUGUI obj = ((cell < _cells.Count) ? _cells[cell] : NewCell());
cell++;
string v2 = v[i] ?? "";
((TMP_Text)obj).richText = r > 0 && i > 0;
((TMP_Text)obj).text = Shown(r, i, v2);
((Graphic)obj).color = ((i == 0) ? name : num);
((TMP_Text)obj).enableAutoSizing = i == 0;
((TMP_Text)obj).fontSizeMax = size;
((TMP_Text)obj).fontSizeMin = size * 0.75f;
((TMP_Text)obj).fontSize = size;
((TMP_Text)obj).overflowMode = (TextOverflowModes)(i == 0);
((TMP_Text)obj).alignment = (TextAlignmentOptions)((i == 0) ? 2049 : 2052);
Place(((TMP_Text)obj).rectTransform, num3, num2 - size * 0.35f, (i == 0) ? (w[i] + 28f) : w[i], rowH);
((Component)obj).gameObject.SetActive(true);
num3 += w[i];
}
}
private string Drawable(string name)
{
if ((Object)(object)_font == (Object)null || string.IsNullOrEmpty(name))
{
return name;
}
_sb.Length = 0;
foreach (char c in name)
{
if (char.IsWhiteSpace(c) || _font.HasCharacter(c, true, false))
{
_sb.Append(c);
}
}
return _sb.ToString().Trim();
}
private float Measure(string text, float size)
{
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_font == (Object)null || string.IsNullOrEmpty(text))
{
return 0f;
}
if ((Object)(object)_ruler == (Object)null)
{
_ruler = NewCell();
_cells.Remove(_ruler);
((TMP_Text)_ruler).text = "";
((TMP_Text)_ruler).richText = true;
}
((TMP_Text)_ruler).fontSize = size;
return ((TMP_Text)_ruler).GetPreferredValues(text).x;
}
private float Ink(string text, float size)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
if (Measure(text, size) <= 0f)
{
return 0f;
}
((TMP_Text)_ruler).text = text;
((TMP_Text)_ruler).ForceMeshUpdate(false, false);
Bounds textBounds = ((TMP_Text)_ruler).textBounds;
float x = ((Bounds)(ref textBounds)).size.x;
((TMP_Text)_ruler).text = "";
return x;
}
internal void Prepare()
{
if ((Object)(object)_canvas == (Object)null)
{
Make();
}
}
private static void Place(RectTransform rt, float x, float y, float w, float h)
{
//IL_0014: 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_001b: 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_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(0f, 1f);
rt.pivot = val;
Vector2 anchorMin = (rt.anchorMax = val);
rt.anchorMin = anchorMin;
rt.anchoredPosition = new Vector2(x, y);
rt.sizeDelta = new Vector2(w, h);
}
private TextMeshProUGUI NewCell()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("cell");
val.transform.SetParent((Transform)(object)_root, false);
TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
((Graphic)val2).raycastTarget = false;
((TMP_Text)val2).enableWordWrapping = false;
((TMP_Text)val2).overflowMode = (TextOverflowModes)0;
((TMP_Text)val2).richText = false;
if ((Object)(object)_font != (Object)null)
{
((TMP_Text)val2).font = _font;
if ((Object)(object)_mat != (Object)null)
{
((TMP_Text)val2).fontSharedMaterial = _mat;
}
}
_cells.Add(val2);
return val2;
}
private void Make()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_0075: 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_0094: Expected O, but got Unknown
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Expected O, but got Unknown
//IL_00fb: 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_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Expected O, but got Unknown
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
_canvas = new GameObject("MONOLITH.StatsBoard");
Object.DontDestroyOnLoad((Object)(object)_canvas);
((Object)_canvas).hideFlags = (HideFlags)61;
Canvas obj = (_cv = _canvas.AddComponent<Canvas>());
obj.renderMode = (RenderMode)0;
obj.sortingOrder = 400;
CanvasScaler obj2 = (_sc = _canvas.AddComponent<CanvasScaler>());
obj2.uiScaleMode = (ScaleMode)1;
obj2.referenceResolution = new Vector2(1920f, 1080f);
obj2.matchWidthOrHeight = 0.5f;
GameObject val = new GameObject("board");
val.transform.SetParent(_canvas.transform, false);
_root = val.AddComponent<RectTransform>();
GameObject val2 = new GameObject("backdrop");
val2.transform.SetParent((Transform)(object)_root, false);
Image val3 = (_backImage = val2.AddComponent<Image>());
((Graphic)val3).color = new Color(0f, 0f, 0f, 0.45f);
((Graphic)val3).raycastTarget = false;
_back = ((Graphic)val3).rectTransform;
RectTransform back = _back;
RectTransform back2 = _back;
RectTransform back3 = _back;
Vector2 val4 = default(Vector2);
((Vector2)(ref val4))..ctor(0f, 1f);
back3.pivot = val4;
Vector2 anchorMin = (back2.anchorMax = val4);
back.anchorMin = anchorMin;
try
{
TMP_Text val6 = null;
if ((Object)(object)RoundManager.Instance != (Object)null)
{
object value = Traverse.Create((object)RoundManager.Instance).Field("playerName").GetValue();
val6 = (TMP_Text)((value is TMP_Text) ? value : null);
}
if ((Object)(object)val6 == (Object)null)
{
val6 = (TMP_Text)(object)Object.FindObjectOfType<TextMeshProUGUI>();
}
if ((Object)(object)val6 != (Object)null && (Object)(object)val6.font != (Object)null)
{
_font = val6.font;
_mat = new Material(val6.fontSharedMaterial)
{
name = "MONOLITH stats shadow"
};
_mat.EnableKeyword(ShaderUtilities.Keyword_Underlay);
_mat.SetColor(ShaderUtilities.ID_UnderlayColor, new Color(0f, 0f, 0f, 0.45f));
_mat.SetFloat(ShaderUtilities.ID_UnderlayOffsetX, 0.25f);
_mat.SetFloat(ShaderUtilities.ID_UnderlayOffsetY, -0.25f);
_mat.SetFloat(ShaderUtilities.ID_UnderlaySoftness, 0.2f);
}
}
catch
{
}
_canvas.SetActive(false);
}
internal void Hide()
{
if ((Object)(object)_canvas != (Object)null)
{
_canvas.SetActive(false);
}
Counters(back: true);
if (!_waitOnly)
{
((Behaviour)this).enabled = false;
}
}
private void Counters(bool back)
{
try
{
if (back)
{
foreach (Behaviour counter in _counters)
{
if ((Object)(object)counter != (Object)null)
{
counter.enabled = true;
}
}
_counters.Clear();
return;
}
PauseManager instance = PauseManager.Instance;
if ((Object)(object)instance == (Object)null)
{
return;
}
Behaviour[] array = (Behaviour[])(object)new Behaviour[2]
{
(Behaviour)instance.minimalFpsText,
(Behaviour)instance.minimalPingText
};
foreach (Behaviour val in array)
{
if ((Object)(object)val != (Object)null && val.enabled && !_counters.Contains(val))
{
val.enabled = false;
_counters.Add(val);
}
}
}
catch (Exception e)
{
Quiet(e);
}
}
internal void Wait()
{
if (!((Behaviour)this).enabled)
{
_waitOnly = true;
((Behaviour)this).enabled = true;
}
}
private void Update()
{
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
if (Waiting.Count > 0)
{
Flush();
}
if (_waitOnly)
{
if (Waiting.Count == 0)
{
_waitOnly = false;
((Behaviour)this).enabled = false;
}
return;
}
if (_full && !_world && Time.unscaledTime < _worldUntil && (Object)(object)_root != (Object)null)
{
try
{
if (InRoom())
{
_worldUntil = -1f;
}
}
catch (Exception e)
{
_worldUntil = -1f;
Flat();
Quiet(e);
}
}
else if (_full && !_world && _worldUntil > 0f)
{
if (MatchStatsPlugin.Log != null)
{
MatchStatsPlugin.Log.LogInfo((object)("Match stats: the victory board stays on the screen: " + (_whyFlat ?? "?")));
}
_worldUntil = -1f;
}
if (_full && _flyAt >= 0f && (Object)(object)_root != (Object)null)
{
float num = Mathf.Clamp01((Time.unscaledTime - _flyAt) / 0.55f);
float num2 = 1f - Mathf.Pow(1f - num, 3f);
Vector2 to = _to;
Rect rect = ((RectTransform)_canvas.transform).rect;
Vector2 val = to + new Vector2(0f, (0f - ((Rect)(ref rect)).height) * 0.6f);
_root.anchoredPosition = Vector2.LerpUnclamped(val, _to, num2);
if (num >= 1f)
{
_flyAt = -1f;
}
}
if (!_full)
{
PauseManager instance = PauseManager.Instance;
if ((Object)(object)instance != (Object)null && instance.onEndRoundScreen)
{
_hideAt = -1f;
}
else if (_hideAt < 0f)
{
_hideAt = Time.unscaledTime + 3f;
}
else if (Time.unscaledTime >= _hideAt)
{
Hide();
}
}
}
}
internal static ConfigEntry<bool> On;
internal static readonly Dictionary<int, P> All = new Dictionary<int, P>();
private static readonly Dictionary<int, float> Known = new Dictionary<int, float>();
private static readonly Dictionary<int, int> KillerOf = new Dictionary<int, int>();
private static readonly Dictionary<int, int> IdOfKiller = new Dictionary<int, int>();
private static readonly Dictionary<int, Hit> Waiting = new Dictionary<int, Hit>();
private static readonly List<int> Done = new List<int>();
private static readonly Dictionary<int, int> IdOf = new Dictionary<int, int>();
private static readonly List<Death> RoundDeaths = new List<Death>();
private static bool _firstDone;
private static bool _takeOn;
private static bool _matchOver;
private static readonly HashSet<PlayerListItem> Tagged = new HashSet<PlayerListItem>();
private static readonly FieldRef<RoundManager, TextMeshProUGUI> RoundSelf = AccessTools.FieldRefAccess<RoundManager, TextMeshProUGUI>("playerName");
private static readonly FieldRef<RoundManager, TextMeshProUGUI[]> RoundOthers = AccessTools.FieldRefAccess<RoundManager, TextMeshProUGUI[]>("enemyName");
private static readonly Regex Tag = new Regex("</?(?:#[0-9a-f]{3,8}|color(?:=[^<>]{1,20})?|b|i|u|s|size[^<>]{0,12}|alpha[^<>]{0,12}|mark[^<>]{0,20}|font[^<>]{0,30}|sup|sub|noparse|br|cspace[^<>]{0,12}|mspace[^<>]{0,12}|voffset[^<>]{0,12}|rotate[^<>]{0,12}|uppercase|lowercase|smallcaps|gradient[^<>]{0,40}|sprite[^<>]{0,40}|style[^<>]{0,20}|nobr|indent[^<>]{0,12}|pos[^<>]{0,12}|line-height[^<>]{0,12}|width[^<>]{0,12}|margin[^<>]{0,12})>", RegexOptions.IgnoreCase);
private static readonly Regex CutTag = new Regex("</?(?:#[0-9a-f]{0,8}|color[^<>]{0,20})$", RegexOptions.IgnoreCase);
private static bool _said;
internal static void Bind(ConfigFile c, Harmony h)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Expected O, but got Unknown
//IL_00c9: Expected O, but got Unknown
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Expected O, but got Unknown
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Expected O, but got Unknown
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Expected O, but got Unknown
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Expected O, but got Unknown
//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
On = c.Bind<bool>("Match Stats", "Enabled", true, "Count kills, deaths, damage and more for every player; show them between rounds and after the match.");
Type type = AccessTools.TypeByName("PlayerHealth");
h.Patch((MethodBase)AccessTools.Method(type, "sync___set_value_health", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Stats), "HealthPost", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
h.Patch((MethodBase)AccessTools.Method(type, "sync___set_value_killer", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Stats), "KillerPost", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
h.Patch((MethodBase)AccessTools.Method(typeof(RoundManager), "NextRoundCall", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Stats), "RoundEnd", (Type[])null), new HarmonyMethod(typeof(Stats), "RoundNames", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
MethodInfo methodInfo = AccessTools.Method(typeof(PlayerListItem), "SetPlayerValues", (Type[])null, (Type[])null);
if (methodInfo != null)
{
h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Stats), "TabTag", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
MethodInfo methodInfo2 = AccessTools.GetDeclaredMethods(typeof(GameManager)).Find((MethodInfo m) => m.Name.StartsWith("RpcLogic___ObserversRoundSpawn", StringComparison.Ordinal));
if (methodInfo2 != null)
{
h.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(Stats), "TakeStart", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
h.Patch((MethodBase)AccessTools.Method(typeof(ScoreManager), "ResetScores", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(Stats), "MatchReset", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
SceneManager.sceneLoaded += delegate(Scene s, LoadSceneMode m)
{
Scene(((Scene)(ref s)).name);
};
GameObject val = new GameObject("MONOLITH.Stats");
Object.DontDestroyOnLoad((Object)val);
((Object)val).hideFlags = (HideFlags)61;
Board.Me = val.AddComponent<Board>();
((Behaviour)Board.Me).enabled = false;
}
private static void HealthPost(PlayerHealth __instance, float value)
{
try
{
if (!On.Value || (Object)(object)__instance == (Object)null)
{
return;
}
int instanceID = ((Object)__instance).GetInstanceID();
float num = ((__instance.fullHealth > 0f) ? __instance.fullHealth : 100f);
if (!Known.TryGetValue(instanceID, out var value2))
{
value2 = num;
}
Known[instanceID] = value;
if (value2 <= 0f && value <= 0f)
{
return;
}
float num2 = Mathf.Min(value2, num) - value;
if (num2 <= 0.01f)
{
return;
}
int num3 = Id(__instance);
if (num3 < 0)
{
return;
}
Hit hit = new Hit
{
Victim = num3,
Dmg = Mathf.Min(num2, Mathf.Min(value2, num)) * 100f / num,
Lethal = (value <= 0f),
Frame = Time.frameCount,
Ph = __instance
};
if (__instance.fellVoid || __instance.suicide)
{
Credit(hit, -1);
return;
}
if (Waiting.TryGetValue(instanceID, out var value3))
{
Credit(value3, Attacker(instanceID, value3));
}
Waiting[instanceID] = hit;
Board.Me.Wait();
}
catch (Exception e)
{
Quiet(e);
}
}
private static void KillerPost(PlayerHealth __instance, Transform value)
{
try
{
if (On.Value && !((Object)(object)__instance == (Object)null) && !((Object)(object)value == (Object)null))
{
int instanceID = ((Object)__instance).GetInstanceID();
int num = IdOfTransform(value);
KillerOf[instanceID] = num;
if (Waiting.TryGetValue(instanceID, out var value2) && value2.Frame >= Time.frameCount - 1)
{
Waiting.Remove(instanceID);
Credit(value2, num);
}
}
}
catch (Exception e)
{
Quiet(e);
}
}
private static int Attacker(int key)
{
if (!KillerOf.TryGetValue(key, out var value))
{
return -1;
}
return value;
}
private static int Attacker(int key, Hit h)
{
int num = Attacker(key);
if (num < 0 && h.Lethal && (Object)(object)h.Ph != (Object)null && (Object)(object)h.Ph.sync___get_value_killer() != (Object)null)
{
num = IdOfTransform(h.Ph.sync___get_value_killer());
}
return num;
}
internal static void Flush(bool all = false)
{
if (Waiting.Count == 0)
{
return;
}
foreach (KeyValuePair<int, Hit> item in Waiting)
{
if (all || item.Value.Frame < Time.frameCount)
{
Credit(item.Value, Attacker(item.Key, item.Value));
Done.Add(item.Key);
}
}
foreach (int item2 in Done)
{
Waiting.Remove(item2);
}
Done.Clear();
}
private static void Credit(Hit h, int atk)
{
P p = Get(h.Victim);
if (atk == h.Victim)
{
atk = -1;
}
P p2 = ((atk >= 0) ? Get(atk) : null);
if (p2 != null && Team(atk) != Team(h.Victim))
{
p2.Dmg += h.Dmg;
p2.RDmg += h.Dmg;
}
if (!h.Lethal)
{
return;
}
p.Deaths++;
p.RD++;
p.Alive = false;
float time = Time.time;
if (p2 != null && Team(atk) != Team(h.Victim))
{
p2.Kills++;
p2.RK++;
p2.RoundKills++;
if (p2.RoundKills == 2)
{
p2.Multi++;
}
for (int num = RoundDeaths.Count - 1; num >= 0; num--)
{
Death death = RoundDeaths[num];
if (time - death.At > 3f)
{
break;
}
if (death.Killer == h.Victim && death.Victim != atk && Team(death.Victim) == Team(atk))
{
p2.Trades++;
break;
}
}
if (!_firstDone)
{
_firstDone = true;
p2.OpenK++;
p.OpenD++;
}
}
else if (!_firstDone)
{
_firstDone = true;
p.OpenD++;
}
RoundDeaths.Add(new Death
{
Victim = h.Victim,
Killer = ((p2 != null) ? atk : (-1)),
At = time
});
int num2 = Team(h.Victim);
int num3 = 0;
int num4 = 0;
P p3 = null;
foreach (KeyValuePair<int, P> item in All)
{
if (item.Value.Alive)
{
if (Team(item.Key) == num2)
{
num3++;
p3 = item.Value;
}
else
{
num4++;
}
}
}
if (num3 == 1 && num4 >= 2 && p3 != null)
{
p3.LastAlive = true;
}
}
private static void TakeStart()
{
try
{
if (On.Value)
{
FinishTake();
_takeOn = true;
}
}
catch (Exception e)
{
Quiet(e);
}
}
private static void FinishTake()
{
Flush(all: true);
if (_takeOn && RoundDeaths.Count > 0)
{
foreach (KeyValuePair<int, ClientInstance> playerInstance in ClientInstance.playerInstances)
{
if ((Object)(object)playerInstance.Value != (Object)null)
{
Get(playerInstance.Key);
}
}
foreach (KeyValuePair<int, P> item in All)
{
P value = item.Value;
if (ClientInstance.playerInstances.ContainsKey(item.Key) && Playing(item.Key))
{
value.Takes++;
if (value.Alive)
{
value.Survived++;
}
if (value.LastAlive && TeamAlive(Team(item.Key)))
{
value.Clutch++;
}
}
}
}
foreach (KeyValuePair<int, P> item2 in All)
{
P value2 = item2.Value;
value2.Alive = true;
value2.LastAlive = false;
value2.RoundKills = 0;
}
_firstDone = false;
RoundDeaths.Clear();
_takeOn = false;
}
private static bool TeamAlive(int team)
{
foreach (KeyValuePair<int, P> item in All)
{
if (item.Value.Alive && Team(item.Key) == team && ClientInstance.playerInstances.ContainsKey(item.Key))
{
return true;
}
}
return false;
}
private static void RoundEnd()
{
try
{
if (On.Value)
{
FinishTake();
Names();
if (All.Count > 0)
{
Board.Me.Show(full: false);
}
}
}
catch (Exception e)
{
Quiet(e);
}
}
private static void TabTag(PlayerListItem __instance)
{
try
{
if ((Object)(object)__instance == (Object)null)
{
return;
}
Fit((TMP_Text)(object)__instance.PlayerNameText);
if (!Tagged.Contains(__instance))
{
Tagged.Add(__instance);
if ((Object)(object)((Component)__instance).GetComponentInParent<TabScreen>(true) != (Object)null)
{
KillTag.Put((TMP_Text)(object)__instance.PlayerNameText, __instance.PlayerIdNumber);
}
}
}
catch (Exception e)
{
Quiet(e);
}
}
private static void Fit(TMP_Text t)
{
if (!((Object)(object)t == (Object)null) && !t.enableAutoSizing)
{
float fontSize = t.fontSize;
t.enableWordWrapping = false;
t.enableAutoSizing = true;
t.fontSizeMax = fontSize;
t.fontSizeMin = Mathf.Max(8f, fontSize * 0.3f);
t.overflowMode = (TextOverflowModes)0;
}
}
private static void RoundNames(RoundManager __instance)
{
try
{
Fit((TMP_Text)(object)RoundSelf.Invoke(__instance));
TextMeshProUGUI[] array = RoundOthers.Invoke(__instance);
if (array != null)
{
TextMeshProUGUI[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
Fit((TMP_Text)(object)array2[i]);
}
}
Names();
}
catch (Exception e)
{
Quiet(e);
}
}
private static void MatchReset()
{
All.Clear();
Tagged.Clear();
Known.Clear();
KillerOf.Clear();
IdOfKiller.Clear();
Waiting.Clear();
IdOf.Clear();
RoundDeaths.Clear();
_firstDone = false;
_takeOn = false;
}
private static void Scene(string name)
{
Known.Clear();
KillerOf.Clear();
IdOfKiller.Clear();
Waiting.Clear();
IdOf.Clear();
Tagged.Clear();
if (name == "VictoryScene")
{
FinishTake();
Names();
_matchOver = true;
if (On.Value && All.Count > 0)
{
Board.Me.Show(full: true);
}
return;
}
Board.Me.Hide();
if (name == "MainMenu" || _matchOver)
{
MatchReset();
_matchOver = false;
}
if (!(name != "MainMenu") || !On.Value)
{
return;
}
FinishTake();
_takeOn = true;
foreach (KeyValuePair<int, P> item in All)
{
item.Value.RK = 0;
item.Value.RD = 0;
item.Value.RDmg = 0f;
}
if ((Object)(object)RoundManager.Instance != (Object)null && (Object)(object)Board.Me != (Object)null)
{
Board.Me.Prepare();
}
}
private static P Get(int id)
{
if (!All.TryGetValue(id, out var value))
{
value = new P();
All[id] = value;
if (ClientInstance.playerInstances.TryGetValue(id, out var value2) && (Object)(object)value2 != (Object)null)
{
value.Name = Untag(value2.PlayerName);
}
}
return value;
}
private static void Names()
{
foreach (KeyValuePair<int, P> item in All)
{
ClientInstance value;
string text = ((ClientInstance.playerInstances.TryGetValue(item.Key, out value) && (Object)(object)value != (Object)null) ? Untag(value.PlayerName) : "");
if (text.Length > 0)
{
item.Value.Name = text;
}
else if (item.Value.Name.Length == 0)
{
item.Value.Name = "player " + (item.Key + 1);
}
}
}
internal static string Untag(string name)
{
if (string.IsNullOrEmpty(name))
{
return "";
}
return CutTag.Replace(Tag.Replace(name, ""), "").Trim();
}
internal static int Team(int id)
{
ScoreManager instance = ScoreManager.Instance;
int result = default(int);
if ((Object)(object)instance != (Object)null && ((SyncIDictionary<int, int>)(object)instance.PlayerIdToTeamId).TryGetValue(id, ref result))
{
return result;
}
return id;
}
private static int Id(PlayerHealth h)
{
int instanceID = ((Object)h).GetInstanceID();
if (IdOf.TryGetValue(instanceID, out var value))
{
return value;
}
value = -1;
if ((Object)(object)h.playerValues != (Object)null && (Object)(object)h.playerValues.playerClient != (Object)null)
{
value = h.playerValues.playerClient.PlayerId;
}
if (value >= 0)
{
IdOf[instanceID] = value;
}
return value;
}
private static int IdOfTransform(Transform t)
{
int instanceID = ((Object)t).GetInstanceID();
if (IdOfKiller.TryGetValue(instanceID, out var value))
{
return value;
}
PlayerHealth val = ((Component)t).GetComponent<PlayerHealth>() ?? ((Component)t).GetComponentInChildren<PlayerHealth>() ?? ((Component)t).GetComponentInParent<PlayerHealth>();
value = (((Object)(object)val != (Object)null) ? Id(val) : (-1));
if (value >= 0)
{
IdOfKiller[instanceID] = value;
}
return value;
}
private static void Quiet(Exception e)
{
if (!_said)
{
_said = true;
if (MatchStatsPlugin.Log != null)
{
MatchStatsPlugin.Log.LogWarning((object)("Match stats: " + e.Message));
}
}
}
internal static string Num(float f)
{
return Mathf.RoundToInt(f).ToString(CultureInfo.InvariantCulture);
}
private static bool Playing(int id)
{
if (id >= 0)
{
return id < 4;
}
return false;
}
internal static List<KeyValuePair<int, P>> Sorted()
{
List<KeyValuePair<int, P>> list = new List<KeyValuePair<int, P>>();
foreach (KeyValuePair<int, P> item in All)
{
if (Playing(item.Key))
{
list.Add(item);
}
}
list.Sort((KeyValuePair<int, P> a, KeyValuePair<int, P> b) => (Team(a.Key) == Team(b.Key)) ? ((b.Value.Kills == a.Value.Kills) ? b.Value.Dmg.CompareTo(a.Value.Dmg) : b.Value.Kills.CompareTo(a.Value.Kills)) : Team(a.Key).CompareTo(Team(b.Key)));
return list;
}
}