Decompiled source of AnnounceMoonAndWeatherChange v2.0.5

AnnounceMoonAndWeatherChange.dll

Decompiled 5 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using AnnounceMoonAndWeatherChange.LobbyCompatibility;
using AnnounceMoonAndWeatherChange.WeatherWarningAnimations;
using AnnounceMoonAndWeatherChange.WeatherWarningAnimations.Impl;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;

[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("TestAccount666.AnnounceMoonAndWeatherChange")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A mod that shows weather warnings and moon route info")]
[assembly: AssemblyFileVersion("2.0.5.0")]
[assembly: AssemblyInformationalVersion("2.0.5+39ac3d3b8d8c6e5045a2f72615a026b442f7f876")]
[assembly: AssemblyProduct("AnnounceMoonAndWeatherChange")]
[assembly: AssemblyTitle("TestAccount666.AnnounceMoonAndWeatherChange")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.5.0")]
[module: UnverifiableCode]
[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.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;
		}
	}
	[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 AnnounceMoonAndWeatherChange
{
	[BepInPlugin("TestAccount666.AnnounceMoonAndWeatherChange", "AnnounceMoonAndWeatherChange", "2.0.5")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class AnnounceMoonAndWeatherChange : BaseUnityPlugin
	{
		internal static ConfigManager? configManager;

		public static EventHandler registerNowEvent;

		public static AnnounceMoonAndWeatherChange Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		private static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			if (DependencyChecker.IsLobbyCompatibilityInstalled())
			{
				Logger.LogInfo((object)"Found LobbyCompatibility Mod, initializing support :)");
				LobbyCompatibilitySupport.Initialize();
			}
			InitializeDefaultAnimations();
			registerNowEvent?.Invoke(this, null);
			Patch();
			if (DependencyChecker.IsWeatherTweaksInstalled())
			{
				WeatherTweaksSupport.enabled = true;
				Logger.LogInfo((object)"WeatherTweaks found! Enabling support for it :)");
			}
			configManager = new ConfigManager(((BaseUnityPlugin)this).Config);
			configManager.HandleConfig();
			Logger.LogInfo((object)"TestAccount666.AnnounceMoonAndWeatherChange v2.0.5 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("TestAccount666.AnnounceMoonAndWeatherChange");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}

		private static void InitializeDefaultAnimations()
		{
			SlidingAnimation.Initialize();
			FadeAnimation.Initialize();
			BlinkingAnimation.Initialize();
		}
	}
	public class ConfigManager
	{
		private readonly ConfigFile _configFile;

		internal ConfigEntry<string> animationType = null;

		internal ConfigEntry<string> announceMoonChangeText = null;

		internal ConfigEntry<int> scrollSpeed = null;

		internal ConfigEntry<bool> showMoonChangeAnnouncement = null;

		internal ConfigEntry<bool> showWeatherWarning = null;

		internal ConfigEntry<float> textColorBlue = null;

		internal ConfigEntry<float> textColorGreen = null;

		internal ConfigEntry<float> textColorRed = null;

		internal ConfigEntry<int> textFontSize = null;

		internal ConfigEntry<string> weatherWarningLowerText = null;

		internal ConfigEntry<string> weatherWarningUpperText = null;

		internal ConfigManager(ConfigFile configFile)
		{
			_configFile = configFile;
		}

		internal void HandleConfig()
		{
			BindConfigValues();
			DeleteOrphanedEntries();
		}

		private void BindConfigValues()
		{
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Expected O, but got Unknown
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Expected O, but got Unknown
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Expected O, but got Unknown
			announceMoonChangeText = _configFile.Bind<string>("Messages", "1. Announce Moon Change Text", "Ship routed to: <MOON>", "The message displayed when moon is changed. <MOON> is replaced with the moon's name");
			weatherWarningUpperText = _configFile.Bind<string>("Messages", "2. Weather Warning Upper Text", "!!! WARNING !!!", "The Header Text for the weather warning");
			weatherWarningLowerText = _configFile.Bind<string>("Messages", "3. Weather Warning Lower Text", "<MOON> is currently <WEATHER>!", "The body message displayed, if the moon has a weather. <MOON> is replaced with the moon's name. <WEATHER> is replaced with the moon's weather");
			showMoonChangeAnnouncement = _configFile.Bind<bool>("Toggles", "1. Show Moon Change Announcement", true, "Whether or not to show the moon change announcement");
			showWeatherWarning = _configFile.Bind<bool>("Toggles", "2. Show Weather Warning", true, "Whether or not to show the weather warning");
			textFontSize = _configFile.Bind<int>("HUD", "1. Text Font Size", 30, "The font size of the weather warning text");
			animationType = _configFile.Bind<string>("HUD", "2. Animation Type", "Sliding", new ConfigDescription("What animation do you want for the weather warning?", (AcceptableValueBase)(object)new AcceptableValueList<string>(AnimationManager.GetAnimationNames().ToArray()), Array.Empty<object>()));
			scrollSpeed = _configFile.Bind<int>("HUD", "3. Animation Speed", 100, new ConfigDescription("The speed for the weather warning animation", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 200), Array.Empty<object>()));
			textColorRed = _configFile.Bind<float>("HUD", "4. Text Color Red", 1f, new ConfigDescription("How much red do you want to have inside your text?", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			textColorGreen = _configFile.Bind<float>("HUD", "5. Text Color Green", 1f, new ConfigDescription("How much green do you want to have inside your text?", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			textColorBlue = _configFile.Bind<float>("HUD", "6. Text Color Blue", 1f, new ConfigDescription("How much blue do you want to have inside your text?", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			AnnounceMoonAndWeatherChange.Logger.LogInfo((object)("Animation set to: " + animationType.Value));
		}

		private void DeleteOrphanedEntries()
		{
			PropertyInfo property = ((object)_configFile).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			if (property == null)
			{
				AnnounceMoonAndWeatherChange.Logger.LogError((object)"Couldn't find orphanedEntriesProp!");
				return;
			}
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(_configFile, null);
			if (dictionary != null && dictionary.Count > 0)
			{
				dictionary.Clear();
				AnnounceMoonAndWeatherChange.Logger.LogWarning((object)"Unused config entries were deleted. Make sure to check your config!");
				_configFile.Save();
			}
		}
	}
	internal static class DependencyChecker
	{
		internal static bool IsWeatherTweaksInstalled()
		{
			return Chainloader.PluginInfos.Values.Any((PluginInfo metadata) => metadata.Metadata.GUID.Contains("WeatherTweaks"));
		}

		internal static bool IsLobbyCompatibilityInstalled()
		{
			return Chainloader.PluginInfos.Values.Any((PluginInfo metadata) => metadata.Metadata.GUID.Contains("LobbyCompatibility"));
		}
	}
	internal static class MessageSender
	{
		private const string MOON_PLACEHOLDER = "<MOON>";

		private const string WEATHER_PLACEHOLDER = "<WEATHER>";

		private static readonly int _Display = Animator.StringToHash("display");

		private static MethodInfo? _playRandomClipMethod;

		private static Action? _playRandomClipExpression;

		internal static void SendWeatherWarning()
		{
			if (IsWeatherWarningEnabled())
			{
				((Component)HUDManager.Instance).gameObject.GetComponent<WarningAnimation>()?.SpeedUp();
				SelectableLevel currentLevel = StartOfRound.Instance.currentLevel;
				if (!((Object)(object)currentLevel == (Object)null) && !IsWeatherOnMoonNone(currentLevel))
				{
					string currentWeather = GetCurrentWeather(currentLevel);
					DisplayWeatherWarning(currentLevel, currentWeather);
				}
			}
		}

		internal static void SendMoonChangeAnnouncement()
		{
			if (!IsMoonChangeAnnouncementEnabled())
			{
				return;
			}
			SelectableLevel currentLevel = StartOfRound.Instance.currentLevel;
			if (!((Object)(object)currentLevel == (Object)null))
			{
				string text = AnnounceMoonAndWeatherChange.configManager?.announceMoonChangeText.Value;
				if (text != null)
				{
					DisplayMoonChangeAnnouncement(currentLevel, text);
				}
			}
		}

		private static bool IsWeatherWarningEnabled()
		{
			return AnnounceMoonAndWeatherChange.configManager?.showWeatherWarning.Value ?? false;
		}

		private static bool IsMoonChangeAnnouncementEnabled()
		{
			return AnnounceMoonAndWeatherChange.configManager?.showMoonChangeAnnouncement.Value ?? false;
		}

		private static string GetCurrentWeather(SelectableLevel currentLevel)
		{
			string text = ((object)(LevelWeatherType)(ref currentLevel.currentWeather)).ToString();
			if (!WeatherTweaksSupport.enabled)
			{
				return text;
			}
			return WeatherTweaksSupport.GetCurrentWeather(currentLevel) ?? text;
		}

		private static bool IsWeatherOnMoonNone(SelectableLevel selectableLevel)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			bool flag = (int)selectableLevel.currentWeather == -1;
			if (!WeatherTweaksSupport.enabled)
			{
				return flag;
			}
			string currentWeather = WeatherTweaksSupport.GetCurrentWeather(selectableLevel);
			if (currentWeather != null)
			{
				return currentWeather.ToLower().Equals("none") && flag;
			}
			AnnounceMoonAndWeatherChange.Logger.LogInfo((object)"Current Weather is null???");
			return flag;
		}

		private static void DisplayWeatherWarning(SelectableLevel currentLevel, string weather)
		{
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			string text = AnnounceMoonAndWeatherChange.configManager?.weatherWarningUpperText.Value;
			string text2 = AnnounceMoonAndWeatherChange.configManager?.weatherWarningLowerText.Value.Replace("<MOON>", currentLevel.PlanetName).Replace("<WEATHER>", weather);
			Type currentAnimation = AnimationManager.GetCurrentAnimation();
			WarningAnimation warningAnimation = (WarningAnimation)(object)((Component)HUDManager.Instance).gameObject.AddComponent(currentAnimation);
			float? num = AnnounceMoonAndWeatherChange.configManager?.textColorRed.Value;
			float? num2 = AnnounceMoonAndWeatherChange.configManager?.textColorGreen.Value;
			float? num3 = AnnounceMoonAndWeatherChange.configManager?.textColorBlue.Value;
			if (!num.HasValue || !num2.HasValue || !num3.HasValue)
			{
				AnnounceMoonAndWeatherChange.Logger.LogError((object)"Couldn't set text color!");
				AnnounceMoonAndWeatherChange.Logger.LogError((object)$"Red: {num}");
				AnnounceMoonAndWeatherChange.Logger.LogError((object)$"Green: {num2}");
				AnnounceMoonAndWeatherChange.Logger.LogError((object)$"Blue: {num3}");
				return;
			}
			warningAnimation.textColor = new Color(num.Value, num2.Value, num3.Value);
			warningAnimation.fontSize = (AnnounceMoonAndWeatherChange.configManager?.textFontSize.Value).Value;
			warningAnimation.animationSpeed = AnnounceMoonAndWeatherChange.configManager.scrollSpeed.Value;
			warningAnimation.text = (text + "\n" + text2).Trim();
			if (_playRandomClipExpression != null)
			{
				_playRandomClipExpression();
			}
			else
			{
				FetchAndExecutePlayRandomClipMethod();
			}
		}

		private static void DisplayMoonChangeAnnouncement(SelectableLevel currentLevel, string announceMoonChangeText)
		{
			HUDManager instance = HUDManager.Instance;
			((TMP_Text)instance.deviceChangeText).text = announceMoonChangeText.Replace("<MOON>", currentLevel.PlanetName);
			instance.deviceChangeAnimator.SetTrigger(_Display);
		}

		private static void FetchAndExecutePlayRandomClipMethod()
		{
			if ((object)_playRandomClipMethod == null)
			{
				_playRandomClipMethod = typeof(RoundManager).GetMethod("PlayRandomClip", BindingFlags.Static | BindingFlags.Public);
			}
			if ((object)_playRandomClipMethod != null)
			{
				Expression[] requiredParameters = GetRequiredParameters();
				MethodCallExpression body = Expression.Call(_playRandomClipMethod, requiredParameters);
				Expression<Action> expression = Expression.Lambda<Action>(body, Array.Empty<ParameterExpression>());
				_playRandomClipExpression = expression.Compile();
				_playRandomClipExpression();
			}
		}

		private static Expression[] GetRequiredParameters()
		{
			AnnounceMoonAndWeatherChange.Logger.LogInfo((object)_playRandomClipMethod?.GetParameters().Length);
			MethodInfo method = AccessTools.Method(typeof(MessageSender), "GetUIAudio", (Type[])null, (Type[])null);
			MethodInfo method2 = AccessTools.Method(typeof(MessageSender), "GetWarningSfx", (Type[])null, (Type[])null);
			int? num = _playRandomClipMethod?.GetParameters().Length;
			if (1 == 0)
			{
			}
			Expression[] result = num switch
			{
				5 => new Expression[5]
				{
					Expression.Call(method),
					Expression.Call(method2),
					Expression.Constant(true),
					Expression.Constant(1f),
					Expression.Constant(0)
				}, 
				6 => new Expression[6]
				{
					Expression.Call(method),
					Expression.Call(method2),
					Expression.Constant(true),
					Expression.Constant(1f),
					Expression.Constant(0),
					Expression.Constant(1000)
				}, 
				_ => throw new NotImplementedException("You're using an unsupported version of Lethal Company. Please report this.")
				{
					HelpLink = "https://github.com/Test-Account666/LethalCompany-AnnounceMoonAndWeatherChange/issues/",
					Source = "https://github.com/Test-Account666/LethalCompany-AnnounceMoonAndWeatherChange"
				}, 
			};
			if (1 == 0)
			{
			}
			return result;
		}

		private static AudioSource GetUIAudio()
		{
			return HUDManager.Instance.UIAudio;
		}

		private static AudioClip[] GetWarningSfx()
		{
			return HUDManager.Instance.warningSFX;
		}
	}
	public static class WeatherTweaksSupport
	{
		internal static bool enabled;

		private static Type? _variablesType;

		private static MethodInfo? _getPlanetCurrentWeatherMethod;

		public static string? GetCurrentWeather(SelectableLevel selectableLevel)
		{
			string result = ((object)(LevelWeatherType)(ref selectableLevel.currentWeather)).ToString();
			if (_variablesType == null && !FetchVariablesType())
			{
				return result;
			}
			if (_getPlanetCurrentWeatherMethod == null && !FetchGetPlanetCurrentWeatherMethod())
			{
				return result;
			}
			if (_getPlanetCurrentWeatherMethod == null)
			{
				return result;
			}
			object[] parameters;
			switch (_getPlanetCurrentWeatherMethod.GetParameters().Length)
			{
			case 2:
				parameters = new object[2] { selectableLevel, true };
				break;
			case 1:
				parameters = new object[1] { selectableLevel };
				break;
			default:
				AnnounceMoonAndWeatherChange.Logger.LogError((object)"You're using an unsupported version of WeatherTweaks!");
				enabled = false;
				return null;
			}
			return _getPlanetCurrentWeatherMethod?.Invoke(null, parameters) as string;
		}

		private static bool FetchVariablesType()
		{
			Type type = AccessTools.TypeByName("WeatherTweaks.Variables");
			if (type == null)
			{
				AnnounceMoonAndWeatherChange.Logger.LogError((object)"[WT Support] Couldn't find Variables type!");
				return false;
			}
			_variablesType = type;
			return true;
		}

		private static bool FetchGetPlanetCurrentWeatherMethod()
		{
			MethodInfo methodInfo = AccessTools.DeclaredMethod(_variablesType, "GetPlanetCurrentWeather", new Type[1] { typeof(SelectableLevel) }, (Type[])null);
			if ((object)methodInfo == null)
			{
				methodInfo = AccessTools.DeclaredMethod(_variablesType, "GetPlanetCurrentWeather", new Type[2]
				{
					typeof(SelectableLevel),
					typeof(bool)
				}, (Type[])null);
			}
			if (methodInfo == null)
			{
				AnnounceMoonAndWeatherChange.Logger.LogError((object)"[WT Support] Couldn't find GetPlanetCurrentWeather method!");
				return false;
			}
			_getPlanetCurrentWeatherMethod = methodInfo;
			return true;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "TestAccount666.AnnounceMoonAndWeatherChange";

		public const string PLUGIN_NAME = "AnnounceMoonAndWeatherChange";

		public const string PLUGIN_VERSION = "2.0.5";
	}
}
namespace AnnounceMoonAndWeatherChange.WeatherWarningAnimations
{
	public class AnimationDictionary : Dictionary<string, Type>
	{
		public new void Add(string key, Type value)
		{
			if (string.IsNullOrEmpty(key) || string.IsNullOrWhiteSpace(key))
			{
				throw new ArgumentException("Animation name can't be null or empty!");
			}
			if (!value.IsSubclassOf(typeof(WarningAnimation)))
			{
				throw new ArgumentException("Animation class has to be of type WarningAnimation!");
			}
			base.Add(key, value);
		}
	}
	public static class AnimationManager
	{
		private const string DEFAULT_ANIMATION = "Sliding";

		private static readonly AnimationDictionary _Animations = new AnimationDictionary();

		public static Type? GetAnimation(string? animation)
		{
			if (string.IsNullOrEmpty(animation))
			{
				return null;
			}
			Type valueOrDefault = _Animations.GetValueOrDefault(animation.ToLower());
			return valueOrDefault ?? _Animations.GetValueOrDefault("Sliding".ToLower());
		}

		public static Type? GetCurrentAnimation()
		{
			return GetAnimation(AnnounceMoonAndWeatherChange.configManager?.animationType.Value.ToLower());
		}

		public static void AddAnimation(string name, Type animationType)
		{
			name = name.ToLower();
			_Animations.Add(name, animationType);
		}

		public static List<string> GetAnimationNames()
		{
			return _Animations.Keys.ToList();
		}
	}
	public abstract class WarningAnimation : MonoBehaviour
	{
		public string text = "";

		public Color textColor = Color.white;

		public int fontSize = 30;

		public float animationSpeed = 100f;

		protected float internalSpeedMultiplier = 1f;

		protected Vector2 position = new Vector2(10f, 10f);

		protected bool stopRendering;

		protected Vector2 textSize = Vector2.zero;

		protected GUIStyle? textStyle;

		protected Texture2D texture2D = null;

		public abstract string AnimationName { get; }

		private void Start()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			AnnounceMoonAndWeatherChange.Logger.LogDebug((object)"Starting animation!");
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			if (!string.IsNullOrEmpty(directoryName))
			{
				string path = Path.Combine(directoryName, "background.png");
				byte[] array = File.ReadAllBytes(path);
				texture2D = new Texture2D(256, 256);
				ImageConversion.LoadImage(texture2D, array);
			}
		}

		private void OnDestroy()
		{
			AnnounceMoonAndWeatherChange.Logger.LogDebug((object)"Stopping animation this instant!");
		}

		private void OnGUI()
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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)
			//IL_002d: 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)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_004a: 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)
			//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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0070: Expected O, but got Unknown
			if (stopRendering)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			if (textStyle == null)
			{
				textStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = fontSize,
					padding = new RectOffset(5, 5, 5, 5),
					alignment = (TextAnchor)4,
					normal = new GUIStyleState
					{
						textColor = textColor
					}
				};
			}
			textSize = textStyle.CalcSize(new GUIContent(text));
			OnGuiUpdate();
		}

		public virtual void SpeedUp()
		{
			internalSpeedMultiplier = 4.5f;
		}

		protected abstract void OnGuiUpdate();
	}
}
namespace AnnounceMoonAndWeatherChange.WeatherWarningAnimations.Impl
{
	public class BlinkingAnimation : WarningAnimation
	{
		private const int MAX_PULSE_TIMES = 4;

		private const float ALPHA_CHANGE_VALUE = 0.01f;

		private float _alpha;

		private int _pulseTimes;

		private bool _started;

		public override string AnimationName => "Blinking";

		internal static void Initialize()
		{
			AnimationManager.AddAnimation("Blinking", typeof(BlinkingAnimation));
		}

		protected override void OnGuiUpdate()
		{
			//IL_003d: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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)
			if (!_started)
			{
				_started = true;
				StartFadeIn();
			}
			position = new Vector2((float)Screen.width - textSize.x, (float)Screen.height / 2f);
			Color color = default(Color);
			((Color)(ref color))..ctor(1f, 0f, 0f, _alpha);
			Color color2 = default(Color);
			((Color)(ref color2))..ctor(textColor.r, textColor.g, textColor.b, _alpha);
			GUI.color = color;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(position.x, position.y, textSize.x, textSize.y);
			GUI.DrawTexture(val, (Texture)(object)texture2D);
			GUI.color = color2;
			GUI.Label(val, text, textStyle);
		}

		public override void SpeedUp()
		{
			stopRendering = true;
		}

		public void StartFadeOut()
		{
			((MonoBehaviour)this).StartCoroutine(FadeOut());
		}

		public void StartFadeIn()
		{
			((MonoBehaviour)this).StartCoroutine(FadeIn());
		}

		private IEnumerator FadeOut()
		{
			while (_alpha > 0f)
			{
				_alpha -= 0.01f * Math.Max(animationSpeed * internalSpeedMultiplier * Time.deltaTime, 0f);
				yield return null;
			}
			_alpha = 0f;
			StartFadeIn();
		}

		private IEnumerator FadeIn()
		{
			if (_pulseTimes >= 4)
			{
				stopRendering = true;
				yield break;
			}
			while (_alpha < 1f)
			{
				_alpha += Math.Min(0.01f * (animationSpeed * internalSpeedMultiplier * Time.deltaTime), 1f);
				yield return null;
			}
			_pulseTimes++;
			_alpha = 1f;
			StartFadeOut();
		}
	}
	public class FadeAnimation : WarningAnimation
	{
		private const float ALPHA_CHANGE_VALUE = 0.01f;

		private float _alpha;

		private int _pulseTimes;

		private bool _started;

		public override string AnimationName => "Fading";

		internal static void Initialize()
		{
			AnimationManager.AddAnimation("Fading", typeof(FadeAnimation));
		}

		protected override void OnGuiUpdate()
		{
			//IL_003d: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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)
			if (!_started)
			{
				_started = true;
				StartFadeIn();
			}
			position = new Vector2((float)Screen.width - textSize.x, (float)Screen.height / 2f);
			Color color = default(Color);
			((Color)(ref color))..ctor(1f, 0f, 0f, _alpha);
			Color color2 = default(Color);
			((Color)(ref color2))..ctor(textColor.r, textColor.g, textColor.b, _alpha);
			GUI.color = color;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(position.x, position.y, textSize.x, textSize.y);
			GUI.DrawTexture(val, (Texture)(object)texture2D);
			GUI.color = color2;
			GUI.Label(val, text, textStyle);
		}

		public override void SpeedUp()
		{
			stopRendering = true;
		}

		public void StartFadeOut()
		{
			((MonoBehaviour)this).StartCoroutine(FadeOut());
		}

		public void StartFadeIn()
		{
			((MonoBehaviour)this).StartCoroutine(FadeIn());
		}

		private IEnumerator FadeOut()
		{
			while (_alpha > 0f)
			{
				_alpha -= 0.01f * Math.Max(animationSpeed * internalSpeedMultiplier * Time.deltaTime, 0f);
				yield return null;
			}
			_alpha = 0f;
			StartFadeIn();
		}

		private IEnumerator FadeIn()
		{
			if (_pulseTimes >= 1)
			{
				stopRendering = true;
				yield break;
			}
			while (_alpha < 1f)
			{
				_alpha += Math.Min(0.01f * (animationSpeed * internalSpeedMultiplier * Time.deltaTime), 1f);
				yield return null;
			}
			_pulseTimes++;
			_alpha = 1f;
			yield return (object)new WaitForSeconds(3f);
			StartFadeOut();
		}
	}
	public class SlidingAnimation : WarningAnimation
	{
		private readonly Vector2 _slideDirection = new Vector2(1f, 0f);

		private bool _started;

		public override string AnimationName => "Sliding";

		internal static void Initialize()
		{
			AnimationManager.AddAnimation("Sliding", typeof(SlidingAnimation));
		}

		protected override void OnGuiUpdate()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_005d: 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_00a2: 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)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (!_started)
			{
				_started = true;
				position = new Vector2(0f - textSize.x, 10f);
			}
			position += _slideDirection * (animationSpeed * internalSpeedMultiplier * Time.deltaTime);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(position.x, position.y, textSize.x, textSize.y);
			GUI.DrawTexture(val, (Texture)(object)texture2D);
			GUI.Label(val, text, textStyle);
			if (position.x > textSize.x + (float)Screen.width)
			{
				stopRendering = true;
			}
		}
	}
}
namespace AnnounceMoonAndWeatherChange.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	public static class StartOfRoundPatch
	{
		private static bool _gameFinishedLoading;

		[HarmonyPatch("Awake")]
		[HarmonyPrefix]
		public static void BeforeAwake()
		{
			_gameFinishedLoading = false;
		}

		[HarmonyPatch("SetShipReadyToLand")]
		[HarmonyPostfix]
		public static void AfterSetShipReadyToLand()
		{
			MessageSender.SendWeatherWarning();
		}

		[HarmonyPatch("ChangeLevel")]
		[HarmonyPostfix]
		public static void AfterChangeLevel()
		{
			if (!_gameFinishedLoading)
			{
				Timer timer = null;
				timer = new Timer(delegate
				{
					_gameFinishedLoading = true;
					HandleChangeLevel();
					timer?.Dispose();
				}, null, 3500L, -1L);
			}
			else
			{
				HandleChangeLevel();
			}
		}

		private static void HandleChangeLevel()
		{
			MessageSender.SendWeatherWarning();
			MessageSender.SendMoonChangeAnnouncement();
		}
	}
}
namespace AnnounceMoonAndWeatherChange.LobbyCompatibility
{
	internal static class LobbyCompatibilitySupport
	{
		internal static void Initialize()
		{
			PluginHelper.RegisterPlugin("TestAccount666.AnnounceMoonAndWeatherChange", new Version("2.0.5"), (CompatibilityLevel)0, (VersionStrictness)2);
		}
	}
}