using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
[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("ShotgunSafety")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Config to the shotgun")]
[assembly: AssemblyTitle("ShotgunSafety")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
[BepInPlugin("com.atomic.shotgunsafety", "Shotgun Safety", "1.4.0")]
public class ShotgunPatch : BaseUnityPlugin
{
internal ConfigEntry<bool>? colorizeTextConfig;
internal ConfigEntry<bool>? colorizeFullTextConfig;
internal ConfigEntry<string>? colorOnConfig;
internal ConfigEntry<string>? colorOffConfig;
internal ConfigEntry<string>? textoffConfig;
internal ConfigEntry<string>? textonConfig;
public static ShotgunPatch Instance { get; private set; }
private void Awake()
{
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Expected O, but got Unknown
Instance = this;
string text = "Text Color";
colorizeTextConfig = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "Colorize Text", false, "Enable or disable colorized text for shotgun safety.");
colorizeFullTextConfig = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "Colorize Full-Text", false, "Enable or disable coloring the entire text instead of just the 'on' or 'off' word.");
colorOnConfig = ((BaseUnityPlugin)this).Config.Bind<string>(text, "On-Text Color", "green", "The color for the 'on' text. Accepted colors: black, blue, green, red, white, yellow, any other colors you think may work. NOTE: Spell it exactly, it also does NOT need a restart when changed!");
colorOffConfig = ((BaseUnityPlugin)this).Config.Bind<string>(text, "Off-Text Color", "red", "The color for the 'off' text. Accepted colors: black, blue, green, red, white, yellow, any other colors you think may work. NOTE: Spell it exactly, it also does NOT need a restart when changed!");
string text2 = "Text Settings";
textoffConfig = ((BaseUnityPlugin)this).Config.Bind<string>(text2, "Safety Text off", "", "Leave empty for the default modded text. Must contain the keyword off, capitals allowed. Default blank = The safety is off:");
textonConfig = ((BaseUnityPlugin)this).Config.Bind<string>(text2, "Safety Text on", "", "Leave empty for the default modded text. Must contain the keyword on, capitals allowed. Default blank = The safety is on:");
Harmony val = new Harmony("com.atomic.shotgunsafety");
val.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)("\n\n---///--- SHOTGUN SAFETY TOOLTIP --///--\n\nConfig:\n" + $"•Colored Text: {colorizeFullTextConfig.Value}\n" + $"•Colored Text Full: {colorizeFullTextConfig.Value}\n" + "•Safety Text On: " + colorOnConfig.Value + "\n•Safety Text Off: " + colorOffConfig.Value + "\n•Custom Text On: " + textonConfig.Value + "\n•Custom Text Off: " + textoffConfig.Value + "\n\nStatus:\nLoaded Successfully!\n\n"));
}
}
[HarmonyPatch(typeof(ShotgunItem), "SetControlTipsForItem")]
public class ShotgunItem_SetControlTipsForItem_Patch
{
private static void Postfix(ShotgunItem __instance)
{
string[] toolTips = ((GrabbableObject)__instance).itemProperties.toolTips;
if (__instance.safetyOn)
{
if (ShotgunPatch.Instance.textonConfig.Value == "")
{
toolTips[2] = ((!ShotgunPatch.Instance.colorizeTextConfig.Value) ? "The safety is on: [Q]" : (ShotgunPatch.Instance.colorizeFullTextConfig.Value ? ("<color=" + ShotgunPatch.Instance.colorOnConfig.Value + ">The safety is on: [Q]</color>") : ("The safety is<color=white></color> <color=" + ShotgunPatch.Instance.colorOnConfig.Value + ">on:</color> <color=white>[Q]</color>")));
}
else
{
string text = "<color=white></color> <color=" + ShotgunPatch.Instance.colorOnConfig.Value + ">";
string value = "</color> <color=white></color>";
string text2 = "on";
string text3 = ShotgunPatch.Instance.textonConfig.Value + " [Q]";
int num = text3.ToLower().IndexOf(text2);
if (num >= 0)
{
text3 = text3.Insert(num, text);
text3 = text3.Insert(num + text.Length + text2.Length, value);
}
else
{
text3 = "This is setup incorrectly! Didn't contain the keyword on: [Q]";
}
toolTips[2] = ((!ShotgunPatch.Instance.colorizeTextConfig.Value) ? (ShotgunPatch.Instance.textoffConfig.Value + " [Q]") : (ShotgunPatch.Instance.colorizeFullTextConfig.Value ? ("<color=" + ShotgunPatch.Instance.colorOffConfig.Value + ">" + ShotgunPatch.Instance.textoffConfig.Value + " [Q]</color>") : text3));
}
}
else if (ShotgunPatch.Instance.textoffConfig.Value == "")
{
toolTips[2] = ((!ShotgunPatch.Instance.colorizeTextConfig.Value) ? "The safety is off: [Q]" : (ShotgunPatch.Instance.colorizeFullTextConfig.Value ? ("<color=" + ShotgunPatch.Instance.colorOffConfig.Value + ">The safety is off: [Q]</color>") : ("The safety is<color=white></color> <color=" + ShotgunPatch.Instance.colorOffConfig.Value + ">off:</color> <color=white>[Q]</color>")));
}
else
{
bool flag = ShotgunPatch.Instance.colorOffConfig.Value.ToLower().Contains("off");
string text4 = "<color=white></color> <color=" + ShotgunPatch.Instance.colorOffConfig.Value + ">";
string value2 = "</color> <color=white></color>";
string text5 = "off";
string text6 = ShotgunPatch.Instance.textoffConfig.Value + " [Q]";
int num2 = text6.ToLower().IndexOf(text5);
if (num2 >= 0)
{
text6 = text6.Insert(num2, text4);
text6 = text6.Insert(num2 + text4.Length + text5.Length, value2);
}
else
{
text6 = "This is setup incorrectly! Didn't contain the keyword off: [Q]";
}
toolTips[2] = ((!ShotgunPatch.Instance.colorizeTextConfig.Value) ? (ShotgunPatch.Instance.textoffConfig.Value + " [Q]") : (ShotgunPatch.Instance.colorizeFullTextConfig.Value ? ("<color=" + ShotgunPatch.Instance.colorOffConfig.Value + ">" + ShotgunPatch.Instance.textoffConfig.Value + " [Q]</color>") : text6));
}
HUDManager.Instance.ChangeControlTipMultiple(toolTips, true, ((GrabbableObject)__instance).itemProperties);
}
}
[HarmonyPatch(typeof(ShotgunItem), "SetSafetyControlTip")]
public class ShotgunItem_SetSafetyControlTip_Patch
{
private static void Postfix(ShotgunItem __instance)
{
string text;
if (__instance.safetyOn)
{
if (ShotgunPatch.Instance.textonConfig.Value == "")
{
text = ((!ShotgunPatch.Instance.colorizeTextConfig.Value) ? "The safety is on: [Q]" : (ShotgunPatch.Instance.colorizeFullTextConfig.Value ? ("<color=" + ShotgunPatch.Instance.colorOnConfig.Value + ">The safety is on: [Q]</color>") : ("The safety is<color=white></color> <color=" + ShotgunPatch.Instance.colorOnConfig.Value + ">on:</color> <color=white>[Q]</color>")));
}
else
{
string text2 = "on";
string text3 = "<color=white></color> <color=" + ShotgunPatch.Instance.colorOnConfig.Value + ">";
string value = "</color> <color=white></color>";
string text4 = ShotgunPatch.Instance.textonConfig.Value + " [Q]";
string text5 = ShotgunPatch.Instance.textonConfig.Value + " [Q]";
int num = text4.ToLower().IndexOf(text2);
if (num >= 0)
{
text5 = text5.Insert(num, text3);
text5 = text5.Insert(num + text3.Length + text2.Length, value);
}
else
{
text4 = "This is setup incorrectly! Didn't contain the keyword on: [Q]";
}
text = ((!ShotgunPatch.Instance.colorizeTextConfig.Value) ? text4 : (ShotgunPatch.Instance.colorizeFullTextConfig.Value ? ("<color=" + ShotgunPatch.Instance.colorOnConfig.Value + ">" + text4 + "</color>") : text5));
}
}
else if (ShotgunPatch.Instance.textoffConfig.Value == "")
{
text = ((!ShotgunPatch.Instance.colorizeTextConfig.Value) ? "The safety is off: [Q]" : (ShotgunPatch.Instance.colorizeFullTextConfig.Value ? ("<color=" + ShotgunPatch.Instance.colorOffConfig.Value + ">The safety is off: [Q]</color>") : ("The safety is<color=white></color> <color=" + ShotgunPatch.Instance.colorOffConfig.Value + ">off:</color> <color=white>[Q]</color>")));
}
else
{
string text6 = "off";
string text7 = "<color=white></color> <color=" + ShotgunPatch.Instance.colorOffConfig.Value + ">";
string value2 = "</color> <color=white></color>";
string text8 = ShotgunPatch.Instance.textoffConfig.Value + " [Q]";
string text9 = ShotgunPatch.Instance.textoffConfig.Value + " [Q]";
int num2 = text8.ToLower().IndexOf(text6);
if (num2 >= 0)
{
text9 = text9.Insert(num2, text7);
text9 = text9.Insert(num2 + text7.Length + text6.Length, value2);
}
else
{
text8 = "This is setup incorrectly! Didn't contain the keyword off: [Q]";
}
text = ((!ShotgunPatch.Instance.colorizeTextConfig.Value) ? text8 : (ShotgunPatch.Instance.colorizeFullTextConfig.Value ? ("<color=" + ShotgunPatch.Instance.colorOffConfig.Value + ">" + text8 + "</color>") : text9));
}
if (((NetworkBehaviour)__instance).IsOwner)
{
HUDManager.Instance.ChangeControlTip(3, text, false);
}
}
}
namespace ShotgunSafety
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ShotgunSafety";
public const string PLUGIN_NAME = "Config to the shotgun";
public const string PLUGIN_VERSION = "1.0.0";
}
}