using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering.Universal;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ema28pro.PeakStickers")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+961367b8e6319b8bd48e030f64d8c9b08f671430")]
[assembly: AssemblyProduct("ema28pro.PeakStickers")]
[assembly: AssemblyTitle("PeakStickers")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ema28pro/Peak-Stickers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
[Embedded]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
[Embedded]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace Microsoft.CodeAnalysis
{
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace PeakStickers
{
[BepInPlugin("ema28pro.PeakStickers", "PeakStickers", "0.1.0")]
public class Plugin : BaseUnityPlugin
{
private StickerButton? stickerButton;
private bool buttonErrorLogged;
public const string Id = "ema28pro.PeakStickers";
internal static ManualLogSource Log { get; private set; }
internal static Plugin? Instance { get; private set; }
internal static ConfigEntry<string> OutputDirectoryConfig { get; private set; }
internal static ConfigEntry<bool> OpenFolderConfig { get; private set; }
internal static ConfigEntry<int> ResolutionConfig { get; private set; }
internal static ConfigEntry<int> BorderWidthConfig { get; private set; }
internal static ConfigEntry<int> RoundnessConfig { get; private set; }
internal static ConfigEntry<bool> AutoCropConfig { get; private set; }
internal static ConfigEntry<bool> IncludeIdlesConfig { get; private set; }
internal static ConfigEntry<string> SampleTimesConfig { get; private set; }
internal static ConfigEntry<string> SelectedPosesConfig { get; private set; }
public static string Name => "PeakStickers";
public static string Version => "0.1.0";
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Instance = this;
OutputDirectoryConfig = ((BaseUnityPlugin)this).Config.Bind<string>("1. Salida", "OutputDirectory", string.Empty, "Carpeta donde se guardan los stickers PNG. Vacío = Mis Imágenes/PEAK Stickers");
OpenFolderConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("1. Salida", "OpenFolderWhenDone", false, "Abrir la carpeta de salida cuando termine de generar");
ResolutionConfig = ((BaseUnityPlugin)this).Config.Bind<int>("2. Stickers", "Resolution", 1024, "Tamaño de cada sticker en píxeles (512, 1024 o 2048)");
BorderWidthConfig = ((BaseUnityPlugin)this).Config.Bind<int>("2. Stickers", "BorderWidth", 12, "Grosor del borde blanco en píxeles (0 = sin línea). Se puede cambiar con el slider de la interfaz");
RoundnessConfig = ((BaseUnityPlugin)this).Config.Bind<int>("2. Stickers", "Roundness", 14, "Redondeo del borde estilo pegatina (0-64): rellena huequitos y suaviza detalles pequeños de la silueta");
AutoCropConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Stickers", "AutoCrop", true, "Recortar cada imagen a la caja del personaje y ajustarla al tamaño del sticker");
SelectedPosesConfig = ((BaseUnityPlugin)this).Config.Bind<string>("2. Stickers", "SelectedPoses", "all", "Poses a generar: all, emotes, idles o el nombre de una pose (ej. A_Scout_Emote_Wave). Se puede cambiar con el desplegable");
IncludeIdlesConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Stickers", "IncludeIdlePoses", true, "Incluir también las 8 variantes de pose idle");
SampleTimesConfig = ((BaseUnityPlugin)this).Config.Bind<string>("3. Poses", "SampleTimes", "Wave=0.4;Clap=0.4;ThumbsUp=0.5;Flex=0.45;Salute=0.5;Shrug=0.5;Think=0.5;CrossedArms=0.5;ImHere=0.5;Nono=0.5;Panic=0.5;Fist=0.5;PunchFist=0.5;Dance1=0.5;Dance2=0.8;Cinema=0.5;Crashout=0.75;Defeat=0.95;Despair=0.9;Sit=0.92;PlayDead=0.95;BackFlip=0.45;Idle1=0.3;Idle2=0.3;Idle3=0.3;Idle4=0.3;Idle5=0.3;Idle6=0.3;Idle7=0.3;Idle8=0.3", "Frame de muestra (0 a 1) de cada pose. Ejemplo: BackFlip=0.45;PlayDead=0.95");
Log.LogInfo((object)(Name + " loaded!"));
}
private void Update()
{
PassportManager instance = PassportManager.instance;
if ((Object)(object)instance == (Object)null)
{
return;
}
if ((Object)(object)stickerButton == (Object)null)
{
try
{
stickerButton = StickerButton.Create(instance);
}
catch (Exception arg)
{
if (!buttonErrorLogged)
{
Log.LogError((object)$"Could not create the sticker button: {arg}");
buttonErrorLogged = true;
}
return;
}
}
stickerButton.SetPassportOpen(((MenuWindow)instance).isOpen);
}
internal void RunGeneration(PassportManager manager, StickerButton button)
{
((MonoBehaviour)this).StartCoroutine(StickerGenerator.Generate(manager, button));
}
internal void ScheduleLabelReset(StickerButton button)
{
((MonoBehaviour)this).StartCoroutine(button.ResetLabelSoon());
}
internal void SaveConfig()
{
((BaseUnityPlugin)this).Config.Save();
}
}
public class StickerButton : MonoBehaviour
{
public const string DefaultLabel = "Generar stickers";
public const string KeyAll = "all";
public const string KeyEmotes = "emotes";
public const string KeyIdles = "idles";
private const float PanelWidth = 250f;
private const float PanelHeight = 132f;
private PassportManager manager;
private TextMeshProUGUI label;
private TextMeshProUGUI caption;
private TextMeshProUGUI borderLabel;
private GameObject popup;
private TMP_FontAsset? font;
private bool popupBuilt;
private bool generating;
public static StickerButton Create(PassportManager manager)
{
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Expected O, but got Unknown
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Expected O, but got Unknown
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Expected O, but got Unknown
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Expected O, but got Unknown
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_0292: Unknown result type (might be due to invalid IL or missing references)
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02be: Unknown result type (might be due to invalid IL or missing references)
//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0323: Unknown result type (might be due to invalid IL or missing references)
//IL_0362: Unknown result type (might be due to invalid IL or missing references)
//IL_036c: Expected O, but got Unknown
//IL_0384: Unknown result type (might be due to invalid IL or missing references)
//IL_038b: Expected O, but got Unknown
//IL_0392: Unknown result type (might be due to invalid IL or missing references)
//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
//IL_03b2: Expected O, but got Unknown
//IL_03be: Unknown result type (might be due to invalid IL or missing references)
//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
//IL_0400: Unknown result type (might be due to invalid IL or missing references)
//IL_042a: Unknown result type (might be due to invalid IL or missing references)
//IL_046f: Unknown result type (might be due to invalid IL or missing references)
//IL_049f: Unknown result type (might be due to invalid IL or missing references)
//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
//IL_052e: Unknown result type (might be due to invalid IL or missing references)
//IL_0544: Unknown result type (might be due to invalid IL or missing references)
//IL_055a: Unknown result type (might be due to invalid IL or missing references)
//IL_0570: Unknown result type (might be due to invalid IL or missing references)
//IL_0586: Unknown result type (might be due to invalid IL or missing references)
//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
//IL_05ad: Expected O, but got Unknown
//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
//IL_05ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0604: Unknown result type (might be due to invalid IL or missing references)
//IL_061a: Unknown result type (might be due to invalid IL or missing references)
//IL_0630: Unknown result type (might be due to invalid IL or missing references)
//IL_0646: Unknown result type (might be due to invalid IL or missing references)
//IL_06a8: Unknown result type (might be due to invalid IL or missing references)
//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
//IL_06e6: Unknown result type (might be due to invalid IL or missing references)
//IL_06fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0712: Unknown result type (might be due to invalid IL or missing references)
//IL_0728: Unknown result type (might be due to invalid IL or missing references)
//IL_0757: Unknown result type (might be due to invalid IL or missing references)
//IL_075e: Expected O, but got Unknown
//IL_0765: Unknown result type (might be due to invalid IL or missing references)
//IL_077e: Unknown result type (might be due to invalid IL or missing references)
//IL_0785: Expected O, but got Unknown
//IL_0791: Unknown result type (might be due to invalid IL or missing references)
//IL_07a7: Unknown result type (might be due to invalid IL or missing references)
//IL_07bd: Unknown result type (might be due to invalid IL or missing references)
//IL_07d3: Unknown result type (might be due to invalid IL or missing references)
//IL_0806: Unknown result type (might be due to invalid IL or missing references)
//IL_0827: Unknown result type (might be due to invalid IL or missing references)
//IL_083d: Unknown result type (might be due to invalid IL or missing references)
//IL_0853: Unknown result type (might be due to invalid IL or missing references)
//IL_0869: Unknown result type (might be due to invalid IL or missing references)
//IL_088b: Unknown result type (might be due to invalid IL or missing references)
//IL_0892: Expected O, but got Unknown
//IL_0899: Unknown result type (might be due to invalid IL or missing references)
//IL_08b2: Unknown result type (might be due to invalid IL or missing references)
//IL_08b9: Expected O, but got Unknown
//IL_08c5: Unknown result type (might be due to invalid IL or missing references)
//IL_08db: Unknown result type (might be due to invalid IL or missing references)
//IL_08f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0907: Unknown result type (might be due to invalid IL or missing references)
//IL_0931: Unknown result type (might be due to invalid IL or missing references)
//IL_0961: Unknown result type (might be due to invalid IL or missing references)
//IL_0968: Expected O, but got Unknown
//IL_096f: Unknown result type (might be due to invalid IL or missing references)
//IL_0988: Unknown result type (might be due to invalid IL or missing references)
//IL_098f: Expected O, but got Unknown
//IL_099b: Unknown result type (might be due to invalid IL or missing references)
//IL_09b1: Unknown result type (might be due to invalid IL or missing references)
//IL_09c7: Unknown result type (might be due to invalid IL or missing references)
//IL_09dd: Unknown result type (might be due to invalid IL or missing references)
//IL_09f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0a14: Unknown result type (might be due to invalid IL or missing references)
//IL_0af5: Unknown result type (might be due to invalid IL or missing references)
//IL_0afa: Unknown result type (might be due to invalid IL or missing references)
//IL_0b1b: Unknown result type (might be due to invalid IL or missing references)
//IL_0b20: Unknown result type (might be due to invalid IL or missing references)
//IL_0b24: Unknown result type (might be due to invalid IL or missing references)
Transform[] array = (Transform[])(object)new Transform[4]
{
((Object)(object)manager.uiObject != (Object)null) ? manager.uiObject.transform : null,
((Object)(object)manager.nameText != (Object)null) ? ((TMP_Text)manager.nameText).transform : null,
((Object)(object)manager.buttonNext != (Object)null) ? manager.buttonNext.transform : null,
((Component)manager).transform
};
Transform val = ((Component)manager).transform;
Canvas val2 = null;
Transform[] array2 = array;
foreach (Transform val3 in array2)
{
if ((Object)(object)val3 == (Object)null)
{
continue;
}
val = val3;
val2 = null;
Transform val4 = val3;
while ((Object)(object)val4 != (Object)null)
{
Canvas component = ((Component)val4).GetComponent<Canvas>();
if ((Object)(object)component != (Object)null)
{
val = val4;
val2 = component;
break;
}
val4 = val4.parent;
}
if ((Object)(object)val2 != (Object)null)
{
break;
}
}
TMP_FontAsset val5 = (((Object)(object)manager.nameText != (Object)null) ? ((TMP_Text)manager.nameText).font : null);
GameObject val6 = new GameObject("PeakStickersPanel", new Type[1] { typeof(RectTransform) });
RectTransform val7 = (RectTransform)val6.transform;
((Transform)val7).SetParent(val, false);
val7.anchorMin = new Vector2(1f, 1f);
val7.anchorMax = new Vector2(1f, 1f);
val7.pivot = new Vector2(1f, 1f);
val7.anchoredPosition = new Vector2(-16f, -16f);
val7.sizeDelta = new Vector2(250f, 132f);
Image val8 = UiFactory.NewImage(val6.transform, "Background", new Color(0.07f, 0.07f, 0.09f, 0.96f));
UiFactory.Stretch(((Graphic)val8).rectTransform);
Canvas val9 = val6.AddComponent<Canvas>();
val9.overrideSorting = true;
val9.sortingOrder = 30000;
val6.AddComponent<GraphicRaycaster>();
StickerButton comp = val6.AddComponent<StickerButton>();
comp.manager = manager;
comp.font = val5;
GameObject val10 = new GameObject("Generate", new Type[1] { typeof(RectTransform) });
((Transform)(RectTransform)val10.transform).SetParent(val6.transform, false);
RectTransform val11 = (RectTransform)val10.transform;
val11.anchorMin = new Vector2(0f, 1f);
val11.anchorMax = new Vector2(1f, 1f);
val11.offsetMin = new Vector2(8f, -48f);
val11.offsetMax = new Vector2(-8f, -8f);
Image val12 = UiFactory.NewImage(val10.transform, "Btn", new Color(0.18f, 0.18f, 0.22f, 1f));
UiFactory.Stretch(((Graphic)val12).rectTransform);
Button val13 = val10.AddComponent<Button>();
((Selectable)val13).targetGraphic = (Graphic)(object)val12;
TextMeshProUGUI val14 = UiFactory.NewLabel(val10.transform, "Generar stickers", 17f, Color.white, (TextAlignmentOptions)514, val5);
UiFactory.Stretch(((TMP_Text)val14).rectTransform);
comp.label = val14;
((UnityEvent)val13.onClick).AddListener(new UnityAction(comp.OnClick));
GameObject val15 = new GameObject("PoseSelect", new Type[1] { typeof(RectTransform) });
((Transform)(RectTransform)val15.transform).SetParent(val6.transform, false);
RectTransform val16 = (RectTransform)val15.transform;
val16.anchorMin = new Vector2(0f, 1f);
val16.anchorMax = new Vector2(1f, 1f);
val16.offsetMin = new Vector2(8f, -86f);
val16.offsetMax = new Vector2(-8f, -54f);
Image val17 = UiFactory.NewImage(val15.transform, "Bg", new Color(0.13f, 0.13f, 0.16f, 1f));
UiFactory.Stretch(((Graphic)val17).rectTransform);
Button val18 = val15.AddComponent<Button>();
((Selectable)val18).targetGraphic = (Graphic)(object)val17;
TextMeshProUGUI val19 = UiFactory.NewLabel(val15.transform, CaptionFor(Plugin.SelectedPosesConfig.Value), 13.5f, Color.white, (TextAlignmentOptions)4097, val5);
UiFactory.Stretch(((TMP_Text)val19).rectTransform);
((TMP_Text)val19).rectTransform.offsetMin = new Vector2(10f, 0f);
((TMP_Text)val19).rectTransform.offsetMax = new Vector2(-26f, 0f);
comp.caption = val19;
Image val20 = UiFactory.NewImage(val15.transform, "Arrow", new Color(1f, 1f, 1f, 0.85f));
val20.sprite = UiFactory.TriangleSprite();
val20.type = (Type)0;
((Graphic)val20).raycastTarget = false;
RectTransform rectTransform = ((Graphic)val20).rectTransform;
rectTransform.anchorMin = new Vector2(1f, 0.5f);
rectTransform.anchorMax = new Vector2(1f, 0.5f);
rectTransform.pivot = new Vector2(1f, 0.5f);
rectTransform.anchoredPosition = new Vector2(-9f, -1f);
rectTransform.sizeDelta = new Vector2(14f, 9f);
((UnityEvent)val18.onClick).AddListener(new UnityAction(comp.TogglePopup));
Image val21 = UiFactory.NewImage(val15.transform, "Options", new Color(0.11f, 0.11f, 0.14f, 0.99f));
RectTransform rectTransform2 = ((Graphic)val21).rectTransform;
rectTransform2.anchorMin = new Vector2(0f, 1f);
rectTransform2.anchorMax = new Vector2(1f, 1f);
rectTransform2.pivot = new Vector2(0.5f, 1f);
rectTransform2.anchoredPosition = new Vector2(0f, -34f);
rectTransform2.sizeDelta = new Vector2(0f, 0f);
((Component)val21).gameObject.SetActive(false);
comp.popup = ((Component)val21).gameObject;
TextMeshProUGUI val22 = UiFactory.NewLabel(val6.transform, $"Borde: {Plugin.BorderWidthConfig.Value}", 13f, new Color(1f, 1f, 1f, 0.9f), (TextAlignmentOptions)4100, val5);
RectTransform rectTransform3 = ((TMP_Text)val22).rectTransform;
rectTransform3.anchorMin = new Vector2(0f, 1f);
rectTransform3.anchorMax = new Vector2(0f, 1f);
rectTransform3.pivot = new Vector2(0f, 1f);
rectTransform3.anchoredPosition = new Vector2(8f, -90f);
rectTransform3.sizeDelta = new Vector2(64f, 24f);
comp.borderLabel = val22;
GameObject val23 = new GameObject("BorderSlider", new Type[1] { typeof(RectTransform) });
((Transform)(RectTransform)val23.transform).SetParent(val6.transform, false);
RectTransform val24 = (RectTransform)val23.transform;
val24.anchorMin = new Vector2(0f, 1f);
val24.anchorMax = new Vector2(1f, 1f);
val24.offsetMin = new Vector2(78f, -114f);
val24.offsetMax = new Vector2(-8f, -90f);
Slider val25 = val23.AddComponent<Slider>();
Image val26 = UiFactory.NewImage(val23.transform, "Track", new Color(0.3f, 0.3f, 0.35f, 1f));
RectTransform rectTransform4 = ((Graphic)val26).rectTransform;
rectTransform4.anchorMin = new Vector2(0f, 0.5f);
rectTransform4.anchorMax = new Vector2(1f, 0.5f);
rectTransform4.pivot = new Vector2(0.5f, 0.5f);
rectTransform4.sizeDelta = new Vector2(-14f, 8f);
GameObject val27 = new GameObject("Fill Area", new Type[1] { typeof(RectTransform) });
((Transform)(RectTransform)val27.transform).SetParent(val23.transform, false);
RectTransform val28 = (RectTransform)val27.transform;
val28.anchorMin = new Vector2(0f, 0.5f);
val28.anchorMax = new Vector2(1f, 0.5f);
val28.pivot = new Vector2(0.5f, 0.5f);
val28.sizeDelta = new Vector2(-14f, 8f);
Image val29 = UiFactory.NewImage(val27.transform, "Fill", new Color(0.45f, 0.75f, 0.9f, 1f));
UiFactory.Stretch(((Graphic)val29).rectTransform);
GameObject val30 = new GameObject("Handle Slide Area", new Type[1] { typeof(RectTransform) });
((Transform)(RectTransform)val30.transform).SetParent(val23.transform, false);
RectTransform val31 = (RectTransform)val30.transform;
val31.anchorMin = new Vector2(0f, 0.5f);
val31.anchorMax = new Vector2(1f, 0.5f);
val31.pivot = new Vector2(0.5f, 0.5f);
val31.sizeDelta = new Vector2(-14f, 0f);
Image val32 = UiFactory.NewImage(val30.transform, "Handle", Color.white);
RectTransform rectTransform5 = ((Graphic)val32).rectTransform;
rectTransform5.sizeDelta = new Vector2(14f, 14f);
val25.fillRect = ((Graphic)val29).rectTransform;
val25.handleRect = rectTransform5;
((Selectable)val25).targetGraphic = (Graphic)(object)val32;
val25.minValue = 0f;
val25.maxValue = 40f;
val25.wholeNumbers = true;
val25.value = Mathf.Clamp(Plugin.BorderWidthConfig.Value, 0, 40);
((UnityEvent<float>)(object)val25.onValueChanged).AddListener((UnityAction<float>)delegate(float v)
{
Plugin.BorderWidthConfig.Value = (int)v;
if ((Object)(object)comp.borderLabel != (Object)null)
{
((TMP_Text)comp.borderLabel).text = $"Borde: {(int)v}";
}
Plugin.Instance?.SaveConfig();
});
val6.SetActive(((MenuWindow)manager).isOpen);
ManualLogSource log = Plugin.Log;
string[] obj = new string[8]
{
"Sticker panel created: host='",
HierarchyPath(val),
"', canvas=",
((Object)(object)val2 != (Object)null) ? ((Object)val2).name : "NONE",
" mode=",
((Object)(object)val2 != (Object)null) ? ((object)val2.renderMode/*cast due to .constrained prefix*/).ToString() : "-",
", ",
null
};
Rect rect = val7.rect;
obj[7] = $"size={((Rect)(ref rect)).size}, open={((MenuWindow)manager).isOpen}";
log.LogInfo((object)string.Concat(obj));
return comp;
}
private void OnClick()
{
if (!generating && !((Object)(object)manager == (Object)null) && !((Object)(object)Plugin.Instance == (Object)null))
{
generating = true;
((TMP_Text)label).text = "Generando…";
ClosePopup();
Plugin.Instance.RunGeneration(manager, this);
}
}
private void TogglePopup()
{
if (!((Object)(object)popup == (Object)null))
{
if (!popup.activeSelf)
{
EnsureOptions();
popup.SetActive(true);
popup.transform.SetAsLastSibling();
}
else
{
ClosePopup();
}
}
}
private void ClosePopup()
{
if ((Object)(object)popup != (Object)null && popup.activeSelf)
{
popup.SetActive(false);
}
}
private void SelectOption(string key, string text)
{
Plugin.SelectedPosesConfig.Value = key;
if ((Object)(object)caption != (Object)null)
{
((TMP_Text)caption).text = text;
}
Plugin.Instance?.SaveConfig();
ClosePopup();
}
private void EnsureOptions()
{
//IL_0129: 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)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Expected O, but got Unknown
//IL_017c: 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_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Expected O, but got Unknown
//IL_01d1: 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_01f1: Expected O, but got Unknown
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: 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)
//IL_026b: Expected O, but got Unknown
//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Expected O, but got Unknown
//IL_0354: Unknown result type (might be due to invalid IL or missing references)
//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
//IL_03de: Unknown result type (might be due to invalid IL or missing references)
//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0424: Unknown result type (might be due to invalid IL or missing references)
//IL_042e: Expected O, but got Unknown
if (popupBuilt)
{
return;
}
popupBuilt = true;
List<(string, bool)> poseStates = StickerGenerator.GetPoseStates();
int num = 0;
int num2 = 0;
foreach (var item4 in poseStates)
{
if (item4.Item2)
{
num2++;
}
else
{
num++;
}
}
List<(string, string)> list = new List<(string, string)>
{
("all", $"Todas ({poseStates.Count})"),
("emotes", $"Solo emotes ({num})"),
("idles", $"Solo idles ({num2})")
};
foreach (var item5 in poseStates)
{
string item = item5.Item1;
list.Add((item, StickerGenerator.StateSuffix(item)));
}
float num3 = (float)list.Count * 28f + 6f;
((RectTransform)popup.transform).sizeDelta = new Vector2(0f, Mathf.Min(num3, 260f));
ScrollRect val = popup.AddComponent<ScrollRect>();
GameObject val2 = new GameObject("Viewport", new Type[1] { typeof(RectTransform) });
((Transform)(RectTransform)val2.transform).SetParent(popup.transform, false);
UiFactory.Stretch((RectTransform)val2.transform);
val2.AddComponent<RectMask2D>();
GameObject val3 = new GameObject("Content", new Type[1] { typeof(RectTransform) });
((Transform)(RectTransform)val3.transform).SetParent(val2.transform, false);
RectTransform val4 = (RectTransform)val3.transform;
val4.anchorMin = new Vector2(0f, 1f);
val4.anchorMax = new Vector2(1f, 1f);
val4.pivot = new Vector2(0.5f, 1f);
val4.anchoredPosition = Vector2.zero;
val4.sizeDelta = new Vector2(0f, num3);
VerticalLayoutGroup val5 = val3.AddComponent<VerticalLayoutGroup>();
((LayoutGroup)val5).padding = new RectOffset(3, 3, 3, 3);
((HorizontalOrVerticalLayoutGroup)val5).spacing = 2f;
((LayoutGroup)val5).childAlignment = (TextAnchor)0;
((HorizontalOrVerticalLayoutGroup)val5).childControlWidth = true;
((HorizontalOrVerticalLayoutGroup)val5).childControlHeight = true;
((HorizontalOrVerticalLayoutGroup)val5).childForceExpandWidth = true;
((HorizontalOrVerticalLayoutGroup)val5).childForceExpandHeight = false;
ContentSizeFitter val6 = val3.AddComponent<ContentSizeFitter>();
val6.verticalFit = (FitMode)2;
val6.horizontalFit = (FitMode)0;
val.viewport = (RectTransform)val2.transform;
val.content = val4;
val.horizontal = false;
val.vertical = true;
val.movementType = (MovementType)2;
val.scrollSensitivity = 26f;
for (int i = 0; i < list.Count; i++)
{
string item2 = list[i].Item1;
string item3 = list[i].Item2;
Image val7 = UiFactory.NewImage((Transform)(object)val4, $"Option{i}", new Color(0.16f, 0.16f, 0.2f, 1f));
GameObject gameObject = ((Component)val7).gameObject;
LayoutElement val8 = gameObject.AddComponent<LayoutElement>();
val8.preferredHeight = 26f;
val8.flexibleWidth = 1f;
Button val9 = gameObject.AddComponent<Button>();
((Selectable)val9).targetGraphic = (Graphic)(object)val7;
TextMeshProUGUI val10 = UiFactory.NewLabel((Transform)(object)itemRtOf(val7), item3, 13f, Color.white, (TextAlignmentOptions)4097, font);
UiFactory.Stretch(((TMP_Text)val10).rectTransform);
((TMP_Text)val10).rectTransform.offsetMin = new Vector2(8f, 0f);
((TMP_Text)val10).rectTransform.offsetMax = new Vector2(-8f, 0f);
string capturedKey = item2;
string capturedText = item3;
((UnityEvent)val9.onClick).AddListener((UnityAction)delegate
{
SelectOption(capturedKey, capturedText);
});
}
static RectTransform itemRtOf(Image img)
{
return ((Graphic)img).rectTransform;
}
}
private static string CaptionFor(string key)
{
List<(string, bool)> poseStates = StickerGenerator.GetPoseStates();
if (!string.IsNullOrWhiteSpace(key))
{
switch (key)
{
case "all":
break;
case "emotes":
case "idles":
{
int num = 0;
bool flag = key == "idles";
foreach (var item3 in poseStates)
{
bool item2 = item3.Item2;
if (item2 == flag)
{
num++;
}
}
if (!flag)
{
return $"Solo emotes ({num})";
}
return $"Solo idles ({num})";
}
default:
foreach (var item4 in poseStates)
{
string item = item4.Item1;
if (string.Equals(item, key, StringComparison.OrdinalIgnoreCase))
{
return StickerGenerator.StateSuffix(item);
}
}
return $"Todas ({poseStates.Count})";
}
}
return $"Todas ({poseStates.Count})";
}
public void SetPassportOpen(bool open)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
if (((Component)this).gameObject.activeSelf != open)
{
((Component)this).gameObject.SetActive(open);
if (!open)
{
ClosePopup();
}
else
{
Plugin.Log.LogInfo((object)$"Sticker panel shown at {((Transform)(RectTransform)((Component)this).transform).position}");
}
}
}
public void SetStatus(string text)
{
if ((Object)(object)label != (Object)null)
{
((TMP_Text)label).text = text;
}
}
public void FinishGeneration()
{
generating = false;
if ((Object)(object)Plugin.Instance != (Object)null)
{
Plugin.Instance.ScheduleLabelReset(this);
}
else
{
ResetLabel();
}
}
public IEnumerator ResetLabelSoon()
{
yield return (object)new WaitForSeconds(4f);
ResetLabel();
}
public void ResetLabel()
{
if ((Object)(object)label != (Object)null)
{
((TMP_Text)label).text = "Generar stickers";
}
}
private static string HierarchyPath(Transform t)
{
string text = ((Object)t).name;
Transform parent = t.parent;
while ((Object)(object)parent != (Object)null)
{
text = ((Object)parent).name + "/" + text;
parent = parent.parent;
}
return text;
}
}
internal static class StickerGenerator
{
private readonly struct PoseInfo
{
public readonly string State;
public readonly float Time;
public readonly bool IsIdle;
public readonly int IdleIndex;
public PoseInfo(string state, float time, bool isIdle, int idleIndex)
{
State = state;
Time = time;
IsIdle = isIdle;
IdleIndex = idleIndex;
}
}
internal const string DefaultSampleTimes = "Wave=0.4;Clap=0.4;ThumbsUp=0.5;Flex=0.45;Salute=0.5;Shrug=0.5;Think=0.5;CrossedArms=0.5;ImHere=0.5;Nono=0.5;Panic=0.5;Fist=0.5;PunchFist=0.5;Dance1=0.5;Dance2=0.8;Cinema=0.5;Crashout=0.75;Defeat=0.95;Despair=0.9;Sit=0.92;PlayDead=0.95;BackFlip=0.45;Idle1=0.3;Idle2=0.3;Idle3=0.3;Idle4=0.3;Idle5=0.3;Idle6=0.3;Idle7=0.3;Idle8=0.3";
private static readonly string[] EmoteStates = new string[22]
{
"A_Scout_Emote_Wave", "A_Scout_Emote_Clap", "A_Scout_Emote_ThumbsUp", "A_Scout_Emote_Flex", "A_Scout_Emote_Salute", "A_Scout_Emote_Shrug", "A_Scout_Emote_Think", "A_Scout_Emote_CrossedArms", "A_Scout_Emote_ImHere", "A_Scout_Emote_Nono",
"A_Scout_Emote_Panic", "A_Scout_Emote_Fist", "A_Scout_Emote_PunchFist", "A_Scout_Emote_Dance1", "A_Scout_Emote_Dance2", "A_Scout_Emote_Cinema", "A_Scout_Emote_Crashout", "A_Scout_Emote_Defeat", "A_Scout_Emote_Despair", "A_Scout_Emote_Sit",
"A_Scout_Emote_PlayDead", "A_Scout_Emote_BackFlip"
};
private static readonly Vector3 FullBodyLocalPos = new Vector3(0f, 1.05f, 1f);
private const float FullBodyOrthoSize = 1.3f;
private const int IdleCount = 8;
private const float DefaultSampleTime = 0.5f;
private static bool dualDiagLogged;
internal static IEnumerator Generate(PassportManager manager, StickerButton button)
{
PlayerCustomizationDummy dummy = manager.dummy;
Camera cam = manager.dummyCamera;
if ((Object)(object)dummy == (Object)null || (Object)(object)dummy.anim == (Object)null || (Object)(object)dummy.refs == (Object)null || (Object)(object)cam == (Object)null)
{
Plugin.Log.LogError((object)"Passport preview not found; cannot generate stickers.");
button.SetStatus("Error: vista previa no encontrada");
button.FinishGeneration();
yield break;
}
List<PoseInfo> poses = BuildPoses(ParseSampleTimes(Plugin.SampleTimesConfig.Value));
poses = FilterBySelection(poses);
if (poses.Count == 0)
{
button.SetStatus("Error: sin poses configuradas");
button.FinishGeneration();
yield break;
}
string text = (Plugin.OutputDirectoryConfig.Value ?? string.Empty).Trim();
if (text.Length == 0)
{
text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "PEAK Stickers");
}
string dir = Path.Combine(text, DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss"));
try
{
Directory.CreateDirectory(dir);
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"Could not create output directory '{dir}': {arg}");
button.SetStatus("Error: no se pudo crear la carpeta");
button.FinishGeneration();
yield break;
}
int resolution = Mathf.Clamp(Plugin.ResolutionConfig.Value, 256, 4096);
int border = Mathf.Clamp(Plugin.BorderWidthConfig.Value, 0, 64);
bool autoCrop = Plugin.AutoCropConfig.Value;
int cropPad = Mathf.Max(8, resolution / 64);
int rtSize = resolution * 2;
Animator anim = dummy.anim;
UniversalAdditionalCameraData urp = ((Component)cam).GetComponent<UniversalAdditionalCameraData>();
RuntimeAnimatorController origController = anim.runtimeAnimatorController;
float origSpeed = anim.speed;
CameraClearFlags savedClear = cam.clearFlags;
Color savedBg = cam.backgroundColor;
RenderTexture savedTarget = cam.targetTexture;
int savedMask = cam.cullingMask;
float savedOrtho = cam.orthographicSize;
Vector3 savedLocalPos = ((Component)cam).transform.localPosition;
Rect savedRect = cam.rect;
bool savedCamEnabled = ((Behaviour)cam).enabled;
bool savedPost = (Object)(object)urp != (Object)null && urp.renderPostProcessing;
Transform transform = ((Component)dummy).transform;
HashSet<Renderer> keep = BuildKeepSet(dummy.refs);
int stickerLayer = FindUnusedLayer();
HashSet<GameObject> layered = new HashSet<GameObject>();
List<(GameObject go, int layer)> savedLayers = new List<(GameObject, int)>();
Transform[] componentsInChildren = ((Component)transform).GetComponentsInChildren<Transform>(true);
foreach (Transform val in componentsInChildren)
{
AddLayerObject(((Component)val).gameObject);
}
foreach (Renderer item2 in keep)
{
AddLayerObject(((Component)item2).gameObject);
}
Renderer[] componentsInChildren2 = ((Component)transform).GetComponentsInChildren<Renderer>(true);
List<(Renderer r, bool enabled)> savedDisabled = new List<(Renderer, bool)>();
Renderer[] array = componentsInChildren2;
foreach (Renderer val2 in array)
{
if (!keep.Contains(val2))
{
savedDisabled.Add((val2, val2.enabled));
}
}
bool savedAnimEnabled = ((Behaviour)anim).enabled;
List<(SkinnedMeshRenderer smr, bool value)> savedUwo = new List<(SkinnedMeshRenderer, bool)>();
RenderTexture rt = new RenderTexture(rtSize, rtSize, 24, (RenderTextureFormat)0);
rt.Create();
Texture2D tex = new Texture2D(rtSize, rtSize, (TextureFormat)4, false);
Texture2D outTex = new Texture2D(resolution, resolution, (TextureFormat)4, false);
int savedCount = 0;
Color32[] lastGoodPx = null;
bool dualMode = false;
bool swapped = false;
Color32[] baseline = Array.Empty<Color32>();
Color clear = new Color(0f, 0f, 0f, 0f);
bool useForcedFraming = true;
bool useLayers = true;
bool useRenderersOff = true;
bool probeOk = false;
try
{
foreach (Renderer item3 in keep)
{
SkinnedMeshRenderer val3 = (SkinnedMeshRenderer)(object)((item3 is SkinnedMeshRenderer) ? item3 : null);
if (val3 != null)
{
savedUwo.Add((val3, val3.updateWhenOffscreen));
val3.updateWhenOffscreen = true;
}
}
RuntimeAnimatorController val4 = null;
Character localCharacter = Character.localCharacter;
if ((Object)(object)localCharacter != (Object)null && localCharacter.refs != null)
{
if ((Object)(object)localCharacter.refs.animator != (Object)null)
{
val4 = localCharacter.refs.animator.runtimeAnimatorController;
}
if ((Object)(object)val4 == (Object)null && (Object)(object)localCharacter.refs.animations != (Object)null)
{
val4 = localCharacter.refs.animations.defaultController;
}
}
if ((Object)(object)val4 != (Object)null && (Object)(object)val4 != (Object)(object)origController)
{
anim.runtimeAnimatorController = val4;
swapped = true;
}
((Behaviour)anim).enabled = true;
anim.Rebind();
anim.SetFloat("Idle", 3f);
anim.speed = 1f;
anim.Update(0.02f);
Plugin.Log.LogInfo((object)($"Animator setup: enabled={((Behaviour)anim).enabled} (was {savedAnimEnabled}), " + $"active={((Component)anim).gameObject.activeInHierarchy}, swapped={swapped}, " + "dummyCtrl='" + (((Object)(object)origController != (Object)null) ? ((Object)origController).name : "null") + "', useCtrl='" + (((Object)(object)anim.runtimeAnimatorController != (Object)null) ? ((Object)anim.runtimeAnimatorController).name : "null") + "', " + $"stickerLayer={stickerLayer}, keep={keep.Count}, disabledNonChar={savedDisabled.Count}"));
((Behaviour)cam).enabled = true;
cam.clearFlags = (CameraClearFlags)2;
cam.backgroundColor = clear;
cam.rect = new Rect(0f, 0f, 1f, 1f);
cam.orthographicSize = 1.3f;
((Component)cam).transform.localPosition = FullBodyLocalPos;
if ((Object)(object)urp != (Object)null)
{
urp.renderPostProcessing = false;
}
int num = 0;
foreach (Renderer item4 in keep)
{
if ((Object)(object)item4 != (Object)null && ((Component)item4).gameObject.activeInHierarchy && item4.enabled && !item4.forceRenderingOff)
{
num++;
}
}
Plugin.Log.LogInfo((object)($"Capture env: camGOActive={((Component)cam).gameObject.activeInHierarchy}, camWorld={((Component)cam).transform.position}, " + $"charWorld={transform.position}, visibleCharRenderers={num}/{keep.Count}, " + $"savedOrtho={savedOrtho}, savedPos={savedLocalPos}"));
List<(string label, bool forced, bool layers, bool rOff, bool ok, int covered)> probes = new List<(string, bool, bool, bool, bool, int)>();
Probe("static(raw+savedFrame)", forced: false, layers: false, renderersOff: false);
Probe("isolated+forcedFrame", forced: true, layers: true, renderersOff: true);
Probe("layersOnly+forcedFrame", forced: true, layers: true, renderersOff: false);
Probe("raw+forcedFrame", forced: true, layers: false, renderersOff: false);
Probe("isolated+savedFrame", forced: false, layers: true, renderersOff: true);
(bool, bool, bool)[] array2 = new(bool, bool, bool)[5]
{
(true, true, true),
(true, true, false),
(false, true, true),
(true, false, false),
(false, false, false)
};
(bool, bool, bool)[] array3 = array2;
for (int k = 0; k < array3.Length; k++)
{
(bool, bool, bool) tuple = array3[k];
foreach (var item5 in probes)
{
if (item5.ok && item5.forced == tuple.Item1 && item5.layers == tuple.Item2 && item5.rOff == tuple.Item3)
{
probeOk = true;
(useForcedFraming, useLayers, useRenderersOff) = tuple;
break;
}
}
if (probeOk)
{
break;
}
}
if (probeOk)
{
ApplyFraming(useForcedFraming);
ApplyIsolation(useLayers, useRenderersOff);
baseline = Capture(cam, rt, tex, savedTarget, clear, ref dualMode);
Plugin.Log.LogInfo((object)($"Capture config: forcedFrame={useForcedFraming}, layers={useLayers}, " + $"renderersOff={useRenderersOff}, dualMode={dualMode}, covered={CountCovered(baseline)}"));
if (!useLayers || !useRenderersOff)
{
Plugin.Log.LogWarning((object)"Isolation unavailable — stickers may include the scene background.");
}
}
else
{
Plugin.Log.LogError((object)"The character never rendered in the capture camera. See probe lines above.");
}
for (int l = 0; l < poses.Count; l++)
{
if ((Object)(object)cam == (Object)null)
{
break;
}
if ((Object)(object)anim == (Object)null)
{
break;
}
PoseInfo p = poses[l];
button.SetStatus($"Generando {l + 1}/{poses.Count}");
ApplyPose(anim, p);
yield return null;
if ((Object)(object)cam == (Object)null || (Object)(object)anim == (Object)null)
{
break;
}
ApplyFraming(useForcedFraming);
ApplyIsolation(useLayers, useRenderersOff);
float num2 = ((float)border + 8f) * 2f / (float)resolution;
float margin = Mathf.Max(1.03f, 1f / Mathf.Max(0.25f, 1f - num2));
FitCameraToBounds(cam, keep, margin);
Color32[] array4 = Capture(cam, rt, tex, savedTarget, clear, ref dualMode);
bool flag = SamePixels(baseline, array4);
if (l == 0)
{
Plugin.Log.LogInfo((object)($"Pose0 '{p.State}': stateMatches={StateMatches(anim, p.State)}, " + $"covered={CountCovered(array4)}/{array4.Length}px, sameAsBaseline={flag}"));
}
if (flag || (lastGoodPx != null && SamePixels(lastGoodPx, array4)))
{
if (l == 0)
{
Plugin.Log.LogWarning((object)("Pose '" + p.State + "' did not apply, skipped."));
}
else
{
Plugin.Log.LogDebug((object)("Pose '" + p.State + "' rendered like a previous pose, skipped."));
}
continue;
}
Color32[] px = Downsample(array4, rtSize, 2);
Color32[] array5 = AddOutline(px, resolution, border, dualMode);
if (autoCrop)
{
array5 = CropToFit(array5, resolution, cropPad);
}
outTex.SetPixels32(array5);
byte[] bytes = ImageConversion.EncodeToPNG(outTex);
lastGoodPx = array4;
savedCount++;
string path = Path.Combine(dir, $"{savedCount:00}_{Suffix(p.State)}.png");
File.WriteAllBytes(path, bytes);
}
if (savedCount == 0 && probeOk && baseline.Length != 0 && CountCovered(baseline) > 0)
{
Color32[] px2 = Downsample(baseline, rtSize, 2);
Color32[] array6 = AddOutline(px2, resolution, border, dualMode);
if (autoCrop)
{
array6 = CropToFit(array6, resolution, cropPad);
}
outTex.SetPixels32(array6);
File.WriteAllBytes(Path.Combine(dir, "00_estatico.png"), ImageConversion.EncodeToPNG(outTex));
savedCount = 1;
Plugin.Log.LogWarning((object)"No pose produced a new image; saved the static character pose as 00_estatico.png.");
}
if (savedCount > 0)
{
button.SetStatus($"¡Listo! {savedCount} stickers");
Plugin.Log.LogInfo((object)$"Saved {savedCount} stickers to: {dir}");
if (Plugin.OpenFolderConfig.Value)
{
try
{
Process.Start(new ProcessStartInfo(dir)
{
UseShellExecute = true
});
yield break;
}
catch (Exception ex)
{
Plugin.Log.LogWarning((object)("Could not open output folder: " + ex.Message));
yield break;
}
}
}
else
{
button.SetStatus("No se generó ningún sticker (revisa el log)");
Plugin.Log.LogError((object)"No stickers were generated. Check the log above.");
}
void Probe(string label, bool forced, bool layers, bool renderersOff)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
ApplyFraming(forced);
ApplyIsolation(layers, renderersOff);
Color32[] array7 = Capture(cam, rt, tex, savedTarget, clear, ref dualMode);
int num3 = CountCovered(array7);
bool item = num3 > 0;
probes.Add((label, forced, layers, renderersOff, item, num3));
Plugin.Log.LogInfo((object)$"Probe '{label}': covered={num3}/{array7.Length}px, {FrustumInfo()}");
}
}
finally
{
Restore();
if ((Object)(object)rt != (Object)null)
{
rt.Release();
Object.DestroyImmediate((Object)(object)rt);
}
if ((Object)(object)tex != (Object)null)
{
Object.DestroyImmediate((Object)(object)tex);
}
if ((Object)(object)outTex != (Object)null)
{
Object.DestroyImmediate((Object)(object)outTex);
}
button.FinishGeneration();
void AddLayerObject(GameObject? go)
{
if ((Object)(object)go != (Object)null && layered.Add(go))
{
savedLayers.Add((go, go.layer));
}
}
void ApplyFraming(bool forced)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
cam.orthographicSize = (forced ? 1.3f : savedOrtho);
((Component)cam).transform.localPosition = (forced ? FullBodyLocalPos : savedLocalPos);
}
void ApplyIsolation(bool layers, bool renderersOff)
{
cam.cullingMask = (layers ? (1 << stickerLayer) : savedMask);
foreach (var (val5, num3) in savedLayers)
{
if ((Object)(object)val5 != (Object)null)
{
val5.layer = (layers ? stickerLayer : num3);
}
}
foreach (var (val6, flag2) in savedDisabled)
{
if ((Object)(object)val6 != (Object)null)
{
val6.enabled = !renderersOff && flag2;
}
}
}
void Restore()
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
RenderTexture active = RenderTexture.active;
if ((Object)(object)active != (Object)null && (Object)(object)active == (Object)(object)rt)
{
RenderTexture.active = null;
}
if ((Object)(object)cam != (Object)null)
{
cam.targetTexture = savedTarget;
cam.clearFlags = savedClear;
cam.backgroundColor = savedBg;
cam.cullingMask = savedMask;
cam.orthographicSize = savedOrtho;
cam.rect = savedRect;
((Component)cam).transform.localPosition = savedLocalPos;
((Behaviour)cam).enabled = savedCamEnabled;
if ((Object)(object)urp != (Object)null)
{
urp.renderPostProcessing = savedPost;
}
}
foreach (var (val5, layer) in savedLayers)
{
if ((Object)(object)val5 != (Object)null)
{
val5.layer = layer;
}
}
foreach (var (val6, enabled) in savedDisabled)
{
if ((Object)(object)val6 != (Object)null)
{
val6.enabled = enabled;
}
}
foreach (var (val7, updateWhenOffscreen) in savedUwo)
{
if ((Object)(object)val7 != (Object)null)
{
val7.updateWhenOffscreen = updateWhenOffscreen;
}
}
if ((Object)(object)anim != (Object)null)
{
if (swapped)
{
anim.runtimeAnimatorController = origController;
}
anim.Rebind();
anim.SetFloat("Idle", 3f);
anim.speed = origSpeed;
((Behaviour)anim).enabled = savedAnimEnabled;
anim.Update(0.02f);
}
}
}
static Color32[] Capture(Camera c, RenderTexture texture, Texture2D target, RenderTexture? target0, Color clearColor, ref bool dual)
{
//IL_005c: 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_004e: Unknown result type (might be due to invalid IL or missing references)
if (!dual)
{
c.backgroundColor = clearColor;
c.targetTexture = texture;
c.Render();
c.targetTexture = target0;
Color32[] array7 = ReadInto(texture, target);
if (CornersOpaque(array7, ((Texture)texture).width))
{
Plugin.Log.LogWarning((object)"Render texture alpha unavailable, using dual-background capture.");
dual = true;
return RenderDual(c, texture, target, target0, clearColor);
}
return array7;
}
return RenderDual(c, texture, target, target0, clearColor);
}
string FrustumInfo()
{
//IL_004b: 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_0053: 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_005d: 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_0079: 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_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
SkinnedMeshRenderer val5 = (((Object)(object)dummy.refs != (Object)null) ? dummy.refs.mainRenderer : null);
if ((Object)(object)val5 == (Object)null || (Object)(object)cam == (Object)null)
{
return "no mainRenderer";
}
Camera obj = cam;
Bounds bounds = ((Renderer)val5).bounds;
Vector3 val6 = obj.WorldToViewportPoint(((Bounds)(ref bounds)).center);
object[] obj2 = new object[4] { val6.x, val6.y, val6.z, null };
bounds = ((Renderer)val5).bounds;
obj2[3] = ((Bounds)(ref bounds)).size;
return string.Format("mainRig vp=({0:F2},{1:F2},z={2:F1}), boundsSize={3:F1}", obj2);
}
}
private static void ApplyPose(Animator anim, PoseInfo p)
{
anim.speed = 1f;
if (!p.IsIdle)
{
anim.SetBool("Emote", true);
}
anim.Play(p.State, 0, 0f);
anim.Update(0.02f);
if (p.IsIdle && !StateMatches(anim, p.State))
{
anim.Rebind();
anim.Update(0.02f);
anim.SetFloat("Idle", (float)p.IdleIndex);
anim.speed = 0f;
anim.Update(0.02f);
}
else
{
anim.Play(p.State, 0, p.Time);
anim.speed = 0f;
anim.Update(0.02f);
}
}
private static bool StateMatches(Animator anim, string stateName)
{
//IL_0002: 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)
AnimatorStateInfo currentAnimatorStateInfo = anim.GetCurrentAnimatorStateInfo(0);
if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName(stateName))
{
return ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Base Layer." + stateName);
}
return true;
}
private static List<PoseInfo> BuildPoses(Dictionary<string, float> times)
{
List<PoseInfo> list = new List<PoseInfo>();
HashSet<string> seen = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
string[] emoteStates = EmoteStates;
foreach (string state in emoteStates)
{
Add(state);
}
foreach (string item in WheelEmoteStates())
{
Add(item);
}
if (Plugin.IncludeIdlesConfig.Value)
{
for (int j = 1; j <= 8; j++)
{
Add($"A_Scout_Idle{j}", idle: true, j);
}
}
return list;
void Add(string text, bool idle = false, int idleIndex = 0)
{
if (seen.Add(text))
{
list.Add(new PoseInfo(text, SampleTime(times, text), idle, idleIndex));
}
}
}
private static IEnumerable<string> WheelEmoteStates()
{
EmoteWheel[] array = Resources.FindObjectsOfTypeAll<EmoteWheel>();
foreach (EmoteWheel val in array)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
Scene scene = ((Component)val).gameObject.scene;
if (!((Scene)(ref scene)).IsValid() || val.data == null)
{
continue;
}
EmoteWheelData[] data = val.data;
foreach (EmoteWheelData val2 in data)
{
if ((Object)(object)val2 != (Object)null && !string.IsNullOrEmpty(val2.anim))
{
yield return val2.anim;
}
}
break;
}
}
private static Dictionary<string, float> ParseSampleTimes(string raw)
{
Dictionary<string, float> dictionary = new Dictionary<string, float>(StringComparer.OrdinalIgnoreCase);
if (string.IsNullOrEmpty(raw))
{
return dictionary;
}
string[] array = raw.Split(';');
foreach (string text in array)
{
int num = text.IndexOf('=');
if (num > 0)
{
string key = text.Substring(0, num).Trim();
if (float.TryParse(text.Substring(num + 1).Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
{
dictionary[key] = result;
}
}
}
return dictionary;
}
private static float SampleTime(Dictionary<string, float> times, string state)
{
string key = Suffix(state);
if (times.TryGetValue(key, out var value))
{
return value;
}
if (times.TryGetValue(state, out value))
{
return value;
}
return 0.5f;
}
private static string Suffix(string state)
{
int num = state.LastIndexOf('_');
if (num < 0)
{
return state;
}
return state.Substring(num + 1);
}
internal static string StateSuffix(string state)
{
return Suffix(state);
}
internal static List<(string state, bool isIdle)> GetPoseStates()
{
List<PoseInfo> list = BuildPoses(ParseSampleTimes(Plugin.SampleTimesConfig.Value));
List<(string, bool)> list2 = new List<(string, bool)>(list.Count);
foreach (PoseInfo item in list)
{
list2.Add((item.State, item.IsIdle));
}
return list2;
}
private static List<PoseInfo> FilterBySelection(List<PoseInfo> poses)
{
string sel = Plugin.SelectedPosesConfig.Value;
if (string.IsNullOrWhiteSpace(sel) || sel == "all")
{
return poses;
}
List<PoseInfo> list = ((sel == "emotes") ? poses.FindAll((PoseInfo p) => !p.IsIdle) : ((!(sel == "idles")) ? poses.FindAll((PoseInfo p) => string.Equals(p.State, sel, StringComparison.OrdinalIgnoreCase)) : poses.FindAll((PoseInfo p) => p.IsIdle)));
if (list.Count == 0)
{
Plugin.Log.LogWarning((object)("Selection '" + sel + "' matched no poses — generating all."));
return poses;
}
Plugin.Log.LogInfo((object)$"Pose selection '{sel}': generating {list.Count} pose(s).");
return list;
}
private static HashSet<Renderer> BuildKeepSet(CustomizationRefs refs)
{
HashSet<Renderer> keep = new HashSet<Renderer>();
if (refs.AllRenderers != null)
{
Renderer[] allRenderers = refs.AllRenderers;
foreach (Renderer val in allRenderers)
{
if ((Object)(object)val != (Object)null)
{
keep.Add(val);
}
}
}
FieldInfo[] fields = typeof(CustomizationRefs).GetFields(BindingFlags.Instance | BindingFlags.Public);
foreach (FieldInfo fieldInfo in fields)
{
if (!fieldInfo.Name.Contains("Shadow", StringComparison.OrdinalIgnoreCase))
{
AddRenderers(fieldInfo.GetValue(refs));
}
}
return keep;
void AddRenderers(object? value)
{
Renderer val2 = (Renderer)((value is Renderer) ? value : null);
if (val2 == null)
{
GameObject val3 = (GameObject)((value is GameObject) ? value : null);
if (val3 == null)
{
if (value is Array array)
{
foreach (object item2 in array)
{
AddRenderers(item2);
}
}
}
else if ((Object)(object)val3 != (Object)null)
{
Renderer[] componentsInChildren = val3.GetComponentsInChildren<Renderer>(true);
foreach (Renderer item in componentsInChildren)
{
keep.Add(item);
}
}
}
else if ((Object)(object)val2 != (Object)null)
{
keep.Add(val2);
}
}
}
private static int FindUnusedLayer()
{
for (int num = 31; num >= 0; num--)
{
if (string.IsNullOrEmpty(LayerMask.LayerToName(num)))
{
return num;
}
}
return 31;
}
private static Color32[] ReadInto(RenderTexture rt, Texture2D tex)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
RenderTexture active = RenderTexture.active;
RenderTexture.active = rt;
tex.ReadPixels(new Rect(0f, 0f, (float)((Texture)rt).width, (float)((Texture)rt).height), 0, 0);
RenderTexture.active = active;
return tex.GetPixels32();
}
private static Color32[] RenderDual(Camera cam, RenderTexture rt, Texture2D tex, RenderTexture? savedTarget, Color clear)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
cam.backgroundColor = Color.black;
cam.targetTexture = rt;
cam.Render();
Color32[] array = ReadInto(rt, tex);
cam.backgroundColor = Color.white;
cam.Render();
Color32[] array2 = ReadInto(rt, tex);
cam.targetTexture = savedTarget;
cam.backgroundColor = clear;
if (!dualDiagLogged)
{
dualDiagLogged = true;
bool flag = SamePixels(array, array2);
Plugin.Log.LogInfo((object)($"Dual capture diag: blackCovered={CountCovered(array)}/{array.Length}px, " + $"whiteCovered={CountCovered(array2)}/{array2.Length}px, identical={flag}"));
if (flag)
{
Plugin.Log.LogError((object)"Black and white renders are identical — RT readback or clear color is not working.");
}
}
return CombineDual(array, array2);
}
private static Color32[] CombineDual(Color32[] black, Color32[] white)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Invalid comparison between Unknown and I4
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: 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)
bool linear = (int)QualitySettings.activeColorSpace == 1;
Color32[] array = (Color32[])(object)new Color32[black.Length];
for (int i = 0; i < black.Length; i++)
{
float num = ToUnit(black[i].r, linear);
float num2 = ToUnit(black[i].g, linear);
float num3 = ToUnit(black[i].b, linear);
float num4 = ToUnit(white[i].r, linear);
float num5 = ToUnit(white[i].g, linear);
float num6 = ToUnit(white[i].b, linear);
float num7 = Mathf.Clamp01(1f - (num4 - num));
float num8 = Mathf.Clamp01(1f - (num5 - num2));
float num9 = Mathf.Clamp01(1f - (num6 - num3));
float num10 = (num7 + num8 + num9) / 3f;
if (num10 < 0.004f)
{
array[i] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)0);
continue;
}
byte b = FromUnit(Mathf.Clamp01(num / num10), linear);
byte b2 = FromUnit(Mathf.Clamp01(num2 / num10), linear);
byte b3 = FromUnit(Mathf.Clamp01(num3 / num10), linear);
array[i] = new Color32(b, b2, b3, (byte)Mathf.RoundToInt(num10 * 255f));
}
return array;
}
private static float ToUnit(byte v, bool linear)
{
float num = (float)(int)v / 255f;
if (!linear)
{
return num;
}
if (!(num <= 0.04045f))
{
return Mathf.Pow((num + 0.055f) / 1.055f, 2.4f);
}
return num / 12.92f;
}
private static byte FromUnit(float f, bool linear)
{
if (!linear)
{
return (byte)Mathf.RoundToInt(Mathf.Clamp01(f) * 255f);
}
float num = ((f <= 0.0031308f) ? (f * 12.92f) : (1.055f * Mathf.Pow(f, 5f / 12f) - 0.055f));
return (byte)Mathf.RoundToInt(Mathf.Clamp01(num) * 255f);
}
private static bool CornersOpaque(Color32[] px, int size)
{
if (px.Length < size * size)
{
return false;
}
int num = px[0].a + px[size - 1].a + px[(size - 1) * size].a + px[size * size - 1].a;
return num > 0;
}
private static int CountCovered(Color32[] px)
{
int num = 0;
for (int i = 0; i < px.Length; i++)
{
if (px[i].a > 0)
{
num++;
}
}
return num;
}
private static bool FitCameraToBounds(Camera cam, HashSet<Renderer> keep, float margin)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//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_00a1: 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)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: 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_005a: 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_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: 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_0105: 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_0125: 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_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: 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_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: 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)
bool flag = false;
Bounds val = default(Bounds);
foreach (Renderer item in keep)
{
if (!((Object)(object)item == (Object)null) && ((Component)item).gameObject.activeInHierarchy && item.enabled && !item.forceRenderingOff)
{
if (!flag)
{
val = item.bounds;
flag = true;
}
else
{
((Bounds)(ref val)).Encapsulate(item.bounds);
}
}
}
if (flag)
{
Vector3 size = ((Bounds)(ref val)).size;
if (!(((Vector3)(ref size)).sqrMagnitude < 1E-06f))
{
Transform transform = ((Component)cam).transform;
Vector3 right = transform.right;
Vector3 up = transform.up;
Vector3 forward = transform.forward;
float num = 0f;
float num2 = 0f;
Vector3 val2 = default(Vector3);
for (int i = 0; i < 8; i++)
{
((Vector3)(ref val2))..ctor(((i & 1) == 0) ? ((Bounds)(ref val)).min.x : ((Bounds)(ref val)).max.x, ((i & 2) == 0) ? ((Bounds)(ref val)).min.y : ((Bounds)(ref val)).max.y, ((i & 4) == 0) ? ((Bounds)(ref val)).min.z : ((Bounds)(ref val)).max.z);
Vector3 val3 = val2 - ((Bounds)(ref val)).center;
num = Mathf.Max(num, Mathf.Abs(Vector3.Dot(val3, right)));
num2 = Mathf.Max(num2, Mathf.Abs(Vector3.Dot(val3, up)));
}
cam.orthographicSize = Mathf.Max(0.4f, Mathf.Max(num, num2) * margin);
Vector3 val4 = ((Bounds)(ref val)).center - transform.position;
float num3 = Vector3.Dot(val4, forward);
transform.position = ((Bounds)(ref val)).center - forward * num3;
return true;
}
}
return false;
}
private static Color32[] CropToFit(Color32[] px, int size, int pad)
{
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: 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_01e5: 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_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_0365: Unknown result type (might be due to invalid IL or missing references)
//IL_036a: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Unknown result type (might be due to invalid IL or missing references)
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_028d: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: 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_02a3: 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_02b2: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0301: Unknown result type (might be due to invalid IL or missing references)
int num = size;
int num2 = size;
int num3 = -1;
int num4 = -1;
for (int i = 0; i < size; i++)
{
int num5 = i * size;
for (int j = 0; j < size; j++)
{
if (px[num5 + j].a > 8)
{
if (j < num)
{
num = j;
}
if (j > num3)
{
num3 = j;
}
if (i < num2)
{
num2 = i;
}
if (i > num4)
{
num4 = i;
}
}
}
}
if (num3 < 0)
{
return px;
}
int num6 = Mathf.Max(0, num - pad);
int num7 = Mathf.Max(0, num2 - pad);
int num8 = Mathf.Min(size - 1, num3 + pad);
int num9 = Mathf.Min(size - 1, num4 + pad);
int num10 = num8 - num6 + 1;
int num11 = num9 - num7 + 1;
if (num10 >= size && num11 >= size)
{
return px;
}
float num12 = Mathf.Min((float)size / (float)num10, (float)size / (float)num11);
int num13 = Mathf.Min(size, Mathf.RoundToInt((float)num10 * num12));
int num14 = Mathf.Min(size, Mathf.RoundToInt((float)num11 * num12));
if (num13 < 1 || num14 < 1)
{
return px;
}
int num15 = (size - num13) / 2;
int num16 = (size - num14) / 2;
Color32[] array = (Color32[])(object)new Color32[size * size];
for (int k = 0; k < num14; k++)
{
float num17 = (float)num7 + (((float)k + 0.5f) / num12 - 0.5f);
int num18 = Mathf.Clamp(Mathf.FloorToInt(num17), 0, size - 1);
int num19 = Mathf.Clamp(num18 + 1, 0, size - 1);
float fy = Mathf.Clamp01(num17 - (float)num18);
for (int l = 0; l < num13; l++)
{
float num20 = (float)num6 + (((float)l + 0.5f) / num12 - 0.5f);
int num21 = Mathf.Clamp(Mathf.FloorToInt(num20), 0, size - 1);
int num22 = Mathf.Clamp(num21 + 1, 0, size - 1);
float fx = Mathf.Clamp01(num20 - (float)num21);
Color32 val = px[num18 * size + num21];
Color32 val2 = px[num18 * size + num22];
Color32 val3 = px[num19 * size + num21];
Color32 val4 = px[num19 * size + num22];
float num23 = Lerp((int)val.a, (int)val2.a, (int)val3.a, (int)val4.a, fx, fy) / 255f;
byte b = byte.MaxValue;
byte b2 = byte.MaxValue;
byte b3 = byte.MaxValue;
if (num23 > 0.002f)
{
float num24 = Lerp4PM((int)val.r, val.a, (int)val2.r, val2.a, (int)val3.r, val3.a, (int)val4.r, val4.a, fx, fy);
float num25 = Lerp4PM((int)val.g, val.a, (int)val2.g, val2.a, (int)val3.g, val3.a, (int)val4.g, val4.a, fx, fy);
float num26 = Lerp4PM((int)val.b, val.a, (int)val2.b, val2.a, (int)val3.b, val3.a, (int)val4.b, val4.a, fx, fy);
b = ClampByte(num24 / num23);
b2 = ClampByte(num25 / num23);
b3 = ClampByte(num26 / num23);
}
array[(num16 + k) * size + num15 + l] = new Color32(b, b2, b3, (byte)Mathf.Clamp(Mathf.RoundToInt(num23 * 255f), 0, 255));
}
}
return array;
static byte ClampByte(float v)
{
return (byte)Mathf.Clamp(Mathf.RoundToInt(v * 255f), 0, 255);
}
static float Lerp(float a, float num28, float c, float d, float num29, float num31)
{
float num27 = Mathf.Lerp(a, num28, num29);
float num30 = Mathf.Lerp(c, d, num29);
return Mathf.Lerp(num27, num30, num31);
}
static float Lerp4PM(float ra, byte aa, float rb, byte ab, float rc, byte ac, float rd, byte ad, float num28, float num30)
{
float num27 = Mathf.Lerp(ra * (float)(int)aa / 65025f, rb * (float)(int)ab / 65025f, num28);
float num29 = Mathf.Lerp(rc * (float)(int)ac / 65025f, rd * (float)(int)ad / 65025f, num28);
return Mathf.Lerp(num27, num29, num30);
}
}
private static bool SamePixels(Color32[] a, Color32[] b)
{
if (a.Length != b.Length || a.Length == 0)
{
return false;
}
for (int i = 0; i < a.Length; i++)
{
if (a[i].r != b[i].r || a[i].g != b[i].g || a[i].b != b[i].b || a[i].a != b[i].a)
{
return false;
}
}
return true;
}
private static Color32[] Downsample(Color32[] src, int srcSize, int factor)
{
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: 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_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: 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_006c: 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)
int num = srcSize / factor;
Color32[] array = (Color32[])(object)new Color32[num * num];
int num2 = factor * factor;
for (int i = 0; i < num; i++)
{
for (int j = 0; j < num; j++)
{
int num3 = 0;
int num4 = 0;
int num5 = 0;
int num6 = 0;
for (int k = 0; k < factor; k++)
{
int num7 = (i * factor + k) * srcSize + j * factor;
for (int l = 0; l < factor; l++)
{
Color32 val = src[num7 + l];
num3 += val.r;
num4 += val.g;
num5 += val.b;
num6 += val.a;
}
}
array[i * num + j] = new Color32((byte)(num3 / num2), (byte)(num4 / num2), (byte)(num5 / num2), (byte)(num6 / num2));
}
}
return array;
}
private static Color32[] AddOutline(Color32[] px, int size, int border, bool straightColors)
{
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: 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_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: 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_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
byte[] array = new byte[px.Length];
for (int i = 0; i < px.Length; i++)
{
array[i] = px[i].a;
}
int num = Mathf.Clamp(Plugin.RoundnessConfig.Value, 0, 64);
byte[] array2 = new byte[array.Length];
for (int j = 0; j < array.Length; j++)
{
array2[j] = (byte)((array[j] > 6) ? byte.MaxValue : 0);
}
if (num > 0)
{
array2 = MaxFilter(array2, size, num, horizontal: true);
array2 = MaxFilter(array2, size, num, horizontal: false);
array2 = MinFilter(array2, size, num, horizontal: true);
array2 = MinFilter(array2, size, num, horizontal: false);
}
byte[] src;
if (border > 0)
{
src = MaxFilter(array2, size, border, horizontal: true);
src = MaxFilter(src, size, border, horizontal: false);
src = BoxBlur3(src, size, 2);
}
else
{
src = new byte[array.Length];
}
Color32[] array3 = (Color32[])(object)new Color32[px.Length];
for (int k = 0; k < px.Length; k++)
{
Color32 val = px[k];
byte b = ((val.a > src[k]) ? val.a : src[k]);
if (val.a > 6)
{
byte b2 = val.r;
byte b3 = val.g;
byte b4 = val.b;
if (!straightColors)
{
b2 = Unpremultiply(val.r, val.a);
b3 = Unpremultiply(val.g, val.a);
b4 = Unpremultiply(val.b, val.a);
}
array3[k] = new Color32(b2, b3, b4, b);
}
else
{
array3[k] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b);
}
}
return array3;
}
private static byte Unpremultiply(byte v, byte a)
{
if (a == 0 || a == byte.MaxValue)
{
return v;
}
int num = (v * 255 + a / 2) / a;
return (byte)((num > 255) ? 255u : ((uint)num));
}
private static byte[] MaxFilter(byte[] src, int size, int radius, bool horizontal)
{
byte[] array = new byte[src.Length];
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
int num = ((j - radius >= 0) ? (j - radius) : 0);
int num2 = ((j + radius >= size) ? (size - 1) : (j + radius));
byte b = 0;
for (int k = num; k <= num2; k++)
{
byte b2 = (horizontal ? src[i * size + k] : src[k * size + i]);
if (b2 > b)
{
b = b2;
}
}
if (horizontal)
{
array[i * size + j] = b;
}
else
{
array[j * size + i] = b;
}
}
}
return array;
}
private static byte[] MinFilter(byte[] src, int size, int radius, bool horizontal)
{
byte[] array = new byte[src.Length];
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
int num = ((j - radius >= 0) ? (j - radius) : 0);
int num2 = ((j + radius >= size) ? (size - 1) : (j + radius));
byte b = byte.MaxValue;
for (int k = num; k <= num2; k++)
{
byte b2 = (horizontal ? src[i * size + k] : src[k * size + i]);
if (b2 < b)
{
b = b2;
}
}
if (horizontal)
{
array[i * size + j] = b;
}
else
{
array[j * size + i] = b;
}
}
}
return array;
}
private static byte[] BoxBlur3(byte[] src, int size, int passes)
{
byte[] array = src;
for (int i = 0; i < passes; i++)
{
byte[] array2 = new byte[array.Length];
for (int j = 0; j < size; j++)
{
for (int k = 0; k < size; k++)
{
int num = ((k > 0) ? (k - 1) : 0);
int num2 = ((k < size - 1) ? (k + 1) : (size - 1));
int num3 = ((j > 0) ? (j - 1) : 0);
int num4 = ((j < size - 1) ? (j + 1) : (size - 1));
int num5 = 0;
int num6 = 0;
for (int l = num3; l <= num4; l++)
{
for (int m = num; m <= num2; m++)
{
num5 += array[l * size + m];
num6++;
}
}
array2[j * size + k] = (byte)((num5 + num6 / 2) / num6);
}
}
array = array2;
}
return array;
}
}
internal static class UiFactory
{
private static Sprite? rounded;
private static Sprite? triangle;
internal static Sprite RoundedSprite()
{
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Expected O, but got Unknown
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)rounded != (Object)null)
{
return rounded;
}
float num = 64f;
float num2 = 30f;
Color32[] array = (Color32[])(object)new Color32[16384];
for (int i = 0; i < 128; i++)
{
for (int j = 0; j < 128; j++)
{
float num3 = (float)j + 0.5f - num;
float num4 = (float)i + 0.5f - num;
float num5 = Mathf.Abs(num3) - (num - num2);
float num6 = Mathf.Abs(num4) - (num - num2);
float num7 = Mathf.Sqrt(Mathf.Max(num5, 0f) * Mathf.Max(num5, 0f) + Mathf.Max(num6, 0f) * Mathf.Max(num6, 0f)) + Mathf.Min(Mathf.Max(num5, num6), 0f) - num2;
byte b = (byte)Mathf.RoundToInt(Mathf.Clamp01(0.5f - num7) * 255f);
array[i * 128 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b);
}
}
Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false);
val.SetPixels32(array);
val.Apply();
rounded = Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(36f, 36f, 36f, 36f));
return rounded;
}
internal static Sprite TriangleSprite()
{
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Expected O, but got Unknown
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: 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)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)triangle != (Object)null)
{
return triangle;
}
Color32[] array = (Color32[])(object)new Color32[160];
for (int i = 0; i < 10; i++)
{
float num = (float)i / 9f;
float num2 = (1f - num) * 7f + 0.5f;
for (int j = 0; j < 16; j++)
{
float num3 = Mathf.Abs((float)j + 0.5f - 8f) - num2;
byte b = (byte)Mathf.RoundToInt(Mathf.Clamp01(0.5f - num3) * 255f);
array[i * 16 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b);
}
}
Texture2D val = new Texture2D(16, 10, (TextureFormat)4, false);
val.SetPixels32(array);
val.Apply();
triangle = Sprite.Create(val, new Rect(0f, 0f, 16f, 10f), new Vector2(0.5f, 0.5f), 100f);
return triangle;
}
internal static Image NewImage(Transform parent, string name, Color color)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//IL_0020: 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)
GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
((Transform)(RectTransform)val.transform).SetParent(parent, false);
Image val2 = val.AddComponent<Image>();
val2.sprite = RoundedSprite();
val2.type = (Type)1;
((Graphic)val2).color = color;
return val2;
}
internal static TextMeshProUGUI NewLabel(Transform parent, string text, float fontSize, Color color, TextAlignmentOptions alignment, TMP_FontAsset? font)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
//IL_0024: 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_005f: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("Label", new Type[1] { typeof(RectTransform) });
((Transform)(RectTransform)val.transform).SetParent(parent, false);
TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
if ((Object)(object)font != (Object)null)
{
((TMP_Text)val2).font = font;
}
((TMP_Text)val2).text = text;
((TMP_Text)val2).fontSize = fontSize;
((Graphic)val2).color = color;
((TMP_Text)val2).alignment = alignment;
((Graphic)val2).raycastTarget = false;
return val2;
}
internal static void Stretch(RectTransform rt)
{
//IL_0001: 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_0017: 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)
rt.anchorMin = Vector2.zero;
rt.anchorMax = Vector2.one;
rt.offsetMin = Vector2.zero;
rt.offsetMax = Vector2.zero;
}
}
}
namespace System.Diagnostics.CodeAnalysis
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ConstantExpectedAttribute : Attribute
{
public object? Min { get; set; }
public object? Max { get; set; }
}
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ExperimentalAttribute : Attribute
{
public string DiagnosticId { get; }
public string? UrlFormat { get; set; }
public ExperimentalAttribute(string diagnosticId)
{
DiagnosticId = diagnosticId;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
internal sealed class MemberNotNullAttribute : Attribute
{
public string[] Members { get; }
public MemberNotNullAttribute(string member)
{
Members = new string[1] { member };
}
public MemberNotNullAttribute(params string[] members)
{
Members = members;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
internal sealed class MemberNotNullWhenAttribute : Attribute
{
public bool ReturnValue { get; }
public string[] Members { get; }
public MemberNotNullWhenAttribute(bool returnValue, string member)
{
ReturnValue = returnValue;
Members = new string[1] { member };
}
public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
{
ReturnValue = returnValue;
Members = members;
}
}
[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class SetsRequiredMembersAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class StringSyntaxAttribute : Attribute
{
public const string CompositeFormat = "CompositeFormat";
public const string DateOnlyFormat = "DateOnlyFormat";
public const string DateTimeFormat = "DateTimeFormat";
public const string EnumFormat = "EnumFormat";
public const string GuidFormat = "GuidFormat";
public const string Json = "Json";
public const string NumericFormat = "NumericFormat";
public const string Regex = "Regex";
public const string TimeOnlyFormat = "TimeOnlyFormat";
public const string TimeSpanFormat = "TimeSpanFormat";
public const string Uri = "Uri";
public const string Xml = "Xml";
public string Syntax { get; }
public object?[] Arguments { get; }
public StringSyntaxAttribute(string syntax)
{
Syntax = syntax;
Arguments = new object[0];
}
public StringSyntaxAttribute(string syntax, params object?[] arguments)
{
Syntax = syntax;
Arguments = arguments;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class UnscopedRefAttribute : Attribute
{
}
}
namespace System.Runtime.Versioning
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class RequiresPreviewFeaturesAttribute : Attribute
{
public string? Message { get; }
public string? Url { get; set; }
public RequiresPreviewFeaturesAttribute()
{
}
public RequiresPreviewFeaturesAttribute(string? message)
{
Message = message;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CallerArgumentExpressionAttribute : Attribute
{
public string ParameterName { get; }
public CallerArgumentExpressionAttribute(string parameterName)
{
ParameterName = parameterName;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CollectionBuilderAttribute : Attribute
{
public Type BuilderType { get; }
public string MethodName { get; }
public CollectionBuilderAttribute(Type builderType, string methodName)
{
BuilderType = builderType;
MethodName = methodName;
}
}
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CompilerFeatureRequiredAttribute : Attribute
{
public const string RefStructs = "RefStructs";
public const string RequiredMembers = "RequiredMembers";
public string FeatureName { get; }
public bool IsOptional { get; set; }
public CompilerFeatureRequiredAttribute(string featureName)
{
FeatureName = featureName;
}
}
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
{
public string[] Arguments { get; }
public InterpolatedStringHandlerArgumentAttribute(string argument)
{
Arguments = new string[1] { argument };
}
public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
{
Arguments = arguments;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class InterpolatedStringHandlerAttribute : Attribute
{
}
[EditorBrowsable(EditorBrowsableState.Never)]
[ExcludeFromCodeCoverage]
internal static class IsExternalInit
{
}
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ModuleInitializerAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class OverloadResolutionPriorityAttribute : Attribute
{
public int Priority { get; }
public OverloadResolutionPriorityAttribute(int priority)
{
Priority = priority;
}
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
[ExcludeFromCodeCoverage]
internal sealed class ParamCollectionAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class RequiredMemberAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[ExcludeFromCodeCoverage]
internal sealed class RequiresLocationAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class SkipLocalsInitAttribute : Attribute
{
}
}