using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using TMPro;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("GameMessageLib")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GameMessageLib")]
[assembly: AssemblyTitle("GameMessageLib")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace GameMessageLib
{
[BepInPlugin("com.rounds.gamemessagelib", "GameMessageLib", "1.0.0")]
[BepInProcess("Rounds.exe")]
public class GameMessagePlugin : BaseUnityPlugin
{
public const string ModId = "com.rounds.gamemessagelib";
public const string ModName = "GameMessageLib";
public const string Version = "1.0.0";
public static GameMessagePlugin Instance { get; private set; }
internal static ManualLogSource Log { get; private set; }
private void Awake()
{
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Logger.LogInfo((object)"GameMessageLib v1.0.0 loaded");
}
}
public enum MessageType
{
Info,
Success,
Warning,
Error
}
public static class GameMessage
{
private static GameObject _canvasGO;
private static Transform _container;
private static readonly List<GameMessageUI> _activeMessages = new List<GameMessageUI>();
private static Sprite _roundedSprite;
private const float DefaultDuration = 5f;
private const float MessageSpacing = 6f;
private const float MessageHeight = 36f;
private const float TopOffset = 15f;
public static void Show(string text, MessageType type = MessageType.Info, float duration = 5f)
{
try
{
EnsureCanvas();
float targetY = 0f - (15f + (float)_activeMessages.Count * 42f);
GameObject val = CreateMessageObject(text, type, duration, targetY);
GameMessageUI component = val.GetComponent<GameMessageUI>();
if ((Object)(object)component != (Object)null)
{
_activeMessages.Add(component);
}
}
catch (Exception ex)
{
ManualLogSource log = GameMessagePlugin.Log;
if (log != null)
{
log.LogError((object)("GameMessage.Show error: " + ex.Message));
}
}
}
public static void Info(string text, float duration = 5f)
{
Show(text, MessageType.Info, duration);
}
public static void Success(string text, float duration = 5f)
{
Show(text, MessageType.Success, duration);
}
public static void Warn(string text, float duration = 5f)
{
Show(text, MessageType.Warning, duration);
}
public static void Error(string text, float duration = 5f)
{
Show(text, MessageType.Error, duration);
}
internal static void OnMessageDestroyed(GameMessageUI msg)
{
_activeMessages.Remove(msg);
Reposition();
}
private static void Reposition()
{
for (int i = 0; i < _activeMessages.Count; i++)
{
if (!((Object)(object)_activeMessages[i] == (Object)null))
{
float targetY = 0f - (15f + (float)i * 42f);
_activeMessages[i].SetTargetY(targetY);
}
}
}
private static void EnsureCanvas()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
//IL_006e: 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_009b: Expected O, but got Unknown
//IL_00c4: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: 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)
if (!((Object)(object)_canvasGO != (Object)null))
{
_canvasGO = new GameObject("GML_MessageCanvas");
Object.DontDestroyOnLoad((Object)(object)_canvasGO);
Canvas val = _canvasGO.AddComponent<Canvas>();
val.renderMode = (RenderMode)0;
val.sortingOrder = 9999;
CanvasScaler val2 = _canvasGO.AddComponent<CanvasScaler>();
val2.uiScaleMode = (ScaleMode)1;
val2.referenceResolution = new Vector2(1920f, 1080f);
val2.matchWidthOrHeight = 0.5f;
_canvasGO.AddComponent<GraphicRaycaster>();
GameObject val3 = new GameObject("MessageContainer");
val3.transform.SetParent(_canvasGO.transform, false);
RectTransform val4 = val3.AddComponent<RectTransform>();
val4.anchorMin = new Vector2(0.5f, 1f);
val4.anchorMax = new Vector2(0.5f, 1f);
val4.pivot = new Vector2(0.5f, 1f);
val4.anchoredPosition = Vector2.zero;
val4.sizeDelta = new Vector2(600f, 600f);
_container = val3.transform;
}
}
private static GameObject CreateMessageObject(string text, MessageType type, float duration, float targetY)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0030: 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_005c: 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_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Expected O, but got Unknown
//IL_00eb: 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_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("GML_Msg");
val.transform.SetParent(_container, false);
RectTransform val2 = val.AddComponent<RectTransform>();
val2.anchorMin = new Vector2(0.5f, 1f);
val2.anchorMax = new Vector2(0.5f, 1f);
val2.pivot = new Vector2(0.5f, 1f);
val2.anchoredPosition = new Vector2(0f, 40f);
val2.sizeDelta = new Vector2(460f, 36f);
Image val3 = val.AddComponent<Image>();
val3.sprite = GetRoundedSprite();
val3.type = (Type)0;
((Graphic)val3).color = GetBackgroundColor(type);
((Graphic)val3).raycastTarget = false;
GameObject val4 = new GameObject("Text");
val4.transform.SetParent(val.transform, false);
RectTransform val5 = val4.AddComponent<RectTransform>();
val5.anchorMin = Vector2.zero;
val5.anchorMax = Vector2.one;
val5.offsetMin = new Vector2(14f, 0f);
val5.offsetMax = new Vector2(-14f, 0f);
TextMeshProUGUI val6 = val4.AddComponent<TextMeshProUGUI>();
((TMP_Text)val6).text = text;
((TMP_Text)val6).fontSize = 17f;
((Graphic)val6).color = GetTextColor(type);
((TMP_Text)val6).alignment = (TextAlignmentOptions)514;
((TMP_Text)val6).enableWordWrapping = false;
((TMP_Text)val6).overflowMode = (TextOverflowModes)1;
((Graphic)val6).raycastTarget = false;
GameMessageUI gameMessageUI = val.AddComponent<GameMessageUI>();
gameMessageUI.Init(targetY, duration, val3, val6);
return val;
}
private static Sprite GetRoundedSprite()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_roundedSprite != (Object)null)
{
return _roundedSprite;
}
Texture2D val = new Texture2D(460, 36, (TextureFormat)4, false);
((Texture)val).filterMode = (FilterMode)1;
((Texture)val).wrapMode = (TextureWrapMode)1;
Color32[] array = (Color32[])(object)new Color32[16560];
for (int i = 0; i < 36; i++)
{
for (int j = 0; j < 460; j++)
{
float num = RoundedAlpha((float)j + 0.5f, (float)i + 0.5f, 460, 36, 6);
array[i * 460 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num * 255f));
}
}
val.SetPixels32(array);
val.Apply();
_roundedSprite = Sprite.Create(val, new Rect(0f, 0f, 460f, 36f), new Vector2(0.5f, 0.5f), 1f);
return _roundedSprite;
}
private static float RoundedAlpha(float px, float py, int w, int h, int r)
{
float num;
float num2;
if (px < (float)r && py < (float)r)
{
num = r;
num2 = r;
}
else if (px > (float)(w - r) && py < (float)r)
{
num = w - r;
num2 = r;
}
else if (px < (float)r && py > (float)(h - r))
{
num = r;
num2 = h - r;
}
else
{
if (!(px > (float)(w - r)) || !(py > (float)(h - r)))
{
return 1f;
}
num = w - r;
num2 = h - r;
}
float num3 = Mathf.Sqrt((px - num) * (px - num) + (py - num2) * (py - num2));
return Mathf.Clamp01((float)r - num3 + 0.5f);
}
private static Color GetBackgroundColor(MessageType type)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: 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_008b: 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_0088: Unknown result type (might be due to invalid IL or missing references)
return (Color)(type switch
{
MessageType.Success => new Color(0.13f, 0.19f, 0.13f, 0.93f),
MessageType.Warning => new Color(0.24f, 0.21f, 0.1f, 0.93f),
MessageType.Error => new Color(0.24f, 0.11f, 0.11f, 0.93f),
_ => new Color(0.11f, 0.13f, 0.21f, 0.93f),
});
}
private static Color GetTextColor(MessageType type)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: 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_008b: 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_0088: Unknown result type (might be due to invalid IL or missing references)
return (Color)(type switch
{
MessageType.Success => new Color(0.55f, 0.93f, 0.55f, 1f),
MessageType.Warning => new Color(0.97f, 0.84f, 0.35f, 1f),
MessageType.Error => new Color(1f, 0.47f, 0.47f, 1f),
_ => new Color(0.67f, 0.81f, 1f, 1f),
});
}
}
internal class GameMessageUI : MonoBehaviour
{
private enum Phase
{
SlideIn,
Hold,
FadeOut
}
private float _targetY;
private float _duration;
private Image _bg;
private TextMeshProUGUI _text;
private Phase _phase = Phase.SlideIn;
private float _timer;
private float _currentY;
private const float SlideInTime = 0.25f;
private const float FadeOutTime = 0.35f;
private const float StartAboveY = 40f;
public void Init(float targetY, float duration, Image bg, TextMeshProUGUI text)
{
_targetY = targetY;
_duration = duration;
_bg = bg;
_text = text;
_currentY = 40f;
_timer = 0f;
_phase = Phase.SlideIn;
}
public void SetTargetY(float y)
{
_targetY = y;
}
private void Update()
{
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: 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_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: 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_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
_timer += Time.unscaledDeltaTime;
RectTransform component = ((Component)this).GetComponent<RectTransform>();
if ((Object)(object)component == (Object)null)
{
return;
}
switch (_phase)
{
case Phase.SlideIn:
{
float num3 = Mathf.Clamp01(_timer / 0.25f);
float num4 = 1f - (1f - num3) * (1f - num3);
_currentY = Mathf.Lerp(40f, _targetY, num4);
component.anchoredPosition = new Vector2(0f, _currentY);
if (num3 >= 1f)
{
_phase = Phase.Hold;
_timer = 0f;
}
break;
}
case Phase.Hold:
_currentY = Mathf.Lerp(_currentY, _targetY, Time.unscaledDeltaTime * 10f);
component.anchoredPosition = new Vector2(0f, _currentY);
if (_timer >= _duration)
{
_phase = Phase.FadeOut;
_timer = 0f;
}
break;
case Phase.FadeOut:
{
float num = Mathf.Clamp01(_timer / 0.35f);
float num2 = 1f - num;
if ((Object)(object)_bg != (Object)null)
{
Color color = ((Graphic)_bg).color;
((Graphic)_bg).color = new Color(color.r, color.g, color.b, color.a * num2);
}
if ((Object)(object)_text != (Object)null)
{
Color color2 = ((Graphic)_text).color;
((Graphic)_text).color = new Color(color2.r, color2.g, color2.b, num2);
}
_currentY += Time.unscaledDeltaTime * 25f;
component.anchoredPosition = new Vector2(0f, _currentY);
if (num >= 1f)
{
GameMessage.OnMessageDestroyed(this);
Object.Destroy((Object)(object)((Component)this).gameObject);
}
break;
}
}
}
}
}