using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CodeTalker.Networking;
using CodeTalker.Packets;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mirror;
using Nessie.ATLYSS.EasySettings;
using Nessie.ATLYSS.EasySettings.UIElements;
using Newtonsoft.Json;
using Steamworks;
using UnityEngine;
using UnityEngine.Events;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("OrbColors")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.2.0")]
[assembly: AssemblyInformationalVersion("1.2.2+fc32196c9e0d1c4fc5ce28459ea2b99d2cf71029")]
[assembly: AssemblyProduct("OrbColors")]
[assembly: AssemblyTitle("OrbColors")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.2.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;
}
}
}
internal static class LCMPluginInfo
{
public const string PLUGIN_GUID = "OrbColors";
public const string PLUGIN_NAME = "OrbColors";
public const string PLUGIN_VERSION = "1.2.2";
}
namespace OrbColors
{
[BepInPlugin("OrbColors", "OrbColors", "1.2.2")]
public class Plugin : BaseUnityPlugin
{
[CompilerGenerated]
private static class <>O
{
public static PacketListener <0>__ReceiveOrbColorPacket;
public static PacketListener <1>__ReceivePlayerJoinPacket;
}
internal static ConfigEntry<bool> _orbColorEnabled;
internal static Dictionary<string, ConfigEntry<float>> _color = new Dictionary<string, ConfigEntry<float>>();
internal static ConfigEntry<float> _size;
internal static Dictionary<string, (bool _orbColorsEnabled, Color _color, float _size)> _playerOrbColors = new Dictionary<string, (bool, Color, float)>();
internal static List<BaseAtlyssElement> _settingsElements = new List<BaseAtlyssElement>();
internal static ManualLogSource Logger = null;
internal static ConfigFile Config = null;
private void Awake()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Expected O, but got Unknown
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Config = ((BaseUnityPlugin)this).Config;
Logger.LogInfo((object)"Plugin OrbColors version 1.2.2 is loaded!");
new Harmony("OrbColors").PatchAll(Assembly.GetExecutingAssembly());
((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
Settings.OnApplySettings.AddListener((UnityAction)delegate
{
((BaseUnityPlugin)this).Config.Save();
});
object obj = <>O.<0>__ReceiveOrbColorPacket;
if (obj == null)
{
PacketListener val = ReceiveOrbColorPacket;
<>O.<0>__ReceiveOrbColorPacket = val;
obj = (object)val;
}
CodeTalkerNetwork.RegisterListener<OrbColorPacket>((PacketListener)obj);
object obj2 = <>O.<1>__ReceivePlayerJoinPacket;
if (obj2 == null)
{
PacketListener val2 = ReceivePlayerJoinPacket;
<>O.<1>__ReceivePlayerJoinPacket = val2;
obj2 = (object)val2;
}
CodeTalkerNetwork.RegisterListener<PlayerJoinPacket>((PacketListener)obj2);
}
internal static void InitConfig()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Expected O, but got Unknown
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Expected O, but got Unknown
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Expected O, but got Unknown
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Expected O, but got Unknown
string text = $"File {ProfileDataManager._current._selectedFileIndex + 1}";
ConfigDefinition val = new ConfigDefinition(text, "OrbColorsEnabled");
ConfigDescription val2 = new ConfigDescription("Use Custom Orb Color?", (AcceptableValueBase)null, Array.Empty<object>());
_orbColorEnabled = Config.Bind<bool>(val, false, val2);
Dictionary<string, float> dictionary = new Dictionary<string, float>();
dictionary.Add("Red", 0.5f);
dictionary.Add("Green", 0.5f);
dictionary.Add("Blue", 0.5f);
foreach (KeyValuePair<string, float> item in dictionary)
{
item.Deconstruct(out var key, out var value);
string text2 = key;
float num = value;
ConfigDefinition val3 = new ConfigDefinition(text, "Shield" + text2);
ConfigDescription val4 = new ConfigDescription(text2, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>());
_color.Add(text2, Config.Bind<float>(val3, num, val4));
}
ConfigDefinition val5 = new ConfigDefinition(text, "ShieldSize");
ConfigDescription val6 = new ConfigDescription("Size", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>());
_size = Config.Bind<float>(val5, 6.5f, val6);
}
internal static void AddSettings()
{
SettingsTab modTab = Settings.ModTab;
_settingsElements.Add((BaseAtlyssElement)(object)modTab.AddHeader(ProfileDataManager._current._characterFile._nickName + "'s Shield Orb Color"));
_settingsElements.Add((BaseAtlyssElement)(object)modTab.AddToggle(((ConfigEntryBase)_orbColorEnabled).Description.Description, _orbColorEnabled));
foreach (var (text2, val2) in _color)
{
_settingsElements.Add((BaseAtlyssElement)(object)modTab.AddAdvancedSlider(text2, val2, false));
}
_settingsElements.Add((BaseAtlyssElement)(object)modTab.AddAdvancedSlider(((ConfigEntryBase)_size).Description.Description, _size, false));
}
internal static void SendOrbColorPacket()
{
if (NetworkClient.active)
{
OrbColorPacket orbColorPacket = new OrbColorPacket(_orbColorEnabled.Value, _color["Red"].Value, _color["Green"].Value, _color["Blue"].Value, _size.Value);
CodeTalkerNetwork.SendNetworkPacket((PacketBase)(object)orbColorPacket);
}
}
internal static void ReceiveOrbColorPacket(PacketHeader header, PacketBase packet)
{
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
if (!(packet is OrbColorPacket orbColorPacket))
{
return;
}
Logger.LogInfo((object)$"Packet Recieved | Plugin: {((PacketBase)orbColorPacket).PacketSourceGUID} | Steam ID: {header.SenderID} | PayLoad: {orbColorPacket.Enabled}, {orbColorPacket.Red}, {orbColorPacket.Green}, {orbColorPacket.Blue}, {orbColorPacket.Size}");
string key = header.SenderID.ToString();
if (orbColorPacket.Enabled)
{
Color item = default(Color);
((Color)(ref item))..ctor(orbColorPacket.Red, orbColorPacket.Green, orbColorPacket.Blue);
if (!_playerOrbColors.TryAdd(key, (orbColorPacket.Enabled, item, orbColorPacket.Size)))
{
_playerOrbColors[key] = (orbColorPacket.Enabled, item, orbColorPacket.Size);
}
}
else if (_playerOrbColors.ContainsKey(key))
{
_playerOrbColors.Remove(key);
}
}
internal static void ReceivePlayerJoinPacket(PacketHeader header, PacketBase packet)
{
if (packet is PlayerJoinPacket && _orbColorEnabled.Value)
{
string key = header.SenderID.ToString();
if (_playerOrbColors.ContainsKey(key))
{
_playerOrbColors.Remove(key);
}
SendOrbColorPacket();
}
}
internal static void SetOfflineOrbColor()
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: 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_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
if (AtlyssNetworkManager._current._soloMode)
{
Color item = default(Color);
((Color)(ref item))..ctor(_color["Red"].Value, _color["Green"].Value, _color["Blue"].Value);
Dictionary<string, (bool _orbColorsEnabled, Color _color, float _size)> playerOrbColors = _playerOrbColors;
CSteamID steamID = SteamUser.GetSteamID();
if (!playerOrbColors.TryAdd(((object)(CSteamID)(ref steamID)).ToString(), (_orbColorEnabled.Value, item, _size.Value)))
{
Dictionary<string, (bool _orbColorsEnabled, Color _color, float _size)> playerOrbColors2 = _playerOrbColors;
steamID = SteamUser.GetSteamID();
playerOrbColors2[((object)(CSteamID)(ref steamID)).ToString()] = (_orbColorEnabled.Value, item, _size.Value);
}
}
}
}
public class OrbColorPacket : PacketBase
{
public override string PacketSourceGUID => "OrbColors";
[JsonProperty]
public bool Enabled { get; set; }
[JsonProperty]
public float Red { get; set; }
[JsonProperty]
public float Green { get; set; }
[JsonProperty]
public float Blue { get; set; }
[JsonProperty]
public float Size { get; set; }
public OrbColorPacket(bool enabled, float red, float green, float blue, float size)
{
Enabled = enabled;
Red = red;
Green = green;
Blue = blue;
Size = size;
((PacketBase)this)..ctor();
}
}
public class PlayerJoinPacket : PacketBase
{
public override string PacketSourceGUID => "OrbColors";
}
[HarmonyPatch(typeof(PlayerCombat), "OnBlockingChange")]
internal class PlayerCombatPatch
{
[HarmonyPrefix]
public static bool OnBlockingChange(PlayerCombat __instance, bool _newBool)
{
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: 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)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)__instance._player) || __instance._player._bufferingStatus || !Plugin._playerOrbColors.ContainsKey(__instance._player._steamID) || !Plugin._playerOrbColors[__instance._player._steamID]._orbColorsEnabled)
{
return true;
}
float item = Plugin._playerOrbColors[__instance._player._steamID]._size;
if (_newBool)
{
int num = 0;
if (Object.op_Implicit((Object)(object)__instance._equippedWeapon))
{
num = __instance._equippedWeapon._weaponHoldClipIndex;
}
__instance._pSound._aSrcGeneral.PlayOneShot(__instance._pSound._generalSounds[12], 0.35f);
if (Object.op_Implicit((Object)(object)__instance._equippedShield) && (int)__instance._currentScriptableWeaponType._weaponHandedness == 0)
{
__instance._pVisual.Local_CrossFadeAnim("Block_Shield", 0f, 3);
}
else
{
__instance._pVisual.Local_CrossFadeAnim(__instance._currentScriptableWeaponType._weaponAnimSlots[num]._weaponBlockAnimation ?? "", 0f, 3);
}
((Component)__instance._pVisual._blockOrbEffect).transform.localScale = Vector3.one * item * 2f;
__instance._pVisual._blockOrbEffect.setScale = new Vector3(item, item, item);
__instance._pVisual._preventRotationLerp = false;
if (((NetworkBehaviour)__instance).isLocalPlayer)
{
__instance._pVisual.Cmd_ResetSpinPlayerModel();
}
}
else
{
__instance._pVisual.Local_CrossFadeAnim("Empty", 0f, 3);
__instance._pVisual._blockOrbEffect.setScale = Vector3.zero;
}
return false;
}
}
[HarmonyPatch(typeof(PlayerVisual), "Handle_BlockOrbEffects")]
internal class PlayerVisualPatch
{
public static bool Prefix(PlayerVisual __instance)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
if (NetworkClient.active && Plugin._playerOrbColors.TryGetValue(__instance._player._steamID, out (bool, Color, float) value) && value.Item1)
{
((Renderer)__instance._blockOrbRender).material.SetColor("_EmissionColor", value.Item2);
if (__instance._pCombat._inParryWindow && !__instance._parryWindowEffect.isEmitting)
{
__instance._parryWindowEffect.Play();
}
if (!__instance._pCombat._isBlocking || !__instance._pCombat._inParryWindow)
{
__instance._parryWindowEffect.Stop();
}
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Player), "OnStartAuthority")]
internal class PlayerPatch
{
public static void Postfix()
{
if (NetworkClient.active)
{
Plugin.InitConfig();
Plugin.AddSettings();
CodeTalkerNetwork.SendNetworkPacket((PacketBase)(object)new PlayerJoinPacket());
Plugin.SetOfflineOrbColor();
}
}
}
[HarmonyPatch(typeof(ConfigFile), "Save")]
internal class ConfigFilePatch
{
public static bool Prefix(ConfigFile __instance)
{
if (NetworkClient.active && __instance.ConfigFilePath.EndsWith("OrbColors.cfg"))
{
Plugin.SendOrbColorPacket();
Plugin.SetOfflineOrbColor();
}
return true;
}
}
[HarmonyPatch(typeof(CharacterSelectManager), "Select_CharacterFile")]
internal class CharacterSelectManagerPatch
{
public static void Prefix()
{
Plugin._color = new Dictionary<string, ConfigEntry<float>>();
Plugin._playerOrbColors = new Dictionary<string, (bool, Color, float)>();
foreach (BaseAtlyssElement settingsElement in Plugin._settingsElements)
{
Settings.ModTab.ContentElements.Remove(settingsElement);
((Component)settingsElement.Root).gameObject.SetActive(false);
}
Plugin._settingsElements.Clear();
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}