using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
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 = "")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("Pitan")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.2.0")]
[assembly: AssemblyInformationalVersion("0.0.2")]
[assembly: AssemblyProduct("ChatDurationPlus")]
[assembly: AssemblyTitle("ChatDurationPlus")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.2.0")]
[module: UnverifiableCode]
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;
}
}
}
namespace ChatDurationPlus
{
[BepInPlugin("Pitan.ChatDurationPlus", "ChatDurationPlus", "0.0.2")]
public class ChatDurationPlus : BaseUnityPlugin
{
internal static ChatDurationPlus Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
}
internal void Patch()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
private void Update()
{
}
}
[HarmonyPatch(typeof(LobbyChatUI))]
internal static class LobbyChatUIPatch
{
private static readonly ConditionalWeakTable<LobbyChatUI, TimerData> timers = new ConditionalWeakTable<LobbyChatUI, TimerData>();
private static readonly FieldInfo ttsVoiceField = AccessTools.Field(typeof(LobbyChatUI), "ttsVoice");
[HarmonyPostfix]
[HarmonyPatch("Update")]
private static void DisplayTimePatch(LobbyChatUI __instance)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
TimerData orCreateValue = timers.GetOrCreateValue(__instance);
TTSVoice val = (TTSVoice)ttsVoiceField.GetValue(__instance);
if ((Object)(object)val == (Object)null)
{
return;
}
if (val.isSpeaking)
{
orCreateValue.reset();
orCreateValue.lastText = val.voiceText;
}
else if (orCreateValue.extraTime > 0f)
{
orCreateValue.extraTime -= Time.deltaTime;
if (string.IsNullOrEmpty(((TMP_Text)((SemiUI)__instance).uiText).text))
{
((TMP_Text)((SemiUI)__instance).uiText).text = orCreateValue.lastText;
}
}
}
}
public class TimerData
{
public float extraTime = 15f;
public bool isInit = false;
public string lastText = "";
public static float defaultExtraTime;
public static string path;
static TimerData()
{
defaultExtraTime = 15f;
path = Path.Combine(Paths.ConfigPath, "ChatDurationPlus.json");
if (!File.Exists(path))
{
Directory.CreateDirectory(Path.GetDirectoryName(path));
File.WriteAllText(path, JsonConvert.SerializeObject((object)new
{
extraTime = defaultExtraTime
}, (Formatting)1));
return;
}
try
{
string text = File.ReadAllText(path);
TimerData timerData = JsonConvert.DeserializeObject<TimerData>(text);
if (timerData != null)
{
defaultExtraTime = timerData.extraTime;
}
}
catch
{
}
}
public void reset()
{
extraTime = defaultExtraTime;
isInit = false;
}
public TimerData()
{
extraTime = defaultExtraTime;
}
}
[HarmonyPatch(typeof(WorldSpaceUITTS))]
internal static class WorldSpaceUITTSPatch
{
private static readonly ConditionalWeakTable<WorldSpaceUITTS, TimerData> timers = new ConditionalWeakTable<WorldSpaceUITTS, TimerData>();
public static bool isExtend(WorldSpaceUITTS instance)
{
if ((Object)(object)instance.ttsVoice != (Object)null && instance.ttsVoice.isSpeaking)
{
timers.GetOrCreateValue(instance).reset();
return true;
}
if (timers.TryGetValue(instance, out TimerData value) && value.extraTime > 0f)
{
value.extraTime -= Time.deltaTime;
return true;
}
return false;
}
[HarmonyPostfix]
[HarmonyPatch("Update")]
private static void PostfixUpdate(WorldSpaceUITTS __instance)
{
//IL_009d: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
if (isExtend(__instance))
{
FieldInfo fieldInfo = AccessTools.Field(typeof(WorldSpaceUITTS), "textAlphaTarget");
FieldInfo fieldInfo2 = AccessTools.Field(typeof(WorldSpaceUITTS), "textAlpha");
FieldInfo fieldInfo3 = AccessTools.Field(typeof(WorldSpaceUITTS), "textColor");
fieldInfo.SetValue(__instance, 1f);
float num = (float)fieldInfo2.GetValue(__instance);
float num2 = Mathf.Lerp(num, 1f, 30f * Time.deltaTime);
fieldInfo2.SetValue(__instance, num2);
Color val = (Color)fieldInfo3.GetValue(__instance);
((Graphic)__instance.text).color = new Color(val.r, val.g, val.b, num2);
}
}
}
[HarmonyPatch(typeof(Object), "Destroy", new Type[] { typeof(Object) })]
internal static class ObjectDestroyPatch
{
private static bool Prefix(Object obj)
{
GameObject val = (GameObject)(object)((obj is GameObject) ? obj : null);
if (val != null)
{
WorldSpaceUITTS component = val.GetComponent<WorldSpaceUITTS>();
if ((Object)(object)component != (Object)null && WorldSpaceUITTSPatch.isExtend(component))
{
return false;
}
}
return true;
}
}
}