using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
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: AssemblyTitle("NightToDay")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NightToDay")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("001cb94b-d809-4904-89d7-c853521687be")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("travy.nighttoday", "NightToDay", "1.0.9")]
public class NightToDayPlugin : BaseUnityPlugin
{
private ConfigEntry<bool> CfgEnabled;
private ConfigEntry<int> CfgSlotCount;
private ConfigEntry<float> CfgBarHeightPx;
private ConfigEntry<bool> CfgAutoY;
private ConfigEntry<float> CfgAutoYFrac;
private ConfigEntry<float> CfgExtraYPx;
private ConfigEntry<float> CfgManualYPx;
private ConfigEntry<float> CfgMarkerLineFrac;
private ConfigEntry<float> CfgMarkerLineWidthPx;
private ConfigEntry<float> CfgMarkerHeadSizePx;
private ConfigEntry<bool> CfgMarkerPointRight;
private ConfigEntry<float> CfgSlotWidthPxFallback;
private ConfigEntry<float> CfgSlotSpacingPxFallback;
private GameObject _rootGO;
private RectTransform _hotbarParent;
private RectTransform _selectedRT;
private Image _barImg;
private RectTransform _barRect;
private RectTransform _markerRoot;
private Image _markerLineImg;
private RectTransform _markerLineRect;
private Image _markerHeadImg;
private RectTransform _markerHeadRect;
private int _lastSelectedSlotIndex = 0;
private bool _hasPrevSlotSample = false;
private int _prevSlotIndex = 0;
private float _prevSelectedX = 0f;
private float _slotSpacingPx = 88f;
private float _slotWidthPx = 84f;
private Texture2D _gradientTex;
private Sprite _gradientSprite;
private Texture2D _whiteTex;
private Sprite _whiteSprite;
private Sprite _triangleSprite;
private float _nextFindTime = 0f;
private void Awake()
{
CfgEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable the hotbar time bar UI");
CfgSlotCount = ((BaseUnityPlugin)this).Config.Bind<int>("Layout", "SlotCount", 10, "Hotbar slot count (1..0)");
CfgBarHeightPx = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "BarHeightPx", 6f, "Bar height in pixels");
CfgAutoY = ((BaseUnityPlugin)this).Config.Bind<bool>("Layout", "AutoY", true, "Auto position bar inside the slot (recommended)");
CfgAutoYFrac = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "AutoYFrac", 0.78f, "Where inside the slot to place the bar (0..1).");
CfgExtraYPx = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "ExtraYPx", 18f, "Extra vertical nudge in pixels. Positive moves up.");
CfgManualYPx = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "ManualYPx", 40f, "Manual Y offset (pixels) from hotbar parent's bottom (used if AutoY=false)");
CfgSlotWidthPxFallback = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "SlotWidthPxFallback", 84f, "Fallback slot width (until learned)");
CfgSlotSpacingPxFallback = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "SlotSpacingPxFallback", 88f, "Fallback slot spacing (until learned)");
CfgMarkerLineFrac = ((BaseUnityPlugin)this).Config.Bind<float>("Marker", "MarkerLineFrac", 0.55f, "Marker line length as fraction of bar height");
CfgMarkerLineWidthPx = ((BaseUnityPlugin)this).Config.Bind<float>("Marker", "MarkerLineWidthPx", 2f, "Marker line width (px)");
CfgMarkerHeadSizePx = ((BaseUnityPlugin)this).Config.Bind<float>("Marker", "MarkerHeadSizePx", 8f, "Marker triangle size (px)");
CfgMarkerPointRight = ((BaseUnityPlugin)this).Config.Bind<bool>("Marker", "PointRight", true, "If true, arrow points right (>) instead of down.");
_slotSpacingPx = Mathf.Max(1f, CfgSlotSpacingPxFallback.Value);
_slotWidthPx = Mathf.Max(1f, CfgSlotWidthPxFallback.Value);
BuildSprites();
}
private void OnDestroy()
{
SafeDestroyUI();
if ((Object)(object)_gradientTex != (Object)null)
{
Object.Destroy((Object)(object)_gradientTex);
}
if ((Object)(object)_whiteTex != (Object)null)
{
Object.Destroy((Object)(object)_whiteTex);
}
}
private void Update()
{
if (!CfgEnabled.Value)
{
HideUI();
return;
}
if (!IsInGame())
{
HideUI();
return;
}
if (((Object)(object)_selectedRT == (Object)null || (Object)(object)_hotbarParent == (Object)null) && Time.unscaledTime >= _nextFindTime)
{
_nextFindTime = Time.unscaledTime + 0.5f;
TryBindHotbar();
}
if ((Object)(object)_selectedRT == (Object)null || (Object)(object)_hotbarParent == (Object)null)
{
HideUI();
return;
}
EnsureUIBuilt();
_lastSelectedSlotIndex = TryGetSelectedSlotIndex();
LearnSpacingFromSelection();
ApplyLayoutAlignedToHotbar();
UpdateMarker();
ShowUI();
}
private bool IsInGame()
{
try
{
Type type = AccessTools.TypeByName("PlayerUI");
if (type == null)
{
return false;
}
FieldInfo field = type.GetField("Instance", BindingFlags.Static | BindingFlags.Public);
if (field == null)
{
return false;
}
object value = field.GetValue(null);
return value != null;
}
catch
{
return false;
}
}
private void TryBindHotbar()
{
try
{
Type type = AccessTools.TypeByName("PlayerUI");
if (type == null)
{
return;
}
FieldInfo field = type.GetField("Instance", BindingFlags.Static | BindingFlags.Public);
if (field == null)
{
return;
}
object value = field.GetValue(null);
if (value == null)
{
return;
}
FieldInfo field2 = type.GetField("selectedRT", BindingFlags.Instance | BindingFlags.NonPublic);
if (!(field2 == null))
{
ref RectTransform selectedRT = ref _selectedRT;
object? value2 = field2.GetValue(value);
selectedRT = (RectTransform)((value2 is RectTransform) ? value2 : null);
if (!((Object)(object)_selectedRT == (Object)null))
{
ref RectTransform hotbarParent = ref _hotbarParent;
Transform parent = ((Transform)_selectedRT).parent;
hotbarParent = (RectTransform)(object)((parent is RectTransform) ? parent : null);
}
}
}
catch
{
}
}
private void EnsureUIBuilt()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Expected O, but got Unknown
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: 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_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Expected O, but got Unknown
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Expected O, but got Unknown
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Expected O, but got Unknown
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_rootGO != (Object)null))
{
_rootGO = new GameObject("NightToDay_TimeBar_ROOT");
_rootGO.transform.SetParent((Transform)(object)_hotbarParent, false);
RectTransform val = _rootGO.AddComponent<RectTransform>();
val.anchorMin = new Vector2(0f, 0f);
val.anchorMax = new Vector2(0f, 0f);
val.pivot = new Vector2(0f, 0f);
val.anchoredPosition = Vector2.zero;
val.sizeDelta = new Vector2(10f, 10f);
GameObject val2 = new GameObject("Bar");
val2.transform.SetParent(_rootGO.transform, false);
_barRect = val2.AddComponent<RectTransform>();
_barRect.anchorMin = new Vector2(0f, 0f);
_barRect.anchorMax = new Vector2(0f, 0f);
_barRect.pivot = new Vector2(0f, 0.5f);
_barImg = val2.AddComponent<Image>();
((Graphic)_barImg).raycastTarget = false;
_barImg.sprite = _gradientSprite;
_barImg.type = (Type)0;
_barImg.preserveAspect = false;
GameObject val3 = new GameObject("Marker");
val3.transform.SetParent(val2.transform, false);
_markerRoot = val3.AddComponent<RectTransform>();
GameObject val4 = new GameObject("Line");
val4.transform.SetParent(val3.transform, false);
_markerLineRect = val4.AddComponent<RectTransform>();
_markerLineImg = val4.AddComponent<Image>();
((Graphic)_markerLineImg).raycastTarget = false;
_markerLineImg.sprite = _whiteSprite;
_markerLineImg.type = (Type)0;
((Graphic)_markerLineImg).color = Color.white;
GameObject val5 = new GameObject("Head");
val5.transform.SetParent(val3.transform, false);
_markerHeadRect = val5.AddComponent<RectTransform>();
_markerHeadImg = val5.AddComponent<Image>();
((Graphic)_markerHeadImg).raycastTarget = false;
_markerHeadImg.sprite = _triangleSprite;
_markerHeadImg.type = (Type)0;
((Graphic)_markerHeadImg).color = Color.white;
}
}
private void SafeDestroyUI()
{
try
{
if ((Object)(object)_rootGO != (Object)null)
{
Object.Destroy((Object)(object)_rootGO);
}
}
catch
{
}
_rootGO = null;
_hotbarParent = null;
_selectedRT = null;
_barImg = null;
_barRect = null;
_markerRoot = null;
_markerLineImg = null;
_markerLineRect = null;
_markerHeadImg = null;
_markerHeadRect = null;
}
private void ApplyLayoutAlignedToHotbar()
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: 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_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0406: Unknown result type (might be due to invalid IL or missing references)
//IL_0373: Unknown result type (might be due to invalid IL or missing references)
//IL_038e: Unknown result type (might be due to invalid IL or missing references)
//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0302: Unknown result type (might be due to invalid IL or missing references)
//IL_032b: Unknown result type (might be due to invalid IL or missing references)
//IL_033c: Unknown result type (might be due to invalid IL or missing references)
//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
//IL_050b: Unknown result type (might be due to invalid IL or missing references)
//IL_042d: Unknown result type (might be due to invalid IL or missing references)
//IL_0448: Unknown result type (might be due to invalid IL or missing references)
//IL_0463: Unknown result type (might be due to invalid IL or missing references)
//IL_0474: Unknown result type (might be due to invalid IL or missing references)
//IL_0494: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_barRect == (Object)null || (Object)(object)_selectedRT == (Object)null)
{
return;
}
int num = Mathf.Max(2, CfgSlotCount.Value);
float num2 = Mathf.Max(1f, _slotSpacingPx);
float num3 = Mathf.Max(1f, _slotWidthPx);
float x = _selectedRT.anchoredPosition.x;
int num4 = Mathf.Clamp(_lastSelectedSlotIndex, 0, num - 1);
float num5 = x - (float)num4 * num2;
float num6 = num5 + num2 * (float)(num - 1);
float num7 = num5 - num3 * 0.5f;
float num8 = num6 + num3 * 0.5f;
float num9 = Mathf.Max(1f, num8 - num7);
float num10 = Mathf.Max(2f, CfgBarHeightPx.Value);
float num12;
if (CfgAutoY.Value)
{
Rect rect = _selectedRT.rect;
float height = ((Rect)(ref rect)).height;
float num11 = Mathf.Clamp01(CfgAutoYFrac.Value);
num12 = _selectedRT.anchoredPosition.y + height * (num11 - 0.5f);
num12 += CfgExtraYPx.Value;
}
else
{
num12 = CfgManualYPx.Value + CfgExtraYPx.Value;
}
_barRect.sizeDelta = new Vector2(num9, num10);
_barRect.anchoredPosition = new Vector2(num7, num12);
float num13 = Mathf.Max(1f, CfgMarkerLineWidthPx.Value);
float num14 = Mathf.Max(4f, CfgMarkerHeadSizePx.Value);
bool value = CfgMarkerPointRight.Value;
if ((Object)(object)_markerRoot != (Object)null)
{
if (value)
{
_markerRoot.anchorMin = new Vector2(0f, 0.5f);
_markerRoot.anchorMax = new Vector2(0f, 0.5f);
_markerRoot.pivot = new Vector2(0.5f, 0.5f);
}
else
{
_markerRoot.anchorMin = new Vector2(0f, 1f);
_markerRoot.anchorMax = new Vector2(0f, 1f);
_markerRoot.pivot = new Vector2(0.5f, 1f);
}
}
if ((Object)(object)_markerLineRect != (Object)null)
{
if (value)
{
float num15 = Mathf.Clamp01(CfgMarkerLineFrac.Value) * num14;
_markerLineRect.anchorMin = new Vector2(0.5f, 0.5f);
_markerLineRect.anchorMax = new Vector2(0.5f, 0.5f);
_markerLineRect.pivot = new Vector2(1f, 0.5f);
_markerLineRect.sizeDelta = new Vector2(Mathf.Max(1f, num15), Mathf.Max(1f, num13));
_markerLineRect.anchoredPosition = Vector2.zero;
}
else
{
float num16 = Mathf.Clamp01(CfgMarkerLineFrac.Value) * num10;
_markerLineRect.anchorMin = new Vector2(0.5f, 1f);
_markerLineRect.anchorMax = new Vector2(0.5f, 1f);
_markerLineRect.pivot = new Vector2(0.5f, 1f);
_markerLineRect.sizeDelta = new Vector2(num13, Mathf.Max(1f, num16));
_markerLineRect.anchoredPosition = Vector2.zero;
}
}
if ((Object)(object)_markerHeadRect != (Object)null)
{
_markerHeadRect.sizeDelta = new Vector2(num14, num14);
if (value)
{
_markerHeadRect.anchorMin = new Vector2(0.5f, 0.5f);
_markerHeadRect.anchorMax = new Vector2(0.5f, 0.5f);
_markerHeadRect.pivot = new Vector2(0.5f, 0.5f);
_markerHeadRect.anchoredPosition = Vector2.zero;
((Transform)_markerHeadRect).localRotation = Quaternion.Euler(0f, 0f, 90f);
}
else
{
_markerHeadRect.anchorMin = new Vector2(0.5f, 1f);
_markerHeadRect.anchorMax = new Vector2(0.5f, 1f);
_markerHeadRect.pivot = new Vector2(0.5f, 1f);
_markerHeadRect.anchoredPosition = Vector2.zero;
((Transform)_markerHeadRect).localRotation = Quaternion.identity;
}
}
}
private void LearnSpacingFromSelection()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((Object)(object)_selectedRT == (Object)null)
{
return;
}
int lastSelectedSlotIndex = _lastSelectedSlotIndex;
float x = _selectedRT.anchoredPosition.x;
if (!_hasPrevSlotSample)
{
_hasPrevSlotSample = true;
_prevSlotIndex = lastSelectedSlotIndex;
_prevSelectedX = x;
return;
}
int num = lastSelectedSlotIndex - _prevSlotIndex;
if (num != 0)
{
float num2 = x - _prevSelectedX;
float num3 = Mathf.Abs(num2) / Mathf.Abs((float)num);
if (num3 > 10f && num3 < 500f)
{
_slotSpacingPx = Mathf.Lerp(_slotSpacingPx, num3, 0.35f);
}
}
_prevSlotIndex = lastSelectedSlotIndex;
_prevSelectedX = x;
_slotWidthPx = Mathf.Lerp(_slotWidthPx, Mathf.Max(10f, _slotSpacingPx - 4f), 0.2f);
}
catch
{
}
}
private void UpdateMarker()
{
//IL_002d: 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_008a: 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)
if ((Object)(object)_barRect == (Object)null || (Object)(object)_markerRoot == (Object)null)
{
return;
}
float x = _barRect.sizeDelta.x;
if (!(x <= 1f))
{
float num = TryGetNormalizedDayTime();
float num2 = Mathf.Clamp01(num) * x;
_markerRoot.anchoredPosition = new Vector2(num2, 0f);
if ((Object)(object)_markerHeadRect != (Object)null)
{
_markerHeadRect.anchoredPosition = Vector2.zero;
}
if ((Object)(object)_markerLineRect != (Object)null)
{
_markerLineRect.anchoredPosition = Vector2.zero;
}
}
}
private float TryGetNormalizedDayTime()
{
try
{
Type type = AccessTools.TypeByName("DayNight");
if (type == null)
{
return 0f;
}
FieldInfo field = type.GetField("Instance", BindingFlags.Static | BindingFlags.Public);
if (field == null)
{
return 0f;
}
object value = field.GetValue(null);
if (value == null)
{
return 0f;
}
FieldInfo field2 = type.GetField("dayTime", BindingFlags.Instance | BindingFlags.Public);
if (field2 == null)
{
return 0f;
}
object value2 = field2.GetValue(value);
if (!TryConvertToFloat(value2, out var v))
{
return 0f;
}
return Mathf.Repeat(v / 24f, 1f);
}
catch
{
return 0f;
}
}
private bool TryConvertToFloat(object raw, out float v)
{
v = 0f;
if (raw == null)
{
return false;
}
if (raw is float)
{
v = (float)raw;
return true;
}
if (raw is double)
{
v = (float)(double)raw;
return true;
}
if (raw is int)
{
v = (int)raw;
return true;
}
if (raw is uint)
{
v = (uint)raw;
return true;
}
if (raw is short)
{
v = (short)raw;
return true;
}
if (raw is ushort)
{
v = (int)(ushort)raw;
return true;
}
if (raw is byte)
{
v = (int)(byte)raw;
return true;
}
return false;
}
private int TryGetSelectedSlotIndex()
{
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
try
{
Type type = AccessTools.TypeByName("PlayerInventory");
if (type == null)
{
return 0;
}
FieldInfo field = type.GetField("Instance", BindingFlags.Static | BindingFlags.Public);
if (field == null)
{
return 0;
}
object value = field.GetValue(null);
if (value == null)
{
return 0;
}
FieldInfo field2 = type.GetField("selectedSlot", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field2 != null)
{
object value2 = field2.GetValue(value);
if (value2 is int result)
{
return result;
}
if (value2 is int result2)
{
return result2;
}
}
FieldInfo field3 = type.GetField("_selectedSlot", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field3 != null)
{
object value3 = field3.GetValue(value);
if (value3 is int result3)
{
return result3;
}
if (value3 is int result4)
{
return result4;
}
}
float num = (((Object)(object)_selectedRT != (Object)null) ? _selectedRT.anchoredPosition.x : 0f);
float num2 = Mathf.Round(num / Mathf.Max(1f, _slotSpacingPx));
return Mathf.Clamp((int)num2, 0, Mathf.Max(0, CfgSlotCount.Value - 1));
}
catch
{
return 0;
}
}
private void BuildSprites()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
//IL_0064: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Expected O, but got Unknown
//IL_0144: 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_0185: 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_0096: 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_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
_gradientTex = new Texture2D(256, 1, (TextureFormat)4, false);
((Texture)_gradientTex).wrapMode = (TextureWrapMode)1;
((Texture)_gradientTex).filterMode = (FilterMode)1;
Color val = default(Color);
((Color)(ref val))..ctor(0.35f, 0.1f, 0.55f, 1f);
Color val2 = default(Color);
((Color)(ref val2))..ctor(1f, 0.55f, 0.12f, 1f);
Color val3 = val;
for (int i = 0; i < 256; i++)
{
float num = (float)i / 255f;
Color val4 = ((num < 0.5f) ? Color.Lerp(val, val2, num / 0.5f) : Color.Lerp(val2, val3, (num - 0.5f) / 0.5f));
_gradientTex.SetPixel(i, 0, val4);
}
_gradientTex.Apply();
_gradientSprite = Sprite.Create(_gradientTex, new Rect(0f, 0f, 256f, 1f), new Vector2(0.5f, 0.5f), 100f);
_whiteTex = new Texture2D(1, 1, (TextureFormat)4, false);
((Texture)_whiteTex).wrapMode = (TextureWrapMode)1;
((Texture)_whiteTex).filterMode = (FilterMode)0;
_whiteTex.SetPixel(0, 0, Color.white);
_whiteTex.Apply();
_whiteSprite = Sprite.Create(_whiteTex, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0.5f), 100f);
_triangleSprite = BuildTriangleSprite(32);
}
private Sprite BuildTriangleSprite(int size)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
//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_0043: Unknown result type (might be due to invalid IL or missing references)
//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_00cf: Unknown result type (might be due to invalid IL or missing references)
Texture2D val = new Texture2D(size, size, (TextureFormat)4, false);
((Texture)val).wrapMode = (TextureWrapMode)1;
((Texture)val).filterMode = (FilterMode)1;
Color val2 = default(Color);
((Color)(ref val2))..ctor(0f, 0f, 0f, 0f);
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
val.SetPixel(j, i, val2);
}
}
Color white = Color.white;
for (int k = 0; k < size; k++)
{
float num = (float)k / (float)(size - 1);
int num2 = Mathf.RoundToInt((1f - num) * ((float)size * 0.45f));
int num3 = size / 2;
int num4 = Mathf.Clamp(num3 - num2, 0, size - 1);
int num5 = Mathf.Clamp(num3 + num2, 0, size - 1);
int num6 = size - 1 - k;
for (int l = num4; l <= num5; l++)
{
val.SetPixel(l, num6, white);
}
}
val.Apply();
return Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 1f), 100f);
}
private void ShowUI()
{
if ((Object)(object)_rootGO != (Object)null && !_rootGO.activeSelf)
{
_rootGO.SetActive(true);
}
}
private void HideUI()
{
if ((Object)(object)_rootGO != (Object)null && _rootGO.activeSelf)
{
_rootGO.SetActive(false);
}
}
}
internal static class AccessTools
{
public static Type TypeByName(string name)
{
if (string.IsNullOrEmpty(name))
{
return null;
}
Type type = Type.GetType(name);
if (type != null)
{
return type;
}
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
for (int i = 0; i < assemblies.Length; i++)
{
try
{
Type[] types = assemblies[i].GetTypes();
for (int j = 0; j < types.Length; j++)
{
if (types[j] != null && types[j].Name == name)
{
return types[j];
}
}
}
catch
{
}
}
return null;
}
}