using System;
using System.Collections;
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 System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ChatBox.NonPatch;
using ChatBox.Patch;
using ChatBox.Single;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using TMPro;
using Unity.VisualScripting;
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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ChatBox")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+68f672046a362d07549235a3846638011556063a")]
[assembly: AssemblyProduct("ChatBox")]
[assembly: AssemblyTitle("ChatBox")]
[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.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 ChatBox
{
internal class ConfigManager
{
public ExtendedConfigEntry<bool> EnableConfiguration;
public ExtendedConfigEntry<float> lateTargetAlpha;
public ExtendedConfigEntry<bool> startMessageEnabled;
public ExtendedConfigEntry<float> fadeDelay;
public ExtendedConfigEntry<float> startAlpha;
public ExtendedConfigEntry<int> messageLimit;
public ExtendedConfigEntry<float> chatBox_X;
public ExtendedConfigEntry<float> chatBox_Y;
public ConfigManager()
{
BindConfigs();
ClearUnusedEntries();
}
private void BindConfigs()
{
EnableConfiguration = new ExtendedConfigEntry<bool>("General Settings", "EnableConfiguration", defaultValue: false, "Enable if you want to use custom set config setting values. If disabled, the default config setting values will be used.");
lateTargetAlpha = new ExtendedConfigEntry<float>("General Settings", "AfterFadeVisibility", 0.2f, "How visible the chat box is going to be after fading.", useEnableConfiguration: true);
startMessageEnabled = new ExtendedConfigEntry<bool>("General Settings", "StartMessageEnabled", defaultValue: true, "If enabled, TAXMAN will post 'ChatBox active!' in the chat each time a level starts.", useEnableConfiguration: true);
fadeDelay = new ExtendedConfigEntry<float>("General Settings", "FadeDelay", 4f, "How long the chat box will stay visible before fading.", useEnableConfiguration: true);
startAlpha = new ExtendedConfigEntry<float>("General Settings", "BeforeFadeVisibility", 1f, "How visible the chat box is going to be before fading.", useEnableConfiguration: true);
messageLimit = new ExtendedConfigEntry<int>("General Settings", "MessageLimit", 4, "How many messages will be shown on the screen.", useEnableConfiguration: true);
chatBox_X = new ExtendedConfigEntry<float>("General Settings", "ChatBox_X", 107f, "ChatBox X position.", useEnableConfiguration: true);
chatBox_Y = new ExtendedConfigEntry<float>("General Settings", "ChatBox_Y", 100f, "ChatBox Y position.", useEnableConfiguration: true);
}
private void ClearUnusedEntries()
{
ConfigFile config = ((BaseUnityPlugin)ChatBox.Instance).Config;
PropertyInfo property = ((object)config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(config, null);
dictionary.Clear();
config.Save();
}
}
public class ExtendedConfigEntry<T>
{
public ConfigEntry<T> ConfigEntry;
public Func<T> GetValue;
public Action<T> SetValue;
public bool UseEnableConfiguration = false;
public T DefaultValue => (T)((ConfigEntryBase)ConfigEntry).DefaultValue;
public T Value
{
get
{
return GetValue();
}
set
{
SetValue(value);
}
}
public ExtendedConfigEntry(string section, string key, T defaultValue, string description, bool useEnableConfiguration = false)
{
ConfigEntry = ((BaseUnityPlugin)ChatBox.Instance).Config.Bind<T>(section, key, defaultValue, description);
UseEnableConfiguration = useEnableConfiguration;
Initialize();
}
public ExtendedConfigEntry(string section, string key, T defaultValue, ConfigDescription configDescription = null, bool useEnableConfiguration = false)
{
ConfigEntry = ((BaseUnityPlugin)ChatBox.Instance).Config.Bind<T>(section, key, defaultValue, configDescription);
UseEnableConfiguration = useEnableConfiguration;
Initialize();
}
private void Initialize()
{
if (GetValue == null)
{
GetValue = () => (UseEnableConfiguration && !ChatBox.ConfigManager.EnableConfiguration.Value) ? DefaultValue : ConfigEntry.Value;
}
if (SetValue == null)
{
SetValue = delegate(T value)
{
ConfigEntry.Value = value;
};
}
}
public void ResetToDefault()
{
ConfigEntry.Value = (T)((ConfigEntryBase)ConfigEntry).DefaultValue;
}
}
[BepInPlugin("ChatBox-UnloadedHangar", "ChatBox", "1.0.8")]
public class ChatBox : BaseUnityPlugin
{
public static class PluginInfo
{
public const string Guid = "ChatBox-UnloadedHangar";
public const string Name = "ChatBox";
public const string Ver = "1.0.8";
}
internal static ManualLogSource logger;
internal static ChatBox Instance;
internal static ConfigManager ConfigManager;
private Harmony _harmony;
private void Awake()
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
logger = Logger.CreateLogSource("ChatBox-UnloadedHangar");
logger.LogInfo((object)"ChatBox-UnloadedHangar loaded");
ConfigManager = new ConfigManager();
_harmony = new Harmony("ChatBox-UnloadedHangar");
_harmony.PatchAll();
}
}
public class Singleton<T> : MonoBehaviour where T : Component
{
private static T _instance;
public static T Instance
{
get
{
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Expected O, but got Unknown
if ((Object)(object)_instance == (Object)null)
{
T[] array = Object.FindObjectsOfType(typeof(T)) as T[];
if (array.Length != 0)
{
_instance = array[0];
}
if (array.Length > 1)
{
ChatBox.logger.LogError((object)("There is more than one " + typeof(T).Name + " in the scene."));
}
if ((Object)(object)_instance == (Object)null)
{
GameObject val = new GameObject();
((Object)val).name = "_" + typeof(T).Name;
_instance = val.AddComponent<T>();
}
}
return _instance;
}
}
}
}
namespace ChatBox.Patch
{
[HarmonyPatch]
internal class Patches : MonoBehaviour
{
internal static int i;
internal static GameObject ChatObject;
internal static GameObject ChatObjectMenu;
[HarmonyPrefix]
[HarmonyPatch(typeof(GameDirector), "Start")]
private static void FlashlightPatch()
{
if (SemiFunc.IsMultiplayer() & (SemiFunc.RunIsLevel() | SemiFunc.RunIsShop() | SemiFunc.RunIsLobby()))
{
try
{
ChatObject = ((Component)Singleton<global::ChatBox.Single.ChatObject>.Instance).gameObject;
((Object)ChatObject).name = "ChatObject";
ChatObject.transform.parent = ((Component)((Component)GoalUI.instance).transform.parent).transform;
ChatObject.layer = 5;
ChatObject.AddComponent<RectTransform>();
return;
}
catch (Exception arg)
{
ChatBox.logger.LogError((object)$"Construction error {arg}");
return;
}
}
if (SemiFunc.RunIsLobbyMenu())
{
try
{
ChatObjectMenu = ((Component)Singleton<global::ChatBox.Single.ChatObject>.Instance).gameObject;
((Object)ChatObjectMenu).name = "ChatObjectMenu";
ChatObjectMenu.transform.parent = ((Component)((Component)GoalUI.instance).transform.parent).transform;
ChatObjectMenu.layer = 5;
ChatObjectMenu.AddComponent<RectTransform>();
}
catch (Exception arg2)
{
ChatBox.logger.LogError((object)$"Lobby construction error {arg2}");
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ChatManager), "StateActive")]
private static void ChatManagerPatch()
{
try
{
if (SemiFunc.InputDown((InputKey)9) && ChatManager.instance.chatMessage != "")
{
PhotonView val = PhotonView.Get((Component)(object)NonPatches.Instance);
val.RPC("BridgedMessage", (RpcTarget)0, new object[3]
{
ChatManager.instance.chatMessage,
NonPatches.Instance.GetLocalPlayerColorSafe(),
PlayerAvatar.instance.playerName
});
}
}
catch (Exception arg)
{
ChatBox.logger.LogError((object)$"Unsupported chat action! {arg}");
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GameDirector), "Start")]
private static void ObjectSpawnPatch()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
GameObject val = new GameObject("NonPatchesObj");
val.AddComponent<NonPatches>();
val.AddComponent<PhotonView>().ViewID = 789546446;
}
}
}
namespace ChatBox.NonPatch
{
public class NonPatches : MonoBehaviour
{
public string lastChatMessage = "";
public List<string> ChatMessageHistory = new List<string>();
internal string MessageText = "";
internal string MessageTextInserted = "";
public static NonPatches Instance { get; private set; }
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
}
internal int CheckMessageLimit()
{
if (ChatBox.ConfigManager.messageLimit.Value.ToString().Contains("-"))
{
ChatBox.ConfigManager.messageLimit.Value = ChatBox.ConfigManager.messageLimit.DefaultValue;
ChatBox.logger.LogWarning((object)"Negative number detected in MessageLimit variable, reseting to default value to avoid conflicts...");
return 1;
}
return 0;
}
internal void AddChatMessage(string chatMessage, string hexColorOfPlayerWhoTyped, string nameOfUserWhoTyped = "")
{
if (!(lastChatMessage == chatMessage))
{
lastChatMessage = chatMessage;
FadeChatTarget(ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>(), ChatBox.ConfigManager.fadeDelay.Value, ChatBox.ConfigManager.startAlpha.Value, ChatBox.ConfigManager.lateTargetAlpha.Value);
if (ChatMessageHistory.Count >= ChatBox.ConfigManager.messageLimit.Value)
{
((TMP_Text)ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>()).text.Remove(0, ChatMessageHistory[0].Length);
ChatMessageHistory.Remove(ChatMessageHistory[0]);
}
StringBuilder stringBuilder = new StringBuilder(chatMessage);
stringBuilder.Replace("@player1", GetLobbyPlayerNameSafe(0));
stringBuilder.Replace("@player2", GetLobbyPlayerNameSafe(1));
stringBuilder.Replace("@player3", GetLobbyPlayerNameSafe(2));
stringBuilder.Replace("@player4", GetLobbyPlayerNameSafe(3));
stringBuilder.Replace("@player5", GetLobbyPlayerNameSafe(4));
stringBuilder.Replace("@player6", GetLobbyPlayerNameSafe(5));
chatMessage = stringBuilder.ToString();
string item = ((!string.IsNullOrEmpty(nameOfUserWhoTyped)) ? ("<color=#" + hexColorOfPlayerWhoTyped + "> " + nameOfUserWhoTyped + " </color>: <color=white> " + chatMessage + " </color>") : ("<color=#7069ff> " + chatMessage + " </color>"));
ChatMessageHistory.Add(item);
((TMP_Text)ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>()).text = "";
for (int i = 0; ChatMessageHistory.Count > i; i++)
{
TextMeshProUGUI component = ChatObject.ChatObjectInterface.GetComponent<TextMeshProUGUI>();
((TMP_Text)component).text = ((TMP_Text)component).text + "\n" + ChatMessageHistory[i];
}
}
}
[PunRPC]
internal void BridgedMessage(string message, string playerHexColor, string playerName)
{
Instance.AddChatMessage(message, playerHexColor, playerName);
}
internal string GetLobbyPlayerNameSafe(int index)
{
if (GameDirector.instance.PlayerList.Count > index)
{
return GameDirector.instance.PlayerList[index].playerName;
}
return "Empty slot";
}
internal Color GetLobbyPlayerColorSafe(int index)
{
//IL_0036: 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_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
if (GameDirector.instance.PlayerList.Count > index)
{
return GameDirector.instance.PlayerList[index].playerAvatarVisuals.color;
}
return Color.gray;
}
public void FadeChatTarget(TextMeshProUGUI target, float fadeDelay = 2f, float startAlpha = 1f, float lateTargetAlpha = 0.2f)
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
Coroutine val = ((MonoBehaviour)this).StartCoroutine(IFadeChat(target, fadeDelay, lateTargetAlpha));
if (fadeDelay == 0f && startAlpha == lateTargetAlpha)
{
((Graphic)target).color = new Color(1f, 1f, 1f, lateTargetAlpha);
return;
}
((Graphic)target).color = new Color(1f, 1f, 1f, startAlpha);
if (val != null)
{
((MonoBehaviour)this).StopCoroutine(val);
}
val = ((MonoBehaviour)this).StartCoroutine(IFadeChat(target, fadeDelay, lateTargetAlpha));
}
private IEnumerator IFadeChat(TextMeshProUGUI target, float fadeDelay, float targetAlpha)
{
yield return (object)new WaitForSeconds(fadeDelay);
((Graphic)target).color = new Color(1f, 1f, 1f, targetAlpha);
}
internal static void SetChatObjectCoords()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
Patches.ChatObject.transform.position = new Vector3(ChatBox.ConfigManager.chatBox_X.Value, ChatBox.ConfigManager.chatBox_Y.Value, 0f);
}
internal static void SetChatObjectMenuCoords()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
Patches.ChatObjectMenu.transform.position = new Vector3(615f, 100f, 0f);
}
internal string GetLocalPlayerColorSafe()
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; GameDirector.instance.PlayerList.Count > i; i++)
{
if (GameDirector.instance.PlayerList[i].playerName == PlayerAvatar.instance.playerName)
{
return XColor.ToHexString(GameDirector.instance.PlayerList[i].playerAvatarVisuals.color);
}
}
return "";
}
}
}
namespace ChatBox.LogClass
{
[Obsolete]
internal class Log
{
[Obsolete]
internal static ManualLogSource logSource;
[Obsolete]
internal static void Initalize(ManualLogSource LogSource)
{
logSource = LogSource;
}
[Obsolete]
internal static void LogDebug(object data)
{
logSource.LogDebug(data);
}
[Obsolete]
internal static void LogError(object data)
{
logSource.LogError(data);
}
[Obsolete]
internal static void LogFatal(object data)
{
logSource.LogFatal(data);
}
[Obsolete]
internal static void LogInfo(object data)
{
logSource.LogInfo(data);
}
[Obsolete]
internal static void LogMessage(object data)
{
logSource.LogMessage(data);
}
[Obsolete]
internal static void LogWarning(object data)
{
logSource.LogWarning(data);
}
}
}
namespace ChatBox.Single
{
internal class ChatObject : MonoBehaviour
{
internal static GameObject ChatObjectInterface;
internal static ChatObject instance { get; private set; }
private void Awake()
{
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
}
private void Start()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Expected O, but got Unknown
if (SemiFunc.IsMultiplayer() & (SemiFunc.RunIsLevel() | SemiFunc.RunIsShop() | SemiFunc.RunIsLobby()))
{
ChatObjectInterface = new GameObject("ChatObjectInterface");
ChatObjectInterface.transform.parent = Patches.ChatObject.transform;
ChatObjectInterface.layer = 5;
ChatObjectInterface.AddComponent<RectTransform>();
ChatObjectInterface.AddComponent<TextMeshProUGUI>();
((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).fontSize = 12f;
((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).characterSpacing = -3.77f;
((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).lineSpacing = -10f;
((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).alignment = (TextAlignmentOptions)1025;
if (ChatBox.ConfigManager.startMessageEnabled.Value)
{
((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).text = "<color=red>TAXMAN</color>: <color=white>ChatBox active!</color> \n";
NonPatches.Instance.ChatMessageHistory.Add("<color=red>TAXMAN</color>: <color=white>ChatBox active!</color> \n");
}
NonPatches.SetChatObjectCoords();
}
else if (SemiFunc.RunIsLobbyMenu())
{
ChatObjectInterface = new GameObject("ChatObjectInterface");
ChatObjectInterface.transform.parent = Patches.ChatObjectMenu.transform;
ChatObjectInterface.layer = 5;
ChatObjectInterface.AddComponent<RectTransform>();
ChatObjectInterface.AddComponent<TextMeshProUGUI>();
((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).fontSize = 12f;
((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).characterSpacing = -3.77f;
((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).lineSpacing = -10f;
((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).alignment = (TextAlignmentOptions)1025;
if (ChatBox.ConfigManager.startMessageEnabled.Value)
{
((TMP_Text)ChatObjectInterface.GetComponent<TextMeshProUGUI>()).text = "<color=red>TAXMAN</color>: <color=white>ChatBox active!</color> \n";
NonPatches.Instance.ChatMessageHistory.Add("<color=red>TAXMAN</color>: <color=white>ChatBox active!</color> \n");
}
NonPatches.SetChatObjectMenuCoords();
if (NonPatches.Instance.CheckMessageLimit() == 1)
{
((TMP_Text)Patches.ChatObject.GetComponent<TextMeshProUGUI>()).text = "<color=red>TAXMAN</color>: <color=white>Negative number detected in MessageLimit variable, reseting to default value to avoid conflicts...</color> \n";
NonPatches.Instance.ChatMessageHistory.Add("<color=red>TAXMAN</color>: <color=white>Negative number detected in MessageLimit variable, reseting to default value to avoid conflicts...</color> \n");
}
}
}
}
}