using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.UI;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RoR2;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
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.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Flashbang")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Flashbang")]
[assembly: AssemblyTitle("Flashbang")]
[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 Flashbang
{
public static class Assets
{
public static AssetBundle mainAssetBundle = null;
internal static string assetBundleName = "flashbang";
internal static string assemblyDir => Path.GetDirectoryName(Flashbang.pluginInfo.Location);
public static void PopulateAssets()
{
mainAssetBundle = AssetBundle.LoadFromFile(Path.Combine(assemblyDir, assetBundleName));
}
}
internal static class SoundBanks
{
private static bool initialized;
public static string SoundBankDirectory => Path.Combine(Assets.assemblyDir);
public static void Init()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Invalid comparison between Unknown and I4
//IL_0056: 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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Invalid comparison between Unknown and I4
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
if (!initialized)
{
initialized = true;
AKRESULT val = AkSoundEngine.AddBasePath(SoundBankDirectory);
if ((int)val == 1)
{
Log.Info("Added bank base path : " + SoundBankDirectory);
}
else
{
Log.Error("Error adding base path : " + SoundBankDirectory + " " + $"Error code : {val}");
}
uint num = default(uint);
AkSoundEngine.LoadBank("flashbang.bnk", ref num);
if ((int)val == 1)
{
Log.Info("Added bank : flashbang.bnk");
}
else
{
Log.Error("Error loading bank : flashbang.bnk " + $"Error code : {val}");
}
}
}
}
[BepInPlugin("bouncyshield.Flashbang", "Flashbang", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Flashbang : BaseUnityPlugin
{
public class Sink : INetMessage, ISerializableObject
{
private NetworkInstanceId id;
public Sink()
{
}
public Sink(CharacterBody x)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
id = x.master.networkIdentity.netId;
}
public void Serialize(NetworkWriter writer)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
writer.Write(id);
}
public void Deserialize(NetworkReader reader)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
id = reader.ReadNetworkId();
}
public void OnReceived()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
if (id == LocalUserManager.GetFirstLocalUser().cachedMaster.networkIdentity.netId)
{
Instance.FlashbangPlayer();
}
}
}
public const string PluginGUID = "bouncyshield.Flashbang";
public const string PluginAuthor = "bouncyshield";
public const string PluginName = "Flashbang";
public const string PluginVersion = "1.0.0";
public static PluginInfo pluginInfo;
public static Flashbang Instance;
private HUD hud;
private GameObject Whitescreen;
private GameObject Dizzyscreen;
private float alpha;
private EquipmentDef flashbang;
public void Awake()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
pluginInfo = ((BaseUnityPlugin)this).Info;
Log.Init(((BaseUnityPlugin)this).Logger);
Assets.PopulateAssets();
Instance = this;
HUD.Awake += new hook_Awake(GetHud);
EquipmentSlot.PerformEquipmentAction += new hook_PerformEquipmentAction(EquipmentActivate);
CreateEquipment();
NetworkingAPI.RegisterMessageType<Sink>();
}
public void OnDestroy()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
HUD.Awake -= new hook_Awake(GetHud);
EquipmentSlot.PerformEquipmentAction -= new hook_PerformEquipmentAction(EquipmentActivate);
}
public void Start()
{
SoundBanks.Init();
}
public void Update()
{
}
private void GetHud(orig_Awake orig, HUD self)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Expected O, but got Unknown
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: 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_0121: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
hud = self;
Dizzyscreen = new GameObject("Dizzyscreen");
Dizzyscreen.transform.SetParent(hud.mainContainer.transform);
RectTransform val = Dizzyscreen.AddComponent<RectTransform>();
val.anchorMin = Vector2.zero;
val.anchorMax = Vector2.one;
val.sizeDelta = Vector2.zero;
val.anchoredPosition = Vector2.zero;
Dizzyscreen.AddComponent<Image>();
Whitescreen = new GameObject("Whitescreen");
Whitescreen.transform.SetParent(hud.mainContainer.transform);
val = Whitescreen.AddComponent<RectTransform>();
val.anchorMin = Vector2.zero;
val.anchorMax = Vector2.one;
val.sizeDelta = Vector2.zero;
val.anchoredPosition = Vector2.zero;
Image val2 = Whitescreen.AddComponent<Image>();
val2.sprite = Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, 4f, 4f), Vector2.zero);
FlashAlpha(0f);
}
private void FlashAlpha(float x)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
((Graphic)Whitescreen.GetComponent<Image>()).color = new Color(1f, 1f, 1f, x);
((Graphic)Dizzyscreen.GetComponent<Image>()).color = new Color(1f, 1f, 1f, x);
}
private void FlashbangPlayer()
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Whitescreen != (Object)null && (Object)(object)Dizzyscreen != (Object)null)
{
Texture2D val = ScreenCapture.CaptureScreenshotAsTexture();
Dizzyscreen.GetComponent<Image>().sprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero);
((MonoBehaviour)this).StartCoroutine(Fade());
AkSoundEngine.PostEvent(2753768932u, ((Component)Run.instance).gameObject);
Log.Info("Flashbang!");
}
else
{
Log.Warning("Bad flashbang...");
}
}
private IEnumerator Fade()
{
alpha = 1f;
FlashAlpha(alpha);
while (alpha >= 0f)
{
yield return (object)new WaitForSeconds(0.04f);
alpha -= 0.01f * (2f - alpha);
FlashAlpha(alpha);
}
}
private void CreateEquipment()
{
//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_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Expected O, but got Unknown
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Expected O, but got Unknown
flashbang = ScriptableObject.CreateInstance<EquipmentDef>();
((Object)flashbang).name = "FLASHBANG_NAME";
flashbang.nameToken = "FLASHBANG_NAME";
flashbang.pickupToken = "FLASHBANG_PICKUP";
flashbang.descriptionToken = "FLASHBANG_DESC";
flashbang.loreToken = "FLASHBANG_LORE";
flashbang.pickupIconSprite = Assets.mainAssetBundle.LoadAsset<Sprite>("flashbang.png");
flashbang.pickupModelPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/StunChanceOnHit/PickupStunGrenade.prefab").WaitForCompletion();
flashbang.appearsInMultiPlayer = true;
flashbang.appearsInSinglePlayer = true;
flashbang.canBeRandomlyTriggered = true;
flashbang.enigmaCompatible = true;
flashbang.canDrop = true;
flashbang.cooldown = 25f;
ItemAPI.Add(new CustomEquipment(flashbang, new ItemDisplayRuleDict((ItemDisplayRule[])null)));
}
private bool EquipmentActivate(orig_PerformEquipmentAction orig, EquipmentSlot self, EquipmentDef def)
{
if ((Object)(object)def == (Object)(object)flashbang && NetworkServer.active)
{
FireFlashbang(self.characterBody);
return true;
}
return orig.Invoke(self, def);
}
private void FireFlashbang(CharacterBody body)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: 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)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Expected O, but got Unknown
Vector3 position = ((Component)body).gameObject.transform.position;
foreach (CharacterBody instances in CharacterBody.instancesList)
{
double num = Vector3.Distance(((Component)instances).gameObject.transform.position, position);
if (num <= 70.0)
{
if (instances.isPlayerControlled)
{
NetMessageExtensions.Send((INetMessage)(object)new Sink(instances), (NetworkDestination)1);
continue;
}
DamageInfo val = new DamageInfo
{
damage = Math.Max(instances.healthComponent.fullCombinedHealth / 10f, 50f),
inflictor = ((Component)body).gameObject,
attacker = ((Component)body).gameObject,
procCoefficient = 0f
};
instances.healthComponent.TakeDamage(val);
SetStateOnHurt.SetStunOnObject(((Component)instances).gameObject, 5f);
}
}
}
}
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
}
}
namespace Flashbang.Properties
{
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resources
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
ResourceManager resourceManager = new ResourceManager("Flashbang.Properties.Resources", typeof(Resources).Assembly);
resourceMan = resourceManager;
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
internal Resources()
{
}
}
}