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.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using RoR2;
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("ExamplePlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ded4bf354dc707d4f13b879e339028794895d824")]
[assembly: AssemblyProduct("ExamplePlugin")]
[assembly: AssemblyTitle("ExamplePlugin")]
[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 ExamplePlugin
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("Phorg.LeagueItems", "LeagueItems", "1.0.0")]
public class ExamplePlugin : BaseUnityPlugin
{
public static class AssetLoader
{
private static string pluginDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
private static string bundlePath = Path.Combine(pluginDir, "AssetBundles", "prefabs");
private static AssetBundle bundle = AssetBundle.LoadFromFile(bundlePath);
public static GameObject LoadAsset(string assetName)
{
if ((Object)(object)bundle == (Object)null)
{
Debug.LogError((object)("Failed to load bundle at " + bundlePath));
}
return bundle.LoadAsset<GameObject>(assetName);
}
public static void ListAllAssets()
{
string[] allAssetNames = bundle.GetAllAssetNames();
foreach (string text in allAssetNames)
{
Chat.AddMessage("Bundle contains asset: " + text);
}
}
}
public const string PluginGUID = "Phorg.LeagueItems";
public const string PluginAuthor = "Phorg";
public const string PluginName = "LeagueItems";
public const string PluginVersion = "1.0.0";
public void Awake()
{
Log.Init(((BaseUnityPlugin)this).Logger);
TempVFX.Load();
PulseHitVFXListener.Init();
AllyArmor.Define();
AllyArmor.Hooks();
FlickerBlade.Define();
FlickerBlade.Hooks();
HorizonFocus.Define();
HorizonFocus.Hooks();
UnendingDespair.Define();
UnendingDespair.Hooks();
RegisterLanguage();
}
private void Update()
{
}
private static void RegisterLanguage()
{
LanguageAPI.Add("FLICKERBLADE_NAME", "Flicker Blade");
LanguageAPI.Add("FLICKERBLADE_PICKUP", "Primary hits grant stacking attack-speed.");
LanguageAPI.Add("FLICKERBLADE_DESC", "Hits with your <style=cIsUtility>Primary skill</style> grant a stacking buff that increases <style=cIsDamage>Attack Speed by 5% (+1% per stack)</style> for <style=cIsUtility>0.5s (+0.5s per stack)</style>. Duration refreshes on each hit.");
LanguageAPI.Add("FLICKERBLADE_LORE", "“The blade is faster than thought…”");
LanguageAPI.Add("LOCKET_OF_THE_IRON_SOLARI_NAME", "Locket of the Iron Solari");
LanguageAPI.Add("LOCKET_OF_THE_IRON_SOLARI_PICKUP", "Allies gain armour from your presence.");
LanguageAPI.Add("LOCKET_OF_THE_IRON_SOLARI_DESC", "<style=cIsHealing>Increase armor</style> for minions by <style=cIsHealing>10</style> (+10 per stack).");
LanguageAPI.Add("LOCKET_OF_THE_IRON_SOLARI_LORE", "The sun’s protection, entrusted to you.");
LanguageAPI.Add("UNENDING_DESPAIR_NAME", "Unending Despair");
LanguageAPI.Add("UNENDING_DESPAIR_PICKUP", "Lost barrier erupts in damaging pulses.");
LanguageAPI.Add("UNENDING_DESPAIR_DESC", "Out-of-combat, regenerate a <style=cIsHealing>temporary barrier</style> for <style=cIsHealing>10%</style> max health.Losing more than <style=cIsHealing>10%</style> max health in barrier, will emit a pulse dealing <style=cIsDamage>250% of the lost amount</style> (+150% per stack). ");
LanguageAPI.Add("UNENDING_DESPAIR_LORE", "Hope is a candle; despair the wind.");
LanguageAPI.Add("HORIZON_FOCUS_NAME", "Horizon Focus");
LanguageAPI.Add("HORIZON_FOCUS_PICKUP", "Stuns chunk enemy health.");
LanguageAPI.Add("HORIZON_FOCUS_DESC", "When you <style=cIsDamage>stun, freeze, root or shock</style> an enemy, deal <style=cIsDamage>20%</style> of their current health (+10% per stack) as additional damage.");
LanguageAPI.Add("HORIZON_FOCUS_LORE", "The world narrows to a single point…");
}
public static Sprite LoadSpriteFromFile(string fileName)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string text = Path.Combine(directoryName, "icons", fileName);
if (!File.Exists(text))
{
Debug.LogError((object)(fileName + " Icon not found at path: " + text));
return null;
}
byte[] array = File.ReadAllBytes(text);
Texture2D val = new Texture2D(2, 2, (TextureFormat)5, false);
if (!ImageConversion.LoadImage(val, array))
{
Debug.LogError((object)(fileName + " Failed to load image data."));
return null;
}
return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
}
}
internal static class FlickerBlade
{
[CompilerGenerated]
private static class <>O
{
public static hook_ProcessHitEnemy <0>__AddAttackSpeedBuff;
public static StatHookEventHandler <1>__ApplyRageBuff;
}
internal static ItemDef ItemDef;
internal static BuffDef RageBuff;
internal static void Define()
{
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Expected O, but got Unknown
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Expected O, but got Unknown
RageBuff = ScriptableObject.CreateInstance<BuffDef>();
((Object)RageBuff).name = "RAGEBLADE_STACK";
RageBuff.iconSprite = ExamplePlugin.LoadSpriteFromFile("FlickerBladeBuff.png");
RageBuff.canStack = true;
RageBuff.isDebuff = false;
RageBuff.isCooldown = false;
RageBuff.isHidden = false;
ContentAddition.AddBuffDef(RageBuff);
ItemDef = ScriptableObject.CreateInstance<ItemDef>();
((Object)ItemDef).name = "FLICKERBLADE_NAME";
ItemDef.nameToken = "FLICKERBLADE_NAME";
ItemDef.pickupToken = "FLICKERBLADE_PICKUP";
ItemDef.descriptionToken = "FLICKERBLADE_DESC";
ItemDef.loreToken = "FLICKERBLADE_LORE";
ItemDef.tier = (ItemTier)2;
ItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier3Def.asset").WaitForCompletion();
ItemDef.pickupIconSprite = ExamplePlugin.LoadSpriteFromFile("FlickerBlade.png");
ItemDef.canRemove = true;
ItemDef.hidden = false;
GameObject pickupModelPrefab = ExamplePlugin.AssetLoader.LoadAsset("flickerBladeItem");
ItemDef.pickupModelPrefab = pickupModelPrefab;
ItemAPI.Add(new CustomItem(ItemDef, new ItemDisplayRuleDict((ItemDisplayRule[])null)));
}
internal static void Hooks()
{
//IL_0011: 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)
//IL_001c: Expected O, but got Unknown
//IL_0032: 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_003d: Expected O, but got Unknown
object obj = <>O.<0>__AddAttackSpeedBuff;
if (obj == null)
{
hook_ProcessHitEnemy val = AddAttackSpeedBuff;
<>O.<0>__AddAttackSpeedBuff = val;
obj = (object)val;
}
GlobalEventManager.ProcessHitEnemy += (hook_ProcessHitEnemy)obj;
object obj2 = <>O.<1>__ApplyRageBuff;
if (obj2 == null)
{
StatHookEventHandler val2 = ApplyRageBuff;
<>O.<1>__ApplyRageBuff = val2;
obj2 = (object)val2;
}
RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj2;
}
private static void AddAttackSpeedBuff(orig_ProcessHitEnemy orig, GlobalEventManager self, DamageInfo di, GameObject victim)
{
//IL_0051: 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)
orig.Invoke(self, di, victim);
CharacterBody val = (Object.op_Implicit((Object)(object)di.attacker) ? di.attacker.GetComponent<CharacterBody>() : null);
if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.inventory))
{
return;
}
bool flag = ((Enum)di.damageType.damageSource).HasFlag((Enum)(object)(DamageSource)1);
int itemCount = val.inventory.GetItemCount(ItemDef.itemIndex);
if (flag && itemCount != 0)
{
float num = 0.5f + 0.5f * (float)itemCount;
int buffCount = val.GetBuffCount(RageBuff);
val.ClearTimedBuffs(RageBuff);
for (int i = 0; i <= buffCount; i++)
{
val.AddTimedBuff(RageBuff, num);
}
}
}
private static void ApplyRageBuff(CharacterBody body, StatHookEventArgs args)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
int buffCount = body.GetBuffCount(RageBuff);
if (buffCount != 0)
{
int num = (Object.op_Implicit((Object)(object)body.inventory) ? body.inventory.GetItemCount(ItemDef.itemIndex) : 0);
float num2 = 0.05f + 0.01f * (float)(num - 1);
args.attackSpeedMultAdd += num2 * (float)buffCount;
}
}
}
internal static class HorizonFocus
{
[CompilerGenerated]
private static class <>O
{
public static hook_OnTakeDamageServer <0>__StunWatcher;
}
internal static ItemDef ItemDef;
private const DamageType StunFlags = 50331936u;
internal static void Define()
{
//IL_006d: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Expected O, but got Unknown
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
ItemDef = ScriptableObject.CreateInstance<ItemDef>();
((Object)ItemDef).name = "HORIZON_FOCUS_NAME";
ItemDef.nameToken = "HORIZON_FOCUS_NAME";
ItemDef.pickupToken = "HORIZON_FOCUS_PICKUP";
ItemDef.descriptionToken = "HORIZON_FOCUS_DESC";
ItemDef.loreToken = "HORIZON_FOCUS_LORE";
ItemDef.tier = (ItemTier)1;
ItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier2Def.asset").WaitForCompletion();
ItemDef.pickupIconSprite = ExamplePlugin.LoadSpriteFromFile("HorizonFocus.png");
ItemDef.canRemove = true;
ItemDef.hidden = false;
GameObject pickupModelPrefab = ExamplePlugin.AssetLoader.LoadAsset("horizonFocusItem");
ItemDef.pickupModelPrefab = pickupModelPrefab;
ItemAPI.Add(new CustomItem(ItemDef, new ItemDisplayRuleDict((ItemDisplayRule[])null)));
}
internal static void Hooks()
{
//IL_0011: 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)
//IL_001c: Expected O, but got Unknown
object obj = <>O.<0>__StunWatcher;
if (obj == null)
{
hook_OnTakeDamageServer val = StunWatcher;
<>O.<0>__StunWatcher = val;
obj = (object)val;
}
SetStateOnHurt.OnTakeDamageServer += (hook_OnTakeDamageServer)obj;
}
private static void StunWatcher(orig_OnTakeDamageServer orig, SetStateOnHurt self, DamageReport report)
{
//IL_0067: 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_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: 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_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: 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_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Expected O, but got Unknown
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Expected O, but got Unknown
orig.Invoke(self, report);
if (report == null)
{
return;
}
DamageInfo damageInfo = report.damageInfo;
CharacterBody victimBody = report.victimBody;
CharacterBody attackerBody = report.attackerBody;
if (Object.op_Implicit((Object)(object)victimBody) && Object.op_Implicit((Object)(object)attackerBody) && Object.op_Implicit((Object)(object)attackerBody.inventory) && DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)50331936)) != 0)
{
int itemCount = attackerBody.inventory.GetItemCount(ItemDef.itemIndex);
if (itemCount > 0)
{
float damage = victimBody.healthComponent.combinedHealth * (0.4f + 0.1f * (float)itemCount);
DamageInfo val = new DamageInfo
{
attacker = ((Component)attackerBody).gameObject,
inflictor = ((Component)attackerBody).gameObject,
crit = false,
damage = damage,
damageColorIndex = (DamageColorIndex)3,
damageType = DamageTypeCombo.op_Implicit((DamageType)0),
position = victimBody.corePosition,
procCoefficient = 0f
};
victimBody.healthComponent.TakeDamage(val);
EffectManager.SpawnEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/ImpactEffects/IgniteExplosionVFX"), new EffectData
{
origin = victimBody.corePosition
}, false);
}
}
}
}
internal static class AllyArmor
{
[CompilerGenerated]
private static class <>O
{
public static StatHookEventHandler <0>__GrantAllyArmor;
}
internal static ItemDef ItemDef;
internal static void Define()
{
//IL_006d: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Expected O, but got Unknown
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
ItemDef = ScriptableObject.CreateInstance<ItemDef>();
((Object)ItemDef).name = "LOCKET_OF_THE_IRON_SOLARI_NAME";
ItemDef.nameToken = "LOCKET_OF_THE_IRON_SOLARI_NAME";
ItemDef.pickupToken = "LOCKET_OF_THE_IRON_SOLARI_PICKUP";
ItemDef.descriptionToken = "LOCKET_OF_THE_IRON_SOLARI_DESC";
ItemDef.loreToken = "LOCKET_OF_THE_IRON_SOLARI_LORE";
ItemDef.tier = (ItemTier)0;
ItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier1Def.asset").WaitForCompletion();
ItemDef.pickupIconSprite = ExamplePlugin.LoadSpriteFromFile("Locket.png");
ItemDef.canRemove = true;
ItemDef.hidden = false;
GameObject pickupModelPrefab = ExamplePlugin.AssetLoader.LoadAsset("locketItem");
ItemDef.pickupModelPrefab = pickupModelPrefab;
ItemAPI.Add(new CustomItem(ItemDef, new ItemDisplayRuleDict((ItemDisplayRule[])null)));
}
internal static void Hooks()
{
//IL_0011: 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)
//IL_001c: Expected O, but got Unknown
object obj = <>O.<0>__GrantAllyArmor;
if (obj == null)
{
StatHookEventHandler val = GrantAllyArmor;
<>O.<0>__GrantAllyArmor = val;
obj = (object)val;
}
RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj;
}
private static void GrantAllyArmor(CharacterBody body, StatHookEventArgs args)
{
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.master))
{
return;
}
CharacterMaster master = body.master;
if ((Object)(object)master.playerCharacterMasterController != (Object)null || !Object.op_Implicit((Object)(object)master.minionOwnership.ownerMaster))
{
return;
}
Inventory inventory = master.minionOwnership.ownerMaster.inventory;
if (Object.op_Implicit((Object)(object)inventory))
{
int itemCount = inventory.GetItemCount(ItemDef.itemIndex);
if (itemCount > 0)
{
float num = (float)itemCount * 10f;
args.armorAdd += num;
}
}
}
private static void AfterRecalc(orig_RecalculateStats orig, CharacterBody body)
{
float armor = body.armor;
orig.Invoke(body);
float armor2 = body.armor;
if (armor2 != armor)
{
Chat.AddMessage($"[DEBUG] {body.GetDisplayName()} armor: {armor} → {armor2}");
}
}
}
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);
}
}
public class PulseMarker : MonoBehaviour
{
public Vector3 center;
public float ttl = 1f;
private void Update()
{
ttl -= Time.deltaTime;
if (ttl <= 0f)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
}
public class PulseHitVFXListener
{
public static GameObject OnHitVFXPrefab;
public static void Init()
{
GlobalEventManager.onServerDamageDealt += OnServerDamageDealt;
}
private static void OnServerDamageDealt(DamageReport report)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
if (!NetworkServer.active || !Object.op_Implicit((Object)(object)report?.victimBody))
{
return;
}
GameObject inflictor = report.damageInfo.inflictor;
if (!Object.op_Implicit((Object)(object)inflictor))
{
return;
}
PulseMarker component = inflictor.GetComponent<PulseMarker>();
if (Object.op_Implicit((Object)(object)component))
{
Vector3 corePosition = report.victimBody.corePosition;
Vector3 val = corePosition - component.center;
if (((Vector3)(ref val)).sqrMagnitude > 1E-06f)
{
((Vector3)(ref val)).Normalize();
}
else
{
val = Vector3.up;
}
if (Object.op_Implicit((Object)(object)TempVFX.OnHitImpactPrefab))
{
Debug.LogWarning((object)"[UD] OnHitImpactPrefab exists");
EffectManager.SimpleImpactEffect(TempVFX.OnHitImpactPrefab, corePosition, val, true);
}
}
}
}
public static class TempVFX
{
public static GameObject OnHitImpactPrefab;
public static void Load()
{
OnHitImpactPrefab = LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/OmniImpactVFX") ?? LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/ImpactEffects/OmniImpactVFX");
if (!Object.op_Implicit((Object)(object)OnHitImpactPrefab))
{
Debug.LogWarning((object)"[UD] TempVFX: Could not find OmniImpactVFX, on-hit effects will be skipped.");
}
}
}
internal static class UnendingDespair
{
private class BarrierPulseTracker : MonoBehaviour
{
private CharacterBody body;
private HealthComponent hc;
private float lastBarrier;
private static readonly float BASE_THRESHOLD_FRAC = 0.1f;
private float accumulatedLoss = 0f;
private ItemIndex ItemIndex => ItemDef.itemIndex;
private void Awake()
{
body = ((Component)this).GetComponent<CharacterBody>();
hc = body.healthComponent;
lastBarrier = hc.barrier;
}
private void FixedUpdate()
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)hc))
{
return;
}
int num = (Object.op_Implicit((Object)(object)body.inventory) ? body.inventory.GetItemCount(ItemIndex) : 0);
if (num == 0)
{
lastBarrier = hc.barrier;
return;
}
float barrier = hc.barrier;
if (barrier >= lastBarrier)
{
lastBarrier = barrier;
return;
}
float num2 = lastBarrier - barrier;
if (num2 <= 0f)
{
lastBarrier = barrier;
return;
}
accumulatedLoss += num2;
float num3 = BASE_THRESHOLD_FRAC * body.maxHealth;
if (accumulatedLoss >= num3)
{
FirePulse(accumulatedLoss, num);
accumulatedLoss = 0f;
}
lastBarrier = barrier;
}
private void FirePulse(float depletedBarrier, int stacks)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: 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_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: 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_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_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Expected O, but got Unknown
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
float num = 2.5f + 1.5f * (float)(stacks - 1);
float baseDamage = depletedBarrier * num;
GameObject val = new GameObject("UD_PulseMarker");
PulseMarker pulseMarker = val.AddComponent<PulseMarker>();
pulseMarker.center = body.corePosition;
pulseMarker.ttl = 1f;
BlastAttack val2 = new BlastAttack
{
attacker = ((Component)body).gameObject,
inflictor = val,
attackerFiltering = (AttackerFiltering)2,
baseDamage = baseDamage,
baseForce = 0f,
bonusForce = Vector3.zero,
crit = body.RollCrit(),
damageColorIndex = (DamageColorIndex)2,
damageType = DamageTypeCombo.op_Implicit((DamageType)0),
falloffModel = (FalloffModel)0,
position = body.corePosition,
procCoefficient = 0.25f,
radius = 12f + 2f * (float)(stacks - 1)
};
val2.Fire();
}
}
[CompilerGenerated]
private static class <>O
{
public static Action<CharacterBody> <0>__AddTrackerIfNeeded;
public static hook_FixedUpdate <1>__BarrierOutOfCombat;
}
internal static ItemDef ItemDef;
internal static GameObject PulseVFX;
internal static void Define()
{
//IL_006d: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Expected O, but got Unknown
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
//IL_00da: 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)
ItemDef = ScriptableObject.CreateInstance<ItemDef>();
((Object)ItemDef).name = "UNENDING_DESPAIR_NAME";
ItemDef.nameToken = "UNENDING_DESPAIR_NAME";
ItemDef.pickupToken = "UNENDING_DESPAIR_PICKUP";
ItemDef.descriptionToken = "UNENDING_DESPAIR_DESC";
ItemDef.loreToken = "UNENDING_DESPAIR_LORE";
ItemDef.tier = (ItemTier)2;
ItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier3Def.asset").WaitForCompletion();
ItemDef.pickupIconSprite = ExamplePlugin.LoadSpriteFromFile("UnendingDespair.png");
ItemDef.canRemove = true;
ItemDef.hidden = false;
GameObject pickupModelPrefab = ExamplePlugin.AssetLoader.LoadAsset("unendingDespairItem");
ItemDef.pickupModelPrefab = pickupModelPrefab;
ItemAPI.Add(new CustomItem(ItemDef, new ItemDisplayRuleDict((ItemDisplayRule[])null)));
PulseVFX = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Common/VFX/OmniExplosionVFX.prefab").WaitForCompletion();
}
internal static void Hooks()
{
//IL_0032: 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_003d: Expected O, but got Unknown
CharacterBody.onBodyStartGlobal += AddTrackerIfNeeded;
object obj = <>O.<1>__BarrierOutOfCombat;
if (obj == null)
{
hook_FixedUpdate val = BarrierOutOfCombat;
<>O.<1>__BarrierOutOfCombat = val;
obj = (object)val;
}
CharacterBody.FixedUpdate += (hook_FixedUpdate)obj;
}
private static void AddTrackerIfNeeded(CharacterBody body)
{
if (!Object.op_Implicit((Object)(object)((Component)body).GetComponent<BarrierPulseTracker>()))
{
((Component)body).gameObject.AddComponent<BarrierPulseTracker>();
}
}
private static void BarrierOutOfCombat(orig_FixedUpdate orig, CharacterBody body)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(body);
if (NetworkServer.active && !((Object)(object)body == (Object)null) && !((Object)(object)body.inventory == (Object)null) && body.inventory.GetItemCount(ItemDef.itemIndex) != 0 && body.outOfDanger)
{
float num = body.maxHealth * 0.1f;
float num2 = num - body.healthComponent.barrier;
if (num2 > 1f)
{
body.healthComponent.AddBarrier(num2);
}
}
}
}
}