using System;
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.Bootstrap;
using BepInEx.Logging;
using On.RoR2;
using R2API;
using R2API.Utils;
using RiskyMod.Allies;
using RoR2;
using RoR2.CharacterAI;
using UnityEngine;
[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("BingusMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BingusMod")]
[assembly: AssemblyTitle("BingusMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BingusMod;
internal class Assets
{
internal static GameObject BingusPrefab;
internal static Sprite BingusIcon;
internal static ItemDef BingusItemDef;
private const string ModPrefix = "@BingusMod:";
internal static void Init()
{
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BingusMod.ror2bingus"))
{
AssetBundle val = AssetBundle.LoadFromStream(stream);
BingusPrefab = val.LoadAsset<GameObject>("Assets/Import/bingus/bingus.prefab");
BingusIcon = val.LoadAsset<Sprite>("Assets/Import/bingus_icon/bingus_icon.png");
}
BingusAsRedTierItem();
AddLanguageTokens();
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
internal static void RiskyModCompat(Inventory inv)
{
inv.GiveItem(AllyItems.AllyMarkerItem, 1);
inv.GiveItem(AllyItems.AllyScalingItem, 1);
inv.GiveItem(AllyItems.AllyRegenItem, 40);
inv.GiveItem(AllyItems.AllyAllowVoidDeathItem, 1);
}
private static void BingusAsRedTierItem()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//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_00e2: 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_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Expected O, but got Unknown
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Expected O, but got Unknown
BingusItemDef = ScriptableObject.CreateInstance<ItemDef>();
ItemDef bingusItemDef = BingusItemDef;
((Object)bingusItemDef).name = "BINGUS";
bingusItemDef.deprecatedTier = (ItemTier)2;
bingusItemDef.pickupModelPrefab = BingusPrefab;
bingusItemDef.pickupIconSprite = BingusIcon;
bingusItemDef.nameToken = "Bingus";
bingusItemDef.pickupToken = "Entering low health state charms enemies";
bingusItemDef.descriptionToken = "Entering <style=cDeath>low health state</style> charms <style=cIsUtility>2</style> enemies <style=cStack>(+1 per stack)</style>. Why? because they are stupid and think bingus squish is cute.";
bingusItemDef.loreToken = "do not let its look fool you, it's a class-534 threat.";
ItemTag[] array = new ItemTag[3];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
bingusItemDef.tags = (ItemTag[])(object)array;
ItemDisplayRule[] array2 = (ItemDisplayRule[])(object)new ItemDisplayRule[1];
array2[0].followerPrefab = BingusPrefab;
array2[0].childName = "Head";
array2[0].localScale = new Vector3(1f, 1f, 1f);
array2[0].localAngles = new Vector3(-90f, 0f, 0f);
array2[0].localPos = new Vector3(0f, -0.25f, -0.34f);
CustomItem val = new CustomItem(BingusItemDef, array2);
bool flag = ItemAPI.Add(val);
bool debounce = false;
HealthComponent.FixedUpdate += (hook_FixedUpdate)delegate(orig_FixedUpdate orig, HealthComponent self)
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Invalid comparison between Unknown and I4
if (((object)self).Equals((object?)null) || !self.body.isPlayerControlled)
{
orig.Invoke(self);
}
else
{
CharacterBody body = self.body;
if (body.inventory.GetItemCount(BingusItemDef) > 0)
{
if (self.isHealthLow && !debounce)
{
Random random = new Random();
debounce = true;
for (int i = 0; i <= body.inventory.GetItemCount(BingusItemDef); i++)
{
TeamComponent val2 = new TeamComponent();
try
{
if (TeamComponent.GetTeamMembers((TeamIndex)2).Count == 0)
{
orig.Invoke(self);
return;
}
val2 = TeamComponent.GetTeamMembers((TeamIndex)2)[random.Next(1, TeamComponent.GetTeamMembers((TeamIndex)2).Count)];
if (!((Object)(object)((Component)val2.body).gameObject.transform == (Object)null))
{
if (val2.body.master.isBoss)
{
val2 = TeamComponent.GetTeamMembers((TeamIndex)2)[random.Next(1, TeamComponent.GetTeamMembers((TeamIndex)2).Count)];
}
goto IL_0132;
}
}
catch (ArgumentOutOfRangeException)
{
}
continue;
IL_0132:
BaseAI component = ((Component)val2.body.master).GetComponent<BaseAI>();
val2.body.master.teamIndex = (TeamIndex)1;
val2.body.teamComponent.teamIndex = (TeamIndex)1;
if (Chainloader.PluginInfos.ContainsKey("com.RiskyLives.RiskyMod") && Object.op_Implicit((Object)(object)val2.body.inventory))
{
RiskyModCompat(val2.body.inventory);
}
component.currentEnemy.Reset();
component.ForceAcquireNearestEnemyIfNoCurrentEnemy();
}
}
if (!self.isHealthLow && debounce)
{
debounce = false;
}
for (int j = 0; j < TeamComponent.GetTeamMembers((TeamIndex)1).Count; j++)
{
TeamComponent val3 = TeamComponent.GetTeamMembers((TeamIndex)1)[j];
if (!val3.body.isPlayerControlled && !((Object)(object)((Component)body).gameObject.transform != (Object)null))
{
BaseAI component2 = val3.body.masterObject.GetComponent<BaseAI>();
if ((int)component2.currentEnemy.characterBody.teamComponent.teamIndex == 1)
{
component2.currentEnemy.Reset();
component2.ForceAcquireNearestEnemyIfNoCurrentEnemy();
}
}
}
}
orig.Invoke(self);
}
};
}
private static void AddLanguageTokens()
{
LanguageAPI.Add("BINGUS_NAME", "Bingus");
LanguageAPI.Add("BINGUS_PICKUP", "Entering <style=cDeath>low health state</style> state charms enemies");
LanguageAPI.Add("BINGUS_DESC", "Entering <style=cDeath>low health state</style> charms <style=cIsUtility>2</style> enemies <style=cStack>(+1 per stack)</style>. Why? because they are stupid and think bingus squish is cute.");
LanguageAPI.Add("BINGUS_LORE", "do not let its look fool you, it's a class-534 threat.");
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[R2APISubmoduleDependency(new string[] { "ItemAPI", "LanguageAPI" })]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.bonix.bingusmod", "Bingus Mod", "1.1.3")]
public class CustomItem : BaseUnityPlugin
{
private const string ModVer = "1.1.3";
private const string ModName = "Bingus Mod";
public const string ModGuid = "com.bonix.bingusmod";
internal static ManualLogSource Logger;
public void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Assets.Init();
}
}