using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using InControl;
using SFQoL;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("Ultrawide")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+0922aaa3eb00395cd915dd4c8ab0cabd99607f03")]
[assembly: AssemblyProduct("Ultrawide")]
[assembly: AssemblyTitle("Ultrawide")]
[assembly: AssemblyVersion("1.0.1.0")]
namespace SFQoL
{
internal static class Compat
{
private static bool searched;
private static FieldInfo roundsActive;
private static PropertyInfo roundsArmed;
private static FieldInfo cardPicking;
private static bool cardSearched;
public static bool Rounds
{
get
{
Find();
try
{
if ((object)roundsArmed != null && (bool)roundsArmed.GetValue(null, null))
{
return true;
}
if ((object)roundsActive != null && (bool)roundsActive.GetValue(null))
{
return true;
}
}
catch
{
}
return false;
}
}
public static bool CardScreen
{
get
{
if (!cardSearched)
{
Type type = RoundsType("StickRounds.CardPick");
cardSearched = (object)type != null || Time.frameCount > 1;
if ((object)type != null)
{
cardPicking = type.GetField("Picking", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
}
}
try
{
return (object)cardPicking != null && (bool)cardPicking.GetValue(null);
}
catch
{
return false;
}
}
}
public static bool RoundsMatch
{
get
{
Find();
try
{
return (object)roundsActive != null && (bool)roundsActive.GetValue(null) && !GameManager.stillInMenu;
}
catch
{
return false;
}
}
}
private static Type RoundsType(string name)
{
if (!Chainloader.PluginInfos.TryGetValue("stickfight.stickrounds", out var value) || (Object)(object)value.Instance == (Object)null)
{
return null;
}
return ((object)value.Instance).GetType().Assembly.GetType(name, throwOnError: false);
}
private static void Find()
{
if (!searched)
{
Type type = RoundsType("StickRounds.RoundsMode");
searched = (object)type != null || Time.frameCount > 1;
if ((object)type != null)
{
roundsActive = type.GetField("Active", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
roundsArmed = type.GetProperty("Armed", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
}
}
}
public static bool IsBotDevice(InputDevice d)
{
if (d != null)
{
return ((object)d).GetType().Name == "BotDevice";
}
return false;
}
}
internal static class QolConfig
{
public static ConfigEntry<bool> Enabled(ConfigFile config, string section, string description)
{
return config.Bind<bool>(section, "Enabled", true, description);
}
private static Dictionary<ConfigDefinition, string> Orphans(ConfigFile config)
{
return Traverse.Create((object)config).Property("OrphanedEntries", (object[])null).GetValue<Dictionary<ConfigDefinition, string>>();
}
public static string Old(ConfigFile config, string section, string key)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
Dictionary<ConfigDefinition, string> dictionary = Orphans(config);
if (dictionary == null || !dictionary.TryGetValue(new ConfigDefinition(section, key), out var value))
{
return null;
}
return value;
}
public static void SetOld(ConfigFile config, string section, string key, string value)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
Dictionary<ConfigDefinition, string> dictionary = Orphans(config);
if (dictionary != null)
{
dictionary[new ConfigDefinition(section, key)] = value;
}
}
public static void DropOld(ConfigFile config)
{
Dictionary<ConfigDefinition, string> dictionary = Orphans(config);
if (dictionary != null && dictionary.Count != 0)
{
dictionary.Clear();
config.Save();
}
}
}
internal static class Ui
{
public static readonly Color Panel = new Color(0.176f, 0.176f, 0.176f);
public static readonly Color Strip = new Color(0.147f, 0.147f, 0.147f);
public static readonly Color Item = new Color(0.265f, 0.265f, 0.265f);
public static readonly Color Grey = new Color(0.6f, 0.6f, 0.6f);
private static TMP_FontAsset font;
private static Sprite box;
private static bool boxSearched;
private static Camera menuCam;
private static float menuCamSearchAt;
public static TMP_FontAsset Font
{
get
{
if ((Object)(object)font == (Object)null)
{
GameManager instance = GameManager.Instance;
if ((Object)(object)instance != (Object)null && (Object)(object)instance.winText != (Object)null)
{
font = ((TMP_Text)instance.winText).font;
}
if ((Object)(object)font == (Object)null)
{
TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
foreach (TMP_FontAsset val in array)
{
if (((Object)val).name.StartsWith("Anton"))
{
font = val;
break;
}
}
}
}
return font;
}
}
public static Sprite BoxSprite
{
get
{
if ((Object)(object)box == (Object)null && !boxSearched)
{
boxSearched = true;
Sprite[] array = Resources.FindObjectsOfTypeAll<Sprite>();
foreach (Sprite val in array)
{
if (((Object)val).name == "box")
{
box = val;
break;
}
}
}
return box;
}
}
public static int MenuLayer
{
get
{
int num = LayerMask.NameToLayer("MENU");
if (num < 0)
{
return 31;
}
return num;
}
}
public static void Attach(Canvas c)
{
//IL_00dd: 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_00aa: Invalid comparison between Unknown and I4
if ((Object)(object)c == (Object)null)
{
return;
}
if (((Object)(object)menuCam == (Object)null || !((Behaviour)menuCam).isActiveAndEnabled) && Time.unscaledTime >= menuCamSearchAt)
{
menuCamSearchAt = Time.unscaledTime + 1f;
menuCam = null;
Camera[] allCameras = Camera.allCameras;
foreach (Camera val in allCameras)
{
if (((Object)val).name == "Camera_Pause" && (val.cullingMask & (1 << MenuLayer)) != 0)
{
menuCam = val;
break;
}
}
}
if ((Object)(object)menuCam != (Object)null && ((Behaviour)menuCam).isActiveAndEnabled)
{
if ((int)c.renderMode != 1 || (Object)(object)c.worldCamera != (Object)(object)menuCam)
{
c.renderMode = (RenderMode)1;
c.worldCamera = menuCam;
c.planeDistance = 1f;
}
}
else if ((int)c.renderMode != 0)
{
c.renderMode = (RenderMode)0;
}
}
public static Canvas MakeCanvas(string name, int order)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject(name)
{
layer = MenuLayer
};
Object.DontDestroyOnLoad((Object)val);
Canvas val2 = val.AddComponent<Canvas>();
val2.renderMode = (RenderMode)0;
val2.sortingOrder = order;
Attach(val2);
CanvasScaler obj = val.AddComponent<CanvasScaler>();
obj.uiScaleMode = (ScaleMode)1;
obj.referenceResolution = new Vector2(1920f, 1080f);
obj.matchWidthOrHeight = 0.5f;
return val2;
}
public static RectTransform Rect(Transform parent, string name)
{
//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_002a: 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_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: 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_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_0076: Expected O, but got Unknown
GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) })
{
layer = ((Component)parent).gameObject.layer
};
val.transform.SetParent(parent, false);
RectTransform val2 = (RectTransform)val.transform;
Vector2 val3 = default(Vector2);
((Vector2)(ref val3))..ctor(0.5f, 0.5f);
val2.anchorMax = val3;
val2.anchorMin = val3;
val2.pivot = new Vector2(0.5f, 0.5f);
return val2;
}
public static Image Box(Transform parent, string name, Color color, Vector2 pos, Vector2 size, bool rounded = false)
{
//IL_0008: 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_0022: 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_0055: Unknown result type (might be due to invalid IL or missing references)
RectTransform obj = Rect(parent, name);
obj.anchoredPosition = pos;
obj.sizeDelta = size;
Image val = ((Component)obj).gameObject.AddComponent<Image>();
((Graphic)val).color = color;
((Graphic)val).raycastTarget = false;
if (rounded && (Object)(object)BoxSprite != (Object)null)
{
val.sprite = BoxSprite;
Vector4 border = BoxSprite.border;
if (((Vector4)(ref border)).sqrMagnitude > 0f)
{
val.type = (Type)1;
}
}
return val;
}
public static void Fill(RectTransform rt, float inset)
{
//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_0019: 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)
rt.anchorMin = Vector2.zero;
rt.anchorMax = Vector2.one;
rt.offsetMin = new Vector2(inset, inset);
rt.offsetMax = new Vector2(0f - inset, 0f - inset);
}
public static TextMeshProUGUI Text(Transform parent, string name, string text, float size, Color color, TextAlignmentOptions align)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
TextMeshProUGUI val = ((Component)Rect(parent, name)).gameObject.AddComponent<TextMeshProUGUI>();
if ((Object)(object)Font != (Object)null)
{
((TMP_Text)val).font = Font;
}
((TMP_Text)val).fontSize = size;
((Graphic)val).color = color;
((TMP_Text)val).alignment = align;
((TMP_Text)val).enableWordWrapping = false;
((TMP_Text)val).richText = true;
((Graphic)val).raycastTarget = false;
((TMP_Text)val).text = text;
return val;
}
public static Color PlayerColor(Controller c)
{
//IL_00bf: 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_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)c != (Object)null)
{
SpriteRenderer componentInChildren = ((Component)c).GetComponentInChildren<SpriteRenderer>();
SetColorWhenDamaged val = (((Object)(object)componentInChildren != (Object)null) ? ((Component)componentInChildren).GetComponent<SetColorWhenDamaged>() : null);
if ((Object)(object)val == (Object)null)
{
val = ((Component)c).GetComponentInChildren<SetColorWhenDamaged>(true);
}
if ((Object)(object)val != (Object)null && val.startColor.a > 0f)
{
Color startColor = val.startColor;
startColor.a = 1f;
return startColor;
}
ControllerHandler instance = ControllerHandler.Instance;
if ((Object)(object)instance != (Object)null && instance.colors != null && c.playerID >= 0 && c.playerID < instance.colors.Length && (Object)(object)instance.colors[c.playerID] != (Object)null)
{
return instance.colors[c.playerID].color;
}
}
return Color.white;
}
public static Color SlotColor(int id)
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: 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_0050: Unknown result type (might be due to invalid IL or missing references)
ControllerHandler instance = ControllerHandler.Instance;
if ((Object)(object)instance != (Object)null && instance.colors != null && id >= 0 && id < instance.colors.Length && (Object)(object)instance.colors[id] != (Object)null)
{
Color color = instance.colors[id].color;
color.a = 1f;
return color;
}
return Color.white;
}
public static string Hex(Color c)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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)
return "#" + ((int)(Mathf.Clamp01(c.r) * 255f)).ToString("X2") + ((int)(Mathf.Clamp01(c.g) * 255f)).ToString("X2") + ((int)(Mathf.Clamp01(c.b) * 255f)).ToString("X2");
}
public static string Colored(string text, Color c)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
return "<color=" + Hex(c) + ">" + text + "</color>";
}
public static Color WithAlpha(Color c, float a)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
c.a = a;
return c;
}
}
}
namespace Ultrawide
{
[BepInPlugin("stickfight.ultrawide", "Resolution Patch", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
public const string Guid = "stickfight.ultrawide";
public const string Name = "Resolution Patch";
public const string Version = "1.0.1";
internal static ConfigEntry<bool> Enabled;
internal static ManualLogSource Log;
private void Awake()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
Enabled = QolConfig.Enabled(((BaseUnityPlugin)this).Config, "Ultrawide", "On screens that aren't 16:9 (21:9, 32:9, 16:10, 4:3), fights fill the whole screen: the game's grey bars move out of the way and each map's background and weather reach the edges.");
QolConfig.DropOld(((BaseUnityPlugin)this).Config);
Resolutions.Patch(new Harmony("stickfight.ultrawide"));
GameObject val = new GameObject("Ultrawide");
Object.DontDestroyOnLoad((Object)val);
((Object)val).hideFlags = (HideFlags)61;
val.AddComponent<Filler>();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Resolution Patch 1.0.1 loaded.");
}
}
[DefaultExecutionOrder(10000)]
internal class Filler : MonoBehaviour
{
private class Grown
{
public Transform T;
public Vector3 Scale;
public Vector3 Set;
public float UnitWidth;
public float UnitHeight;
public float MaxScale;
}
private class Weather
{
public ParticleSystem Ps;
public Vector3 Box;
public int Axis;
public float Rate;
public float Width;
}
private class Panel
{
public RectTransform Rt;
public float Width;
}
private class Parked
{
public RectTransform Rt;
public float Side;
public Vector3 Base;
public Vector3 Set;
}
private const float ViewHeight = 20f;
private const float BarsHalfWidth = 18.6f;
private const float BarsHalfHeight = 10.3f;
private const float Wide = 1.7877778f;
private readonly List<Grown> grown = new List<Grown>();
private readonly List<Weather> weather = new List<Weather>();
private readonly HashSet<int> seen = new HashSet<int>();
private float nextScan;
private float appliedAspect = -1f;
private bool appliedOn;
private Transform bars;
private Transform fade;
private Vector3 barsScale;
private Vector3 fadeScale;
private Vector3 barsSet;
private Vector3 fadeSet;
private float barsK = 1f;
private float nextBarsLook;
private readonly List<Panel> panels = new List<Panel>();
private RectTransform menuCanvas;
private float nextPanels;
private bool panelsWide;
private float panelsWidth;
private readonly List<Parked> parked = new List<Parked>();
private Transform gameCanvas;
private float parkedShift;
private float barsKy = 1f;
private static void View(float aspect, out float w, out float h)
{
float num = Mathf.Max(aspect, 1.78f);
h = 20f * num / aspect;
w = h * aspect;
}
private static bool Off169(float aspect)
{
return Mathf.Abs(aspect - 1.7777778f) > 0.01f;
}
private void Update()
{
float num = ((Screen.height > 0) ? ((float)Screen.width / (float)Screen.height) : 1.7777778f);
bool flag = Plugin.Enabled.Value && Off169(num) && !GameManager.stillInMenu;
if (flag && Time.unscaledTime >= nextScan)
{
nextScan = Time.unscaledTime + 0.5f;
Scan();
}
Prune();
Panels(Plugin.Enabled.Value && num > 1.7877778f);
if (flag == appliedOn && Mathf.Approximately(num, appliedAspect))
{
return;
}
appliedOn = flag;
appliedAspect = num;
foreach (Grown item in grown)
{
Apply(item, flag, num);
}
foreach (Weather item2 in weather)
{
Apply(item2, flag, num);
}
ApplyBars(flag, num);
}
private void Scan()
{
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Invalid comparison between Unknown and I4
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: 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_0160: 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)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_029e: Unknown result type (might be due to invalid IL or missing references)
//IL_02a0: 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_02f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
float aspect = (float)Screen.width / (float)Screen.height;
if ((Object)(object)bars == (Object)null && Time.unscaledTime >= nextBarsLook)
{
nextBarsLook = Time.unscaledTime + 2f;
FindBars();
if ((Object)(object)bars != (Object)null)
{
ApplyBars(appliedOn, aspect);
}
}
if ((Object)(object)gameCanvas == (Object)null)
{
FindParked();
MoveParked(parkedShift);
}
SpriteRenderer[] array = Object.FindObjectsOfType<SpriteRenderer>();
foreach (SpriteRenderer val in array)
{
if ((Object)(object)val == (Object)null || !((Object)val).name.StartsWith("BG_") || !seen.Add(((Object)val).GetInstanceID()))
{
continue;
}
Transform val2 = ((Component)val).transform;
Transform parent = val2.parent;
while ((Object)(object)parent != (Object)null)
{
if (((Object)parent).name.StartsWith("BG_") && (Object)(object)((Component)parent).GetComponent<SpriteRenderer>() != (Object)null)
{
val2 = parent;
}
parent = parent.parent;
}
if (!((Object)(object)val2 != (Object)(object)((Component)val).transform) && !((Object)(object)((Component)val).GetComponentInChildren<Collider>(true) != (Object)null) && !((Object)(object)((Component)val).GetComponentInParent<Collider>() != (Object)null))
{
Bounds bounds = ((Renderer)val).bounds;
float z = ((Bounds)(ref bounds)).size.z;
bounds = ((Renderer)val).bounds;
float y = ((Bounds)(ref bounds)).size.y;
float num = Mathf.Abs(((Component)val).transform.localScale.x);
if (!(z < 20f) && !(y < 16f) && !(num < 0.0001f))
{
Grown grown = new Grown
{
T = ((Component)val).transform,
Scale = ((Component)val).transform.localScale,
UnitWidth = z / num,
UnitHeight = y / num,
MaxScale = num
};
this.grown.Add(grown);
Apply(grown, appliedOn, aspect);
}
}
}
ParticleSystem[] array2 = Object.FindObjectsOfType<ParticleSystem>();
foreach (ParticleSystem val3 in array2)
{
if ((Object)(object)val3 == (Object)null || !seen.Add(((Object)val3).GetInstanceID()))
{
continue;
}
ShapeModule shape = val3.shape;
if (!((ShapeModule)(ref shape)).enabled || (int)((ShapeModule)(ref shape)).shapeType != 5)
{
continue;
}
int axis = 0;
float num2 = 0f;
for (int j = 0; j < 3; j++)
{
Vector3 zero = Vector3.zero;
int num3 = j;
Vector3 box = ((ShapeModule)(ref shape)).box;
((Vector3)(ref zero))[num3] = ((Vector3)(ref box))[j];
float num4 = Mathf.Abs(((Component)val3).transform.TransformVector(zero).z);
if (num4 > num2)
{
num2 = num4;
axis = j;
}
}
if (!(num2 < 28f) && !((Object)(object)((Component)val3).GetComponentInParent<Controller>() != (Object)null))
{
Weather obj = new Weather
{
Ps = val3,
Box = ((ShapeModule)(ref shape)).box,
Axis = axis
};
EmissionModule emission = val3.emission;
obj.Rate = ((EmissionModule)(ref emission)).rateOverTimeMultiplier;
obj.Width = num2;
Weather weather = obj;
this.weather.Add(weather);
Apply(weather, appliedOn, aspect);
}
}
}
private void Panels(bool wide)
{
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Expected O, but got Unknown
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: 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_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
if (wide && Time.unscaledTime >= nextPanels)
{
nextPanels = Time.unscaledTime + 2f;
if ((Object)(object)menuCanvas == (Object)null)
{
panels.Clear();
GameObject val = GameObject.Find("GameManagement");
Transform val2 = (((Object)(object)val != (Object)null) ? val.transform.Find("Menu") : null);
Canvas val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<Canvas>() : null);
if ((Object)(object)val3 != (Object)null)
{
menuCanvas = (RectTransform)((Component)val3).transform;
panelsWidth = -1f;
Image[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Image>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
RectTransform rectTransform = ((Graphic)componentsInChildren[i]).rectTransform;
if (rectTransform.anchorMin == rectTransform.anchorMax && Mathf.Abs(rectTransform.sizeDelta.x - 1920f) < 2f && rectTransform.sizeDelta.y >= 1000f)
{
panels.Add(new Panel
{
Rt = rectTransform,
Width = rectTransform.sizeDelta.x
});
}
}
}
}
}
float num;
if (!wide || !((Object)(object)menuCanvas != (Object)null))
{
num = 0f;
}
else
{
Rect rect = menuCanvas.rect;
num = Mathf.Max(1920f, ((Rect)(ref rect)).width + 40f);
}
float num2 = num;
if (wide == panelsWide && Mathf.Approximately(num2, panelsWidth))
{
return;
}
panelsWide = wide;
panelsWidth = num2;
foreach (Panel panel in panels)
{
if ((Object)(object)panel.Rt != (Object)null)
{
panel.Rt.sizeDelta = new Vector2(wide ? num2 : panel.Width, panel.Rt.sizeDelta.y);
}
}
}
private void FindParked()
{
//IL_016c: 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_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
parked.Clear();
GameObject val = GameObject.Find("GameManagement");
gameCanvas = (((Object)(object)val != (Object)null) ? val.transform.Find("GameCanvas") : null);
if ((Object)(object)gameCanvas == (Object)null)
{
return;
}
Vector3[] array = (Vector3[])(object)new Vector3[4];
RectTransform[] componentsInChildren = ((Component)gameCanvas).GetComponentsInChildren<RectTransform>(true);
foreach (RectTransform val2 in componentsInChildren)
{
if ((Object)(object)val2 == (Object)(object)gameCanvas)
{
continue;
}
val2.GetWorldCorners(array);
float num = Mathf.Min(array[0].y, array[2].y);
float num2 = Mathf.Max(array[0].y, array[2].y);
float num3 = ((num2 < -10f) ? (-1f) : ((num > 10f) ? 1f : 0f));
if (num3 == 0f || num2 - num < 0.01f)
{
continue;
}
bool flag = false;
foreach (Parked item in parked)
{
if (((Transform)val2).IsChildOf((Transform)(object)item.Rt))
{
flag = true;
break;
}
}
if (!flag)
{
parked.Add(new Parked
{
Rt = val2,
Side = num3,
Base = ((Transform)val2).localPosition,
Set = ((Transform)val2).localPosition
});
}
}
}
private void MoveParked(float shift)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: 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)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: 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_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
parkedShift = shift;
foreach (Parked item in parked)
{
if (!((Object)(object)item.Rt == (Object)null))
{
Transform parent = ((Transform)item.Rt).parent;
Vector3 val = Vector3.up * shift * item.Side;
Vector3 val2 = (((Object)(object)parent != (Object)null) ? parent.InverseTransformVector(val) : val);
item.Set = item.Base + val2;
((Transform)item.Rt).localPosition = item.Set;
}
}
}
private void FindBars()
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.Find("RigidCam");
Transform val2 = (((Object)(object)val != (Object)null) ? val.transform.Find("LoadingCanvas") : null);
if (!((Object)(object)val2 == (Object)null))
{
bars = val2.Find("Bars");
fade = val2.Find("Image");
if ((Object)(object)bars != (Object)null)
{
barsScale = bars.localScale;
}
if ((Object)(object)fade != (Object)null)
{
fadeScale = fade.localScale;
}
}
}
private void ApplyBars(bool on, float aspect)
{
View(aspect, out var w, out var h);
barsK = (on ? Mathf.Max(1f, (w * 0.5f + 1.5f) / 18.6f) : 1f);
barsKy = (on ? Mathf.Max(1f, (h * 0.5f + 1f) / 10.3f) : 1f);
SetBars();
if ((Object)(object)gameCanvas == (Object)null && on)
{
FindParked();
}
MoveParked(on ? Mathf.Max(0f, h * 0.5f - 10f) : 0f);
}
private void SetBars()
{
//IL_003e: 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_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)bars != (Object)null)
{
barsSet = new Vector3(barsScale.x * barsK, barsScale.y * barsKy, barsScale.z);
bars.localScale = barsSet;
}
if ((Object)(object)fade != (Object)null)
{
fadeSet = new Vector3(fadeScale.x * barsK, fadeScale.y * barsKy, fadeScale.z);
fade.localScale = fadeSet;
}
}
private static float Factor(Grown g, float aspect)
{
View(aspect, out var w, out var h);
float num = g.UnitWidth * g.MaxScale;
float num2 = g.UnitHeight * g.MaxScale;
return Mathf.Max(1f, Mathf.Max((w + 2f) / num, (h + 2f) / num2));
}
private static void Apply(Grown g, bool on, float aspect)
{
//IL_0047: 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_0058: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)g.T == (Object)null))
{
float num = (on ? Factor(g, aspect) : 1f);
g.Set = new Vector3(g.Scale.x * num, g.Scale.y * num, g.Scale.z);
g.T.localScale = g.Set;
}
}
private static void Apply(Weather w, bool on, float aspect)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: 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_0084: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)w.Ps == (Object)null))
{
View(aspect, out var w2, out var _);
float num = (on ? Mathf.Max(1f, (w2 + 4f) / w.Width) : 1f);
ShapeModule shape = w.Ps.shape;
Vector3 box = w.Box;
int axis = w.Axis;
((Vector3)(ref box))[axis] = ((Vector3)(ref box))[axis] * num;
((ShapeModule)(ref shape)).box = box;
EmissionModule emission = w.Ps.emission;
((EmissionModule)(ref emission)).rateOverTimeMultiplier = w.Rate * num;
}
}
private void LateUpdate()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: 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)
//IL_013a: 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_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: 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_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: 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_00dc: 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)
if (!appliedOn)
{
return;
}
bool num = (Object)(object)bars != (Object)null && bars.localScale != barsSet;
bool flag = (Object)(object)fade != (Object)null && fade.localScale != fadeSet;
if (num)
{
barsScale = bars.localScale;
}
if (flag)
{
fadeScale = fade.localScale;
}
if (num || flag)
{
SetBars();
}
if (parkedShift > 0f)
{
bool flag2 = false;
foreach (Parked item in parked)
{
if ((Object)(object)item.Rt != (Object)null && ((Transform)item.Rt).localPosition != item.Set)
{
item.Base = ((Transform)item.Rt).localPosition;
flag2 = true;
}
}
if (flag2)
{
MoveParked(parkedShift);
}
}
for (int i = 0; i < this.grown.Count; i++)
{
Grown grown = this.grown[i];
if (!((Object)(object)grown.T == (Object)null))
{
Vector3 localScale = grown.T.localScale;
if (!(localScale == grown.Set))
{
grown.Scale = localScale;
grown.MaxScale = Mathf.Max(grown.MaxScale, Mathf.Abs(localScale.x));
Apply(grown, on: true, appliedAspect);
}
}
}
}
private void Prune()
{
grown.RemoveAll((Grown g) => (Object)(object)g.T == (Object)null);
weather.RemoveAll((Weather w) => (Object)(object)w.Ps == (Object)null);
if (seen.Count > 4000)
{
seen.Clear();
}
}
}
internal static class Resolutions
{
private static readonly MethodInfo Getter = AccessTools.PropertyGetter(typeof(Screen), "resolutions");
private static readonly MethodInfo Sort = AccessTools.Method(typeof(List<Resolution>), "Sort", new Type[1] { typeof(Comparison<Resolution>) }, (Type[])null);
internal static void Patch(Harmony h)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
HarmonyMethod val = new HarmonyMethod(typeof(Resolutions), "Swap", (Type[])null);
h.Patch((MethodBase)AccessTools.Method(typeof(ResolutionSetting), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null);
h.Patch((MethodBase)AccessTools.Method(typeof(OptionsHolder), "SetNonStatic", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null);
}
private static IEnumerable<CodeInstruction> Swap(IEnumerable<CodeInstruction> code)
{
foreach (CodeInstruction item in code)
{
if (CodeInstructionExtensions.Calls(item, Getter))
{
item.operand = AccessTools.Method(typeof(Resolutions), "List", (Type[])null, (Type[])null);
}
else if (CodeInstructionExtensions.Calls(item, Sort))
{
item.opcode = OpCodes.Call;
item.operand = AccessTools.Method(typeof(Resolutions), "SortBySize", (Type[])null, (Type[])null);
}
yield return item;
}
}
private static Resolution[] List()
{
return (from r in Screen.resolutions
group r by ((Resolution)(ref r)).width * 100000 + ((Resolution)(ref r)).height into g
select g.OrderByDescending((Resolution r) => ((Resolution)(ref r)).refreshRate).First() into r
orderby ((Resolution)(ref r)).width, ((Resolution)(ref r)).height
select r).ToArray();
}
private static void SortBySize(List<Resolution> list, Comparison<Resolution> ignored)
{
List<Resolution> collection = (from r in list
orderby ((Resolution)(ref r)).width, ((Resolution)(ref r)).height
select r).ToList();
list.Clear();
list.AddRange(collection);
}
}
}