using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Peak.Afflictions;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.VegChicks.TempStatus")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+461492a4bc407cfe060e9637bf1216a3a763f9f1")]
[assembly: AssemblyProduct("com.github.VegChicks.TempStatus")]
[assembly: AssemblyTitle("TempStatus")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace TempStatus
{
[BepInPlugin("com.github.VegChicks.TempStatus", "TempStatus", "0.1.0")]
public class Plugin : BaseUnityPlugin
{
private GameObject? canvasObj;
private Text? statusText;
private float updateTimer;
private const float updateInterval = 0.1f;
private ConfigEntry<float>? distanceVisibilityOffsetConfig;
private ConfigEntry<float>? fogTintColorRConfig;
private ConfigEntry<float>? fogTintColorGConfig;
private ConfigEntry<float>? fogTintColorBConfig;
private ConfigEntry<float>? fogTintColorAConfig;
private Harmony? harmony;
public const string Id = "com.github.VegChicks.TempStatus";
internal static ManualLogSource Log { get; private set; } = null;
internal static float DistanceVisibilityOffset { get; private set; } = 30f;
internal static Vector4 FogTintColor { get; private set; } = new Vector4(0.72067463f, 0.7391309f, 79f / 106f, 0f);
public static string Name => "TempStatus";
public static string Version => "0.1.0";
private void Awake()
{
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
distanceVisibilityOffsetConfig = ((BaseUnityPlugin)this).Config.Bind<float>("FogSettings", "DistanceVisibilityOffset", 30f, "Controls the _DistanceVisibilityOffset material property for fog spheres. Default: 30");
DistanceVisibilityOffset = distanceVisibilityOffsetConfig.Value;
distanceVisibilityOffsetConfig.SettingChanged += delegate
{
DistanceVisibilityOffset = distanceVisibilityOffsetConfig.Value;
Log.LogInfo((object)$"DistanceVisibilityOffset updated to: {DistanceVisibilityOffset}");
};
fogTintColorRConfig = ((BaseUnityPlugin)this).Config.Bind<float>("FogSettings", "FogTintColorR", 0.72067463f, "Red component of _FogtintColor material property. Default: 0.72067463");
fogTintColorGConfig = ((BaseUnityPlugin)this).Config.Bind<float>("FogSettings", "FogTintColorG", 0.7391309f, "Green component of _FogtintColor material property. Default: 0.7391309");
fogTintColorBConfig = ((BaseUnityPlugin)this).Config.Bind<float>("FogSettings", "FogTintColorB", 79f / 106f, "Blue component of _FogtintColor material property. Default: 0.745283");
fogTintColorAConfig = ((BaseUnityPlugin)this).Config.Bind<float>("FogSettings", "FogTintColorA", 0f, "Alpha component of _FogtintColor material property. Default: 0");
UpdateFogTintColor();
fogTintColorRConfig.SettingChanged += delegate
{
UpdateFogTintColor();
};
fogTintColorGConfig.SettingChanged += delegate
{
UpdateFogTintColor();
};
fogTintColorBConfig.SettingChanged += delegate
{
UpdateFogTintColor();
};
fogTintColorAConfig.SettingChanged += delegate
{
UpdateFogTintColor();
};
harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
harmony.PatchAll();
Log.LogInfo((object)"Harmony patches applied!");
SceneManager.sceneLoaded += OnSceneLoaded;
}
private void Update()
{
if ((Object)(object)statusText == (Object)null || (Object)(object)canvasObj == (Object)null)
{
GameObject val = GameObject.Find("TempStatusCanvas");
if ((Object)(object)val != (Object)null)
{
canvasObj = val;
Transform val2 = canvasObj.transform.Find("TempStatusText");
if ((Object)(object)val2 != (Object)null)
{
statusText = ((Component)val2).GetComponent<Text>();
}
}
if ((Object)(object)statusText == (Object)null || (Object)(object)canvasObj == (Object)null)
{
return;
}
}
updateTimer += Time.deltaTime;
if (updateTimer < 0.1f)
{
return;
}
updateTimer = 0f;
CharacterAfflictions val3 = Character.localCharacter?.refs?.afflictions;
if ((Object)(object)val3 == (Object)null)
{
if ((Object)(object)statusText != (Object)null)
{
statusText.text = GetDisplayTextWithTimestamp("Waiting for player...");
}
return;
}
if ((Object)(object)canvasObj == (Object)null || (Object)(object)statusText == (Object)null)
{
CreateUI();
}
List<string> list;
try
{
list = ReadAfflictions(val3);
}
catch (Exception arg)
{
Log.LogError((object)$"Exception in ReadAfflictions: {arg}");
list = new List<string>();
}
if ((Object)(object)statusText != (Object)null)
{
string displayTextWithTimestamp;
if (list.Count == 0)
{
displayTextWithTimestamp = GetDisplayTextWithTimestamp("No active afflictions");
}
else
{
string text = "Affliction | Remaining | Total | Elapsed | Bonus";
string text2 = new string('-', text.Length);
string text3 = string.Join("\n", list);
displayTextWithTimestamp = GetDisplayTextWithTimestamp(text + "\n" + text2 + "\n" + text3);
}
statusText.text = displayTextWithTimestamp;
}
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
if (((Scene)(ref scene)).name == "Title" || ((Scene)(ref scene)).name == "Airport" || ((Scene)(ref scene)).name == "Pretitle")
{
if ((Object)(object)canvasObj != (Object)null)
{
Object.Destroy((Object)(object)canvasObj);
canvasObj = null;
statusText = null;
}
}
else
{
CreateUI();
}
}
private void CreateUI()
{
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Expected O, but got Unknown
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Expected O, but got Unknown
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)GameObject.Find("TempStatusCanvas") != (Object)null)
{
if ((Object)(object)canvasObj == (Object)null)
{
canvasObj = GameObject.Find("TempStatusCanvas");
}
if ((Object)(object)statusText == (Object)null && (Object)(object)canvasObj != (Object)null)
{
Transform val = canvasObj.transform.Find("TempStatusText");
if ((Object)(object)val != (Object)null)
{
statusText = ((Component)val).GetComponent<Text>();
}
}
return;
}
canvasObj = new GameObject("TempStatusCanvas");
Canvas val2 = canvasObj.AddComponent<Canvas>();
val2.renderMode = (RenderMode)0;
val2.sortingOrder = 1000;
CanvasScaler val3 = canvasObj.AddComponent<CanvasScaler>();
val3.uiScaleMode = (ScaleMode)1;
val3.referenceResolution = new Vector2(1920f, 1080f);
val3.matchWidthOrHeight = 0.5f;
GameObject val4 = new GameObject("TempStatusText");
val4.transform.SetParent(canvasObj.transform, false);
statusText = val4.AddComponent<Text>();
statusText.text = GetDisplayTextWithTimestamp("Loading...");
((Graphic)statusText).raycastTarget = false;
statusText.font = Resources.GetBuiltinResource<Font>("CourierNew.ttf");
if ((Object)(object)statusText.font == (Object)null)
{
statusText.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
}
if ((Object)(object)statusText.font == (Object)null)
{
statusText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
}
if ((Object)(object)statusText.font == (Object)null)
{
Font[] array = Resources.FindObjectsOfTypeAll<Font>();
if (array.Length != 0)
{
statusText.font = array[0];
}
}
statusText.fontSize = 12;
((Graphic)statusText).color = Color.white;
statusText.alignment = (TextAnchor)0;
statusText.horizontalOverflow = (HorizontalWrapMode)1;
statusText.verticalOverflow = (VerticalWrapMode)1;
RectTransform component = val4.GetComponent<RectTransform>();
component.anchorMin = new Vector2(0f, 1f);
component.anchorMax = new Vector2(0f, 1f);
component.pivot = new Vector2(0f, 1f);
component.anchoredPosition = new Vector2(10f, -10f);
component.sizeDelta = new Vector2(700f, 800f);
Log.LogInfo((object)"UI created!");
}
private string GetDisplayTextWithTimestamp(string text)
{
string text2 = DateTime.Now.ToString("HH:mm:ss.fff");
return "[" + text2 + "]\n" + text;
}
private List<string> ReadAfflictions(CharacterAfflictions afflictions)
{
//IL_02b1: 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_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: 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_00be: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
List<string> list = new List<string>();
Log.LogInfo((object)"ReadAfflictions: Starting");
if ((Object)(object)afflictions == (Object)null)
{
Log.LogWarning((object)"ReadAfflictions: afflictions is null");
return list;
}
IEnumerable<AfflictionType> enumerable = Enum.GetValues(typeof(AfflictionType)).Cast<AfflictionType>();
Log.LogInfo((object)$"ReadAfflictions: Found {enumerable.Count()} affliction types in enum");
Dictionary<AfflictionType, List<Affliction>> dictionary = new Dictionary<AfflictionType, List<Affliction>>();
try
{
if (afflictions.afflictionList != null)
{
Log.LogInfo((object)$"ReadAfflictions: Found {afflictions.afflictionList.Count} afflictions in list");
foreach (Affliction affliction in afflictions.afflictionList)
{
if (affliction == null)
{
continue;
}
try
{
AfflictionType afflictionType = affliction.GetAfflictionType();
if (!dictionary.ContainsKey(afflictionType))
{
dictionary[afflictionType] = new List<Affliction>();
}
dictionary[afflictionType].Add(affliction);
}
catch (Exception ex)
{
Log.LogWarning((object)("ReadAfflictions: Error getting affliction type: " + ex.Message));
}
}
}
else
{
Log.LogInfo((object)"ReadAfflictions: afflictionList is null");
}
}
catch (Exception ex2)
{
Log.LogWarning((object)("ReadAfflictions: Error accessing afflictionList: " + ex2.Message));
Log.LogWarning((object)("ReadAfflictions: Stack trace: " + ex2.StackTrace));
}
foreach (AfflictionType item in enumerable)
{
AfflictionType current2 = item;
try
{
string arg = FormatAfflictionName(((object)(AfflictionType)(ref current2)).ToString()).TrimEnd();
if (dictionary.TryGetValue(current2, out var value) && value.Count > 0)
{
for (int i = 0; i < value.Count; i++)
{
Affliction val = value[i];
string text = $"{arg} #{i + 1}";
float totalTime = val.totalTime;
float timeElapsed = val.timeElapsed;
float bonusTime = val.bonusTime;
float num = totalTime - timeElapsed;
list.Add($"{text} | {num:F1}s | {totalTime:F1}s | {timeElapsed:F1}s | {bonusTime:F1}s");
Log.LogInfo((object)$"ReadAfflictions: {text.TrimEnd()} - Remaining={num:F1}s, Total={totalTime:F1}s, Elapsed={timeElapsed:F1}s, Bonus={bonusTime:F1}s");
}
}
}
catch (Exception ex3)
{
Log.LogWarning((object)$"ReadAfflictions: Error processing affliction type {current2}: {ex3.Message}");
}
}
Log.LogInfo((object)$"ReadAfflictions: Completed - Listed {list.Count} affliction types");
return list;
}
private string FormatAfflictionName(string afflictionType)
{
return Regex.Replace(afflictionType, "([a-z])([A-Z])", "$1 $2");
}
private void UpdateFogTintColor()
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
FogTintColor = new Vector4(fogTintColorRConfig?.Value ?? 0.72067463f, fogTintColorGConfig?.Value ?? 0.7391309f, fogTintColorBConfig?.Value ?? (79f / 106f), fogTintColorAConfig?.Value ?? 0f);
Log.LogInfo((object)$"FogTintColor updated to: R={FogTintColor.x}, G={FogTintColor.y}, B={FogTintColor.z}, A={FogTintColor.w}");
}
private void OnDestroy()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
Harmony? obj = harmony;
if (obj != null)
{
obj.UnpatchSelf();
}
if ((Object)(object)canvasObj != (Object)null)
{
Object.Destroy((Object)(object)canvasObj);
}
}
}
[HarmonyPatch(typeof(FogSphere), "SetSharderVars")]
public static class FogSphereSetSharderVarsPatch
{
private static void Postfix(FogSphere __instance)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
if (__instance.mpb != null && (Object)(object)__instance.rend != (Object)null)
{
__instance.mpb.SetFloat("_DistanceVisibilityOffset", Plugin.DistanceVisibilityOffset);
__instance.mpb.SetVector("_FogtintColor", Plugin.FogTintColor);
__instance.rend.SetPropertyBlock(__instance.mpb);
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}