using System;
using System.Collections.Generic;
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 LGBTQHitscan.Utils;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Fields;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("LGBTQHitscan")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LGBTQ Hitscan")]
[assembly: AssemblyTitle("LGBTQHitscan")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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]
[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]
[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;
}
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace LGBTQHitscan
{
public enum FlagChoice
{
Random,
Transgender,
Pansexual,
Nonbinary,
Lesbian,
Gay,
Bisexual,
Asexual,
Agender
}
public static class HitscanConfig
{
public static PluginConfigurator Config;
public static BoolField Enabled;
public static EnumField<FlagChoice> Flag;
public static void Initialize()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
Config = PluginConfigurator.Create("LGBTQ Hitscan", "com.achelia.lgbtqhitscan");
Config.icon = BundleLoader.LoadIcon("LGBTQHitscan.icon.png");
Enabled = new BoolField(Config.rootPanel, "Enabled", "enabled", true);
Flag = new EnumField<FlagChoice>(Config.rootPanel, "Beam Flag", "flag", FlagChoice.Random);
}
}
internal static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.achelia.lgbtqhitscan";
public const string PLUGIN_NAME = "LGBTQ Hitscan";
public const string PLUGIN_VERSION = "1.0.0";
}
[BepInPlugin("com.achelia.lgbtqhitscan", "LGBTQ Hitscan", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(RevolverBeam), "Start")]
private class RevolverBeamPatch
{
private static void Postfix(RevolverBeam __instance)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Expected O, but got Unknown
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
string text = PickFlagKey();
if (text == null)
{
return;
}
LineRenderer component = ((Component)__instance).GetComponent<LineRenderer>();
if ((Object)(object)component == (Object)null)
{
return;
}
Gradient val = new Gradient();
val.colorKeys = (GradientColorKey[])(object)new GradientColorKey[2]
{
new GradientColorKey(Color.white, 0f),
new GradientColorKey(Color.white, 1f)
};
val.alphaKeys = (GradientAlphaKey[])(object)new GradientAlphaKey[2]
{
new GradientAlphaKey(1f, 0f),
new GradientAlphaKey(1f, 1f)
};
component.colorGradient = val;
Material val2 = new Material(((Renderer)component).material);
val2.mainTexture = (Texture)(object)CachedTextures[text];
((Renderer)component).material = val2;
Color color = AverageColors[text];
Sprite muzzleFlashSprite = MuzzleFlashSprite;
SpriteRenderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<SpriteRenderer>(true);
foreach (SpriteRenderer val3 in componentsInChildren)
{
if (((Object)val3).name.ToLower().Contains("muzzle"))
{
val3.color = color;
if ((Object)(object)muzzleFlashSprite != (Object)null)
{
val3.sprite = muzzleFlashSprite;
}
}
}
Light component2 = ((Component)__instance).GetComponent<Light>();
if ((Object)(object)component2 != (Object)null)
{
component2.color = color;
}
}
}
public static readonly Dictionary<string, Texture2D> CachedTextures = new Dictionary<string, Texture2D>();
public static readonly Dictionary<string, Color> AverageColors = new Dictionary<string, Color>();
public static readonly List<string> FlagPool = new List<string>();
public static readonly Dictionary<FlagChoice, string> FlagKeys = new Dictionary<FlagChoice, string>
{
{
FlagChoice.Transgender,
"tran"
},
{
FlagChoice.Pansexual,
"pan"
},
{
FlagChoice.Nonbinary,
"non"
},
{
FlagChoice.Lesbian,
"les"
},
{
FlagChoice.Gay,
"gay"
},
{
FlagChoice.Bisexual,
"bi"
},
{
FlagChoice.Asexual,
"ase"
},
{
FlagChoice.Agender,
"age"
}
};
private static readonly string[] FlagFiles = new string[9] { "tran.png", "pan.png", "non.png", "les.png", "gay.png", "bi.png", "ase.png", "age.png", "muzzleflashwhite1.png" };
private const string AssetPath = "Assets/Custom/improudofyou/";
private const string MuzzleFlashKey = "flash";
internal static ManualLogSource Log;
private static Sprite muzzleFlashSprite;
private static Harmony harmony;
private static Sprite MuzzleFlashSprite
{
get
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)muzzleFlashSprite != (Object)null)
{
return muzzleFlashSprite;
}
if (!CachedTextures.TryGetValue("flash", out Texture2D value))
{
return null;
}
return muzzleFlashSprite = Sprite.Create(value, new Rect(0f, 0f, (float)((Texture)value).width, (float)((Texture)value).height), new Vector2(0.5f, 0.5f), 100f);
}
}
private static bool Enabled
{
get
{
if (HitscanConfig.Enabled != null)
{
return HitscanConfig.Enabled.value;
}
return true;
}
}
private static string PickFlagKey()
{
if (!Enabled)
{
return null;
}
FlagChoice flagChoice = ((HitscanConfig.Flag != null) ? HitscanConfig.Flag.value : FlagChoice.Random);
if (flagChoice != FlagChoice.Random && FlagKeys.TryGetValue(flagChoice, out string value) && CachedTextures.ContainsKey(value))
{
return value;
}
if (FlagPool.Count == 0)
{
return null;
}
return FlagPool[Random.Range(0, FlagPool.Count)];
}
private void Awake()
{
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
BundleLoader.Initialize();
string[] flagFiles = FlagFiles;
for (int i = 0; i < flagFiles.Length; i++)
{
LoadTexture(flagFiles[i]);
}
Log.LogInfo((object)("Loaded " + FlagPool.Count + " of " + (FlagFiles.Length - 1) + " flag textures."));
HitscanConfig.Initialize();
harmony = new Harmony("com.achelia.lgbtqhitscan");
harmony.PatchAll();
Log.LogInfo((object)"LGBTQ Hitscan 1.0.0 loaded.");
}
private static void LoadTexture(string file)
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)BundleLoader.Bundle == (Object)null)
{
return;
}
Texture2D val = BundleLoader.Bundle.LoadAsset<Texture2D>("Assets/Custom/improudofyou/" + file);
if ((Object)(object)val == (Object)null)
{
Log.LogWarning((object)("Asset bundle does not contain " + file + "."));
return;
}
string text = Path.GetFileNameWithoutExtension(file);
if (text == "muzzleflashwhite1")
{
text = "flash";
}
CachedTextures[text] = val;
AverageColors[text] = CalculateAverageColor(val);
if (text != "flash" && !FlagPool.Contains(text))
{
FlagPool.Add(text);
}
}
private static Color CalculateAverageColor(Texture2D texture)
{
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
Color[] pixels = texture.GetPixels();
float num = 0f;
float num2 = 0f;
float num3 = 0f;
float num4 = 0f;
for (int i = 0; i < pixels.Length; i++)
{
num += pixels[i].r;
num2 += pixels[i].g;
num3 += pixels[i].b;
num4 += pixels[i].a;
}
float num5 = pixels.Length;
return new Color(num / num5, num2 / num5, num3 / num5, num4 / num5);
}
}
}
namespace LGBTQHitscan.Utils
{
public static class BundleLoader
{
private const string BundleResourceName = "LGBTQHitscan.bundle";
public static AssetBundle? Bundle;
public static void Initialize()
{
if ((Object)(object)Bundle != (Object)null)
{
return;
}
using Stream stream = typeof(BundleLoader).Assembly.GetManifestResourceStream("LGBTQHitscan.bundle");
if (stream == null)
{
Plugin.Log.LogError((object)"Embedded asset bundle 'LGBTQHitscan.bundle' was not found in the assembly.");
return;
}
using MemoryStream memoryStream = new MemoryStream();
stream.CopyTo(memoryStream);
Bundle = AssetBundle.LoadFromMemory(memoryStream.ToArray());
if ((Object)(object)Bundle == (Object)null)
{
Plugin.Log.LogError((object)"Failed to load the asset bundle from memory.");
}
else
{
Plugin.Log.LogInfo((object)"Asset bundle loaded.");
}
}
public static Sprite? LoadIcon(string resourcePath)
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
try
{
using Stream stream = typeof(BundleLoader).Assembly.GetManifestResourceStream(resourcePath);
if (stream == null)
{
Plugin.Log.LogWarning((object)("Embedded icon '" + resourcePath + "' was not found in the assembly."));
return null;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
if (!ImageConversion.LoadImage(val, array))
{
Plugin.Log.LogWarning((object)("Embedded icon '" + resourcePath + "' could not be decoded."));
return null;
}
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
}
catch
{
return null;
}
}
}
}