using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Battle;
using BepInEx;
using BepInEx.Logging;
using Cruciball;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Peglin.Achievements;
using PeglinUI;
using PeglinUI.LoadoutManager;
using PeglinUI.MainMenu;
using PeglinUI.UIUtils;
using TMPro;
using ToolBox.Serialization;
using UI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CustomCruciball")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Allows customising of individual cruciball levels from a custom start")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0+5a129409347849bccd26bb0c92c543ec0b325320")]
[assembly: AssemblyProduct("Custom Cruciball")]
[assembly: AssemblyTitle("CustomCruciball")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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;
}
}
}
namespace CustomCruciball
{
public class Assets
{
public static readonly Sprite Unchecked = MakeSprite("unchecked.png");
public static readonly Sprite Checked = MakeSprite("checked.png");
private static byte[] GetAsset(string assetname)
{
Assembly assembly = typeof(Plugin).Assembly;
string name = assembly.GetName().Name + ".assets." + assetname;
Stream manifestResourceStream = assembly.GetManifestResourceStream(name);
int num = (int)manifestResourceStream.Length;
int i = 0;
byte[] array = new byte[num];
int num2;
for (; i < num; i += num2)
{
num2 = manifestResourceStream.Read(array, i, num - i);
if (num2 == 0)
{
break;
}
}
return array;
}
private static Sprite MakeSprite(string assetname)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
ImageConversion.LoadImage(val, GetAsset(assetname));
((Texture)val).filterMode = (FilterMode)0;
((Texture)val).wrapMode = (TextureWrapMode)1;
((Texture)val).wrapModeU = (TextureWrapMode)1;
((Texture)val).wrapModeV = (TextureWrapMode)1;
((Texture)val).wrapModeW = (TextureWrapMode)1;
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
}
}
public class Constants
{
public const int NUM_LEVELS = 20;
public const int NUM_COLS = 3;
public const int NUM_ROWS = 7;
public const float POPUP_XMIN = -147f;
public const float POPUP_XMAX = 147f;
public const float POPUP_YMIN = -75f;
public const float POPUP_YMAX = 85f;
public const float CELL_WIDTH = 98f;
public const float CELL_HEIGHT = 22.857143f;
public static readonly string[] LABELS = new string[20]
{
"Add one Pebball\nPebballs have -0/-1", "Minibosses can\nappear in ?", "One less <sprite name=\"CRIT_PEG\">", "Misnavigation deals\nmore damage", "One less <sprite name=\"REFRESH_PEG\">", "Enemies have more HP", "Post-battle\nhealing reduced", "Receive less gold", "<sprite name=\"RIGGED_BOMB\"> hurts more", "Bosses have more HP",
"Add Terriball", "Reduced <sprite name=\"BOMB\"> damage", "Heal less\nafter bosses", "Reduced Max HP", "Extra enemy turn\non reload", "Add Horriball", "Minibosses deal\nmore damage", "Shop is more\nexpensive", "Additional enemies", "Additional boss\nmechanics"
};
}
[HarmonyPatch]
public class CustomUI
{
[CompilerGenerated]
private static class <>O
{
public static UnityAction <0>__MoveToCruxEditor;
}
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static UnityAction <>9__22_0;
public static UnityAction <>9__22_1;
internal void <InitialisePage>b__22_0()
{
ReturnFromCruxEditor(apply: false);
}
internal void <InitialisePage>b__22_1()
{
ReturnFromCruxEditor(apply: true);
}
}
private static GameObject cruxButtonPanel;
private static GameObject cruxButtonLabel;
private static GameObject cruxDisplay;
private static GameObject cruxInputPopup;
private static GameObject[] cruxDisplayImg;
private static GameObject[] cruxCheckbox;
private static LoadoutManager loadoutManager;
private static CruciballManager cruciballManager;
private static GameObject buttonRow;
private static GameObject seedButtonPanel;
private static GameObject seedText;
private static GameObject seedButton;
private static GameObject seedButtonLabel;
private static GameObject loadoutBasePanel;
private static GameObject seedInputPopup;
private static GameObject popupContainer;
private static GameObject seedApplyButton;
private static GameObject cruciballWheelButton;
private static GameObject cruciballWheel;
[HarmonyPatch(typeof(LoadoutManager), "MoveToLoadoutSelection")]
[HarmonyPostfix]
private static void InitialiseUI()
{
if ((Object)(object)loadoutManager == (Object)null)
{
loadoutManager = Utils.GetResource<LoadoutManager>();
if ((Object)(object)loadoutManager == (Object)null)
{
Plugin.Logger.LogError((object)"Could not find LoadoutManager!");
return;
}
}
if ((Object)(object)cruciballManager == (Object)null)
{
cruciballManager = Utils.GetResource<CruciballManager>();
if ((Object)(object)cruciballManager == (Object)null)
{
Plugin.Logger.LogError((object)"Could not find CruciballManager!");
return;
}
}
InitialiseBaseCanvas();
InitialiseButton();
InitialisePage();
UpdateCruxDisplay();
}
private static void InitialiseBaseCanvas()
{
if (!((Object)(object)cruciballWheel != (Object)null))
{
GameObject gameObject = ((Component)loadoutManager.characterSelectCanvasGroup).gameObject;
cruciballWheelButton = ((Component)gameObject.transform.Find("CruciballToggleButton")).gameObject;
cruciballWheel = ((Component)gameObject.transform.Find("CruciballLevelSelectContainer")).gameObject;
}
}
private static void InitialiseButton()
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: 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_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Expected O, but got Unknown
//IL_0219: 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_0224: Expected O, but got Unknown
if (!((Object)(object)cruxButtonPanel != (Object)null))
{
seedButtonPanel = ((Component)((Component)loadoutManager.seedDisplay).transform.parent).gameObject;
buttonRow = ((Component)seedButtonPanel.transform.parent).gameObject;
seedText = ((Component)seedButtonPanel.GetComponentInChildren<TextMeshProUGUI>()).gameObject;
seedButton = ((Component)seedButtonPanel.GetComponentInChildren<Button>()).gameObject;
seedButtonLabel = ((Component)seedButton.GetComponentInChildren<ImageReactToButtonPressDepress>()).gameObject;
((RectTransform)seedButtonPanel.transform).sizeDelta = new Vector2(180f, 34.2343f);
cruxButtonPanel = MakePanel(buttonRow, "CruxButtonPanel", 180f, 32.2343f);
CopyImage(seedButtonPanel, cruxButtonPanel);
cruxButtonLabel = MakeText(cruxButtonPanel, "CruxButtonLabel", "Cruciball", 80f, 29.5f, (TextAlignmentOptions)4097, 14f, 20f);
cruxDisplay = MakeObject(cruxButtonPanel, "CruxDisplay", 120f, 24f);
cruxDisplayImg = (GameObject[])(object)new GameObject[20];
for (int i = 0; i < 20; i++)
{
GameObject val = MakeImage(cruxDisplay, $"CruxDisplay{i}", Assets.Unchecked);
val.transform.localScale = new Vector3(0.75f, 0.75f, 1f);
int num = i % 10;
int num2 = i / 10;
val.transform.localPosition = new Vector3(12f * (float)num - 54f, 0f - (12f * (float)num2 - 6f), 1f);
cruxDisplayImg[i] = val;
}
Button componentInChildren = MakeButton(cruxButtonPanel, "CruxButton", 40f, 40f, 0).GetComponentInChildren<Button>();
if (componentInChildren.onClick == null)
{
componentInChildren.onClick = new ButtonClickedEvent();
}
ButtonClickedEvent onClick = componentInChildren.onClick;
object obj = <>O.<0>__MoveToCruxEditor;
if (obj == null)
{
UnityAction val2 = MoveToCruxEditor;
<>O.<0>__MoveToCruxEditor = val2;
obj = (object)val2;
}
((UnityEvent)onClick).AddListener((UnityAction)obj);
}
}
private static void InitialisePage()
{
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Expected O, but got Unknown
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Expected O, but got Unknown
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Expected O, but got Unknown
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Expected O, but got Unknown
if ((Object)(object)cruxInputPopup != (Object)null)
{
return;
}
loadoutBasePanel = loadoutManager.loadoutBasePanel;
seedInputPopup = ((Component)loadoutManager.seedInputPopup).gameObject;
popupContainer = ((Component)seedInputPopup.transform.parent).gameObject;
GameObject gameObject = ((Component)seedInputPopup.transform.Find("FadeBackground")).gameObject;
GameObject gameObject2 = ((Component)gameObject.transform.Find("SeedInputBackground")).gameObject;
seedApplyButton = ((Component)gameObject2.transform.Find("ButtonPanel").GetChild(0)).gameObject;
cruxInputPopup = MakeObject(popupContainer, "CruxInputPopup", 543f, 200f);
cruxInputPopup.SetActive(false);
CopyImage(gameObject, cruxInputPopup);
GameObject val = MakeObject(cruxInputPopup, "CruxInputPopupBg", 300f, 175f);
CopyImage(gameObject2, val);
GameObject obj = MakePanel(val, "CruxButtonRow", 300f, 15f, vertical: false, -15f);
obj.transform.localPosition = new Vector3(0f, -84f, 0f);
GameObject val2 = MakeButton(obj, "CruxReset", 100f, 30f, 2, "Reset");
GameObject obj2 = MakeButton(obj, "CruxApply", 100f, 30f, 1, "Apply");
Button componentInChildren = val2.GetComponentInChildren<Button>();
if (componentInChildren.onClick == null)
{
componentInChildren.onClick = new ButtonClickedEvent();
}
ButtonClickedEvent onClick = componentInChildren.onClick;
object obj3 = <>c.<>9__22_0;
if (obj3 == null)
{
UnityAction val3 = delegate
{
ReturnFromCruxEditor(apply: false);
};
<>c.<>9__22_0 = val3;
obj3 = (object)val3;
}
((UnityEvent)onClick).AddListener((UnityAction)obj3);
componentInChildren = obj2.GetComponentInChildren<Button>();
if (componentInChildren.onClick == null)
{
componentInChildren.onClick = new ButtonClickedEvent();
}
ButtonClickedEvent onClick2 = componentInChildren.onClick;
object obj4 = <>c.<>9__22_1;
if (obj4 == null)
{
UnityAction val4 = delegate
{
ReturnFromCruxEditor(apply: true);
};
<>c.<>9__22_1 = val4;
obj4 = (object)val4;
}
((UnityEvent)onClick2).AddListener((UnityAction)obj4);
cruxCheckbox = (GameObject[])(object)new GameObject[20];
for (int i = 0; i < 20; i++)
{
MakeCheckbox(cruxInputPopup, i);
}
}
private static void DbgObject(string label, GameObject obj)
{
Plugin.Logger.LogInfo((object)$"{label} {obj}");
Component[] components = obj.GetComponents<Component>();
foreach (Component val in components)
{
Plugin.Logger.LogInfo((object)$" * {((object)val).GetType()}");
}
}
private static GameObject MakeObject(GameObject parent, string name, float width, float height)
{
//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_002f: 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)
//IL_0053: Expected O, but got Unknown
GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
RectTransform component = val.GetComponent<RectTransform>();
((Transform)component).SetParent(parent.transform, false);
component.sizeDelta = new Vector2(width, height);
((Transform)component).localScale = new Vector3(1f, 1f, 1f);
return val;
}
private static GameObject MakePanel(GameObject parent, string name, float width, float height, bool vertical = false, float spacing = 3f)
{
GameObject val = MakeObject(parent, name, width, height);
HorizontalOrVerticalLayoutGroup val2 = (HorizontalOrVerticalLayoutGroup)((!vertical) ? ((object)val.AddComponent<HorizontalLayoutGroup>()) : ((object)val.AddComponent<VerticalLayoutGroup>()));
val2.childControlWidth = false;
val2.childControlHeight = false;
val2.childForceExpandWidth = false;
val2.childForceExpandHeight = false;
val2.spacing = spacing;
((LayoutGroup)val2).childAlignment = (TextAnchor)4;
return val;
}
private static GameObject MakeText(GameObject parent, string name, string label, float width, float height, TextAlignmentOptions align, float fontSizeMin, float fontSizeMax)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
GameObject obj = MakeObject(parent, name, width, height);
TextMeshProUGUI obj2 = obj.AddComponent<TextMeshProUGUI>();
((TMP_Text)obj2).text = label;
((TMP_Text)obj2).alignment = align;
((Graphic)obj2).color = new Color(0f, 0f, 0f, 1f);
((TMP_Text)obj2).enableAutoSizing = true;
((TMP_Text)obj2).enableKerning = true;
((TMP_Text)obj2).enableWordWrapping = false;
((TMP_Text)obj2).fontSize = fontSizeMax;
((TMP_Text)obj2).fontSizeMax = fontSizeMax;
((TMP_Text)obj2).fontSizeMin = fontSizeMin;
return obj;
}
private static GameObject MakeButton(GameObject parent, string name, float width, float height, int style, string text = "")
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Expected O, but got Unknown
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Expected O, but got Unknown
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Expected O, but got Unknown
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Expected O, but got Unknown
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Expected O, but got Unknown
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Expected O, but got Unknown
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_0224: Expected O, but got Unknown
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Expected O, but got Unknown
GameObject val = MakeObject(parent, name, width, height);
val.AddComponent<ButtonHandleHover>();
Button val2 = val.AddComponent<Button>();
ButtonDownUpHandler val3 = val.AddComponent<ButtonDownUpHandler>();
switch (style)
{
case 0:
{
val.transform.localScale = new Vector3(0.75f, 0.75f, 1f);
CopyImage(seedButton, val);
Button component2 = seedButton.GetComponent<Button>();
((Selectable)val2).transition = ((Selectable)component2).transition;
((Selectable)val2).spriteState = ((Selectable)component2).spriteState;
GameObject val5 = MakeObject(val, name + "_lbl", width, height);
CopyImage(seedButtonLabel, val5);
ImageReactToButtonPressDepress val6 = val5.AddComponent<ImageReactToButtonPressDepress>();
if (val3.onPointerDown == null)
{
val3.onPointerDown = new UnityEvent();
}
if (val3.onPointerUp == null)
{
val3.onPointerUp = new UnityEvent();
}
val3.onPointerDown.AddListener(new UnityAction(val6.Press));
val3.onPointerUp.AddListener(new UnityAction(val6.Depress));
break;
}
case 1:
case 2:
{
val.transform.localScale = new Vector3(0.54f, 0.54f, 1f);
CopyImage(seedApplyButton, val);
if (style == 1)
{
((Graphic)val.GetComponent<Image>()).color = new Color(0.2078f, 0.5686f, 0.3373f, 1f);
}
else
{
((Graphic)val.GetComponent<Image>()).color = new Color(0.783f, 0.3049f, 0.2992f, 1f);
}
Button component = seedApplyButton.GetComponent<Button>();
((Selectable)val2).transition = ((Selectable)component).transition;
((Selectable)val2).spriteState = ((Selectable)component).spriteState;
TextReactToButtonPressDepress val4 = MakeText(val, name + "_lbl", text, width, height, (TextAlignmentOptions)4098, 20f, 20f).AddComponent<TextReactToButtonPressDepress>();
if (val3.onPointerDown == null)
{
val3.onPointerDown = new UnityEvent();
}
if (val3.onPointerUp == null)
{
val3.onPointerUp = new UnityEvent();
}
val3.onPointerDown.AddListener(new UnityAction(val4.Press));
val3.onPointerUp.AddListener(new UnityAction(val4.Depress));
break;
}
}
return val;
}
private static void CopyImage(GameObject src, GameObject dst)
{
//IL_000f: 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_004b: 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)
RectTransform component = src.GetComponent<RectTransform>();
RectTransform component2 = dst.GetComponent<RectTransform>();
component2.sizeDelta = component.sizeDelta;
((Transform)component2).localScale = ((Transform)component).localScale;
Image component3 = src.GetComponent<Image>();
Image obj = dst.AddComponent<Image>();
obj.sprite = component3.sprite;
obj.pixelsPerUnitMultiplier = component3.pixelsPerUnitMultiplier;
obj.type = component3.type;
((Graphic)obj).color = ((Graphic)component3).color;
}
private static GameObject MakeImage(GameObject parent, string name, Sprite sprite)
{
//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_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)
Rect rect = sprite.rect;
float width = ((Rect)(ref rect)).width;
rect = sprite.rect;
GameObject obj = MakeObject(parent, name, width, ((Rect)(ref rect)).height);
obj.AddComponent<Image>().sprite = sprite;
return obj;
}
private static GameObject MakeCheckbox(GameObject parent, int ix)
{
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Expected O, but got Unknown
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Expected O, but got Unknown
float num;
float num2;
if (ix < 7)
{
num = 0f;
num2 = ix;
}
else if (ix < 13)
{
num = 1f;
num2 = (float)ix - 6.5f;
}
else
{
num = 2f;
num2 = ix - 13;
}
GameObject val = MakeObject(parent, $"CruxCheckboxPanel{ix + 1}", 98f, 22.857143f);
val.transform.localPosition = new Vector3(-147f + 98f * (num + 0.5f), 85f - 22.857143f * (num2 + 0.5f), 0f);
cruxCheckbox[ix] = MakeImage(val, $"CruxCheckbox{ix + 1}", Assets.Unchecked);
cruxCheckbox[ix].transform.localPosition = new Vector3(-37.571426f, 0f, 0f);
MakeText(val, $"CruxCheckboxLabel{ix + 1}", $"[{ix + 1}] {Constants.LABELS[ix]}", 75.14285f, 22.857143f, (TextAlignmentOptions)4097, 10f, 10f).transform.localPosition = new Vector3(11.428572f, 0f, 0f);
Button val2 = val.AddComponent<Button>();
if (val2.onClick == null)
{
val2.onClick = new ButtonClickedEvent();
}
((UnityEvent)val2.onClick).AddListener((UnityAction)delegate
{
ToggleCheckbox(ix);
});
return val;
}
[HarmonyPatch(typeof(SeedInputPopup), "ReturnToCustomStartMenu")]
[HarmonyPostfix]
private static void CloseCustomSeed(SeedInputPopup __instance)
{
seedText.SetActive(!__instance.hasCustomSeed);
}
[HarmonyPatch(typeof(LoadoutManager), "DefaultLoadout")]
[HarmonyPostfix]
private static void ResetCustomSeed()
{
seedText.SetActive(true);
}
private static void UpdateDisplay(GameObject obj, bool state)
{
if ((Object)(object)obj != (Object)null)
{
obj.GetComponent<Image>().sprite = (state ? Assets.Checked : Assets.Unchecked);
}
}
internal static void UpdateCruxDisplay()
{
if ((Object)(object)cruxButtonLabel != (Object)null)
{
cruxButtonLabel.SetActive(!State.inst.isCustom);
}
if ((Object)(object)cruxDisplay != (Object)null)
{
cruxDisplay.SetActive(State.inst.isCustom);
}
for (int i = 0; i < 20; i++)
{
UpdateDisplay(cruxDisplayImg[i], State.inst.levels[i]);
}
}
private static void UpdateCruxCheckboxes()
{
if (!State.inst.isCustom)
{
int currentCruciballLevel = cruciballManager._currentCruciballLevel;
for (int i = 0; i < 20; i++)
{
State.inst.levels[i] = i < currentCruciballLevel;
}
}
for (int j = 0; j < 20; j++)
{
UpdateDisplay(cruxCheckbox[j], State.inst.levels[j]);
}
}
private static void ToggleCheckbox(int ix)
{
State.inst.levels[ix] = !State.inst.levels[ix];
UpdateDisplay(cruxCheckbox[ix], State.inst.levels[ix]);
}
private static void MoveToCruxEditor()
{
loadoutBasePanel.SetActive(false);
cruxInputPopup.SetActive(true);
UpdateCruxCheckboxes();
}
private static void ReturnFromCruxEditor(bool apply)
{
State.inst.isCustom = apply;
loadoutBasePanel.SetActive(true);
cruxInputPopup.SetActive(false);
UpdateCruxDisplay();
}
[HarmonyPatch(typeof(LoadoutManager), "ReturnFromLoadoutSelection")]
[HarmonyPostfix]
private static void FinishedCustomStart()
{
cruciballWheelButton.SetActive(!State.inst.isCustom);
cruciballWheel.SetActive(!State.inst.isCustom);
}
[HarmonyPatch(typeof(LoadoutManager), "ReturnFromLoadoutSelection")]
[HarmonyPostfix]
private static void ShowCustomWarning(LoadoutManager __instance)
{
if (State.inst.isCustom)
{
__instance.customLoadoutWarning.SetActive(true);
}
}
[HarmonyPatch(typeof(LoadoutManager), "SetupDataForNewGame")]
[HarmonyPostfix]
private static void DisableAchievements(LoadoutManager __instance)
{
if (State.inst.isCustom)
{
AchievementManager.AchievementsOn = false;
}
}
[HarmonyPatch(typeof(PlayButton), "SetUpNewGameOnLoadMapData")]
[HarmonyPostfix]
private static void SetCustomRun()
{
if (State.inst.isCustom)
{
StaticGameData.CurrentRunStats.isCustomRun = true;
}
}
}
[HarmonyPatch]
public class Hooks
{
private static int currContext = -1;
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPrefix]
private static bool GetCruciballLevel(ref int __result)
{
if (!State.inst.isCustom)
{
return true;
}
if (currContext >= 0)
{
__result = (State.inst.levels[currContext] ? 20 : 0);
return false;
}
__result = 0;
for (int i = 0; i < 20; i++)
{
if (State.inst.levels[i])
{
__result++;
}
}
return false;
}
[HarmonyPatch(typeof(BattleController), "Awake")]
[HarmonyPostfix]
private static void HandleLeshy(BattleController __instance)
{
if (State.inst.isCustom)
{
__instance._pegManager.isC20Leshy = State.inst.levels[19];
}
}
[HarmonyPatch(typeof(PlayerInfoUI), "ChangeFloorText")]
[HarmonyPostfix]
private static void CustomDisplay(PlayerInfoUI __instance)
{
if (State.inst.isCustom && (Object)(object)__instance.cruciballText != (Object)null)
{
((Component)((TMP_Text)__instance.cruciballText).transform.parent).gameObject.SetActive(true);
((TMP_Text)__instance.cruciballText).text = "Cruciball Custom";
}
}
[HarmonyPatch(typeof(CruciballManager), "AdditionalStarterStones")]
[HarmonyPrefix]
private static void Enable0(ref int __state)
{
__state = currContext;
currContext = 0;
}
[HarmonyPatch(typeof(CruciballManager), "AdditionalStarterStones")]
[HarmonyPostfix]
private static void Disable0(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "WeakStones")]
[HarmonyPrefix]
private static void Enable0Weak(ref int __state)
{
__state = currContext;
currContext = 0;
}
[HarmonyPatch(typeof(CruciballManager), "WeakStones")]
[HarmonyPostfix]
private static void Disable0Weak(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "GetUnknownMapEliteChance")]
[HarmonyPrefix]
private static void Enable1(ref int __state)
{
__state = currContext;
currContext = 1;
}
[HarmonyPatch(typeof(CruciballManager), "GetUnknownMapEliteChance")]
[HarmonyPostfix]
private static void Disable1(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "FewerCritPegs")]
[HarmonyPrefix]
private static void Enable2(ref int __state)
{
__state = currContext;
currContext = 2;
}
[HarmonyPatch(typeof(CruciballManager), "FewerCritPegs")]
[HarmonyPostfix]
private static void Disable2(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "GetModifiedMisnavigationDamage")]
[HarmonyPrefix]
private static void Enable3(ref int __state)
{
__state = currContext;
currContext = 3;
}
[HarmonyPatch(typeof(CruciballManager), "GetModifiedMisnavigationDamage")]
[HarmonyPostfix]
private static void Disable3(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "FewerRefreshPegs")]
[HarmonyPrefix]
private static void Enable4(ref int __state)
{
__state = currContext;
currContext = 4;
}
[HarmonyPatch(typeof(CruciballManager), "FewerRefreshPegs")]
[HarmonyPostfix]
private static void Disable4(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "EnemyShouldUseImprovedHealth")]
[HarmonyPrefix]
private static void Enable5(ref int __state, bool boss)
{
__state = currContext;
currContext = (boss ? 9 : 5);
}
[HarmonyPatch(typeof(CruciballManager), "EnemyShouldUseImprovedHealth")]
[HarmonyPostfix]
private static void Disable5(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "GetModifiedPostBattleHeal")]
[HarmonyPrefix]
private static void Enable6(ref int __state)
{
__state = currContext;
currContext = 6;
}
[HarmonyPatch(typeof(CruciballManager), "GetModifiedPostBattleHeal")]
[HarmonyPostfix]
private static void Disable6(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "IsLessGoldAvailable")]
[HarmonyPrefix]
private static void Enable7(ref int __state)
{
__state = currContext;
currContext = 7;
}
[HarmonyPatch(typeof(CruciballManager), "IsLessGoldAvailable")]
[HarmonyPostfix]
private static void Disable7(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "GetStartingGold")]
[HarmonyPrefix]
private static void Enable7Start(ref int __state)
{
__state = currContext;
currContext = 7;
}
[HarmonyPatch(typeof(CruciballManager), "GetStartingGold")]
[HarmonyPostfix]
private static void Disable7Start(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "GetAvailableBattleGold")]
[HarmonyPrefix]
private static void Enable7Battle(ref int __state)
{
__state = currContext;
currContext = 7;
}
[HarmonyPatch(typeof(CruciballManager), "GetAvailableBattleGold")]
[HarmonyPostfix]
private static void Disable7Battle(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "GetModifiedExternalGoldAdd")]
[HarmonyPrefix]
private static void Enable7Ext(ref int __state)
{
__state = currContext;
currContext = 7;
}
[HarmonyPatch(typeof(CruciballManager), "GetModifiedExternalGoldAdd")]
[HarmonyPostfix]
private static void Disable7Ext(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "IncreasedRiggedDamage")]
[HarmonyPrefix]
private static void Enable8(ref int __state)
{
__state = currContext;
currContext = 8;
}
[HarmonyPatch(typeof(CruciballManager), "IncreasedRiggedDamage")]
[HarmonyPostfix]
private static void Disable8(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "ShouldAddCursedOrb")]
[HarmonyPrefix]
private static void Enable10(ref int __state)
{
__state = currContext;
currContext = 10;
}
[HarmonyPatch(typeof(CruciballManager), "ShouldAddCursedOrb")]
[HarmonyPostfix]
private static void Disable10(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "DecreasedBombDamage")]
[HarmonyPrefix]
private static void Enable11(ref int __state)
{
__state = currContext;
currContext = 11;
}
[HarmonyPatch(typeof(CruciballManager), "DecreasedBombDamage")]
[HarmonyPostfix]
private static void Disable11(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "LessHealingFromBosses")]
[HarmonyPrefix]
private static void Enable12(ref int __state)
{
__state = currContext;
currContext = 12;
}
[HarmonyPatch(typeof(CruciballManager), "LessHealingFromBosses")]
[HarmonyPostfix]
private static void Disable12(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "ShouldReduceMaxHP")]
[HarmonyPrefix]
private static void Enable13(ref int __state)
{
__state = currContext;
currContext = 13;
}
[HarmonyPatch(typeof(CruciballManager), "ShouldReduceMaxHP")]
[HarmonyPostfix]
private static void Disable13(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "EnemiesGetExtraReloadTurn")]
[HarmonyPrefix]
private static void Enable14(ref int __state)
{
__state = currContext;
currContext = 14;
}
[HarmonyPatch(typeof(CruciballManager), "EnemiesGetExtraReloadTurn")]
[HarmonyPostfix]
private static void Disable14(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "ShouldAddUnremovableCursedOrb")]
[HarmonyPrefix]
private static void Enable15(ref int __state)
{
__state = currContext;
currContext = 15;
}
[HarmonyPatch(typeof(CruciballManager), "ShouldAddUnremovableCursedOrb")]
[HarmonyPostfix]
private static void Disable15(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "GetMinibossDamageModifier")]
[HarmonyPrefix]
private static void Enable16(ref int __state)
{
__state = currContext;
currContext = 16;
}
[HarmonyPatch(typeof(CruciballManager), "GetMinibossDamageModifier")]
[HarmonyPostfix]
private static void Disable16(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "ShouldIncreaseShopPrices")]
[HarmonyPrefix]
private static void Enable17(ref int __state)
{
__state = currContext;
currContext = 17;
}
[HarmonyPatch(typeof(CruciballManager), "ShouldIncreaseShopPrices")]
[HarmonyPostfix]
private static void Disable17(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "CanSpawnBonusEnemies")]
[HarmonyPrefix]
private static void Enable18(ref int __state)
{
__state = currContext;
currContext = 18;
}
[HarmonyPatch(typeof(CruciballManager), "CanSpawnBonusEnemies")]
[HarmonyPostfix]
private static void Disable18(int __state)
{
currContext = __state;
}
[HarmonyPatch(typeof(CruciballManager), "ShouldUpgradeBosses")]
[HarmonyPrefix]
private static void Enable19(ref int __state)
{
__state = currContext;
currContext = 19;
}
[HarmonyPatch(typeof(CruciballManager), "ShouldUpgradeBosses")]
[HarmonyPostfix]
private static void Disable19(int __state)
{
currContext = __state;
}
}
[BepInPlugin("com.mrphlip.peglin.CustomCruciball", "Custom Cruciball", "1.0")]
[BepInProcess("Peglin.exe")]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("com.mrphlip.peglin.CustomCruciball");
internal static ManualLogSource Logger;
private void Awake()
{
harmony.PatchAll();
Logger = ((BaseUnityPlugin)this).Logger;
}
}
[HarmonyPatch]
public class State : SaveObjectData
{
public static readonly State inst = new State();
public bool isCustom;
public bool[] levels = new bool[20];
public static readonly string KEY = "com.mrphlip.peglin.CustomCruciball_CustomCruxData";
public override string Name => KEY;
[HarmonyPatch(typeof(LoadoutManager), "Cancel")]
[HarmonyPrefix]
private static void Cancel()
{
inst.isCustom = false;
}
[HarmonyPatch(typeof(LoadoutManager), "DefaultLoadout")]
[HarmonyPrefix]
private static void Reset()
{
inst.isCustom = false;
CustomUI.UpdateCruxDisplay();
}
[HarmonyPatch(typeof(LoadoutManager), "OnEnable")]
[HarmonyPrefix]
private static void Init()
{
inst.isCustom = false;
}
private State()
: base(true, (SaveType)1)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
SaveManager.OnLoadRequested = (LoadRequested)Delegate.Combine((Delegate?)(object)SaveManager.OnLoadRequested, (Delegate?)new LoadRequested(Load));
SaveManager.OnSaveRequested = (SaveRequested)Delegate.Combine((Delegate?)(object)SaveManager.OnSaveRequested, (Delegate?)new SaveRequested(base.Save));
}
private void Load()
{
State state = (State)(object)DataSerializer.Load<SaveObjectData>(KEY, (SaveType)1);
if (state != null)
{
isCustom = state.isCustom;
Array.Copy(state.levels, levels, 20);
}
else
{
isCustom = false;
}
}
}
public class Utils
{
public static T GetResource<T>() where T : Object
{
T[] array = Resources.FindObjectsOfTypeAll<T>();
if (array.Length != 0)
{
return array[0];
}
return default(T);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.mrphlip.peglin.CustomCruciball";
public const string PLUGIN_NAME = "Custom Cruciball";
public const string PLUGIN_VERSION = "1.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}