using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using StateLogger;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using flanne;
using flanne.Player;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Final")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Final")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("53e96529-a751-4a99-acae-2243ab77ca54")]
[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 StateLogger
{
[BepInPlugin("lucas.statelogger", "State Logger", "2.0.0")]
public class GameStateMonitor : BaseUnityPlugin
{
private const string PluginGuid = "lucas.statelogger";
private const string PluginName = "State Logger";
private const string PluginVersion = "2.0.0";
internal static ManualLogSource Log;
public static State CurrentState;
private Harmony harmony;
private void Awake()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
harmony = new Harmony("lucas.statelogger");
PatchAllStateSubclasses();
}
private void PatchAllStateSubclasses()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
Type typeFromHandle = typeof(State);
HashSet<MethodInfo> patched = new HashSet<MethodInfo>();
HarmonyMethod postfix = new HarmonyMethod(typeof(GameStateMonitor).GetMethod("EnterPostfix", BindingFlags.Static | BindingFlags.NonPublic));
HarmonyMethod postfix2 = new HarmonyMethod(typeof(GameStateMonitor).GetMethod("ExitPostfix", BindingFlags.Static | BindingFlags.NonPublic));
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
Type[] types;
try
{
types = assembly.GetTypes();
}
catch (ReflectionTypeLoadException ex)
{
types = ex.Types;
}
if (types == null)
{
continue;
}
Type[] array = types;
foreach (Type type in array)
{
if (!(type == null) && !type.IsAbstract && typeFromHandle.IsAssignableFrom(type))
{
TryPatchMethod(type, "Enter", postfix, patched);
TryPatchMethod(type, "Exit", postfix2, patched);
}
}
}
}
private void TryPatchMethod(Type type, string methodName, HarmonyMethod postfix, HashSet<MethodInfo> patched)
{
MethodInfo method;
try
{
method = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
}
catch
{
return;
}
if (method == null || method.IsAbstract || patched.Contains(method))
{
return;
}
try
{
harmony.Patch((MethodBase)method, (HarmonyMethod)null, postfix, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
patched.Add(method);
}
catch (Exception ex)
{
Log.LogWarning((object)("Failed to patch " + type.FullName + "." + methodName + ": " + ex.Message));
}
}
private static void EnterPostfix(State __instance)
{
CurrentState = __instance;
}
private static void ExitPostfix(State __instance)
{
if ((Object)(object)CurrentState == (Object)(object)__instance)
{
CurrentState = null;
}
}
}
}
namespace Final
{
public class ActionManager
{
private GameAction currentExecutingAction = null;
private bool executionToggle = true;
public List<GameAction> Actions { get; } = new List<GameAction>();
public bool ExecutingActions { get; private set; } = false;
public void AddAction(GameAction action)
{
Actions.Add(action);
SyncDisplay();
}
public void StartExecuting()
{
ExecutingActions = true;
}
public void Tick()
{
if (ExecutingActions && Actions.Count > 0)
{
if (executionToggle)
{
currentExecutingAction = Actions[0];
SyncDisplay();
currentExecutingAction.execute();
currentExecutingAction.Complete = true;
if (currentExecutingAction.Complete)
{
currentExecutingAction = null;
Actions.RemoveAt(0);
}
executionToggle = false;
}
else
{
executionToggle = true;
}
}
if (ExecutingActions && Actions.Count == 0)
{
ExecutingActions = false;
executionToggle = false;
}
}
public void SyncDisplay()
{
Main.Instance.uiAssetLoader.SyncActionDisplay(Actions);
}
}
[BepInPlugin("com.yourname.myplugin", "Plugin", "1.0.0")]
public class Main : BaseUnityPlugin
{
internal static ManualLogSource Log;
private static readonly HashSet<string> PausingStateNames = new HashSet<string> { "PauseState", "PowerupMenuState", "DevilDealState", "GunEvoMenuState", "ChestState", "OptionsState", "SynergyUIState" };
public bool placementMode = false;
public List<GameObject> InjectedUIComponents = new List<GameObject>();
public PlacementManager placementManager = new PlacementManager();
public ActionManager actionManager = new ActionManager();
public ImageRipper imageRipper = new ImageRipper();
public ScreenLogger screenLogger = new ScreenLogger();
public UIControl uiAssetLoader = new UIControl();
public GameObject _enemyUIInstance = null;
public GameObject canvasObj = null;
public string pendingEnemyName = "";
private bool firstFightStateDetected = false;
public static Main Instance { get; private set; }
private void Awake()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
Harmony val = new Harmony("com.yourname.myplugin");
val.PatchAll();
placementManager = new PlacementManager();
Patches.CatalogEnemyPrefabs();
uiAssetLoader.Start();
}
private void Update()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: 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)
Keyboard current = Keyboard.current;
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name == "Battle" && !firstFightStateDetected)
{
FirstFightState();
firstFightStateDetected = true;
}
activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name != "Battle")
{
firstFightStateDetected = false;
}
activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name == "Battle" && ((ButtonControl)current.tabKey).wasPressedThisFrame && !actionManager.ExecutingActions)
{
GameObject val = GameObject.Find("MainUIInjection");
if ((Object)(object)val == (Object)null)
{
GameObject val2 = uiAssetLoader.MakeMainUI(canvasObj.transform);
val2.transform.SetAsFirstSibling();
if ((Object)(object)val2 != (Object)null)
{
((Object)val2).name = "MainUIInjection";
}
}
else
{
placementManager.CancelPlacement();
Object.Destroy((Object)(object)val);
uiAssetLoader.UnsetDisplayBox();
actionManager.StartExecuting();
}
}
placementManager.Update();
TimeControl();
actionManager.SyncDisplay();
}
private void FixedUpdate()
{
actionManager.Tick();
}
private void FirstFightState()
{
canvasObj = GameObject.Find("Canvas");
imageRipper.FightSceneRip();
Patches.GatherResources();
GameObject val = uiAssetLoader.CreateActionDisplayUI(canvasObj.transform);
GameObject val2 = uiAssetLoader.CreateDisplayBox(canvasObj.transform);
val.transform.SetAsFirstSibling();
val2.transform.SetAsFirstSibling();
}
private void TimeControl()
{
string text = ((object)GameStateMonitor.CurrentState)?.GetType().Name;
bool flag = text != null && PausingStateNames.Contains(text);
if (text == "TransitionToRetryState" && firstFightStateDetected)
{
firstFightStateDetected = false;
}
else if (flag || (Object)(object)GameObject.Find("MainUIInjection") != (Object)null)
{
Time.timeScale = 0f;
}
else
{
Time.timeScale = 1f;
}
}
}
public class GameAction
{
public string Name { get; set; }
public bool Complete { get; set; } = false;
public Action action { get; set; }
public GameAction(string name)
{
Name = name;
}
public void execute()
{
action?.Invoke();
}
}
public class ImageRipper
{
public Image GenericBox;
public Image ScrollHandle;
public Image ScrollBar;
public TMP_FontAsset[] fonts;
public TMP_FontAsset Lantern;
public TMP_FontAsset Express;
public Color LanternRed;
public Color ButtonBlue;
public void FightSceneRip()
{
GenericBox = GameObject.Find("PauseMenu").GetComponent<Image>();
ScrollHandle = GameObject.Find("Canvas/SynergiesUI/Scroll View/Scrollbar/Sliding Area/Handle").GetComponent<Image>();
ScrollBar = GameObject.Find("Canvas/SynergiesUI/Scroll View/Scrollbar").GetComponent<Image>();
fonts = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
GameObject gameObject = ((Component)GameObject.Find("ShootControls").transform.Find("Keybind")).gameObject;
TMP_FontAsset[] array = fonts;
foreach (TMP_FontAsset val in array)
{
if (((Object)val).name == "Lantern")
{
Lantern = val;
}
else if (((Object)val).name == "Express")
{
Express = val;
}
}
ColorUtility.TryParseHtmlString("#fd5161", ref LanternRed);
ColorUtility.TryParseHtmlString("#293448", ref ButtonBlue);
}
}
public static class Patches
{
[HarmonyPatch(typeof(PlayerXP), "Awake")]
public static class PlayerXP_Awake_Patch
{
public static PlayerXP Instance { get; private set; }
[HarmonyPostfix]
private static void Postfix(PlayerXP __instance)
{
Instance = __instance;
}
}
[HarmonyPatch(typeof(PlayerBuffs))]
public class PlayerBuffsPatch
{
public static PlayerBuffs Instance { get; private set; }
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPostfix(PlayerBuffs __instance)
{
Instance = __instance;
}
[HarmonyPatch("OnDestroy")]
[HarmonyPrefix]
private static void OnDestroyPrefix(PlayerBuffs __instance)
{
if ((Object)(object)Instance == (Object)(object)__instance)
{
Instance = null;
}
}
}
[HarmonyPatch(typeof(PlayerController))]
public class PlayerControllerPatch
{
public static PlayerController Instance { get; private set; }
[HarmonyPatch(typeof(PlayerController), "Awake")]
[HarmonyPostfix]
private static void AwakePostfix(PlayerController __instance)
{
Instance = __instance;
}
}
[HarmonyPatch(typeof(ReloadState))]
public class ReloadState_Enter_Patch
{
[HarmonyPatch("Enter")]
[HarmonyPrefix]
private static bool Prefix(ReloadState __instance)
{
if (Time.timeScale == 1f)
{
return true;
}
FieldInfo fieldInfo = AccessTools.Field(typeof(PlayerState), "owner");
object value = fieldInfo.GetValue(__instance);
MethodInfo methodInfo = AccessTools.Method(value.GetType(), "ChangeState", (Type[])null, (Type[])null).MakeGenericMethod(typeof(IdleState));
methodInfo.Invoke(value, null);
return false;
}
}
[HarmonyPatch(typeof(Gun))]
public class GunPatch
{
public static Gun Instance { get; private set; }
[HarmonyPatch("LoadGun")]
[HarmonyPrefix]
private static void LoadGunPrefix(Gun __instance)
{
Instance = __instance;
}
[HarmonyPatch("StartShooting")]
[HarmonyPrefix]
private static bool StartShootingPrefix()
{
if (Time.timeScale == 1f)
{
return true;
}
return false;
}
}
public static Dictionary<string, GameObject> enemyPrefabs = new Dictionary<string, GameObject>();
public static GunEvolution[] GunEvolutions;
public static GunData[] Guns;
public static Powerup[] AllPowerups;
public static void GatherResources()
{
GunEvolutions = Resources.FindObjectsOfTypeAll<GunEvolution>();
Guns = Resources.FindObjectsOfTypeAll<GunData>();
AllPowerups = Resources.FindObjectsOfTypeAll<Powerup>();
}
public static void CatalogEnemyPrefabs()
{
AIComponent[] array = Resources.FindObjectsOfTypeAll<AIComponent>();
AIComponent[] array2 = array;
foreach (AIComponent val in array2)
{
if (!enemyPrefabs.ContainsKey(((Object)((Component)val).gameObject).name))
{
enemyPrefabs.Add(((Object)((Component)val).gameObject).name, ((Component)val).gameObject);
}
}
}
public static float GetXPToNextLevel(PlayerXP PlayerXPInstance)
{
FieldInfo fieldInfo = AccessTools.Field(typeof(PlayerXP), "xp");
float num = (float)fieldInfo.GetValue(PlayerXPInstance);
float num2 = PlayerXPInstance.level + 1;
if (num2 < 20f)
{
return num2 * 10f - 5f - num + 0.1f;
}
if (num2 < 40f)
{
return num2 * 13f - 6f - num + 0.1f;
}
if (num2 < 60f)
{
return num2 * 16f - 8f - num + 0.1f;
}
return num2 * num2 - num + 0.1f;
}
public static void LVUP()
{
PlayerXP_Awake_Patch.Instance.GainXP(GetXPToNextLevel(PlayerXP_Awake_Patch.Instance));
}
}
public class PlacementManager
{
private GameObject enemyUIInstance;
private string pendingEnemyName = "";
public bool PlacementMode { get; private set; } = false;
public void Update()
{
if (PlacementMode)
{
Keyboard current = Keyboard.current;
if (((ButtonControl)current.leftCtrlKey).wasPressedThisFrame)
{
CancelPlacement();
}
else if (Mouse.current.leftButton.wasPressedThisFrame)
{
PlaceEnemy();
}
}
}
public void StartPlacement(string enemyName)
{
pendingEnemyName = enemyName;
PlacementMode = true;
}
private void PlaceEnemy()
{
//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)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
//IL_0085: 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_012f: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue();
Vector3 worldPos = Camera.main.ScreenToWorldPoint(new Vector3(val.x, val.y, Camera.main.nearClipPlane));
worldPos.z = 0f;
string selectedEnemyName = pendingEnemyName;
GameObject previewObj = new GameObject(selectedEnemyName + "_PlacementPreview");
previewObj.transform.position = worldPos;
if (Patches.enemyPrefabs.TryGetValue(selectedEnemyName, out var value))
{
SpriteRenderer componentInChildren = value.GetComponentInChildren<SpriteRenderer>();
if ((Object)(object)componentInChildren != (Object)null)
{
SpriteRenderer val2 = previewObj.AddComponent<SpriteRenderer>();
val2.sprite = componentInChildren.sprite;
((Renderer)val2).sortingLayerID = ((Renderer)componentInChildren).sortingLayerID;
((Renderer)val2).sortingOrder = ((Renderer)componentInChildren).sortingOrder;
val2.color = new Color(1f, 1f, 1f, 0.5f);
previewObj.transform.localScale = value.transform.localScale;
}
}
GameAction gameAction = new GameAction("SpawnEnemy");
gameAction.action = delegate
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
if (Patches.enemyPrefabs.TryGetValue(selectedEnemyName, out var value2))
{
Object.Instantiate<GameObject>(value2, worldPos, Quaternion.identity);
}
if ((Object)(object)previewObj != (Object)null)
{
Object.Destroy((Object)(object)previewObj);
}
};
Main.Instance.actionManager.AddAction(gameAction);
}
public void CancelPlacement()
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
PlacementMode = false;
pendingEnemyName = "";
if ((Object)(object)enemyUIInstance != (Object)null)
{
Object.Destroy((Object)(object)enemyUIInstance);
enemyUIInstance = null;
}
GameObject val = GameObject.Find("MainUIInjection");
if (!((Object)(object)val != (Object)null))
{
return;
}
foreach (Transform item in val.transform)
{
Transform val2 = item;
if (((Object)val2).name != "EnemiesUI")
{
((Component)val2).gameObject.SetActive(true);
}
}
}
}
public class ScreenLogger
{
private class DummyRunner : MonoBehaviour
{
}
private TextMeshProUGUI _text;
private MonoBehaviour _runner;
public void LogToScreen(string message, float duration = 1f, float fadeTime = 1f)
{
if ((Object)(object)_text == (Object)null)
{
CreateUI();
}
if (!((Object)(object)_text == (Object)null))
{
((TMP_Text)_text).text = message;
((TMP_Text)_text).alpha = 1f;
_runner.StopAllCoroutines();
_runner.StartCoroutine(FadeOut(duration, fadeTime));
}
}
private void CreateUI()
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find("Canvas");
if ((Object)(object)val == (Object)null)
{
Debug.LogWarning((object)"ScreenLogger: Canvas not found.");
return;
}
_runner = val.GetComponent<MonoBehaviour>();
if ((Object)(object)_runner == (Object)null)
{
_runner = (MonoBehaviour)(object)val.AddComponent<DummyRunner>();
}
GameObject val2 = new GameObject("ScreenLoggerText");
val2.transform.SetParent(val.transform, false);
_text = val2.AddComponent<TextMeshProUGUI>();
((TMP_Text)_text).fontSize = 28f;
((TMP_Text)_text).alignment = (TextAlignmentOptions)514;
((Graphic)_text).raycastTarget = false;
((TMP_Text)_text).font = Main.Instance.imageRipper.Lantern;
((Graphic)_text).color = Main.Instance.imageRipper.LanternRed;
RectTransform rectTransform = ((TMP_Text)_text).rectTransform;
rectTransform.anchorMin = new Vector2(0.5f, 0.2f);
rectTransform.anchorMax = new Vector2(0.5f, 0.2f);
rectTransform.anchoredPosition = Vector2.zero;
rectTransform.sizeDelta = new Vector2(800f, 100f);
}
private IEnumerator FadeOut(float delay, float fadeTime)
{
yield return (object)new WaitForSecondsRealtime(delay);
float t = 0f;
while (t < fadeTime)
{
t += Time.unscaledDeltaTime;
((TMP_Text)_text).alpha = Mathf.Lerp(1f, 0f, t / fadeTime);
yield return null;
}
((TMP_Text)_text).alpha = 0f;
}
}
public class UIControl
{
public string mainBundlePath = Path.Combine(Paths.PluginPath, "CreativeMode/20mtdbundle");
public AssetBundle mainBundle;
private GameObject actionDisplayInstance = null;
private Transform actionDisplayContent = null;
private readonly List<GameObject> actionDisplayBoxes = new List<GameObject>();
private GameObject displayBoxInstance = null;
private string[] ButtonBoxNames = new string[3] { "PowerUps", "Enemies", "Guns" };
private const float ActionDisplayBoxDefaultWidth = 160f;
private const float ActionDisplayBoxDefaultHeight = 30f;
private const float ActionDisplayBoxSpacing = 4f;
private const float ActionDisplayTextMaxFontSize = 10f;
private const float ActionDisplayTextMinFontSize = 4f;
private const float ActionDisplayTextHorizontalPadding = 4f;
private const float ActionDisplayTextVerticalPadding = 2f;
private const float ActionDisplayVisibleAreaScale = 0.95f;
private Color PanelButtonColor;
public void Start()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
mainBundle = LoadBundleSafe(mainBundlePath);
PanelButtonColor = ParseColor("#293448");
}
private AssetBundle LoadBundleSafe(string path)
{
AssetBundle val = AssetBundle.LoadFromFile(path);
if ((Object)(object)val == (Object)null)
{
Debug.LogError((object)("Failed to load asset bundle at " + path));
}
return val;
}
private GameObject LoadPrefab(AssetBundle bundle, string assetName)
{
if ((Object)(object)bundle == (Object)null)
{
Main.Log.LogError((object)("Asset bundle is null, cannot load '" + assetName + "'"));
return null;
}
GameObject val = bundle.LoadAsset<GameObject>(assetName);
if ((Object)(object)val == (Object)null)
{
Main.Log.LogError((object)("Could not load '" + assetName + "' from bundle!"));
}
return val;
}
private Color ParseColor(string hex)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
Color result = default(Color);
ColorUtility.TryParseHtmlString(hex, ref result);
return result;
}
private T FindComponent<T>(Transform root, string path) where T : Component
{
Transform val = root.Find(path);
if ((Object)(object)val == (Object)null)
{
Main.Log.LogError((object)("Could not find '" + path + "' under '" + ((Object)root).name + "'"));
return default(T);
}
T component = ((Component)val).GetComponent<T>();
if ((Object)(object)component == (Object)null)
{
Main.Log.LogError((object)("'" + path + "' has no " + typeof(T).Name + " component"));
}
return component;
}
private void StyleBackground(Transform uiRoot)
{
Image val = FindComponent<Image>(uiRoot, "BG");
if (!((Object)(object)val == (Object)null))
{
val.sprite = Main.Instance.imageRipper.GenericBox.sprite;
val.type = (Type)1;
}
}
private void StyleScrollbar(Transform uiRoot)
{
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
Image val = FindComponent<Image>(uiRoot, "Scrollbar");
Image val2 = FindComponent<Image>(uiRoot, "Scrollbar/Sliding Area/Handle");
if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
{
val.sprite = Main.Instance.imageRipper.ScrollBar.sprite;
((Graphic)val).color = ((Graphic)Main.Instance.imageRipper.ScrollBar).color;
val2.sprite = Main.Instance.imageRipper.ScrollHandle.sprite;
((Graphic)val2).color = ((Graphic)Main.Instance.imageRipper.ScrollHandle).color;
}
}
private Button StyleMenuButton(Transform uiRoot, string buttonName)
{
//IL_0029: 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)
Button val = FindComponent<Button>(uiRoot, buttonName);
if ((Object)(object)val == (Object)null)
{
return null;
}
((Graphic)((Component)val).GetComponent<Image>()).color = Main.Instance.imageRipper.ButtonBlue;
TextMeshProUGUI val2 = FindComponent<TextMeshProUGUI>(((Component)val).transform, "Text");
if ((Object)(object)val2 != (Object)null)
{
((TMP_Text)val2).font = Main.Instance.imageRipper.Lantern;
((Graphic)val2).color = Main.Instance.imageRipper.LanternRed;
}
return val;
}
private void ClearButtonPanels(Transform uiRoot)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
foreach (Transform item in uiRoot)
{
Transform val = item;
if (ButtonBoxNames.Contains(((Object)((Component)val).gameObject).name))
{
Object.Destroy((Object)(object)((Component)val).gameObject);
}
}
}
private void AddTrigger(EventTrigger trigger, EventTriggerType type, UnityAction<BaseEventData> callback)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: 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_000e: Expected O, but got Unknown
Entry val = new Entry
{
eventID = type
};
((UnityEvent<BaseEventData>)(object)val.callback).AddListener(callback);
trigger.triggers.Add(val);
}
private GameObject CreateTooltipButton(Transform parent, string objectName, string labelText, Color baseColor, UnityAction onClick, UnityAction onHoverShowTooltip)
{
//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_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Expected O, but got Unknown
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Expected O, but got Unknown
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: 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)
GameObject val = new GameObject(objectName, new Type[3]
{
typeof(RectTransform),
typeof(Button),
typeof(Image)
});
val.transform.SetParent(parent, false);
Image btnImage = val.GetComponent<Image>();
((Graphic)btnImage).color = baseColor;
GameObject val2 = new GameObject("Text", new Type[2]
{
typeof(RectTransform),
typeof(TextMeshProUGUI)
});
val2.transform.SetParent(val.transform, false);
RectTransform component = val2.GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.sizeDelta = Vector2.zero;
TextMeshProUGUI txt = val2.GetComponent<TextMeshProUGUI>();
((TMP_Text)txt).text = labelText;
((TMP_Text)txt).fontSize = 7f;
((TMP_Text)txt).alignment = (TextAlignmentOptions)514;
((TMP_Text)txt).enableWordWrapping = true;
((TMP_Text)txt).overflowMode = (TextOverflowModes)3;
((TMP_Text)txt).font = Main.Instance.imageRipper.Express;
if (onClick != null)
{
((UnityEvent)val.GetComponent<Button>().onClick).AddListener(onClick);
}
EventTrigger trigger = val.AddComponent<EventTrigger>();
AddTrigger(trigger, (EventTriggerType)0, delegate
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
((Graphic)txt).color = Main.Instance.imageRipper.LanternRed;
UnityAction obj = onHoverShowTooltip;
if (obj != null)
{
obj.Invoke();
}
});
AddTrigger(trigger, (EventTriggerType)1, delegate
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
((Graphic)txt).color = Color.white;
UnsetDisplayBox();
});
AddTrigger(trigger, (EventTriggerType)2, delegate
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
((Graphic)btnImage).color = Color.black;
});
AddTrigger(trigger, (EventTriggerType)3, delegate
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
((Graphic)btnImage).color = baseColor;
});
return val;
}
public GameObject MakeMainUI(Transform parent)
{
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Expected O, but got Unknown
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Expected O, but got Unknown
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Expected O, but got Unknown
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Expected O, but got Unknown
GameObject val = LoadPrefab(mainBundle, "MainUI");
if ((Object)(object)val == (Object)null)
{
return null;
}
GameObject uiInstance = Object.Instantiate<GameObject>(val, parent);
Button val2 = StyleMenuButton(uiInstance.transform, "LVUpButton");
Button val3 = StyleMenuButton(uiInstance.transform, "PowerUpsButton");
Button val4 = StyleMenuButton(uiInstance.transform, "EnemiesButton");
Button val5 = StyleMenuButton(uiInstance.transform, "GunsButton");
if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null)
{
Main.Log.LogError((object)"MainUI is missing one or more menu buttons.");
return uiInstance;
}
((UnityEvent)val2.onClick).AddListener((UnityAction)delegate
{
GameAction item = new GameAction("LVUP")
{
action = delegate
{
Patches.LVUP();
}
};
Main.Instance.actionManager.Actions.Add(item);
SyncActionDisplay(Main.Instance.actionManager.Actions);
});
((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
{
ClearButtonPanels(uiInstance.transform);
createPowerUpUI(uiInstance.transform, Patches.AllPowerups, Main.Instance.actionManager.Actions);
});
((UnityEvent)val5.onClick).AddListener((UnityAction)delegate
{
ClearButtonPanels(uiInstance.transform);
createGunUI(uiInstance.transform, Patches.Guns, Patches.GunEvolutions, Main.Instance.actionManager.Actions);
});
((UnityEvent)val4.onClick).AddListener((UnityAction)delegate
{
ClearButtonPanels(uiInstance.transform);
Main.Instance._enemyUIInstance = createEnemyUI(uiInstance.transform, Patches.enemyPrefabs, delegate(string enemyName)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
Main.Instance.placementManager.StartPlacement(enemyName);
foreach (Transform item2 in uiInstance.transform)
{
Transform val6 = item2;
((Component)val6).gameObject.SetActive(false);
}
});
});
return uiInstance;
}
public GameObject CreateDisplayBox(Transform parent)
{
GameObject val = LoadPrefab(mainBundle, "DisplayBox");
if ((Object)(object)val == (Object)null)
{
return null;
}
GameObject val2 = Object.Instantiate<GameObject>(val, parent);
((Object)val2).name = "DisplayBox";
displayBoxInstance = val2;
StyleBackground(val2.transform);
return val2;
}
public GameObject CreateActionDisplayUI(Transform parent)
{
DestroyActionDisplayUI();
GameObject val = LoadPrefab(mainBundle, "ActionDisplay");
if ((Object)(object)val == (Object)null)
{
return null;
}
actionDisplayInstance = Object.Instantiate<GameObject>(val, parent);
((Object)actionDisplayInstance).name = "ActionDisplayInjection";
StyleBackground(actionDisplayInstance.transform);
actionDisplayContent = actionDisplayInstance.transform.Find("Grid/Content");
SyncActionDisplay(Main.Instance.actionManager.Actions);
return actionDisplayInstance;
}
public void DestroyActionDisplayUI()
{
for (int num = actionDisplayBoxes.Count - 1; num >= 0; num--)
{
if ((Object)(object)actionDisplayBoxes[num] != (Object)null)
{
Object.Destroy((Object)(object)actionDisplayBoxes[num]);
}
}
actionDisplayBoxes.Clear();
actionDisplayContent = null;
if ((Object)(object)actionDisplayInstance != (Object)null)
{
Object.Destroy((Object)(object)actionDisplayInstance);
actionDisplayInstance = null;
}
}
public void SyncActionDisplay(List<GameAction> actions)
{
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)actionDisplayInstance == (Object)null || (Object)(object)actionDisplayContent == (Object)null)
{
return;
}
List<string> list = ((actions == null) ? new List<string>() : actions.Select((GameAction a) => (a != null) ? a.Name : "Unnamed Action").ToList());
for (int num = actionDisplayBoxes.Count - 1; num >= 0; num--)
{
if ((Object)(object)actionDisplayBoxes[num] == (Object)null)
{
actionDisplayBoxes.RemoveAt(num);
}
}
while (actionDisplayBoxes.Count > list.Count)
{
int index = actionDisplayBoxes.Count - 1;
if ((Object)(object)actionDisplayBoxes[index] != (Object)null)
{
Object.Destroy((Object)(object)actionDisplayBoxes[index]);
}
actionDisplayBoxes.RemoveAt(index);
}
for (int num2 = 0; num2 < list.Count; num2++)
{
if (num2 >= actionDisplayBoxes.Count)
{
GameObject val = CreateActionDisplayBox(list[num2]);
((Graphic)val.GetComponent<Image>()).color = Main.Instance.imageRipper.ButtonBlue;
((TMP_Text)val.GetComponentInChildren<TextMeshProUGUI>()).font = Main.Instance.imageRipper.Express;
actionDisplayBoxes.Add(val);
}
else
{
SetActionDisplayBoxText(actionDisplayBoxes[num2], list[num2]);
}
}
FitActionDisplayBoxesToContainer();
}
private GameObject CreateActionDisplayBox(string actionName)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Expected O, but got Unknown
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject(actionName + "_ActionDisplayBox", new Type[4]
{
typeof(RectTransform),
typeof(Image),
typeof(RectMask2D),
typeof(LayoutElement)
});
val.transform.SetParent(actionDisplayContent, false);
RectTransform component = val.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(160f, 30f);
((Graphic)val.GetComponent<Image>()).color = new Color(0.25f, 0.25f, 0.25f, 1f);
GameObject val2 = new GameObject("Text", new Type[2]
{
typeof(RectTransform),
typeof(TextMeshProUGUI)
});
val2.transform.SetParent(val.transform, false);
RectTransform component2 = val2.GetComponent<RectTransform>();
component2.anchorMin = Vector2.zero;
component2.anchorMax = Vector2.one;
component2.offsetMin = new Vector2(4f, 2f);
component2.offsetMax = new Vector2(-4f, -2f);
TextMeshProUGUI component3 = val2.GetComponent<TextMeshProUGUI>();
ConfigureActionDisplayText(component3, new Vector2(160f, 30f));
SetActionDisplayBoxText(val, actionName);
return val;
}
private void SetActionDisplayBoxText(GameObject boxObj, string actionName)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)boxObj == (Object)null))
{
((Object)boxObj).name = actionName + "_ActionDisplayBox";
TextMeshProUGUI componentInChildren = boxObj.GetComponentInChildren<TextMeshProUGUI>(true);
if ((Object)(object)componentInChildren != (Object)null)
{
((TMP_Text)componentInChildren).text = actionName;
ConfigureActionDisplayText(componentInChildren, GetRectTransformSize(boxObj.GetComponent<RectTransform>()));
}
}
}
private void FitActionDisplayBoxesToContainer()
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Expected O, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)actionDisplayContent == (Object)null || actionDisplayBoxes.Count == 0)
{
return;
}
Transform obj = actionDisplayContent;
RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null);
if ((Object)(object)val == (Object)null)
{
return;
}
PrepareActionDisplayContentRect(val);
Vector2 bestAvailableActionDisplaySize = GetBestAvailableActionDisplaySize(val);
GridLayoutGroup val2 = ((Component)actionDisplayContent).GetComponent<GridLayoutGroup>();
if ((Object)(object)val2 == (Object)null)
{
val2 = ((Component)actionDisplayContent).gameObject.AddComponent<GridLayoutGroup>();
}
val2.startAxis = (Axis)0;
val2.constraint = (Constraint)1;
val2.constraintCount = 1;
((LayoutGroup)val2).padding = new RectOffset(2, 2, 2, 2);
val2.spacing = new Vector2(0f, 4f);
int count = actionDisplayBoxes.Count;
float num = Mathf.Max(1f, bestAvailableActionDisplaySize.x - (float)((LayoutGroup)val2).padding.left - (float)((LayoutGroup)val2).padding.right);
float num2 = Mathf.Max(1f, bestAvailableActionDisplaySize.y - (float)((LayoutGroup)val2).padding.top - (float)((LayoutGroup)val2).padding.bottom);
float num3 = num;
float num4 = 30f * (float)count + 4f * (float)Mathf.Max(0, count - 1);
float num5 = 30f;
if (num4 > num2)
{
num5 = (num2 - 4f * (float)Mathf.Max(0, count - 1)) / (float)count;
}
num5 = Mathf.Max(1f, num5);
val2.cellSize = new Vector2(num3, num5);
foreach (GameObject actionDisplayBox in actionDisplayBoxes)
{
if (!((Object)(object)actionDisplayBox == (Object)null))
{
RectTransform component = actionDisplayBox.GetComponent<RectTransform>();
if ((Object)(object)component != (Object)null)
{
component.sizeDelta = val2.cellSize;
}
LayoutElement component2 = actionDisplayBox.GetComponent<LayoutElement>();
if ((Object)(object)component2 != (Object)null)
{
component2.preferredWidth = val2.cellSize.x;
component2.preferredHeight = val2.cellSize.y;
component2.minWidth = 1f;
component2.minHeight = 1f;
}
TextMeshProUGUI componentInChildren = actionDisplayBox.GetComponentInChildren<TextMeshProUGUI>(true);
if ((Object)(object)componentInChildren != (Object)null)
{
ConfigureActionDisplayText(componentInChildren, val2.cellSize);
}
}
}
LayoutRebuilder.ForceRebuildLayoutImmediate(val);
}
private void PrepareActionDisplayContentRect(RectTransform contentRt)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: 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)
Transform parent = ((Transform)contentRt).parent;
RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null);
if (!((Object)(object)val == (Object)null))
{
contentRt.anchorMin = Vector2.zero;
contentRt.anchorMax = Vector2.one;
contentRt.offsetMin = Vector2.zero;
contentRt.offsetMax = Vector2.zero;
contentRt.pivot = new Vector2(0.5f, 1f);
}
}
private Vector2 GetBestAvailableActionDisplaySize(RectTransform contentRt)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: 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_0048: 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)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: 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)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
Transform parent = ((Transform)contentRt).parent;
RectTransform rt = (RectTransform)(object)((parent is RectTransform) ? parent : null);
Vector2 rectTransformSize = GetRectTransformSize(rt);
if (rectTransformSize.x > 0f && rectTransformSize.y > 0f)
{
return rectTransformSize * 0.95f;
}
Vector2 rectTransformSize2 = GetRectTransformSize(contentRt);
if (rectTransformSize2.x > 0f && rectTransformSize2.y > 0f)
{
return rectTransformSize2 * 0.95f;
}
return new Vector2(160f, 30f);
}
private Vector2 GetRectTransformSize(RectTransform rt)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)rt == (Object)null)
{
return Vector2.zero;
}
Rect rect = rt.rect;
float num = Mathf.Abs(((Rect)(ref rect)).width);
rect = rt.rect;
return new Vector2(num, Mathf.Abs(((Rect)(ref rect)).height));
}
private void ConfigureActionDisplayText(TextMeshProUGUI txt, Vector2 boxSize)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)txt == (Object)null))
{
RectTransform component = ((Component)txt).GetComponent<RectTransform>();
if ((Object)(object)component != (Object)null)
{
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.offsetMin = new Vector2(4f, 2f);
component.offsetMax = new Vector2(-4f, -2f);
}
float num = Mathf.Max(1f, boxSize.y - 4f);
float num2 = Mathf.Min(10f, num);
((TMP_Text)txt).alignment = (TextAlignmentOptions)514;
((TMP_Text)txt).enableWordWrapping = false;
((TMP_Text)txt).enableAutoSizing = true;
((TMP_Text)txt).fontSizeMax = num2;
((TMP_Text)txt).fontSizeMin = Mathf.Min(4f, num2) + 10f;
((TMP_Text)txt).fontSize = num2;
((TMP_Text)txt).overflowMode = (TextOverflowModes)1;
((Graphic)txt).raycastTarget = false;
}
}
public GameObject createPowerUpUI(Transform parent, Powerup[] allpowerups, List<GameAction> actions)
{
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Expected O, but got Unknown
//IL_0199: Expected O, but got Unknown
GameObject val = LoadPrefab(mainBundle, "PowerUps");
if ((Object)(object)val == (Object)null)
{
return null;
}
GameObject val2 = Object.Instantiate<GameObject>(val, parent);
((Object)val2).name = "PowerUps";
StyleBackground(val2.transform);
Transform val3 = val2.transform.Find("ScrollArea/Content");
if ((Object)(object)val3 == (Object)null)
{
Main.Log.LogError((object)"Could not find ScrollArea/Content in PowerUps prefab!");
return val2;
}
if (actions == null)
{
Main.Log.LogError((object)"actions list is null!");
return val2;
}
AddSearchBarFunctionality(val3, "PowerUpsSearchBar");
if (allpowerups != null)
{
IEnumerable<Powerup> enumerable = from p in allpowerups
group p by p.nameString into g
select g.First();
foreach (Powerup item2 in enumerable)
{
Powerup currentPowerup = item2;
CreateTooltipButton(val3, currentPowerup.nameString + "_Button", currentPowerup.nameString, PanelButtonColor, (UnityAction)delegate
{
GameAction item = new GameAction("Add Power Up")
{
action = delegate
{
currentPowerup.Apply(Patches.PlayerControllerPatch.Instance);
}
};
actions.Add(item);
SyncActionDisplay(actions);
}, (UnityAction)delegate
{
SetDisplayBox(currentPowerup.description, currentPowerup.icon);
});
}
}
StyleScrollbar(val2.transform);
return val2;
}
public GameObject createEnemyUI(Transform parent, Dictionary<string, GameObject> enemyPrefabs, Action<string> onEnemySelected)
{
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Expected O, but got Unknown
//IL_0121: Expected O, but got Unknown
GameObject val = LoadPrefab(mainBundle, "Enemies");
if ((Object)(object)val == (Object)null)
{
return null;
}
GameObject val2 = Object.Instantiate<GameObject>(val, parent);
((Object)val2).name = "Enemies";
StyleBackground(val2.transform);
Transform val3 = val2.transform.Find("ScrollArea/Content");
if ((Object)(object)val3 == (Object)null)
{
Main.Log.LogError((object)"Could not find ScrollArea/Content in Enemies prefab!");
return val2;
}
if (enemyPrefabs != null)
{
foreach (KeyValuePair<string, GameObject> enemyPrefab2 in enemyPrefabs)
{
string enemyName = enemyPrefab2.Key;
GameObject enemyPrefab = enemyPrefab2.Value;
CreateTooltipButton(val3, enemyName + "_Button", enemyName, PanelButtonColor, (UnityAction)delegate
{
Main.Instance.screenLogger.LogToScreen("Press cntrl to close build mode");
onEnemySelected(enemyName);
}, (UnityAction)delegate
{
SetDisplayBox(enemyName, GetEnemyIcon(enemyPrefab));
});
}
}
StyleScrollbar(val2.transform);
AddSearchBarFunctionality(val3, "EnemiesSearchBar");
return val2;
}
private Sprite GetEnemyIcon(GameObject enemyPrefab)
{
if ((Object)(object)enemyPrefab == (Object)null)
{
return null;
}
SpriteRenderer componentInChildren = enemyPrefab.GetComponentInChildren<SpriteRenderer>();
return ((Object)(object)componentInChildren != (Object)null) ? componentInChildren.sprite : null;
}
public GameObject createGunUI(Transform parent, GunData[] guns, GunEvolution[] gunEvolutions, List<GameAction> actions)
{
//IL_017f: 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_01a3: Expected O, but got Unknown
//IL_01a3: Expected O, but got Unknown
//IL_0284: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_029e: Unknown result type (might be due to invalid IL or missing references)
//IL_02a8: Expected O, but got Unknown
//IL_02a8: Expected O, but got Unknown
GameObject val = LoadPrefab(mainBundle, "Guns");
if ((Object)(object)val == (Object)null)
{
return null;
}
GameObject val2 = Object.Instantiate<GameObject>(val, parent);
((Object)val2).name = "Guns";
StyleBackground(val2.transform);
Transform val3 = val2.transform.Find("ScrollArea/Content");
if ((Object)(object)val3 == (Object)null)
{
Main.Log.LogError((object)"Could not find ScrollArea/Content in Guns prefab!");
return val2;
}
if (actions == null)
{
Main.Log.LogError((object)"actions list is null!");
return val2;
}
AddSearchBarFunctionality(val3, "GunsSearchBar");
if (guns != null)
{
IEnumerable<GunData> enumerable = from g in guns
group g by g.nameString into g
select g.First();
foreach (GunData item2 in enumerable)
{
GunData currentGun = item2;
CreateTooltipButton(val3, currentGun.nameString + "_Button", currentGun.nameString, Main.Instance.imageRipper.ButtonBlue, (UnityAction)delegate
{
GameAction item = new GameAction("Load Gun")
{
action = delegate
{
Patches.GunPatch.Instance.LoadGun(currentGun);
}
};
actions.Add(item);
SyncActionDisplay(actions);
}, (UnityAction)delegate
{
SetDisplayBox(currentGun.description, currentGun.icon);
});
}
}
if (gunEvolutions != null)
{
IEnumerable<GunEvolution> enumerable2 = from e in gunEvolutions
group e by e.nameString into e
select e.First();
foreach (GunEvolution item3 in enumerable2)
{
GunEvolution val4 = item3;
GunData evolutionGunData = Traverse.Create((object)val4).Field("gunData").GetValue<GunData>();
CreateTooltipButton(val3, val4.nameString + "_Button", val4.nameString, Main.Instance.imageRipper.ButtonBlue, (UnityAction)delegate
{
GameAction item = new GameAction("Load Gun")
{
action = delegate
{
Patches.GunPatch.Instance.LoadGun(evolutionGunData);
}
};
actions.Add(item);
SyncActionDisplay(actions);
}, (UnityAction)delegate
{
if ((Object)(object)evolutionGunData != (Object)null)
{
SetDisplayBox("Gun evolution descriptions not avaliable (ask flanne)", GetEvolutionIcon(evolutionGunData));
}
});
}
}
StyleScrollbar(val2.transform);
return val2;
}
private Sprite GetEvolutionIcon(GunData evoGunData)
{
if ((Object)(object)evoGunData == (Object)null || (Object)(object)evoGunData.model == (Object)null)
{
return null;
}
Sprite result = null;
SpriteRenderer[] componentsInChildren = evoGunData.model.GetComponentsInChildren<SpriteRenderer>(true);
foreach (SpriteRenderer val in componentsInChildren)
{
if (((Object)val).name == "SwordSprite")
{
return val.sprite;
}
if (((Object)val).name == "GunSprite")
{
result = val.sprite;
}
}
return result;
}
private void AddSearchBarFunctionality(Transform contentTransform, string barName)
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
GameObject obj = GameObject.Find(barName);
TMP_InputField val = ((obj != null) ? obj.GetComponentInChildren<TMP_InputField>(true) : null);
if (!((Object)(object)val != (Object)null))
{
return;
}
((UnityEvent<string>)(object)val.onValueChanged).AddListener((UnityAction<string>)delegate(string search)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
search = search.ToLower();
foreach (Transform item in contentTransform)
{
Transform val2 = item;
bool active = ((Object)val2).name.ToLower().Contains(search);
((Component)val2).gameObject.SetActive(active);
}
});
val.textComponent.font = Main.Instance.imageRipper.Express;
((Graphic)val.textComponent).color = Color.white;
}
public void SetDisplayBox(string description, Sprite iconSprite)
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)displayBoxInstance == (Object)null)
{
Main.Log.LogError((object)"DisplayBox is null.");
return;
}
Image val = FindComponent<Image>(displayBoxInstance.transform, "Icon");
TextMeshProUGUI val2 = FindComponent<TextMeshProUGUI>(displayBoxInstance.transform, "Description");
if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
{
((Graphic)val).color = Color.white;
val.sprite = iconSprite;
((Behaviour)val).enabled = (Object)(object)iconSprite != (Object)null;
((TMP_Text)val2).text = description ?? string.Empty;
((TMP_Text)val2).font = Main.Instance.imageRipper.Express;
}
}
public void UnsetDisplayBox()
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)displayBoxInstance == (Object)null)
{
Main.Log.LogError((object)"DisplayBox is null.");
return;
}
Image val = FindComponent<Image>(displayBoxInstance.transform, "Icon");
TextMeshProUGUI val2 = FindComponent<TextMeshProUGUI>(displayBoxInstance.transform, "Description");
if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
{
val.sprite = null;
((Behaviour)val).enabled = false;
Color color = ((Graphic)val).color;
color.a = 0f;
((Graphic)val).color = color;
((TMP_Text)val2).text = string.Empty;
}
}
}
}