using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using AIGraph;
using Agents;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Enemies;
using Il2CppInterop.Runtime;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using Player;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("PersistentBioScanner")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0e290719c0f14be491b75e18febe0a55e72ddb2a")]
[assembly: AssemblyProduct("PersistentBioScanner")]
[assembly: AssemblyTitle("PersistentBioScanner")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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;
}
}
}
namespace PersistentBioScanner
{
public class BioScanner : MonoBehaviour
{
public enum AnchorPointX
{
Left = -1,
Right = 1
}
public enum AnchorPointY
{
Top = 1,
Bottom = -1
}
public enum PreDefinedPositions
{
BesideTheMinimap,
OnTopTheMinimap,
BetweenTheMinimapAndResourceInfo,
AboveTheConsole,
OnTheBottomRightCorner_WhenMinimapIsNotThere,
Custom
}
private List<(Image image, CanvasGroup cg)> enemies = new List<(Image, CanvasGroup)>();
private Image centerPlayer;
private CanvasGroup masterCanvasGroup;
private PlayerAgent player;
private List<EnemyAgent> nearbyEnemies = new List<EnemyAgent>();
private const int maxDetectableEnemies = 50;
private const int scannerUIRadius = 150;
private const float scannerRangeMultiplier = 3f;
private const float entitiesUIDiameter = 15f;
private const float perfect1to1Distance = 10f;
private const float scannerMaxDistance_InMeters = 30f;
private const float scanFrequency = 2f;
private float scanFrequencyTimer = 0f;
private static readonly Vector2 canvasResolution = new Vector2(1920f, 1080f);
private const int nodeSearchDistance = 2;
private Color playerColor = Color.cyan * 0.95f;
private Color enemySleepingColor = Color.white * 0.9f;
private Color enemyAwakeColor = Color.red;
private Color scannerBodyColor = new Color(0f, 0.1f, 0f, 0.6f);
private Color scannerBorderColor = new Color(0.8f, 0.8f, 0.8f, 1f);
private Color fovLineColor = Color.gray;
private const float minEntitiesFadeOutOpacity = 0.1f;
private const float enemiesFadeSpeedMultiplier = 1.5f;
private const float playerFadeSpeedMultiplier = 2f;
private const float borderThickness = 3f;
private const float fovLineThickness = 1.5f;
private const float fovAngle = 45f;
private const int entitiesTextureSize = 32;
private const int fovLineEndOffsetMultiplier = 10;
private const int fovlineStartOffset = 15;
public static readonly Dictionary<PreDefinedPositions, Vector2> predefinedPositions = new Dictionary<PreDefinedPositions, Vector2>
{
{
PreDefinedPositions.BesideTheMinimap,
new Vector2(340f, 25f)
},
{
PreDefinedPositions.OnTopTheMinimap,
new Vector2(25f, 390f)
},
{
PreDefinedPositions.BetweenTheMinimapAndResourceInfo,
new Vector2(25f, 450f)
},
{
PreDefinedPositions.AboveTheConsole,
new Vector2(canvasResolution.x - 300f - 20f, 70f)
},
{
PreDefinedPositions.OnTheBottomRightCorner_WhenMinimapIsNotThere,
new Vector2(10f, 10f)
}
};
private Vector2 scannerUIPosition = Vector2.zero;
private AnchorPointX anchorPointX = AnchorPointX.Right;
private AnchorPointY anchorPointY = AnchorPointY.Bottom;
public BioScanner(IntPtr ptr)
: base(ptr)
{
}//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_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_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
private void Start()
{
//IL_0091: 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_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.position.Value != PreDefinedPositions.Custom)
{
if (!predefinedPositions.TryGetValue(Plugin.position.Value, out scannerUIPosition))
{
scannerUIPosition = new Vector2(Plugin.uiOffsetX.Value, Plugin.uiOffsetY.Value);
anchorPointX = Plugin.uiAnchorX.Value;
anchorPointY = Plugin.uiAnchorY.Value;
}
}
else
{
scannerUIPosition = new Vector2(Plugin.uiOffsetX.Value, Plugin.uiOffsetY.Value);
anchorPointX = Plugin.uiAnchorX.Value;
anchorPointY = Plugin.uiAnchorY.Value;
}
CreateUI();
}
private void CreateFOVLine(Transform t, string name, Sprite sprite, float angle)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
Image component = new GameObject(name, (Type[])(object)new Type[1] { Il2CppType.Of<Image>() }).GetComponent<Image>();
((Component)component).transform.SetParent(t, false);
component.sprite = sprite;
((Graphic)component).color = fovLineColor;
((Graphic)component).rectTransform.sizeDelta = new Vector2(1.5f, 120f);
((Graphic)component).rectTransform.pivot = new Vector2(0.5f, 0f);
((Graphic)component).rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
((Graphic)component).rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
Vector3 val = Quaternion.Euler(0f, 0f, angle) * Vector3.up;
((Graphic)component).rectTransform.anchoredPosition = Vector2.op_Implicit(val * 15f);
((Transform)((Graphic)component).rectTransform).localRotation = Quaternion.Euler(0f, 0f, angle);
}
private void CreateUI()
{
//IL_001c: 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_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: 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_0121: 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_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Expected O, but got Unknown
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: 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_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
//IL_02eb: 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_0390: Unknown result type (might be due to invalid IL or missing references)
//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
Sprite sprite = Utility.CreateSprite_Circle(32);
Sprite sprite2 = Utility.CreateSprite_Triangle(32);
Sprite sprite3 = Utility.CreateSprite_ScannerBGwithBorder_Circle(150, 3f, scannerBodyColor, scannerBorderColor);
Canvas component = new GameObject("PersistentBioScannerCanvas", (Type[])(object)new Type[1] { Il2CppType.Of<Canvas>() }).GetComponent<Canvas>();
Object.DontDestroyOnLoad((Object)(object)((Component)component).gameObject);
component.renderMode = (RenderMode)0;
component.sortingOrder = 50;
masterCanvasGroup = ((Component)component).gameObject.AddComponent<CanvasGroup>();
masterCanvasGroup.blocksRaycasts = false;
masterCanvasGroup.interactable = false;
masterCanvasGroup.alpha = 0f;
CanvasScaler val = ((Component)component).gameObject.AddComponent<CanvasScaler>();
val.uiScaleMode = (ScaleMode)1;
val.referenceResolution = canvasResolution;
Image component2 = new GameObject("BioScannerBG", (Type[])(object)new Type[1] { Il2CppType.Of<Image>() }).GetComponent<Image>();
((Component)component2).transform.SetParent(((Component)component).transform, false);
component2.sprite = sprite3;
((Graphic)component2).color = Color.white;
((Graphic)component2).rectTransform.sizeDelta = new Vector2(300f, 300f);
Vector2 val2 = Utility.CalculateAnchorPoint(anchorPointX, anchorPointY);
((Graphic)component2).rectTransform.anchorMin = val2;
((Graphic)component2).rectTransform.anchorMax = val2;
((Graphic)component2).rectTransform.pivot = val2;
((Graphic)component2).rectTransform.anchoredPosition = new Vector2(scannerUIPosition.x * (float)(0 - anchorPointX), scannerUIPosition.y * (float)(0 - anchorPointY));
Texture2D val3 = new Texture2D(1, 1);
val3.SetPixel(0, 0, Color.white);
val3.Apply();
Sprite sprite4 = Sprite.Create(val3, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0f));
CreateFOVLine(((Component)component2).transform, "FOV Line Left", sprite4, -45f);
CreateFOVLine(((Component)component2).transform, "FOV Line Right", sprite4, 45f);
for (int i = 0; i < 50; i++)
{
Image component3 = new GameObject($"Detected Enemy #{i}", (Type[])(object)new Type[1] { Il2CppType.Of<Image>() }).GetComponent<Image>();
((Component)component3).transform.SetParent(((Component)component2).transform, false);
((Graphic)component3).color = enemySleepingColor;
component3.sprite = sprite;
((Graphic)component3).rectTransform.sizeDelta = new Vector2(15f, 15f);
((Graphic)component3).rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
((Graphic)component3).rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
((Graphic)component3).rectTransform.pivot = new Vector2(0.5f, 0.5f);
CanvasGroup val4 = ((Component)component3).gameObject.AddComponent<CanvasGroup>();
val4.interactable = false;
val4.blocksRaycasts = false;
val4.alpha = 0f;
((Graphic)component3).canvasRenderer.SetAlpha(0f);
enemies.Add((component3, val4));
}
centerPlayer = new GameObject("CenterPlayer", (Type[])(object)new Type[1] { Il2CppType.Of<Image>() }).GetComponent<Image>();
((Component)centerPlayer).transform.SetParent(((Component)component2).transform, false);
centerPlayer.sprite = sprite2;
((Graphic)centerPlayer).color = playerColor;
((Graphic)centerPlayer).rectTransform.sizeDelta = new Vector2(15f, 15f);
}
private int ShouldShow()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Invalid comparison between Unknown and I4
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Invalid comparison between Unknown and I4
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Invalid comparison between Unknown and I4
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Invalid comparison between Unknown and I4
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Invalid comparison between Unknown and I4
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Invalid comparison between Unknown and I4
eGameStateName currentStateName = GameStateManager.CurrentStateName;
eFocusState currentState = FocusStateManager.CurrentState;
if ((int)currentStateName != 10)
{
return 0;
}
if ((int)currentState == 2)
{
return 0;
}
if ((int)currentState == 16)
{
return 0;
}
if ((int)currentState == 13)
{
return 0;
}
if ((int)currentState == 5)
{
return 0;
}
if ((int)currentState == 8)
{
return 0;
}
return 1;
}
private void Update()
{
masterCanvasGroup.alpha = ShouldShow();
if ((Object)(object)player == (Object)null)
{
player = PlayerManager.GetLocalPlayerAgent();
}
if ((Object)(object)player == (Object)null || ((Agent)player).CourseNode == null)
{
HideEnemies();
return;
}
if (scanFrequencyTimer > 0f)
{
scanFrequencyTimer -= Time.deltaTime;
}
else
{
nearbyEnemies.Clear();
AIG_CourseNode.GetEnemiesInNodes(((Agent)player).CourseNode, 2, nearbyEnemies);
scanFrequencyTimer = 2f;
}
RenderNearbyEnemies();
if ((Object)(object)centerPlayer != (Object)null)
{
float num = Mathf.PingPong(Time.time * 2f, 1f);
float alpha = Mathf.Lerp(1f, 0.1f, num);
((Graphic)centerPlayer).canvasRenderer.SetAlpha(alpha);
}
}
private void RenderNearbyEnemies()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: 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_0092: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: 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_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Invalid comparison between Unknown and I4
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = ((Agent)player).Position;
Vector3 forward = player.FPSCamera.Forward;
position.y = 0f;
forward.y = 0f;
((Vector3)(ref forward)).Normalize();
int num = 0;
Enumerator<EnemyAgent> enumerator = nearbyEnemies.GetEnumerator();
while (enumerator.MoveNext())
{
EnemyAgent current = enumerator.Current;
if (!((Object)(object)current == (Object)null) && ((Agent)current).Alive)
{
if (num >= 50)
{
break;
}
Vector3 position2 = current.Position;
position2.y = 0f;
Vector3 val = position2 - position;
float magnitude = ((Vector3)(ref val)).magnitude;
if (!(magnitude > 30f))
{
float num2 = Vector3.SignedAngle(forward, val, Vector3.up);
float num3 = num2 * ((float)Math.PI / 180f);
float num4 = 142.5f;
float num5 = num4 / 30f;
float num6 = Mathf.Sin(num3) * magnitude * num5;
float num7 = Mathf.Cos(num3) * magnitude * num5;
Image item = enemies[num].image;
enemies[num].cg.alpha = 1f;
((Graphic)item).rectTransform.anchoredPosition = new Vector2(num6, num7);
Color color = (((int)current.Locomotion.CurrentStateEnum != 14) ? enemyAwakeColor : enemySleepingColor);
((Graphic)item).canvasRenderer.SetColor(color);
float num8 = Mathf.PingPong(Time.time * 1.5f, 1f);
float alpha = Mathf.Lerp(1f, 0.1f, num8);
((Graphic)item).canvasRenderer.SetAlpha(alpha);
num++;
}
}
}
for (int i = num; i < 50; i++)
{
if (enemies[i].cg.alpha == 1f)
{
enemies[i].cg.alpha = 0f;
((Graphic)enemies[i].image).canvasRenderer.SetAlpha(0f);
}
}
}
private void HideEnemies()
{
foreach (var enemy in enemies)
{
enemy.cg.alpha = 0f;
((Graphic)enemy.image).canvasRenderer.SetAlpha(0f);
}
}
}
[BepInPlugin("INF.PersistentBioScanner", "PersistentBioScanner", "0.9.1")]
public class Plugin : BasePlugin
{
public static ManualLogSource L;
public static ConfigEntry<BioScanner.PreDefinedPositions> position { get; set; }
public static ConfigEntry<BioScanner.AnchorPointX> uiAnchorX { get; set; }
public static ConfigEntry<BioScanner.AnchorPointY> uiAnchorY { get; set; }
public static ConfigEntry<float> uiOffsetX { get; set; }
public static ConfigEntry<float> uiOffsetY { get; set; }
public override void Load()
{
position = ((BasePlugin)this).Config.Bind<BioScanner.PreDefinedPositions>("Positioning", "Pre-defined positions", BioScanner.PreDefinedPositions.BetweenTheMinimapAndResourceInfo, "Pre-Defined Positions. ( NOTE: When used with the Minimap mod by HazardousMonkey and for the options based on the minimap position, refer to the readme )");
uiAnchorX = ((BasePlugin)this).Config.Bind<BioScanner.AnchorPointX>("Positioning", "Anchor X", BioScanner.AnchorPointX.Right, "NOTE: Ignored if not using Custom Pre-Defined position");
uiAnchorY = ((BasePlugin)this).Config.Bind<BioScanner.AnchorPointY>("Positioning", "Anchor Y", BioScanner.AnchorPointY.Bottom, "NOTE: Ignored if not using Custom Pre-Defined position");
uiOffsetX = ((BasePlugin)this).Config.Bind<float>("Positioning", "Offset X", 10f, "NOTE: Ignored if not using Custom Pre-Defined position");
uiOffsetY = ((BasePlugin)this).Config.Bind<float>("Positioning", "Offset Y", 10f, "NOTE: Ignored if not using Custom Pre-Defined position");
L = ((BasePlugin)this).Log;
((BasePlugin)this).AddComponent<BioScanner>();
((BasePlugin)this).Log.LogInfo((object)"PersistentBioScanner is loaded!");
}
}
public static class Utility
{
public static Vector2 CalculateAnchorPoint(BioScanner.AnchorPointX x, BioScanner.AnchorPointY y)
{
//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)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
float num = (float)x;
float num2 = (float)y;
float num3 = (num + 1f) / 2f;
float num4 = (num2 + 1f) / 2f;
return new Vector2(num3, num4);
}
public static Sprite CreateSprite_Triangle(int size)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: 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)
Texture2D val = new Texture2D(size, size, (TextureFormat)5, false);
((Texture)val).filterMode = (FilterMode)1;
((Texture)val).wrapMode = (TextureWrapMode)1;
float num = (float)size / 2f;
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
float num2 = (float)j + 0.5f;
float num3 = (float)i + 0.5f;
float num4 = Mathf.Abs(num2 - num);
float num5 = num * (1f - num3 / (float)size);
float num6 = Mathf.Clamp01(num5 - num4 + 0.5f);
val.SetPixel(j, i, new Color(1f, 1f, 1f, num6));
}
}
val.Apply();
return Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f), 100f);
}
public static Sprite CreateSprite_Circle(int radius)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
//IL_00b4: 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_0075: Unknown result type (might be due to invalid IL or missing references)
int num = radius * 2;
Texture2D val = new Texture2D(num, num, (TextureFormat)5, false);
((Texture)val).filterMode = (FilterMode)1;
((Texture)val).wrapMode = (TextureWrapMode)1;
for (int i = 0; i < num; i++)
{
for (int j = 0; j < num; j++)
{
float num2 = (float)j + 0.5f - (float)radius;
float num3 = (float)i + 0.5f - (float)radius;
float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3);
float num5 = Mathf.Clamp01((float)radius - num4);
val.SetPixel(j, i, new Color(1f, 1f, 1f, num5));
}
}
val.Apply();
return Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), 100f);
}
public static Sprite CreateSprite_ScannerBGwithBorder_Rectangle(int width, int height, int borderThickness, Color innerColor, Color borderColor)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: 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)
Texture2D val = new Texture2D(width, height, (TextureFormat)5, false);
((Texture)val).filterMode = (FilterMode)0;
((Texture)val).wrapMode = (TextureWrapMode)1;
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
bool flag = j < borderThickness;
bool flag2 = j >= width - borderThickness;
bool flag3 = i < borderThickness;
bool flag4 = i >= height - borderThickness;
if (flag || flag2 || flag3 || flag4)
{
val.SetPixel(j, i, borderColor);
}
else
{
val.SetPixel(j, i, innerColor);
}
}
}
val.Apply();
return Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f), 100f);
}
public static Sprite CreateSprite_ScannerBGwithBorder_Circle(int radius, float borderThickness, Color innerColor, Color borderColor)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
//IL_0116: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
int num = radius * 2;
Texture2D val = new Texture2D(num, num, (TextureFormat)5, false);
((Texture)val).filterMode = (FilterMode)1;
((Texture)val).wrapMode = (TextureWrapMode)1;
float num2 = (float)radius - borderThickness;
for (int i = 0; i < num; i++)
{
for (int j = 0; j < num; j++)
{
float num3 = (float)j + 0.5f - (float)radius;
float num4 = (float)i + 0.5f - (float)radius;
float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4);
float num6 = Mathf.Clamp01((float)radius - num5);
if (num6 > 0f)
{
float num7 = Mathf.Clamp01(num5 - num2 + 0.5f);
Color val2 = Color.Lerp(innerColor, borderColor, num7);
if (num5 > (float)radius - 1f)
{
val2.a *= num6;
}
val.SetPixel(j, i, val2);
}
else
{
val.SetPixel(j, i, Color.clear);
}
}
}
val.Apply();
return Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), 100f);
}
}
}