using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.anonymousfroggo.grubadoption")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.3.0")]
[assembly: AssemblyInformationalVersion("0.1.3+a5561193c4df2cdedfc49bae22f6a026cc9dae57")]
[assembly: AssemblyProduct("Grub Adoption")]
[assembly: AssemblyTitle("com.anonymousfroggo.grubadoption")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
public abstract class CustomStat
{
private readonly string id;
protected object value;
private readonly DataType type;
private readonly ModType modType;
private readonly DisplayType displayType;
private readonly ModType globalModType;
protected CustomStat(string id, object initialValue, DataType dataType, ModType modType, DisplayType displayType, ModType globalModType)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_0020: 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)
this.id = id;
value = initialValue;
type = dataType;
this.modType = modType;
this.displayType = displayType;
this.globalModType = globalModType;
base..ctor();
}
public void EndGameStatUpdate(bool win)
{
if (CalculateValueOnEndGame(win))
{
WriteToSessionStats();
}
}
protected virtual bool CalculateValueOnEndGame(bool win)
{
return false;
}
private void WriteToSessionStats()
{
//IL_0013: 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_001f: 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)
StatManager.sessionStats.UpdateStatistic(id, value, type, modType, displayType, globalModType);
}
public string GetId()
{
return id;
}
public abstract string GetDefaultText(StatSource statSource);
public abstract string GetTextPrefix(StatSource statSource);
public abstract bool ShouldAddToScoreScreenSession(bool win);
public abstract bool ShouldAddToScoreScreenGamemode(bool win);
public abstract bool ShouldAddToGamemode(M_Gamemode gamemode);
public abstract bool ShouldAddToLogbook();
public virtual int GetScoreScreenSessionIndex()
{
return 0;
}
public virtual int GetScoreScreenGamemodeIndex()
{
return 0;
}
public virtual int GetGamemodeIndex()
{
return 0;
}
public virtual int GetLogbookIndex()
{
return 0;
}
}
public class StatMaxGrubsAdopted : CustomStat
{
public StatMaxGrubsAdopted()
: base("max-grubs-adopted", 0, (DataType)0, (ModType)2, (DisplayType)0, (ModType)2)
{
}
protected override bool CalculateValueOnEndGame(bool win)
{
if (!win)
{
return false;
}
if (InventoryUtils.TotalItemCount(InventoryUtils.ITEM_NAME_GRUB) == 0)
{
return false;
}
value = InventoryUtils.TotalItemCount(InventoryUtils.ITEM_NAME_GRUB);
return true;
}
public override string GetDefaultText(StatSource statSource)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
return StatUtils.HasPickedUpItem(InventoryUtils.ITEM_NAME_GRUB) ? (GetTextPrefix(statSource) + 0) : "[REDACTED]";
}
public override string GetTextPrefix(StatSource statSource)
{
return "Most Adopted in a Run: ";
}
public override bool ShouldAddToScoreScreenSession(bool win)
{
return false;
}
public override bool ShouldAddToScoreScreenGamemode(bool win)
{
return ShouldAddToGamemode(CL_GameManager.gamemode) && StatUtils.HasPickedUpItem(InventoryUtils.ITEM_NAME_GRUB);
}
public override bool ShouldAddToGamemode(M_Gamemode gamemode)
{
return ((Object)gamemode).name.Equals("GM_Campaign") || ((Object)gamemode).name.Equals("GM_Playground");
}
public override bool ShouldAddToLogbook()
{
return true;
}
public override int GetScoreScreenGamemodeIndex()
{
return 8;
}
public override int GetGamemodeIndex()
{
return 15;
}
public override int GetLogbookIndex()
{
return 14;
}
}
public static class InventoryUtils
{
public static string ITEM_NAME_GRUB = "SlugGrub";
public static int TotalItemCount(string itemName)
{
return BagItemCount(itemName) + HandItemCount(itemName);
}
public static int BagItemCount(string itemName)
{
return ENT_Player.GetInventory().bagItems.Count((Item bagItem) => bagItem.itemName.Equals(itemName));
}
public static int HandItemCount(string itemName)
{
return ENT_Player.GetInventory().itemHands.Count((ItemHand itemHand) => itemHand.currentItem != null && itemHand.currentItem.itemName.Equals(itemName));
}
}
public static class StatUtils
{
public const string STAT_PICKUP_ITEM_PREFIX = "pickup-item-";
public const string STAT_ITEMS_USED = "items-used";
public const string DEFAULT_TEXT_REDACTED = "[REDACTED]";
public static string GetText(CustomStat stat, StatSource statSource)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected I4, but got Unknown
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
if (1 == 0)
{
}
GameStats val = (GameStats)((int)statSource switch
{
2 => StatManager.sessionStats,
0 => StatManager.saveData.GetGameMode(CL_GameManager.GetGamemodeName(true, false)).stats,
3 => StatManager.saveData.gameStats,
_ => null,
});
if (1 == 0)
{
}
GameStats val2 = val;
return val2.HasStatistic(stat.GetId()) ? (stat.GetTextPrefix(statSource) + val2.GetStatistic(stat.GetId()).GetString()) : stat.GetDefaultText(statSource);
}
public static bool HasStat(string id)
{
return StatManager.saveData.gameStats.HasStatistic(id) || StatManager.sessionStats.HasStatistic(id);
}
public static bool HasPickedUpItem(string itemName)
{
return HasStat("pickup-item-" + itemName);
}
}
namespace GrubAdoption
{
[BepInPlugin("com.anonymousfroggo.grubadoption", "Grub Adoption", "0.1.3")]
public class GrubAdoption : BaseUnityPlugin
{
internal static ManualLogSource Logger;
private void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Harmony val = new Harmony("com.anonymousfroggo.grubadoption");
val.PatchAll();
}
}
[HarmonyPatch]
public class CustomStatManager
{
public const string SCORE_SCREEN_SESSION_UI_NAME_PREFIX = "session-stat:";
public const string SCORE_SCREEN_GAMEMODE_UI_NAME_PREFIX = "gamemode-stat:";
public const string GAMEMODE_UI_NAME_PREFIX = "stat-";
public const string LOGBOOK_UI_NAME_PREFIX = "stat-";
private static readonly CustomStatManager instance = new CustomStatManager();
private readonly CustomStat[] customStats = new CustomStat[2]
{
new StatGrubsAdopted(),
new StatMaxGrubsAdopted()
};
private bool win;
public bool forceSaveInCheatMode = false;
public bool forceWinTrue = false;
public static bool Win
{
get
{
return instance.win;
}
set
{
instance.win = value || instance.forceWinTrue;
}
}
[HarmonyPatch(typeof(CL_GameManager), "EndGameStatUpdate")]
[HarmonyPrefix]
public static void EndGameStatUpdate(bool win)
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
Win = win;
CustomStat[] array = instance.customStats;
foreach (CustomStat customStat in array)
{
customStat.EndGameStatUpdate(Win);
}
if (!instance.forceSaveInCheatMode)
{
return;
}
foreach (Statistic statistic in StatManager.sessionStats.statistics)
{
StatManager.saveData.gameStats.UpdateStatistic(statistic.id, statistic.GetValue(), statistic.type, statistic.defaultModType, statistic.displayType, (ModType)1);
}
if ((Object)(object)CL_GameManager.gamemode != (Object)null)
{
StatManager.saveData.UpdateGamemodeStats(CL_GameManager.GetGamemodeName(true, false), StatManager.sessionStats);
}
}
[HarmonyPatch(typeof(UI_ScoreScreen), "ShowScreen")]
[HarmonyPostfix]
public static void AddStatsToScoreScreen(UI_ScoreScreen __instance)
{
if (!((Object)((Component)__instance).gameObject).name.StartsWith("ScorePanel_Standard"))
{
return;
}
Transform val = ((Component)__instance).gameObject.transform.Find("Session Page/Board/Stats/SessionStats/Game Stats Simplified");
Transform val2 = ((Component)__instance).gameObject.transform.Find("Session Page/Board/Stats/Best Stats/Top Score");
CustomStat[] array = instance.customStats;
foreach (CustomStat customStat in array)
{
if (customStat.ShouldAddToScoreScreenSession(Win))
{
GameObject val3 = Object.Instantiate<GameObject>(((Component)val.GetChild(3)).gameObject, val);
((Object)val3).name = "session-stat:" + customStat.GetId();
val3.transform.SetSiblingIndex(customStat.GetScoreScreenSessionIndex());
TextMeshProUGUI component = val3.GetComponent<TextMeshProUGUI>();
((TMP_Text)component).text = StatUtils.GetText(customStat, (StatSource)2);
}
if (customStat.ShouldAddToScoreScreenGamemode(Win))
{
Transform transform = Object.Instantiate<GameObject>(((Component)val2.GetChild(3)).gameObject, val2).transform;
((Object)((Component)transform).gameObject).name = "gamemode-stat:" + customStat.GetId();
transform.SetSiblingIndex(customStat.GetScoreScreenGamemodeIndex());
TextMeshProUGUI component2 = ((Component)transform).GetComponent<TextMeshProUGUI>();
((TMP_Text)component2).text = StatUtils.GetText(customStat, (StatSource)0);
}
}
}
[HarmonyPatch(typeof(UI_GamemodeScreen), "Initialize")]
[HarmonyPostfix]
public static void AddStatsToGamemode(UI_GamemodeScreen __instance, M_Gamemode mode)
{
Transform val = ((Component)__instance).gameObject.transform.Find("Gamemode_Panel_Base_Campaign(Clone)/Mode Page/Board/Stats/Stats/Scoregrid-Extra/");
if ((Object)(object)val == (Object)null)
{
return;
}
CustomStat[] array = instance.customStats;
foreach (CustomStat customStat in array)
{
Transform val2 = val.Find("stat-" + customStat.GetId());
if ((Object)(object)val2 != (Object)null)
{
UiUtils.Destroy(val2);
}
if (customStat.ShouldAddToGamemode(mode))
{
val2 = InstantiateStatText(customStat, val, "stat-", 1);
val2.SetSiblingIndex(customStat.GetGamemodeIndex());
((Component)val2).GetComponent<UT_StatText>().Refresh();
}
}
}
[HarmonyPatch(typeof(UI_MenuScreen), "Initialize")]
[HarmonyPostfix]
public static void AddStatsToLogbook(UI_MenuScreen __instance)
{
if (!((Object)__instance).name.Equals("Logbook"))
{
return;
}
Transform parent = ((Component)__instance).gameObject.transform.Find("Stat Page/Board/Stats/Stats/Scoregrid-Extra");
UiUtils.DestroyChild("Break-Roaches.02", parent);
UiUtils.DestroyChild("Break-Roaches", parent);
CustomStat[] array = instance.customStats;
foreach (CustomStat customStat in array)
{
if (customStat.ShouldAddToLogbook())
{
Transform val = InstantiateStatText(customStat, parent, "stat-", 1);
val.SetSiblingIndex(customStat.GetLogbookIndex());
}
}
}
private static Transform InstantiateStatText(CustomStat stat, Transform parent, string uiNamePrefix, int instantiationIndex)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
Transform transform = Object.Instantiate<GameObject>(((Component)parent.GetChild(instantiationIndex)).gameObject, parent).transform;
((Object)((Component)transform).gameObject).name = uiNamePrefix + stat.GetId();
UT_StatText component = ((Component)transform).GetComponent<UT_StatText>();
component.defaultText = stat.GetDefaultText(component.source);
component.textPrefix = stat.GetTextPrefix(component.source);
((Object)component).name = uiNamePrefix + stat.GetId();
component.statistic = stat.GetId();
return transform;
}
}
public class StatGrubsAdopted : CustomStat
{
public const string DEFAULT_TEXT_NO_GRUBS = "Don't you care about Grubs? :(";
public const string DEFAULT_TEXT_DEATH_WITH_GRUB = "You left your Grub alone T.T";
public const string DEFAULT_TEXT_DEATH_WITH_GRUBS = "You left your Grubs alone T.T";
public const string TEXT_PREFIX_SESSION = "Grubs Adopted: ";
public const string TEXT_PREFIX_GLOBAL = "Total Grubs Adopted: ";
public StatGrubsAdopted()
: base("grubs-adopted", 0, (DataType)0, (ModType)1, (DisplayType)0, (ModType)1)
{
}
protected override bool CalculateValueOnEndGame(bool win)
{
if (!win)
{
return false;
}
int num = InventoryUtils.TotalItemCount(InventoryUtils.ITEM_NAME_GRUB);
if (num == 0)
{
return false;
}
value = num;
GrubAdoption.Logger.LogInfo((object)("Grubs Adopted: " + value));
return true;
}
public override string GetDefaultText(StatSource statSource)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Invalid comparison between Unknown and I4
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
if (!StatUtils.HasPickedUpItem(InventoryUtils.ITEM_NAME_GRUB))
{
return "[REDACTED]";
}
if ((int)statSource == 2)
{
int num = InventoryUtils.TotalItemCount(InventoryUtils.ITEM_NAME_GRUB);
if (1 == 0)
{
}
string result = num switch
{
0 => "Don't you care about Grubs? :(",
1 => "You left your Grub alone T.T",
_ => "You left your Grubs alone T.T",
};
if (1 == 0)
{
}
return result;
}
return GetTextPrefix(statSource) + 0;
}
public override string GetTextPrefix(StatSource statSource)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
return ((int)statSource == 2) ? "Grubs Adopted: " : "Total Grubs Adopted: ";
}
public override bool ShouldAddToScoreScreenSession(bool win)
{
return ShouldAddToGamemode(CL_GameManager.gamemode) && StatUtils.HasPickedUpItem(InventoryUtils.ITEM_NAME_GRUB);
}
public override bool ShouldAddToScoreScreenGamemode(bool win)
{
return ShouldAddToGamemode(CL_GameManager.gamemode) && StatUtils.HasPickedUpItem(InventoryUtils.ITEM_NAME_GRUB);
}
public override bool ShouldAddToGamemode(M_Gamemode gamemode)
{
return ((Object)gamemode).name.Equals("GM_Campaign") || ((Object)gamemode).name.Equals("GM_Playground");
}
public override bool ShouldAddToLogbook()
{
return true;
}
public override int GetScoreScreenSessionIndex()
{
return 7;
}
public override int GetScoreScreenGamemodeIndex()
{
return 7;
}
public override int GetGamemodeIndex()
{
return 14;
}
public override int GetLogbookIndex()
{
return 13;
}
}
public static class UiUtils
{
public static void Destroy(Transform child)
{
Object.Destroy((Object)(object)((Component)child).gameObject);
}
public static void DestroyChild(string childName, Transform parent)
{
Transform val = parent.Find(childName);
if ((Object)(object)val == (Object)null)
{
GrubAdoption.Logger.LogError((object)("Child " + childName + " of " + ((Object)parent).name + " not found"));
}
else
{
Destroy(val);
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.anonymousfroggo.grubadoption";
public const string PLUGIN_NAME = "Grub Adoption";
public const string PLUGIN_VERSION = "0.1.3";
}
}