using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("BetterMore")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BetterMore")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("dd0747dc-1026-4f0c-8b30-7c42bff6753e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BetterMore
{
[BepInPlugin("niceh.BetterMore", "BetterMore", "1.0.0")]
public class BetterMore : BaseUnityPlugin
{
public const string GUID = "niceh.BetterMore";
public const string Name = "BetterMore";
public static BetterMore Instance { get; private set; }
public static ManualLogSource Log { get; private set; }
private void Awake()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
new Harmony("niceh.BetterMore").PatchAll();
}
}
}
namespace BetterMore.Patches
{
[HarmonyPatch(typeof(StartOfRound), "WritePlayerNotes")]
internal static class WritePlayerNotes
{
private static Random CauseOfDeathRandom { get; set; }
private static void Prefix(StartOfRound __instance)
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
foreach (PlayerControllerB item in __instance.allPlayerObjects.Select((GameObject x) => x.GetComponent<PlayerControllerB>()))
{
try
{
if (item.isPlayerDead)
{
CauseOfDeathRandom = new Random((int)item.playerClientId + __instance.randomMapSeed);
string deathNote = GetDeathNote(item.causeOfDeath);
if (!Utility.IsNullOrWhiteSpace(deathNote))
{
__instance.gameStats.allPlayerStats[item.playerClientId].playerNotes.Add(deathNote);
}
}
}
catch (Exception ex)
{
BetterMore.Log.LogError((object)ex);
}
}
}
private static string GetDeathNote(CauseOfDeath causeOfDeath)
{
//IL_0000: 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_0034: Expected I4, but got Unknown
switch (causeOfDeath - 1)
{
case 0:
return RandomT<string>("Beaten up to a pulp.", "Pummeled into oblivion.", "Battered beyond recognition.");
case 1:
return RandomT<string>("Forgot gravity existed.");
case 2:
return RandomT<string>("Reduced to smithereens.", "Evaporated in the boom.", "Went out with a bang.");
case 3:
return RandomT<string>("Ambushed from behind.", "Caught off guard.");
case 4:
return RandomT<string>("Forgot how to breathe.", "Ran out of airtime.");
case 5:
return RandomT<string>("Turned into ground beef.", "Ripped to shreds.", "Mangled beyond repair.", "Shredded to bits.", "Disassembled violently.");
case 6:
return RandomT<string>("Took one for the team.", "Bullet's new best friend.", "Caught the deadly rain.");
case 7:
return RandomT<string>("Squashed flat involuntary.", "Compressed beyond limits.");
case 8:
return RandomT<string>("Turned into fish food.", "Forgot to bring a snorkel.", "Swam with the fishes.");
case 9:
{
string planetName = Object.FindObjectOfType<Terminal>().moonsCatalogueList[RoundManager.Instance.currentLevel.levelID].PlanetName;
return "Still left on " + planetName;
}
case 10:
return RandomT<string>("The most conductive employee.");
default:
return string.Empty;
}
}
private static T RandomT<T>(params T[] tees)
{
return tees[CauseOfDeathRandom.Next(tees.Length)];
}
}
}