using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Pigeon.Math;
using Pigeon.Movement;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("SkinGenerator")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyInformationalVersion("1.3.0")]
[assembly: AssemblyProduct("SkinGenerator")]
[assembly: AssemblyTitle("SkinGenerator")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 SkinGenerator
{
public sealed class SkinGeneratorGui
{
private sealed class SimpleDropdown
{
private readonly RectTransform root;
private readonly RectTransform list;
private readonly RectTransform content;
private readonly Text label;
private readonly Font font;
private readonly Action<int> onSelected;
private readonly List<string> options = new List<string>();
private int selected;
public SimpleDropdown(RectTransform parent, Font font, Vector2 size, Vector2 position, Action<int> onSelected)
{
//IL_0027: 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_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: 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_009f: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Expected O, but got Unknown
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: 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_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
this.font = font;
this.onSelected = onSelected;
root = CreateRectStatic("Dropdown", (Transform)(object)parent, size, position);
Image val = ((Component)root).gameObject.AddComponent<Image>();
((Graphic)val).color = new Color(0.08f, 0.32f, 0.62f, 1f);
Button obj = ((Component)root).gameObject.AddComponent<Button>();
((Selectable)obj).targetGraphic = (Graphic)(object)val;
label = CreateTextStatic("Label", (Transform)(object)root, string.Empty, font, 16, size - new Vector2(24f, 0f), Vector2.zero, (TextAnchor)4);
CreateTextStatic("Arrow", (Transform)(object)root, "v", font, 16, new Vector2(20f, size.y), new Vector2(size.x - 22f, 0f), (TextAnchor)4);
((UnityEvent)obj.onClick).AddListener(new UnityAction(ToggleList));
list = CreateRectStatic("List", (Transform)(object)parent, new Vector2(size.x, 300f), new Vector2(position.x, position.y - size.y - 4f));
((Graphic)((Component)list).gameObject.AddComponent<Image>()).color = new Color(0.025f, 0.12f, 0.25f, 0.99f);
ScrollRect obj2 = ((Component)list).gameObject.AddComponent<ScrollRect>();
RectTransform val2 = CreateRectStatic("Viewport", (Transform)(object)list, new Vector2(size.x - 6f, 292f), new Vector2(3f, -4f));
((Graphic)((Component)val2).gameObject.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.01f);
((Component)val2).gameObject.AddComponent<Mask>().showMaskGraphic = false;
content = CreateRectStatic("Content", (Transform)(object)val2, new Vector2(size.x - 24f, 30f), Vector2.zero);
obj2.viewport = val2;
obj2.content = content;
obj2.horizontal = false;
((Component)list).gameObject.SetActive(false);
}
public void SetOptions(IReadOnlyList<string> values, int selectedIndex)
{
((Component)list).gameObject.SetActive(false);
options.Clear();
options.AddRange(values);
selected = Mathf.Clamp(selectedIndex, 0, Math.Max(0, options.Count - 1));
label.text = ((options.Count == 0) ? "No items" : options[selected]);
RebuildList();
}
private void ToggleList()
{
((Component)list).gameObject.SetActive(!((Component)list).gameObject.activeSelf);
((Transform)list).SetAsLastSibling();
}
private void RebuildList()
{
//IL_004c: 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_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Expected O, but got Unknown
for (int num = ((Transform)content).childCount - 1; num >= 0; num--)
{
Object.Destroy((Object)(object)((Component)((Transform)content).GetChild(num)).gameObject);
}
int num2 = Math.Max(1, options.Count);
content.sizeDelta = new Vector2(content.sizeDelta.x, (float)num2 * 30f + 4f);
for (int i = 0; i < options.Count; i++)
{
int index = i;
RectTransform val = CreateRectStatic("Item", (Transform)(object)content, new Vector2(content.sizeDelta.x - 4f, 28f), new Vector2(2f, -2f - (float)i * 30f));
Image val2 = ((Component)val).gameObject.AddComponent<Image>();
((Graphic)val2).color = new Color(0.08f, 0.32f, 0.62f, 1f);
Button obj = ((Component)val).gameObject.AddComponent<Button>();
((Selectable)obj).targetGraphic = (Graphic)(object)val2;
((Graphic)CreateTextStatic("Text", (Transform)(object)val, options[i], font, 15, val.sizeDelta, Vector2.zero, (TextAnchor)4)).color = Color.white;
((UnityEvent)obj.onClick).AddListener((UnityAction)delegate
{
selected = index;
label.text = options[index];
((Component)list).gameObject.SetActive(false);
onSelected?.Invoke(index);
});
}
}
private static RectTransform CreateRectStatic(string name, Transform parent, Vector2 size, Vector2 position)
{
//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_0036: 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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: 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)
GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
val.transform.SetParent(parent, false);
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMin = new Vector2(0f, 1f);
component.anchorMax = new Vector2(0f, 1f);
component.pivot = new Vector2(0f, 1f);
component.sizeDelta = size;
component.anchoredPosition = position;
return component;
}
private static Text CreateTextStatic(string name, Transform parent, string value, Font font, int size, Vector2 rectSize, Vector2 position, TextAnchor alignment)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: 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)
Text obj = ((Component)CreateRectStatic(name, parent, rectSize, position)).gameObject.AddComponent<Text>();
obj.font = font;
obj.text = value;
obj.fontSize = size;
obj.alignment = alignment;
((Graphic)obj).color = new Color(0.76f, 0.92f, 1f);
((Graphic)obj).raycastTarget = false;
obj.supportRichText = true;
obj.alignByGeometry = true;
return obj;
}
}
private sealed class DragWindow : MonoBehaviour, IPointerDownHandler, IEventSystemHandler, IDragHandler
{
private RectTransform rect;
private RectTransform parentRect;
private Vector2 startPointer;
private Vector2 startPosition;
private bool canDrag;
public void OnPointerDown(PointerEventData eventData)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
ref RectTransform reference = ref rect;
Transform transform = ((Component)this).transform;
reference = (RectTransform)(object)((transform is RectTransform) ? transform : null);
RectTransform obj = rect;
ref RectTransform reference2 = ref parentRect;
Transform obj2 = ((obj != null) ? ((Transform)obj).parent : null);
reference2 = (RectTransform)(object)((obj2 is RectTransform) ? obj2 : null);
if ((Object)(object)rect == (Object)null || (Object)(object)parentRect == (Object)null)
{
canDrag = false;
return;
}
Vector2 val = default(Vector2);
RectTransformUtility.ScreenPointToLocalPointInRectangle(rect, eventData.position, eventData.pressEventCamera, ref val);
canDrag = val.y <= 0f && val.y >= -28f;
RectTransformUtility.ScreenPointToLocalPointInRectangle(parentRect, eventData.position, eventData.pressEventCamera, ref startPointer);
startPosition = rect.anchoredPosition;
}
public void OnDrag(PointerEventData eventData)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: 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_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)rect == (Object)null) && !((Object)(object)parentRect == (Object)null) && canDrag)
{
Vector2 val = default(Vector2);
RectTransformUtility.ScreenPointToLocalPointInRectangle(parentRect, eventData.position, eventData.pressEventCamera, ref val);
rect.anchoredPosition = startPosition + (val - startPointer);
}
}
}
private sealed class CoroutineHost : MonoBehaviour
{
}
private sealed class ModifierHit
{
public string Key { get; }
public string Label { get; }
public float Coefficient { get; }
public ModifierHit(string key, string label, float coefficient)
{
Key = key;
Label = label;
Coefficient = coefficient;
}
}
private sealed class ModifierCriterion
{
public string Key { get; }
public float TargetCoefficient { get; }
public ModifierCriterion(string key, float targetCoefficient)
{
Key = key;
TargetCoefficient = targetCoefficient;
}
}
private sealed class ModifierOption
{
public string Key { get; }
public string Label { get; }
public int Observed { get; set; }
public int Samples { get; set; }
public bool Enabled { get; set; }
public string TargetText { get; set; } = string.Empty;
public float TargetCoefficient
{
get
{
if (!float.TryParse(TargetText, out var result) && !float.TryParse(TargetText.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out result))
{
return 0f;
}
return Mathf.Clamp01(result / 100f);
}
}
public string CoefficientText
{
get
{
if (Samples > 0)
{
return $"{(float)Observed * 100f / (float)Samples:0.##}%";
}
return "0%";
}
}
public ModifierOption(string key, string label)
{
Key = key;
Label = label;
}
}
private static readonly string[] RarityNames = new string[3]
{
((object)(Rarity)1/*cast due to .constrained prefix*/).ToString(),
((object)(Rarity)2/*cast due to .constrained prefix*/).ToString(),
((object)(Rarity)3/*cast due to .constrained prefix*/).ToString()
};
private static readonly Rarity[] Rarities;
private const int ModifierAnalysisSeeds = 2048;
private const int TitleFontSize = 20;
private const int HeaderFontSize = 17;
private const int NormalFontSize = 16;
private const int SmallFontSize = 15;
private readonly ManualLogSource logger;
private readonly int maxSeedSearchAttempts;
private readonly int seedSearchThreads;
private readonly List<IUpgradable> categories = new List<IUpgradable>();
private readonly List<SkinUpgrade> skins = new List<SkinUpgrade>();
private readonly List<string> categoryNames = new List<string>();
private readonly List<string> skinNames = new List<string>();
private readonly List<ModifierOption> modifierOptions = new List<ModifierOption>();
private GameObject root;
private GameObject ownedEventSystem;
private RectTransform window;
private SimpleDropdown categoryDropdown;
private SimpleDropdown rarityDropdown;
private SimpleDropdown skinDropdown;
private InputField countInput;
private Toggle onlyNewToggle;
private Toggle randomSpecialToggle;
private Text statusText;
private Text searchText;
private RectTransform modifierContent;
private Font font;
private Button generateButton;
private CoroutineHost coroutineHost;
private bool visible;
private int selectedCategory;
private int selectedRarity;
private int selectedSkin;
private string lastMessage = "Ready";
private bool isGenerating;
public bool Visible
{
get
{
return visible;
}
set
{
if (visible != value)
{
visible = value;
if ((Object)(object)root != (Object)null)
{
root.SetActive(visible);
}
if (visible)
{
selectedCategory = 0;
selectedSkin = 0;
RefreshCategories();
RefreshSkins();
UpdateControls();
}
}
}
}
public SkinGeneratorGui(ManualLogSource logger, int maxSeedSearchAttempts, int seedSearchThreads)
{
this.logger = logger;
this.maxSeedSearchAttempts = Mathf.Clamp(maxSeedSearchAttempts, 1000, 200000000);
int num = Math.Max(1, Environment.ProcessorCount - 1);
this.seedSearchThreads = ((seedSearchThreads <= 0) ? num : Math.Max(1, Math.Min(seedSearchThreads, Environment.ProcessorCount)));
font = Resources.GetBuiltinResource<Font>("Arial.ttf");
BuildCanvas();
}
public void Dispose()
{
visible = false;
categories.Clear();
skins.Clear();
categoryNames.Clear();
skinNames.Clear();
modifierOptions.Clear();
if ((Object)(object)root != (Object)null)
{
Object.Destroy((Object)(object)root);
root = null;
}
if ((Object)(object)ownedEventSystem != (Object)null)
{
Object.Destroy((Object)(object)ownedEventSystem);
ownedEventSystem = null;
}
}
private void BuildCanvas()
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: 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)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0328: Unknown result type (might be due to invalid IL or missing references)
//IL_0337: Unknown result type (might be due to invalid IL or missing references)
//IL_0380: Unknown result type (might be due to invalid IL or missing references)
//IL_038f: Unknown result type (might be due to invalid IL or missing references)
//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
//IL_040d: Unknown result type (might be due to invalid IL or missing references)
EnsureEventSystem();
root = new GameObject("SkinGeneratorCanvas", new Type[3]
{
typeof(Canvas),
typeof(CanvasScaler),
typeof(GraphicRaycaster)
});
Object.DontDestroyOnLoad((Object)(object)root);
Canvas component = root.GetComponent<Canvas>();
component.renderMode = (RenderMode)0;
component.sortingOrder = 30000;
component.pixelPerfect = true;
CanvasScaler component2 = root.GetComponent<CanvasScaler>();
component2.uiScaleMode = (ScaleMode)1;
component2.referenceResolution = new Vector2(1920f, 1080f);
component2.matchWidthOrHeight = 0.5f;
coroutineHost = root.AddComponent<CoroutineHost>();
window = CreateRect("Window", root.transform, new Vector2(980f, 450f), new Vector2(20f, -120f), new Vector2(0f, 1f), new Vector2(0f, 1f));
((Graphic)((Component)window).gameObject.AddComponent<Image>()).color = new Color(0.035f, 0.105f, 0.21f, 0.96f);
((Component)window).gameObject.AddComponent<DragWindow>();
CreateText("Title", (Transform)(object)window, "Hub skin generator", 20, (FontStyle)1, new Vector2(956f, 30f), new Vector2(12f, -6f), (TextAnchor)3);
categoryDropdown = new SimpleDropdown(window, font, new Vector2(210f, 34f), new Vector2(12f, -40f), OnCategorySelected);
rarityDropdown = new SimpleDropdown(window, font, new Vector2(134f, 34f), new Vector2(230f, -40f), OnRaritySelected);
skinDropdown = new SimpleDropdown(window, font, new Vector2(290f, 34f), new Vector2(372f, -40f), OnSkinSelected);
countInput = CreateInput("Count", (Transform)(object)window, "1", new Vector2(58f, 34f), new Vector2(670f, -40f));
generateButton = CreateButton("Generate", (Transform)(object)window, "Generate", new Vector2(132f, 34f), new Vector2(736f, -40f), Generate);
onlyNewToggle = CreateToggle("OnlyNew", (Transform)(object)window, "Random only new", new Vector2(190f, 28f), new Vector2(12f, -86f));
onlyNewToggle.isOn = true;
randomSpecialToggle = CreateToggle("RandomSpecial", (Transform)(object)window, "Random special only", new Vector2(220f, 28f), new Vector2(214f, -86f));
searchText = CreateText("SearchInfo", (Transform)(object)window, $"Permanent search: {maxSeedSearchAttempts} attempts per skin / {seedSearchThreads} threads.", 15, (FontStyle)0, new Vector2(520f, 28f), new Vector2(448f, -86f), (TextAnchor)3);
CreateText("ModifierTitle", (Transform)(object)window, "Available modifiers", 17, (FontStyle)1, new Vector2(300f, 28f), new Vector2(12f, -124f), (TextAnchor)3);
CreateModifierScroll();
statusText = CreateText("Status", (Transform)(object)window, lastMessage, 16, (FontStyle)0, new Vector2(956f, 30f), new Vector2(12f, -414f), (TextAnchor)3);
root.SetActive(false);
}
private void EnsureEventSystem()
{
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
if ((Object)(object)EventSystem.current != (Object)null)
{
if ((Object)(object)((Component)EventSystem.current).GetComponent<BaseInputModule>() == (Object)null)
{
((Component)EventSystem.current).gameObject.AddComponent<StandaloneInputModule>();
}
}
else
{
ownedEventSystem = new GameObject("SkinGeneratorEventSystem", new Type[2]
{
typeof(EventSystem),
typeof(StandaloneInputModule)
});
Object.DontDestroyOnLoad((Object)(object)ownedEventSystem);
}
}
private void CreateModifierScroll()
{
//IL_0016: 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)
//IL_0034: 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)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = CreateRect("ModifierScroll", (Transform)(object)window, new Vector2(956f, 250f), new Vector2(12f, -156f), new Vector2(0f, 1f), new Vector2(0f, 1f));
((Graphic)((Component)val).gameObject.AddComponent<Image>()).color = new Color(0.025f, 0.12f, 0.25f, 0.98f);
ScrollRect obj = ((Component)val).gameObject.AddComponent<ScrollRect>();
RectTransform val2 = CreateRect("Viewport", (Transform)(object)val, new Vector2(926f, 240f), new Vector2(6f, -5f), new Vector2(0f, 1f), new Vector2(0f, 1f));
((Graphic)((Component)val2).gameObject.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.01f);
((Component)val2).gameObject.AddComponent<Mask>().showMaskGraphic = false;
modifierContent = CreateRect("Content", (Transform)(object)val2, new Vector2(906f, 28f), Vector2.zero, new Vector2(0f, 1f), new Vector2(0f, 1f));
Scrollbar verticalScrollbar = CreateScrollbar((Transform)(object)val, new Vector2(10f, 240f), new Vector2(942f, -5f));
obj.viewport = val2;
obj.content = modifierContent;
obj.horizontal = false;
obj.vertical = true;
obj.verticalScrollbar = verticalScrollbar;
obj.verticalScrollbarVisibility = (ScrollbarVisibility)0;
obj.movementType = (MovementType)2;
}
private void RebuildModifierRows()
{
//IL_005d: 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_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: 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_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
for (int num = ((Transform)modifierContent).childCount - 1; num >= 0; num--)
{
Object.Destroy((Object)(object)((Component)((Transform)modifierContent).GetChild(num)).gameObject);
}
float num2 = Mathf.Max(62f, 34f + (float)modifierOptions.Count * 32f);
modifierContent.sizeDelta = new Vector2(906f, num2);
CreateText("ChanceHeader", (Transform)(object)modifierContent, "Chance", 15, (FontStyle)1, new Vector2(84f, 28f), new Vector2(724f, -2f), (TextAnchor)3);
CreateText("TargetHeader", (Transform)(object)modifierContent, "Target %", 15, (FontStyle)1, new Vector2(84f, 28f), new Vector2(812f, -2f), (TextAnchor)3);
if (modifierOptions.Count == 0)
{
CreateText("NoModifiers", (Transform)(object)modifierContent, "No modifiers detected for this selection.", 16, (FontStyle)0, new Vector2(880f, 30f), new Vector2(8f, -34f), (TextAnchor)3);
return;
}
for (int i = 0; i < modifierOptions.Count; i++)
{
ModifierOption option = modifierOptions[i];
float num3 = -34f - (float)i * 32f;
Toggle obj = CreateToggle("ModToggle", (Transform)(object)modifierContent, option.Label, new Vector2(704f, 28f), new Vector2(8f, num3));
obj.isOn = option.Enabled;
((UnityEvent<bool>)(object)obj.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value)
{
option.Enabled = value;
});
CreateText("Chance", (Transform)(object)modifierContent, option.CoefficientText, 15, (FontStyle)0, new Vector2(84f, 28f), new Vector2(724f, num3), (TextAnchor)3);
InputField obj2 = CreateInput("Target", (Transform)(object)modifierContent, option.TargetText, new Vector2(82f, 28f), new Vector2(812f, num3));
((UnityEvent<string>)(object)obj2.onEndEdit).AddListener((UnityAction<string>)delegate(string value)
{
option.TargetText = value;
});
((UnityEvent<string>)(object)obj2.onValueChanged).AddListener((UnityAction<string>)delegate(string value)
{
option.TargetText = value;
});
}
}
private void Generate()
{
if (isGenerating)
{
return;
}
if (selectedCategory < 0 || selectedCategory >= categories.Count)
{
SetStatus("Select category.");
return;
}
int count = ParseInt(countInput.text, 1, 1, 999);
IUpgradable prefab = categories[selectedCategory].GetPrefab();
List<string> enabledModifierKeys = GetEnabledModifierKeys();
List<ModifierCriterion> enabledModifierCriteria = GetEnabledModifierCriteria();
bool needsModifierSearch = randomSpecialToggle.isOn || enabledModifierKeys.Count > 0;
isGenerating = true;
if ((Object)(object)generateButton != (Object)null)
{
((Selectable)generateButton).interactable = false;
}
SetStatus("Please wait... searching skin seed.");
((MonoBehaviour)coroutineHost).StartCoroutine(GenerateAfterFrame(count, prefab, enabledModifierCriteria, needsModifierSearch));
}
private IEnumerator GenerateAfterFrame(int count, IUpgradable category, List<ModifierCriterion> criteria, bool needsModifierSearch)
{
yield return null;
int num = 0;
try
{
for (int i = 0; i < count; i++)
{
int matchedSeed = 0;
SkinUpgrade val = (needsModifierSearch ? GetRandomModifierSkin(category, criteria, out matchedSeed) : GetSkinForGeneration(category));
if ((Object)(object)val == (Object)null)
{
break;
}
UpgradeInstance val2 = PlayerData.CreateUpgradeInstance(category, (Upgrade)(object)val, true);
val2.CanScrap = true;
if (needsModifierSearch)
{
val2.Seed = matchedSeed;
}
PlayerData.CollectInstance(val2, (UnlockFlags)1);
num++;
}
SetStatus((num > 0) ? $"Generated {num} skin(s)." : "No matching skins found.");
RefreshSkins();
}
catch (Exception ex)
{
SetStatus("Skin generation failed. See BepInEx log.");
logger.LogError((object)ex);
}
finally
{
isGenerating = false;
if ((Object)(object)generateButton != (Object)null)
{
((Selectable)generateButton).interactable = true;
}
}
}
private SkinUpgrade GetSkinForGeneration(IUpgradable category)
{
if (selectedSkin > 0)
{
int num = selectedSkin - 1;
if (num < 0 || num >= skins.Count)
{
return null;
}
return skins[num];
}
List<SkinUpgrade> skinCandidates = GetSkinCandidates(category);
if (skinCandidates.Count != 0)
{
return skinCandidates[Random.Range(0, skinCandidates.Count)];
}
return null;
}
private SkinUpgrade GetRandomModifierSkin(IUpgradable category, IReadOnlyList<ModifierCriterion> requiredModifiers, out int matchedSeed)
{
matchedSeed = 0;
List<SkinUpgrade> skinCandidates = GetSkinCandidates(category);
if (skinCandidates.Count == 0)
{
return null;
}
Shuffle(skinCandidates);
int num = Random.Range(int.MinValue, int.MaxValue);
for (int i = 0; i < skinCandidates.Count; i++)
{
SkinUpgrade val = skinCandidates[i];
if (TryFindSeedForSkin(val, num + i * 104729, requiredModifiers, out matchedSeed))
{
return val;
}
}
return null;
}
private bool TryFindSeedForSkin(SkinUpgrade skin, int searchSalt, IReadOnlyList<ModifierCriterion> requiredModifiers, out int matchedSeed)
{
matchedSeed = 0;
if ((Object)(object)skin == (Object)null)
{
return false;
}
int found = 0;
int foundSeed = 0;
ParallelOptions parallelOptions = new ParallelOptions
{
MaxDegreeOfParallelism = seedSearchThreads
};
Parallel.For(0, maxSeedSearchAttempts, parallelOptions, delegate(int attempt, ParallelLoopState state)
{
if (Volatile.Read(in found) != 0)
{
state.Stop();
}
else
{
int num = MakeSearchSeed(searchSalt, attempt);
if (MatchesSelectedModifiers(skin, num, requiredModifiers, randomSpecialToggle.isOn) && Interlocked.CompareExchange(ref found, 1, 0) == 0)
{
foundSeed = num;
state.Stop();
}
}
});
if (found == 0)
{
return false;
}
matchedSeed = foundSeed;
return true;
}
private List<SkinUpgrade> GetSkinCandidates(IUpgradable category)
{
List<SkinUpgrade> list = new List<SkinUpgrade>(skins.Count);
if (selectedSkin > 0)
{
int num = selectedSkin - 1;
if (num >= 0 && num < skins.Count)
{
list.Add(skins[num]);
}
return list;
}
for (int i = 0; i < skins.Count; i++)
{
if (!onlyNewToggle.isOn || PlayerData.GetUpgradeInfo(category, (Upgrade)(object)skins[i]).TotalInstancesCollected == 0)
{
list.Add(skins[i]);
}
}
if (list.Count == 0 && onlyNewToggle.isOn)
{
list.AddRange(skins);
}
return list;
}
private bool MatchesSelectedModifiers(SkinUpgrade skin, int seed, IReadOnlyList<ModifierCriterion> requiredModifiers, bool allowAnyModifier)
{
//IL_007e: 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)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)skin == (Object)null)
{
return false;
}
int num = requiredModifiers?.Count ?? 0;
int num2 = 0;
int num3 = ((num != 0) ? ((1 << num) - 1) : 0);
bool flag = false;
string text = ((Upgrade)skin).Name ?? string.Empty;
bool flag2 = false;
int num4 = 0;
Enumerator properties = ((Upgrade)skin).GetProperties();
Random val2 = default(Random);
ModifierInfo info = default(ModifierInfo);
while (((Enumerator)(ref properties)).MoveNext())
{
num4++;
UpgradeProperty current = ((Enumerator)(ref properties)).Current;
SkinUpgradeProperty val = (SkinUpgradeProperty)(object)((current is SkinUpgradeProperty) ? current : null);
if (val == null)
{
continue;
}
((Random)(ref val2))..ctor(Upgrade.ModifyPropertySeed(seed, num4));
try
{
string nameModifier = val.GetNameModifier((Upgrade)(object)skin, text, val2, seed, ref info);
if (string.IsNullOrEmpty(nameModifier))
{
continue;
}
flag = true;
if (num == 0)
{
return allowAnyModifier;
}
string modifierKey = GetModifierKey(info, val);
float modifierCoefficient = GetModifierCoefficient(val, seed, num4);
for (int i = 0; i < num; i++)
{
ModifierCriterion modifierCriterion = requiredModifiers[i];
if (string.Equals(modifierKey, modifierCriterion.Key, StringComparison.Ordinal) && modifierCoefficient >= modifierCriterion.TargetCoefficient)
{
num2 |= 1 << i;
break;
}
}
if (num2 == num3)
{
return true;
}
text += (flag2 ? (", " + nameModifier) : (" (" + nameModifier));
flag2 = true;
}
catch (Exception)
{
}
}
if (num != 0)
{
return num2 == num3;
}
return flag && allowAnyModifier;
}
private List<string> GetEnabledModifierKeys()
{
List<string> list = new List<string>();
for (int i = 0; i < modifierOptions.Count; i++)
{
if (modifierOptions[i].Enabled)
{
list.Add(modifierOptions[i].Key);
}
}
return list;
}
private List<ModifierCriterion> GetEnabledModifierCriteria()
{
List<ModifierCriterion> list = new List<ModifierCriterion>();
for (int i = 0; i < modifierOptions.Count; i++)
{
ModifierOption modifierOption = modifierOptions[i];
if (modifierOption.Enabled)
{
list.Add(new ModifierCriterion(modifierOption.Key, modifierOption.TargetCoefficient));
}
}
return list;
}
private List<ModifierHit> GetModifierHits(SkinUpgrade skin, int seed)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: 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_007b: Unknown result type (might be due to invalid IL or missing references)
List<ModifierHit> list = new List<ModifierHit>();
if ((Object)(object)skin == (Object)null)
{
return list;
}
string text = ((Upgrade)skin).Name ?? string.Empty;
bool flag = false;
int num = 0;
Enumerator properties = ((Upgrade)skin).GetProperties();
Random val2 = default(Random);
ModifierInfo info = default(ModifierInfo);
while (((Enumerator)(ref properties)).MoveNext())
{
num++;
UpgradeProperty current = ((Enumerator)(ref properties)).Current;
SkinUpgradeProperty val = (SkinUpgradeProperty)(object)((current is SkinUpgradeProperty) ? current : null);
if (val == null)
{
continue;
}
((Random)(ref val2))..ctor(Upgrade.ModifyPropertySeed(seed, num));
try
{
string nameModifier = val.GetNameModifier((Upgrade)(object)skin, text, val2, seed, ref info);
if (!string.IsNullOrEmpty(nameModifier))
{
list.Add(new ModifierHit(GetModifierKey(info, val), GetModifierLabel(info, nameModifier, val), GetModifierCoefficient(val, seed, num)));
text += (flag ? (", " + nameModifier) : (" (" + nameModifier));
flag = true;
}
}
catch (Exception)
{
}
}
return list;
}
private void RefreshCategories()
{
categories.Clear();
categoryNames.Clear();
Player localPlayer = Player.LocalPlayer;
if ((Object)(object)localPlayer == (Object)null)
{
SetStatus("Local player is not ready.");
return;
}
AddCategory((IUpgradable)(object)localPlayer.Character);
if ((Object)(object)Global.Instance?.DropPod != (Object)null)
{
AddCategory((IUpgradable)(object)Global.Instance.DropPod);
}
IUpgradable[] gear = (IUpgradable[])(object)localPlayer.Gear;
IUpgradable[] array = gear;
if (array != null)
{
for (int i = 0; i < array.Length; i++)
{
AddCategory(array[i]);
}
}
if (categories.Count == 0)
{
SetStatus("No equipped gear with skins found.");
}
categoryDropdown.SetOptions(categoryNames, selectedCategory);
}
private void AddCategory(IUpgradable item)
{
if (item == null)
{
return;
}
IUpgradable prefab = item.GetPrefab();
object obj;
if (prefab == null)
{
obj = null;
}
else
{
GearInfo info = prefab.Info;
obj = ((info != null) ? info.Upgrades : null);
}
if (obj == null || !HasSkin(prefab))
{
return;
}
for (int i = 0; i < categories.Count; i++)
{
if (categories[i] == prefab || categories[i].Info.ID == prefab.Info.ID)
{
return;
}
}
categories.Add(prefab);
categoryNames.Add(prefab.Info.Name + " [" + prefab.Info.APIName + "]");
}
private void RefreshSkins()
{
//IL_0071: 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_008c: Unknown result type (might be due to invalid IL or missing references)
skins.Clear();
skinNames.Clear();
skinNames.Add("Random skin");
if (selectedCategory < 0 || selectedCategory >= categories.Count)
{
RefreshModifiers();
return;
}
List<Upgrade> upgrades = categories[selectedCategory].Info.Upgrades;
Rarity val = Rarities[selectedRarity];
for (int i = 0; i < upgrades.Count; i++)
{
Upgrade obj = upgrades[i];
SkinUpgrade val2 = (SkinUpgrade)(object)((obj is SkinUpgrade) ? obj : null);
if (val2 != null && ((Upgrade)val2).Rarity == val)
{
skins.Add(val2);
}
}
skins.Sort((SkinUpgrade a, SkinUpgrade b) => string.Compare(((Upgrade)a).Name, ((Upgrade)b).Name, StringComparison.OrdinalIgnoreCase));
for (int num = 0; num < skins.Count; num++)
{
skinNames.Add(((Upgrade)skins[num]).Name + " [" + ((Upgrade)skins[num]).APIName + "]");
}
skinDropdown.SetOptions(skinNames, selectedSkin);
RefreshModifiers();
}
private void RefreshModifiers()
{
Dictionary<string, ModifierOption> dictionary = new Dictionary<string, ModifierOption>(StringComparer.Ordinal);
List<SkinUpgrade> skinsForModifierAnalysis = GetSkinsForModifierAnalysis();
int samples = skinsForModifierAnalysis.Count * 2048;
for (int i = 0; i < skinsForModifierAnalysis.Count; i++)
{
SkinUpgrade skin = skinsForModifierAnalysis[i];
for (int j = 0; j < 2048; j++)
{
int seed = MathUtil.Squirrel3Hash(((i + 1) * 73856093) ^ ((j + 1) * 19349663));
List<ModifierHit> modifierHits = GetModifierHits(skin, seed);
for (int k = 0; k < modifierHits.Count; k++)
{
ModifierHit modifierHit = modifierHits[k];
if (!dictionary.TryGetValue(modifierHit.Key, out var value))
{
value = new ModifierOption(modifierHit.Key, modifierHit.Label);
dictionary.Add(modifierHit.Key, value);
}
value.Observed++;
}
}
}
HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal);
Dictionary<string, string> dictionary2 = new Dictionary<string, string>(StringComparer.Ordinal);
for (int l = 0; l < modifierOptions.Count; l++)
{
if (modifierOptions[l].Enabled)
{
hashSet.Add(modifierOptions[l].Key);
}
dictionary2[modifierOptions[l].Key] = modifierOptions[l].TargetText;
}
modifierOptions.Clear();
foreach (ModifierOption value3 in dictionary.Values)
{
value3.Samples = samples;
value3.Enabled = hashSet.Contains(value3.Key);
if (dictionary2.TryGetValue(value3.Key, out var value2))
{
value3.TargetText = value2;
}
modifierOptions.Add(value3);
}
modifierOptions.Sort(delegate(ModifierOption a, ModifierOption b)
{
int num = b.Observed.CompareTo(a.Observed);
return (num == 0) ? string.Compare(a.Label, b.Label, StringComparison.OrdinalIgnoreCase) : num;
});
RebuildModifierRows();
}
private List<SkinUpgrade> GetSkinsForModifierAnalysis()
{
if (selectedSkin > 0)
{
int num = selectedSkin - 1;
if (num < 0 || num >= skins.Count)
{
return new List<SkinUpgrade>();
}
return new List<SkinUpgrade> { skins[num] };
}
return new List<SkinUpgrade>(skins);
}
private void UpdateControls()
{
categoryDropdown.SetOptions(categoryNames, selectedCategory);
rarityDropdown.SetOptions(RarityNames, selectedRarity);
skinDropdown.SetOptions(skinNames, selectedSkin);
countInput.text = (string.IsNullOrEmpty(countInput.text) ? "1" : countInput.text);
onlyNewToggle.isOn = true;
SetStatus(lastMessage);
}
private void OnCategorySelected(int index)
{
selectedCategory = Mathf.Clamp(index, 0, Math.Max(0, categories.Count - 1));
selectedSkin = 0;
RefreshSkins();
}
private void OnRaritySelected(int index)
{
selectedRarity = Mathf.Clamp(index, 0, Rarities.Length - 1);
selectedSkin = 0;
RefreshSkins();
}
private void OnSkinSelected(int index)
{
selectedSkin = Mathf.Clamp(index, 0, Math.Max(0, skinNames.Count - 1));
RefreshModifiers();
}
private void SetStatus(string message)
{
lastMessage = message;
if ((Object)(object)statusText != (Object)null)
{
statusText.text = message;
}
}
private static bool HasSkin(IUpgradable item)
{
List<Upgrade> upgrades = item.Info.Upgrades;
for (int i = 0; i < upgrades.Count; i++)
{
if (upgrades[i] is SkinUpgrade)
{
return true;
}
}
return false;
}
private static string GetModifierKey(ModifierInfo info, SkinUpgradeProperty property)
{
//IL_0000: 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)
if (string.IsNullOrEmpty(info.ID))
{
return "type:" + ((object)property).GetType().FullName;
}
return "id:" + info.ID;
}
private static string GetModifierLabel(ModifierInfo info, string modifier, SkinUpgradeProperty property)
{
//IL_0002: 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_000f: 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_001f: Unknown result type (might be due to invalid IL or missing references)
string text = null;
if (!string.IsNullOrEmpty(info.ID) && !TextBlocks.TryGetString(info.ID, 0, ref text))
{
text = info.ID;
}
string text2 = default(string);
if (!string.IsNullOrEmpty(info.ID) && TextBlocks.TryGetString(info.ID, 1, ref text2) && !string.IsNullOrEmpty(text2) && !string.Equals(text2, text, StringComparison.OrdinalIgnoreCase))
{
text = text + ": " + text2;
}
if (string.IsNullOrEmpty(text))
{
text = StripRichText(modifier);
}
if (!string.IsNullOrEmpty(text))
{
return text;
}
return ((object)property).GetType().Name.Replace("SkinUpgradeProperty_", string.Empty);
}
private static float GetModifierCoefficient(SkinUpgradeProperty property, int seed, int propertyIndex)
{
SkinUpgradePropertyRandStat val = (SkinUpgradePropertyRandStat)(object)((property is SkinUpgradePropertyRandStat) ? property : null);
if (val == null)
{
return 1f;
}
Random val2 = default(Random);
((Random)(ref val2))..ctor(Upgrade.ModifyPropertySeed(seed, propertyIndex));
if (property is SkinUpgradeProperty_Neon)
{
((Random)(ref val2)).Next();
return EvaluateCurve(val.curve, ((Random)(ref val2)).NextFloat());
}
((Random)(ref val2)).NextFloat();
return EvaluateCurve(val.curve, ((Random)(ref val2)).NextFloat());
}
private static float EvaluateCurve(AnimationCurve curve, float value)
{
if (curve != null)
{
return Mathf.Clamp01(curve.Evaluate(value));
}
return 1f;
}
private static string StripRichText(string text)
{
if (string.IsNullOrEmpty(text))
{
return text;
}
char[] array = new char[text.Length];
int length = 0;
bool flag = false;
foreach (char c in text)
{
switch (c)
{
case '<':
flag = true;
continue;
case '>':
flag = false;
continue;
}
if (!flag)
{
array[length++] = c;
}
}
return new string(array, 0, length);
}
private static int ParseInt(string text, int fallback, int min, int max)
{
if (!int.TryParse(text, out var result))
{
return fallback;
}
return Mathf.Clamp(result, min, max);
}
private static int MakeSearchSeed(int salt, int attempt)
{
return MixSeed(salt ^ (attempt * -1640531527), attempt + 668265261);
}
private static int MixSeed(int value, int salt)
{
int num = value + salt * 374761393;
int num2 = (num ^ (num >>> 16)) * -2048144777;
int num3 = (num2 ^ (num2 >>> 13)) * -1028477379;
return num3 ^ (num3 >>> 16);
}
private static void Shuffle<T>(IList<T> values)
{
for (int num = values.Count - 1; num > 0; num--)
{
int index = Random.Range(0, num + 1);
T value = values[num];
values[num] = values[index];
values[index] = value;
}
}
private RectTransform CreateRect(string name, Transform parent, Vector2 size, Vector2 position, Vector2 anchor, Vector2 pivot)
{
//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_002c: 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_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: 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)
GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
val.transform.SetParent(parent, false);
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMin = anchor;
component.anchorMax = anchor;
component.pivot = pivot;
component.sizeDelta = size;
component.anchoredPosition = position;
return component;
}
private Text CreateText(string name, Transform parent, string value, int size, FontStyle style, Vector2 rectSize, Vector2 position, TextAnchor alignment)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: 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)
Text obj = ((Component)CreateRect(name, parent, rectSize, position, new Vector2(0f, 1f), new Vector2(0f, 1f))).gameObject.AddComponent<Text>();
obj.font = font;
obj.text = value;
obj.fontSize = size;
obj.fontStyle = style;
obj.alignment = alignment;
((Graphic)obj).color = new Color(0.76f, 0.92f, 1f);
((Graphic)obj).raycastTarget = false;
obj.supportRichText = true;
obj.alignByGeometry = true;
return obj;
}
private Button CreateButton(string name, Transform parent, string label, Vector2 size, Vector2 position, Action onClick)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: 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_002e: 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_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Expected O, but got Unknown
//IL_0098: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = CreateRect(name, parent, size, position, new Vector2(0f, 1f), new Vector2(0f, 1f));
Image val2 = ((Component)val).gameObject.AddComponent<Image>();
((Graphic)val2).color = new Color(0.08f, 0.32f, 0.62f, 1f);
Button obj = ((Component)val).gameObject.AddComponent<Button>();
((Selectable)obj).targetGraphic = (Graphic)(object)val2;
((UnityEvent)obj.onClick).AddListener((UnityAction)delegate
{
onClick?.Invoke();
});
((Graphic)CreateText("Text", (Transform)(object)val, label, 16, (FontStyle)0, size, Vector2.zero, (TextAnchor)4)).color = Color.white;
return obj;
}
private Toggle CreateToggle(string name, Transform parent, string label, Vector2 size, Vector2 position)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0020: 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_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: 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_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: 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_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = CreateRect(name, parent, size, position, new Vector2(0f, 1f), new Vector2(0f, 1f));
Image val2 = ((Component)val).gameObject.AddComponent<Image>();
((Graphic)val2).color = new Color(0f, 0f, 0f, 0.01f);
Toggle obj = ((Component)val).gameObject.AddComponent<Toggle>();
RectTransform val3 = CreateRect("Box", (Transform)(object)val, new Vector2(18f, 18f), new Vector2(0f, -5f), new Vector2(0f, 1f), new Vector2(0f, 1f));
((Graphic)((Component)val3).gameObject.AddComponent<Image>()).color = new Color(0.02f, 0.08f, 0.16f, 1f);
Image val4 = ((Component)CreateRect("Checkmark", (Transform)(object)val3, new Vector2(12f, 12f), new Vector2(3f, -3f), new Vector2(0f, 1f), new Vector2(0f, 1f))).gameObject.AddComponent<Image>();
((Graphic)val4).color = new Color(0.24f, 0.72f, 1f, 1f);
((Selectable)obj).targetGraphic = (Graphic)(object)val2;
obj.graphic = (Graphic)(object)val4;
CreateText("Label", (Transform)(object)val, label, 16, (FontStyle)0, new Vector2(size.x - 26f, size.y), new Vector2(26f, 0f), (TextAnchor)3);
return obj;
}
private InputField CreateInput(string name, Transform parent, string value, Vector2 size, Vector2 position)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0020: 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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = CreateRect(name, parent, size, position, new Vector2(0f, 1f), new Vector2(0f, 1f));
Image val2 = ((Component)val).gameObject.AddComponent<Image>();
((Graphic)val2).color = new Color(0.02f, 0.08f, 0.16f, 1f);
InputField obj = ((Component)val).gameObject.AddComponent<InputField>();
Text val3 = CreateText("Text", (Transform)(object)val, value, 16, (FontStyle)0, new Vector2(size.x - 10f, size.y), new Vector2(5f, 0f), (TextAnchor)3);
((Graphic)val3).color = Color.white;
Text val4 = CreateText("Placeholder", (Transform)(object)val, string.Empty, 16, (FontStyle)2, new Vector2(size.x - 10f, size.y), new Vector2(5f, 0f), (TextAnchor)3);
((Graphic)val4).color = new Color(1f, 1f, 1f, 0.35f);
obj.textComponent = val3;
obj.placeholder = (Graphic)(object)val4;
obj.text = value;
((Selectable)obj).targetGraphic = (Graphic)(object)val2;
return obj;
}
private Scrollbar CreateScrollbar(Transform parent, Vector2 size, Vector2 position)
{
//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_0013: 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_004c: 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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
RectTransform val = CreateRect("Scrollbar", parent, size, position, new Vector2(0f, 1f), new Vector2(0f, 1f));
((Graphic)((Component)val).gameObject.AddComponent<Image>()).color = new Color(0.015f, 0.06f, 0.12f, 0.95f);
Scrollbar obj = ((Component)val).gameObject.AddComponent<Scrollbar>();
obj.direction = (Direction)2;
RectTransform val2 = CreateRect("Handle", (Transform)(object)val, new Vector2(size.x, 42f), Vector2.zero, new Vector2(0f, 0f), new Vector2(0f, 0f));
val2.anchorMin = Vector2.zero;
val2.anchorMax = Vector2.one;
val2.offsetMin = Vector2.zero;
val2.offsetMax = Vector2.zero;
Image val3 = ((Component)val2).gameObject.AddComponent<Image>();
((Graphic)val3).color = new Color(0.24f, 0.72f, 1f, 0.95f);
((Selectable)obj).targetGraphic = (Graphic)(object)val3;
obj.handleRect = val2;
return obj;
}
static SkinGeneratorGui()
{
//IL_0009: 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_002d: Unknown result type (might be due to invalid IL or missing references)
Rarity[] array = new Rarity[3];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
Rarities = (Rarity[])(object)array;
}
}
[MycoMod(/*Could not decode attribute arguments.*/)]
[BepInPlugin("skingenerator", "SkinGenerator", "1.3.0")]
public sealed class SkinGeneratorPlugin : BaseUnityPlugin
{
public const string PluginGuid = "skingenerator";
public const string PluginName = "SkinGenerator";
public const string PluginVersion = "1.3.0";
private ConfigEntry<KeyboardShortcut> toggleKey;
private ConfigEntry<int> searchAttempts;
private ConfigEntry<int> searchThreads;
private SkinGeneratorGui gui;
internal static ManualLogSource Log { get; private set; }
private void Awake()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Interface", "ToggleKey", new KeyboardShortcut((KeyCode)257, Array.Empty<KeyCode>()), "Key used to show or hide the hub skin generator interface. Format: Unity KeyCode names like Keypad1, F8, Insert. For shortcuts use: LeftControl + F8.");
searchAttempts = ((BaseUnityPlugin)this).Config.Bind<int>("Search", "MaxSeedAttempts", 10000000, "Maximum vanilla seed attempts per candidate skin. Higher values find rarer modifier combinations but use more CPU.");
if (searchAttempts.Value == 1000000)
{
searchAttempts.Value = 10000000;
}
searchThreads = ((BaseUnityPlugin)this).Config.Bind<int>("Search", "WorkerThreads", 0, "CPU worker threads used for permanent seed search. 0 means auto: all logical CPU cores minus one.");
Log.LogInfo((object)"SkinGenerator loaded.");
}
private void Update()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
if (gui != null && !LevelData.IsHub)
{
UnloadInterface();
SetCursor(visible: false);
}
KeyboardShortcut value = toggleKey.Value;
if (!((KeyboardShortcut)(ref value)).IsDown())
{
return;
}
if (LevelData.IsHub)
{
if (gui == null || !gui.Visible)
{
EnsureInterface();
gui.Visible = true;
SetCursor(visible: true);
}
else
{
UnloadInterface();
SetCursor(visible: false);
}
}
else
{
UnloadInterface();
SetCursor(visible: false);
Log.LogMessage((object)"Skin generator works only in hub.");
}
}
private void OnDestroy()
{
UnloadInterface();
}
private void EnsureInterface()
{
if (gui == null)
{
gui = new SkinGeneratorGui(Log, searchAttempts.Value, searchThreads.Value);
}
}
private void UnloadInterface()
{
gui?.Dispose();
gui = null;
GC.Collect();
}
private void SetCursor(bool visible)
{
if (visible)
{
Cursor.visible = true;
Cursor.lockState = (CursorLockMode)0;
}
else if (PlayerInput.IsPlayerEnabled && !PlayerInput.IsMenuEnabled)
{
Cursor.visible = false;
Cursor.lockState = (CursorLockMode)1;
}
}
}
}