using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using Zorro.Core;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CWChat")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Adding text chat to Content Warning")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CWChat")]
[assembly: AssemblyTitle("CWChat")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace CWChat
{
public class ChatNet : MonoBehaviour, IOnEventCallback
{
public List<MsgData> Messages = new List<MsgData>();
private Vector2 scroll = new Vector2(0f, 0f);
public static byte CHAT_MESSAGE_CODE = 16;
public static float OffsetY = -5f;
public static int MaxMessages = 9;
public static Vector2 Size = new Vector2(3000f, 200f);
private string editMessage = "";
private bool showedChat;
private float stopEscapeMenuTime;
private GUIStyle style = new GUIStyle();
private bool tryFocus;
private void Awake()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
style.fontSize = 16;
style.richText = true;
style.normal.textColor = Color.white;
}
private void LateUpdate()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Invalid comparison between Unknown and I4
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Invalid comparison between Unknown and I4
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
if (showedChat)
{
Cursor.lockState = (CursorLockMode)0;
bool flag = false;
if ((int)Event.current.keyCode == 13)
{
if (editMessage.Length > 0)
{
SendMessage(new MsgData(((TMP_Text)Player.localPlayer.refs.visor.visorFaceText).text, editMessage, Player.localPlayer.data.dead, "#" + ColorUtility.ToHtmlStringRGB(Player.localPlayer.refs.visor.visorColor.Value)));
}
flag = true;
}
if ((int)Event.current.keyCode == 27)
{
flag = true;
}
if (flag)
{
GUI.FocusControl((string)null);
Cursor.lockState = (CursorLockMode)1;
editMessage = "";
showedChat = false;
}
stopEscapeMenuTime = 0.2f;
}
else
{
tryFocus = false;
if (Input.GetKeyDown((KeyCode)116))
{
showedChat = true;
}
}
if (stopEscapeMenuTime > 0f)
{
stopEscapeMenuTime -= 1f * Time.deltaTime;
if (Singleton<EscapeMenu>.Instance.Open)
{
Singleton<EscapeMenu>.Instance.Toggle();
}
}
}
private void OnGUI()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
float num = (float)Screen.width / 1728f;
float num2 = (float)Screen.height / 972f;
GUI.matrix = Matrix4x4.TRS(new Vector3(0f, 0f, 0f), Quaternion.identity, new Vector3(num, num2, 1f));
if (showedChat)
{
GUI.SetNextControlName("ChatTextField");
editMessage = GUI.TextField(new Rect(25f, Size.y + 30f + (float)Screen.height * 0.5f + OffsetY, 600f, 30f), editMessage, 256, style);
if (!tryFocus)
{
GUI.FocusControl("ChatTextField");
tryFocus = true;
}
}
GUILayout.BeginArea(new Rect(25f, (float)Screen.height * 0.5f + OffsetY, Size.x, Size.y + 10f));
scroll = GUILayout.BeginScrollView(scroll, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(Size.x),
GUILayout.Height(Size.y + 10f)
});
for (int i = 0; i < Messages.Count; i++)
{
MsgData msgData = Messages[i];
if (!msgData.dead)
{
GUILayout.Label("<color=" + msgData.hex + ">" + msgData.name + "</color> " + msgData.message, style, Array.Empty<GUILayoutOption>());
}
else
{
GUILayout.Label("<color=red>*DEAD*</color> <color=" + msgData.hex + ">" + msgData.name + "</color> " + msgData.message, style, Array.Empty<GUILayoutOption>());
}
}
GUILayout.EndScrollView();
GUILayout.EndArea();
}
public void SendMessage(MsgData msg)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
RaiseEventOptions val = new RaiseEventOptions
{
Receivers = (ReceiverGroup)1
};
PhotonNetwork.RaiseEvent(CHAT_MESSAGE_CODE, (object)new object[4] { msg.name, msg.message, msg.dead, msg.hex }, val, SendOptions.SendReliable);
}
public void AddNewMessage(MsgData msg)
{
if (Messages.Count >= MaxMessages)
{
Messages.RemoveAt(0);
}
Messages.Add(msg);
scroll.y = float.PositiveInfinity;
}
public void OnEvent(EventData photonEvent)
{
if (photonEvent.Code == CHAT_MESSAGE_CODE)
{
object[] array = (object[])photonEvent.CustomData;
AddNewMessage(new MsgData(array[0].ToString(), array[1].ToString(), (bool)array[2], array[3].ToString()));
}
}
private void OnEnable()
{
PhotonNetwork.AddCallbackTarget((object)this);
}
private void OnDisable()
{
PhotonNetwork.RemoveCallbackTarget((object)this);
}
}
public struct MsgData
{
public string name;
public string message;
public bool dead;
public string hex;
public MsgData(string name, string message, bool dead, string hex)
{
this.name = name;
this.message = message;
this.dead = dead;
this.hex = hex;
}
}
[BepInPlugin("CWChat", "CWChat", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static Plugin I;
private Harmony _harmony;
private void Awake()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
I = this;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin CWChat is loaded!");
_harmony = new Harmony("CWChatPatch");
_harmony.PatchAll();
}
public static void Log(object obj)
{
((BaseUnityPlugin)I).Logger.LogInfo((object)obj.ToString());
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "CWChat";
public const string PLUGIN_NAME = "CWChat";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace CWChat.Patches
{
[HarmonyPatch(typeof(Player))]
public static class PlayerPatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void Awake(Player __instance)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
if (__instance.IsLocal)
{
new GameObject("ChatManager").AddComponent<ChatNet>();
Plugin.Log("Created ChatManager");
}
}
}
}