using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using FadeEffectMod; using HarmonyLib; using Il2CppGB.Core.Loading; using MelonLoader; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(FadeEffect), "FadeEffect", "1.0.0", "Zooks", null)] [assembly: MelonGame("Boneloaf", "Gang Beasts")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("FadeEffect")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("FadeEffect mod for Gang Beasts")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("FadeEffect")] [assembly: AssemblyTitle("FadeEffect")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 FadeEffectMod { public enum FadeState { None, FadingOut, FadedOut, FadingIn } public static class FadeManager { public static FadeState CurrentState = FadeState.None; public static float CurrentAlpha = 0f; public static float FadeOutSpeed = 1.15f; public static float FadeInSpeed = 3.5f; public static float FadeInDelay = 0.33f; public static float FadeInExponent = 1f; private static float _delayTimer = 0f; private static float _fadeProgress = 0f; public static void StartFadeOut() { CurrentState = FadeState.FadingOut; _fadeProgress = 0f; } public static void StartFadeIn() { CurrentState = FadeState.FadingIn; _delayTimer = FadeInDelay; _fadeProgress = 0f; } public static void ForceBlack() { CurrentState = FadeState.FadedOut; CurrentAlpha = 1f; _delayTimer = 0f; _fadeProgress = 0f; } public static void Update() { float unscaledDeltaTime = Time.unscaledDeltaTime; if (CurrentState == FadeState.FadingOut) { _fadeProgress += unscaledDeltaTime * FadeOutSpeed; if (_fadeProgress >= 1f) { _fadeProgress = 1f; CurrentState = FadeState.FadedOut; } CurrentAlpha = _fadeProgress; } else { if (CurrentState != FadeState.FadingIn) { return; } if (_delayTimer > 0f) { _delayTimer -= unscaledDeltaTime; CurrentAlpha = 1f; return; } _fadeProgress += unscaledDeltaTime * FadeInSpeed; if (_fadeProgress >= 1f) { _fadeProgress = 1f; CurrentState = FadeState.None; } CurrentAlpha = 1f - Mathf.Pow(_fadeProgress, FadeInExponent); } } } public class FadeEffect : MelonMod { private static GameObject _fadeCanvasObject; private static Canvas _fadeCanvas; private static RawImage _fadeImage; public override void OnUpdate() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) EnsureFadeCanvasExists(); FadeManager.Update(); if ((Object)(object)_fadeImage != (Object)null && (Object)(object)_fadeCanvasObject != (Object)null) { ((Graphic)_fadeImage).color = new Color(0f, 0f, 0f, FadeManager.CurrentAlpha); bool flag = FadeManager.CurrentAlpha > 0f; if (_fadeCanvasObject.activeSelf != flag) { _fadeCanvasObject.SetActive(flag); } } } private static void EnsureFadeCanvasExists() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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) if ((Object)(object)_fadeCanvasObject != (Object)null && (Object)(object)_fadeImage != (Object)null) { return; } try { _fadeCanvasObject = new GameObject("CustomFadeCanvas"); Object.DontDestroyOnLoad((Object)(object)_fadeCanvasObject); _fadeCanvas = _fadeCanvasObject.AddComponent(); _fadeCanvas.renderMode = (RenderMode)0; _fadeCanvas.sortingOrder = 999999; GameObject val = new GameObject("FadeImage"); val.transform.SetParent(_fadeCanvasObject.transform, false); _fadeImage = val.AddComponent(); ((Graphic)_fadeImage).color = new Color(0f, 0f, 0f, 0f); RectTransform component = ((Component)_fadeImage).GetComponent(); component.anchorMin = new Vector2(0f, 0f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(0.5f, 0.5f); component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; _fadeCanvasObject.SetActive(false); } catch (Exception) { } } } [HarmonyPatch(typeof(LoadScreenSystem))] public static class LoadScreenSystemPatches { [HarmonyPatch("ShowLoadingScreen")] [HarmonyPrefix] public static void ShowLoadingScreenPrefix() { try { FadeManager.ForceBlack(); } catch (Exception) { } } [HarmonyPatch("HideLoadingScreen")] [HarmonyPrefix] public static void HideLoadingScreenPrefix() { try { FadeManager.StartFadeIn(); } catch (Exception) { } } } }