using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
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("OffscreenArrows")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+da3bfa97421b477674e4770cfb711a2db3559688")]
[assembly: AssemblyProduct("OffscreenArrows")]
[assembly: AssemblyTitle("OffscreenArrows")]
[assembly: AssemblyVersion("1.0.2.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 OffscreenArrows
{
[BepInPlugin("stickfight.offscreenarrows", "Offscreen Arrows", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
public const string Guid = "stickfight.offscreenarrows";
public const string Name = "Offscreen Arrows";
public const string Version = "1.0.2";
internal static ConfigEntry<bool> Enabled;
private void Awake()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
Enabled = QolConfig.Enabled(((BaseUnityPlugin)this).Config, "Arrows", "A pin in a player's colour at the screen edge points at anyone out of view.");
QolConfig.DropOld(((BaseUnityPlugin)this).Config);
GameObject val = new GameObject("OffscreenArrows");
Object.DontDestroyOnLoad((Object)val);
((Object)val).hideFlags = (HideFlags)61;
val.AddComponent<Arrows>();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Offscreen Arrows 1.0.2 loaded.");
}
}
internal class Arrows : MonoBehaviour
{
private const float Edge = 72f;
private const float NearSize = 49f;
private const float FarSize = 31f;
private const float FarDistance = 25f;
private Canvas canvas;
private RectTransform root;
private Sprite arrowSprite;
private readonly Dictionary<Controller, Image> arrows = new Dictionary<Controller, Image>();
private readonly List<Controller> gone = new List<Controller>();
private readonly HashSet<Controller> seen = new HashSet<Controller>();
private RectTransform barArea;
private CanvasGroup barGroup;
private float nextBarLook;
private readonly Vector3[] corners = (Vector3[])(object)new Vector3[4];
private static Func<Controller, Sprite, Sprite> patternedSprite;
private static Action<Sprite> prepareSprite;
private static bool paintLooked;
private void LateUpdate()
{
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: 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_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: 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_01b0: 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_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: 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_0218: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Unknown result type (might be due to invalid IL or missing references)
//IL_0290: Unknown result type (might be due to invalid IL or missing references)
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0377: Unknown result type (might be due to invalid IL or missing references)
//IL_0389: Unknown result type (might be due to invalid IL or missing references)
//IL_039d: Unknown result type (might be due to invalid IL or missing references)
//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
//IL_030d: Unknown result type (might be due to invalid IL or missing references)
//IL_0326: Unknown result type (might be due to invalid IL or missing references)
//IL_033f: Unknown result type (might be due to invalid IL or missing references)
Camera main = Camera.main;
ControllerHandler instance = ControllerHandler.Instance;
bool num = Plugin.Enabled.Value && (Object)(object)main != (Object)null && (Object)(object)instance != (Object)null && !PauseManager.isPaused && (GameManager.inFight || GameManager.stillInMenu) && !Compat.CardScreen;
if ((Object)(object)canvas == (Object)null)
{
Build();
}
Ui.Attach(canvas);
Rect rect = root.rect;
Vector2 size = ((Rect)(ref rect)).size;
seen.Clear();
if (num)
{
List<Controller> players = instance.players;
Vector2 up = default(Vector2);
for (int i = 0; i < players.Count; i++)
{
Controller val = players[i];
if ((Object)(object)val == (Object)null || !((Component)val).gameObject.activeInHierarchy)
{
continue;
}
CharacterInformation component = ((Component)val).GetComponent<CharacterInformation>();
if ((Object)(object)component == (Object)null || component.isDead)
{
continue;
}
Torso componentInChildren = ((Component)val).GetComponentInChildren<Torso>();
if ((Object)(object)componentInChildren == (Object)null)
{
continue;
}
Vector3 val2 = main.WorldToViewportPoint(((Component)componentInChildren).transform.position);
if (val2.x < 0f || val2.x > 1f || val2.y < 0f || val2.y > 1f)
{
seen.Add(val);
Image val3 = Get(val);
Sprite val4 = PatternedSprite(val);
val3.sprite = (((Object)(object)val4 != (Object)null) ? val4 : arrowSprite);
((Graphic)val3).color = (((Object)(object)val4 != (Object)null) ? Color.white : Ui.PlayerColor(val));
((Vector2)(ref up))..ctor((val2.x - 0.5f) * size.x, (val2.y - 0.5f) * size.y);
if (((Vector2)(ref up)).sqrMagnitude < 1f)
{
up = Vector2.up;
}
float num2 = size.x * 0.5f - 72f;
float num3 = size.y * 0.5f - 72f;
float num4 = Mathf.Min(num2 / Mathf.Max(Mathf.Abs(up.x), 0.001f), num3 / Mathf.Max(Mathf.Abs(up.y), 0.001f));
Vector2 val5 = up * num4;
float num5 = Mathf.Max(Mathf.Max(0f - val2.x, val2.x - 1f) * main.orthographicSize * 2f * main.aspect, Mathf.Max(0f - val2.y, val2.y - 1f) * main.orthographicSize * 2f);
float num6 = Mathf.Lerp(49f, 31f, Mathf.Clamp01(num5 / 25f));
num6 *= 1f + 0.06f * Mathf.Sin(Time.unscaledTime * 6f);
if (val5.y > 0f && BarArea(out var r) && val5.x + num6 * 0.8f > ((Rect)(ref r)).xMin && val5.x - num6 * 0.8f < ((Rect)(ref r)).xMax && val5.y + num6 * 0.8f > ((Rect)(ref r)).yMin)
{
val5.y = ((Rect)(ref r)).yMin - num6 * 0.8f;
}
RectTransform rectTransform = ((Graphic)val3).rectTransform;
rectTransform.anchoredPosition = val5;
rectTransform.sizeDelta = new Vector2(num6 * 1.5f, num6);
((Transform)rectTransform).localRotation = Quaternion.Euler(0f, 0f, Mathf.Atan2(up.y, up.x) * 57.29578f);
if (!((Component)val3).gameObject.activeSelf)
{
((Component)val3).gameObject.SetActive(true);
}
}
}
}
gone.Clear();
foreach (KeyValuePair<Controller, Image> arrow in arrows)
{
if ((Object)(object)arrow.Key == (Object)null)
{
gone.Add(arrow.Key);
if ((Object)(object)arrow.Value != (Object)null)
{
Object.Destroy((Object)(object)((Component)arrow.Value).gameObject);
}
}
else if (!seen.Contains(arrow.Key) && ((Component)arrow.Value).gameObject.activeSelf)
{
((Component)arrow.Value).gameObject.SetActive(false);
}
}
foreach (Controller item in gone)
{
arrows.Remove(item);
}
}
private bool BarArea(out Rect r)
{
//IL_0001: 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_0076: Expected O, but got Unknown
//IL_0114: 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_0135: 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_0149: 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_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: 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)
r = default(Rect);
if ((Object)(object)barArea == (Object)null && Time.unscaledTime >= nextBarLook)
{
nextBarLook = Time.unscaledTime + 2f;
GameObject val = GameObject.Find("MatchTargetBar");
Transform val2 = (((Object)(object)val != (Object)null) ? val.transform.Find("Bar/Area") : null);
if ((Object)(object)val2 != (Object)null)
{
barArea = (RectTransform)val2;
barGroup = ((Component)val2.parent).GetComponent<CanvasGroup>();
}
}
if ((Object)(object)barArea == (Object)null || !((Component)barArea).gameObject.activeInHierarchy || ((Object)(object)barGroup != (Object)null && barGroup.alpha < 0.05f))
{
return false;
}
Canvas componentInParent = ((Component)barArea).GetComponentInParent<Canvas>();
Camera val3 = (((Object)(object)componentInParent != (Object)null) ? componentInParent.worldCamera : null);
Camera worldCamera = canvas.worldCamera;
barArea.GetWorldCorners(corners);
Vector2 val4 = default(Vector2);
RectTransformUtility.ScreenPointToLocalPointInRectangle(root, RectTransformUtility.WorldToScreenPoint(val3, corners[0]), worldCamera, ref val4);
Vector2 val5 = default(Vector2);
RectTransformUtility.ScreenPointToLocalPointInRectangle(root, RectTransformUtility.WorldToScreenPoint(val3, corners[2]), worldCamera, ref val5);
r = Rect.MinMaxRect(Mathf.Min(val4.x, val5.x), Mathf.Min(val4.y, val5.y), Mathf.Max(val4.x, val5.x), Mathf.Max(val4.y, val5.y));
return ((Rect)(ref r)).width > 1f;
}
private Image Get(Controller c)
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
if (arrows.TryGetValue(c, out var value) && (Object)(object)value != (Object)null)
{
return value;
}
RectTransform obj = Ui.Rect((Transform)(object)root, "Arrow");
value = ((Component)obj).gameObject.AddComponent<Image>();
value.sprite = arrowSprite;
((Graphic)value).raycastTarget = false;
obj.pivot = new Vector2(0.36f, 0.5f);
arrows[c] = value;
return value;
}
private void Build()
{
canvas = Ui.MakeCanvas("OffscreenArrowsCanvas", 5);
root = Ui.Rect(((Component)canvas).transform, "Root");
Ui.Fill(root, 0f);
if ((Object)(object)arrowSprite == (Object)null)
{
arrowSprite = MakeArrow(192);
if (FindPaintCan())
{
prepareSprite(arrowSprite);
}
}
}
private static bool FindPaintCan()
{
if (!paintLooked)
{
paintLooked = true;
if (Chainloader.PluginInfos.TryGetValue("stickfight.paintcan", out var value) && (Object)(object)value.Instance != (Object)null)
{
Type type = ((object)value.Instance).GetType().Assembly.GetType("PaintCan.PaintCanApi");
MethodInfo methodInfo = type?.GetMethod("PatternedSprite");
MethodInfo methodInfo2 = type?.GetMethod("PrepareSprite");
if ((object)methodInfo != null && (object)methodInfo2 != null)
{
patternedSprite = (Func<Controller, Sprite, Sprite>)Delegate.CreateDelegate(typeof(Func<Controller, Sprite, Sprite>), methodInfo);
prepareSprite = (Action<Sprite>)Delegate.CreateDelegate(typeof(Action<Sprite>), methodInfo2);
}
}
}
return patternedSprite != null;
}
private Sprite PatternedSprite(Controller c)
{
if (!FindPaintCan())
{
return null;
}
return patternedSprite(c, arrowSprite);
}
private static Sprite MakeArrow(int h)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: 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_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: 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_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
int num = h * 3 / 2;
Texture2D val = new Texture2D(num, h, (TextureFormat)5, false);
((Texture)val).wrapMode = (TextureWrapMode)1;
((Texture)val).filterMode = (FilterMode)1;
float num2 = (float)h * 0.36f;
float num3 = (float)h * 0.065f;
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor((float)num * 0.36f, (float)h * 0.5f);
Vector2 val3 = default(Vector2);
((Vector2)(ref val3))..ctor((float)num * 0.96f, (float)h * 0.5f);
Vector2 val4 = default(Vector2);
((Vector2)(ref val4))..ctor(val2.x + num2 * 0.3f, (float)h * 0.5f + num2 * 0.92f);
Vector2 val5 = default(Vector2);
((Vector2)(ref val5))..ctor(val2.x + num2 * 0.3f, (float)h * 0.5f - num2 * 0.92f);
Color32[] array = (Color32[])(object)new Color32[num * h];
Vector2 val6 = default(Vector2);
for (int i = 0; i < h; i++)
{
for (int j = 0; j < num; j++)
{
((Vector2)(ref val6))..ctor((float)j + 0.5f, (float)i + 0.5f);
float num4 = Mathf.Min(Side(val6, val3, val4), Mathf.Min(Side(val6, val4, val5), Side(val6, val5, val3)));
float num5 = num2 - Vector2.Distance(val6, val2);
float num6 = Mathf.Max(num4, num5);
float num7 = Mathf.Clamp01(num6 + 0.5f);
float num8 = Mathf.Clamp01(num6 - num3 + 0.5f);
byte b = (byte)(Mathf.Lerp(0.12f, 1f, num8) * 255f);
array[i * num + j] = new Color32(b, b, b, (byte)(num7 * 255f));
}
}
val.SetPixels32(array);
val.Apply();
return Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)h), new Vector2(0.36f, 0.5f), 100f);
}
private static float Side(Vector2 p, Vector2 a, Vector2 b)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//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)
//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_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: 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_0023: 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_0025: 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)
Vector2 val = b - a;
Vector2 val2 = new Vector2(0f - val.y, val.x);
Vector2 normalized = ((Vector2)(ref val2)).normalized;
return Vector2.Dot(p - a, normalized);
}
}
}