using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates.SolusWing;
using EntityStates.SolusWing2;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.SolusWing;
using R2API;
using RoR2;
using RoR2.SolusWing;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
[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("RealerSolusWing")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ea7a57ac5190360172084d86053441cddf8f29a2")]
[assembly: AssemblyProduct("RealerSolusWing")]
[assembly: AssemblyTitle("RealerSolusWing")]
[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.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;
}
}
}
namespace RealerSolusWing
{
[BepInPlugin("prodzpod.RealerSolusWing", "RealerSolusWing", "1.1.2")]
public class Main : BaseUnityPlugin
{
public enum GameMode
{
TotalHPFraction,
HealWeakPoints
}
public class RealerSolusWingController : NetworkBehaviour
{
public void Start()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
((Component)this).GetComponent<CharacterBody>().inventory.GiveItemPermanent(ItemCatalog.FindItemIndex("SOLUS_HP_MULTIPLIER"), 1);
foreach (CharacterBody weakpointBody in ((Component)this).GetComponent<SolusWingWeakPointsController>().WeakpointBodies)
{
weakpointBody.inventory.GiveItemPermanent(ItemCatalog.FindItemIndex("WEAKPOINT_HP_MULTIPLIER"), 1);
}
}
public void Update()
{
CharacterBody component = ((Component)this).GetComponent<CharacterBody>();
SolusWingWeakPointsController component2 = ((Component)this).GetComponent<SolusWingWeakPointsController>();
if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component2) && NetworkServer.active)
{
if (ShouldBeImmune(component2) && !component.HasBuff(Buffs.Immune))
{
component.AddBuff(Buffs.Immune);
}
if (!ShouldBeImmune(component2) && component.HasBuff(Buffs.Immune))
{
component.RemoveBuff(Buffs.Immune);
}
}
}
public bool ShouldBeImmune(SolusWingWeakPointsController controller)
{
if (!CoreImmune.Value || !Object.op_Implicit((Object)(object)controller))
{
return false;
}
if (!controller.anyWeakpointsAlive)
{
return false;
}
if (Mode.Value == GameMode.HealWeakPoints && controller.glitchStateMachine.state is GlitchState)
{
return false;
}
return true;
}
}
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static hook_Awake <>9__16_0;
public static hook_IsBossHealthBelowThreshhold <>9__16_1;
public static hook_onWeakpointDestroyedServer <>9__16_2;
public static Predicate<ItemCountPair> <>9__16_5;
public static StatHookEventHandler <>9__16_4;
internal void <Awake>b__16_0(orig_Awake orig, SolusWingWeakPointsController self)
{
orig.Invoke(self);
((Component)self).gameObject.AddComponent<RealerSolusWingController>();
}
internal bool <Awake>b__16_1(orig_IsBossHealthBelowThreshhold orig, SolutionalHauntReferences self, float perc)
{
bool result = orig.Invoke(self, perc);
if (Mode.Value == GameMode.HealWeakPoints)
{
return result;
}
if (!self.bossWasOriginallySpawned || !Object.op_Implicit((Object)(object)self.solusBoss))
{
return false;
}
List<CharacterBody> weakpointBodies = ((Component)self.solusBoss).GetComponent<SolusWingWeakPointsController>().WeakpointBodies;
float num = 0f;
foreach (CharacterBody item in weakpointBodies)
{
if (item.healthComponent.alive)
{
num += item.healthComponent.combinedHealthFraction;
}
}
num /= (float)weakpointBodies.Count;
return self.bossWasOriginallySpawned && num < perc;
}
internal void <Awake>b__16_2(orig_onWeakpointDestroyedServer orig, SolusWingWeakPointsController self, GameObject weakpoint, CharacterBody body)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, weakpoint, body);
if (Mode.Value != GameMode.HealWeakPoints)
{
return;
}
foreach (CharacterBody weakpointBody in self.WeakpointBodies)
{
weakpointBody.healthComponent.HealFraction(1f, default(ProcChainMask));
}
}
internal bool <Awake>b__16_5(ItemCountPair x)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return (Object)(object)x.itemDef == (Object)(object)Items.LunarDagger;
}
internal void <Awake>b__16_4(CharacterBody body, StatHookEventArgs args)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
Inventory val = ((body != null) ? body.inventory : null);
if (val != null && Object.op_Implicit((Object)(object)val))
{
if (body.inventory.GetItemCountEffective(ItemCatalog.FindItemIndex("SOLUS_HP_MULTIPLIER")) > 0)
{
args.healthTotalMult *= SolusHP.Value;
}
if (body.inventory.GetItemCountEffective(ItemCatalog.FindItemIndex("WEAKPOINT_HP_MULTIPLIER")) > 0)
{
args.healthTotalMult *= WeakPointHP.Value;
}
if (body.inventory.GetItemCountEffective(ItemCatalog.FindItemIndex("MULT_HP_MULTIPLIER")) > 0)
{
args.healthTotalMult *= MulTHP.Value;
}
}
}
}
public const string PluginGUID = "prodzpod.RealerSolusWing";
public const string PluginAuthor = "prodzpod";
public const string PluginName = "RealerSolusWing";
public const string PluginVersion = "1.1.2";
public static ManualLogSource Log;
public static PluginInfo pluginInfo;
public static ConfigFile Config;
public static ConfigEntry<bool> CoreImmune;
public static ConfigEntry<GameMode> Mode;
public static ConfigEntry<float> P1Threshold;
public static ConfigEntry<float> P2Threshold;
public static ConfigEntry<int> MulTGlasses;
public static ConfigEntry<float> SolusHP;
public static ConfigEntry<float> WeakPointHP;
public static ConfigEntry<float> MulTHP;
public void Awake()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Expected O, but got Unknown
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Expected O, but got Unknown
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Expected O, but got Unknown
//IL_0250: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Expected O, but got Unknown
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Expected O, but got Unknown
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Expected O, but got Unknown
pluginInfo = ((BaseUnityPlugin)this).Info;
Log = ((BaseUnityPlugin)this).Logger;
Config = new ConfigFile(Path.Combine(Paths.ConfigPath, "prodzpod.RealerSolusWing.cfg"), true);
CoreImmune = Config.Bind<bool>("General", "Make Main Core Immune to Damage", true, "while orbs are active makes it fully immune instead of armor 100 so you can't cheese P1 and lame gameplay");
Mode = Config.Bind<GameMode>("General", "Game Mode", GameMode.TotalHPFraction, "AVAILABLE MODES: phases progress based on the combined health of the four weak points / heal the other weakpoints when one is destroyed");
P1Threshold = Config.Bind<float>("General", "Phase 1 HP Threshold", 90f, "total HP percentage required to pass P1");
P2Threshold = Config.Bind<float>("General", "Phase 2 HP Threshold", 40f, "total HP percentage required to pass P2");
SolusHP = Config.Bind<float>("General", "Solus Wing HP Multiplier", 0.25f, "Health multiplier (if core is immune, this is the health for desperation phase)");
WeakPointHP = Config.Bind<float>("General", "Weak Point HP Multiplier", 1f, "Health multiplier");
MulTGlasses = Config.Bind<int>("Fun", "Umbra of Mul-T Shaped Glass Amount", 1, "less hp for more dmg");
MulTHP = Config.Bind<float>("Fun", "Umbra of Mul-T HP Multiplier", 1f, "Health multiplier");
object obj = <>c.<>9__16_0;
if (obj == null)
{
hook_Awake val = delegate(orig_Awake orig, SolusWingWeakPointsController self)
{
orig.Invoke(self);
((Component)self).gameObject.AddComponent<RealerSolusWingController>();
};
<>c.<>9__16_0 = val;
obj = (object)val;
}
SolusWingWeakPointsController.Awake += (hook_Awake)obj;
object obj2 = <>c.<>9__16_1;
if (obj2 == null)
{
hook_IsBossHealthBelowThreshhold val2 = delegate(orig_IsBossHealthBelowThreshhold orig, SolutionalHauntReferences self, float perc)
{
bool result = orig.Invoke(self, perc);
if (Mode.Value == GameMode.HealWeakPoints)
{
return result;
}
if (!self.bossWasOriginallySpawned || !Object.op_Implicit((Object)(object)self.solusBoss))
{
return false;
}
List<CharacterBody> weakpointBodies = ((Component)self.solusBoss).GetComponent<SolusWingWeakPointsController>().WeakpointBodies;
float num2 = 0f;
foreach (CharacterBody item in weakpointBodies)
{
if (item.healthComponent.alive)
{
num2 += item.healthComponent.combinedHealthFraction;
}
}
num2 /= (float)weakpointBodies.Count;
return self.bossWasOriginallySpawned && num2 < perc;
};
<>c.<>9__16_1 = val2;
obj2 = (object)val2;
}
SolutionalHauntReferences.IsBossHealthBelowThreshhold += (hook_IsBossHealthBelowThreshhold)obj2;
object obj3 = <>c.<>9__16_2;
if (obj3 == null)
{
hook_onWeakpointDestroyedServer val3 = delegate(orig_onWeakpointDestroyedServer orig, SolusWingWeakPointsController self, GameObject weakpoint, CharacterBody body)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, weakpoint, body);
if (Mode.Value == GameMode.HealWeakPoints)
{
foreach (CharacterBody weakpointBody in self.WeakpointBodies)
{
weakpointBody.healthComponent.HealFraction(1f, default(ProcChainMask));
}
}
};
<>c.<>9__16_2 = val3;
obj3 = (object)val3;
}
SolusWingWeakPointsController.onWeakpointDestroyedServer += (hook_onWeakpointDestroyedServer)obj3;
SolusWing2BaseMissionState.healthPercentageForPhase2 = P1Threshold.Value / 100f;
SolusWing2BaseMissionState.healthPercentageForPhase3 = P2Threshold.Value / 100f;
CharacterSpawnCard _csc = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/DLC3/solutionalhaunt/cscVultureMulTInvader.asset").WaitForCompletion();
string[] array = new string[3] { "SOLUS_HP_MULTIPLIER", "WEAKPOINT_HP_MULTIPLIER", "MULT_HP_MULTIPLIER" };
foreach (string text in array)
{
ItemTag[] array2 = new ItemTag[4];
RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
CustomItem val4 = new CustomItem(text, "", "", "", "", (Sprite)null, (GameObject)null, (ItemTag[])(object)array2, (ItemTier)5, true, false, (UnlockableDef)null, Array.Empty<ItemDisplayRule>());
val4.ItemDef.tier = (ItemTier)5;
val4.ItemDef.deprecatedTier = (ItemTier)5;
ItemAPI.Add(val4);
}
ScriptedCombatEncounter.Awake += (hook_Awake)delegate(orig_Awake orig, ScriptedCombatEncounter self)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (self.spawns.Length != 0 && !((Object)(object)self.spawns[0].spawnCard != (Object)(object)_csc))
{
CharacterSpawnCard val7 = (CharacterSpawnCard)self.spawns[0].spawnCard;
int num = val7.itemsToGrant.ToList().FindIndex((ItemCountPair x) => (Object)(object)x.itemDef == (Object)(object)Items.LunarDagger);
val7.itemsToGrant[num].count = MulTGlasses.Value;
CollectionExtensions.AddToArray<ItemCountPair>(val7.itemsToGrant, new ItemCountPair
{
itemDef = ItemCatalog.GetItemDef(ItemCatalog.FindItemIndex("MULT_HP_MULTIPLIER")),
count = 1
});
}
};
object obj4 = <>c.<>9__16_4;
if (obj4 == null)
{
StatHookEventHandler val5 = delegate(CharacterBody body, StatHookEventArgs args)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
Inventory val6 = ((body != null) ? body.inventory : null);
if (val6 != null && Object.op_Implicit((Object)(object)val6))
{
if (body.inventory.GetItemCountEffective(ItemCatalog.FindItemIndex("SOLUS_HP_MULTIPLIER")) > 0)
{
args.healthTotalMult *= SolusHP.Value;
}
if (body.inventory.GetItemCountEffective(ItemCatalog.FindItemIndex("WEAKPOINT_HP_MULTIPLIER")) > 0)
{
args.healthTotalMult *= WeakPointHP.Value;
}
if (body.inventory.GetItemCountEffective(ItemCatalog.FindItemIndex("MULT_HP_MULTIPLIER")) > 0)
{
args.healthTotalMult *= MulTHP.Value;
}
}
};
<>c.<>9__16_4 = val5;
obj4 = (object)val5;
}
RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj4;
}
}
}