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 On.RoR2.UI;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
[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 = ".NET Standard 2.0")]
[assembly: AssemblyCompany("EdgeOfNight")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EdgeOfNight")]
[assembly: AssemblyTitle("EdgeOfNight")]
[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 EdgeOfNightMod
{
internal static class Assets
{
internal static GameObject EdgeOfNightPrefab;
internal static Sprite EdgeOfNightIcon;
internal static ManualLogSource Logger;
private const string ModPrefix = "@EdgeOfNightMod:";
internal static ItemDef EdgeOfNightItemDef;
internal static void Init(ManualLogSource Logger)
{
Assets.Logger = Logger;
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("EdgeOfNight.eonassetbundle"))
{
AssetBundle val = AssetBundle.LoadFromStream(stream);
EdgeOfNightPrefab = val.LoadAsset<GameObject>("Assets/AssetsBundlesWanted/Edge_of_Night.prefab");
EdgeOfNightIcon = val.LoadAsset<Sprite>("Assets/AssetsBundlesWanted/Edge_of_Night.png");
}
CreateEdgeOfNightItem();
AddLanguageTokens();
}
private static void CreateEdgeOfNightItem()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Expected O, but got Unknown
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Expected O, but got Unknown
EdgeOfNightItemDef = ScriptableObject.CreateInstance<ItemDef>();
((Object)EdgeOfNightItemDef).name = "EdgeOfNight";
EdgeOfNightItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier2Def.asset").WaitForCompletion();
EdgeOfNightItemDef.pickupModelPrefab = EdgeOfNightPrefab;
EdgeOfNightItemDef.pickupIconSprite = EdgeOfNightIcon;
EdgeOfNightItemDef.nameToken = "EDGEOFNIGHT_NAME";
EdgeOfNightItemDef.pickupToken = "EDGEOFNIGHT_PICKUP";
EdgeOfNightItemDef.descriptionToken = "EDGEOFNIGHT_DESC";
EdgeOfNightItemDef.loreToken = "EDGEOFNIGHT_LORE";
EdgeOfNightItemDef.tags = (ItemTag[])(object)new ItemTag[2]
{
(ItemTag)3,
(ItemTag)1
};
EdgeOfNightItemDef.canRemove = true;
EdgeOfNightItemDef.hidden = false;
ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null);
CustomItem val2 = new CustomItem(EdgeOfNightItemDef, val);
if (!ItemAPI.Add(val2))
{
EdgeOfNightItemDef = null;
Logger.LogError((object)"Unable to add Edge of Night item");
}
}
private static void AddLanguageTokens()
{
LanguageAPI.Add("EDGEOFNIGHT_NAME", "Edge of Night");
LanguageAPI.Add("EDGEOFNIGHT_PICKUP", "When attacked by an Elite enemy, temporarily gain that Elite's power.");
LanguageAPI.Add("EDGEOFNIGHT_DESC", $"Upon being attacked by an Elite enemy, gain that Elite's <style=cIsDamage>power</style> for <style=cIsUtility>{EdgeOfNight.GetTotalBuffTime(1)}s</style> <style=cStack>(+{EdgeOfNight.buffStackBonus}s per stack)</style>. Recharges every <style=cIsUtility>{EdgeOfNight.cooldownDuration}</style> seconds.");
LanguageAPI.Add("EDGEOFNIGHT_LORE", "It's just a cool-looking cape..?");
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[R2APISubmoduleDependency(new string[] { "ItemAPI", "LanguageAPI" })]
[BepInPlugin("George.EdgeofNightMod", "EdgeofNightMod", "0.1")]
public class EdgeOfNight : BaseUnityPlugin
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static hook_OnTakeDamageServer <>9__12_0;
public static hook_RecalculateStats <>9__12_1;
public static hook_SetItemIndex <>9__12_2;
internal void <HooksContainer>b__12_0(orig_OnTakeDamageServer orig, CharacterBody self, DamageReport damageReport)
{
VerifyBody(self, damageReport);
orig.Invoke(self, damageReport);
}
internal void <HooksContainer>b__12_1(orig_RecalculateStats orig, CharacterBody self)
{
UpdateBuff(self);
orig.Invoke(self);
}
internal void <HooksContainer>b__12_2(orig_SetItemIndex orig, ItemIcon self, ItemIndex newIndex, int newCount)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: 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)
orig.Invoke(self, newIndex, newCount);
if ((Object)(object)self.tooltipProvider != (Object)null && newIndex == Assets.EdgeOfNightItemDef.itemIndex)
{
self.tooltipProvider.overrideBodyText = GetDisplayInformation();
}
}
}
private const string ModVer = "0.1";
public const string ModAuthor = "George";
public const string ModName = "EdgeofNightMod";
public const string PluginGUID = "George.EdgeofNightMod";
public static ManualLogSource Log;
public static BuffDef activeBuff;
public static BuffDef cooldownBuff;
public static float buffDuration = 1f;
public static float buffStackBonus = 2f;
public static float cooldownDuration = 8f;
public void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Assets.Init(Log);
CreateBuffs();
HooksContainer();
}
private static void CreateBuffs()
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: 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)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
activeBuff = ScriptableObject.CreateInstance<BuffDef>();
activeBuff.iconSprite = Assets.EdgeOfNightIcon;
((Object)activeBuff).name = "EdgeOfNightBuff";
activeBuff.canStack = false;
activeBuff.isDebuff = false;
activeBuff.isCooldown = false;
activeBuff.isHidden = false;
activeBuff.buffColor = Color.white;
ContentAddition.AddBuffDef(activeBuff);
cooldownBuff = ScriptableObject.CreateInstance<BuffDef>();
cooldownBuff.iconSprite = Assets.EdgeOfNightIcon;
((Object)cooldownBuff).name = "EdgeOfNightCooldownBuff";
cooldownBuff.canStack = true;
cooldownBuff.isDebuff = false;
cooldownBuff.isCooldown = true;
cooldownBuff.isHidden = false;
cooldownBuff.buffColor = Color.gray;
ContentAddition.AddBuffDef(cooldownBuff);
}
private static void HooksContainer()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_005f: 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_006a: Expected O, but got Unknown
object obj = <>c.<>9__12_0;
if (obj == null)
{
hook_OnTakeDamageServer val = delegate(orig_OnTakeDamageServer orig, CharacterBody self, DamageReport damageReport)
{
VerifyBody(self, damageReport);
orig.Invoke(self, damageReport);
};
<>c.<>9__12_0 = val;
obj = (object)val;
}
CharacterBody.OnTakeDamageServer += (hook_OnTakeDamageServer)obj;
object obj2 = <>c.<>9__12_1;
if (obj2 == null)
{
hook_RecalculateStats val2 = delegate(orig_RecalculateStats orig, CharacterBody self)
{
UpdateBuff(self);
orig.Invoke(self);
};
<>c.<>9__12_1 = val2;
obj2 = (object)val2;
}
CharacterBody.RecalculateStats += (hook_RecalculateStats)obj2;
object obj3 = <>c.<>9__12_2;
if (obj3 == null)
{
hook_SetItemIndex val3 = delegate(orig_SetItemIndex orig, ItemIcon self, ItemIndex newIndex, int newCount)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: 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)
orig.Invoke(self, newIndex, newCount);
if ((Object)(object)self.tooltipProvider != (Object)null && newIndex == Assets.EdgeOfNightItemDef.itemIndex)
{
self.tooltipProvider.overrideBodyText = GetDisplayInformation();
}
};
<>c.<>9__12_2 = val3;
obj3 = (object)val3;
}
ItemIcon.SetItemIndex += (hook_SetItemIndex)obj3;
}
public static void VerifyBody(CharacterBody self, DamageReport damageReport)
{
if (Object.op_Implicit((Object)(object)self) && self.isPlayerControlled)
{
int itemCount = self.inventory.GetItemCount(Assets.EdgeOfNightItemDef);
if (itemCount > 0)
{
ActivateEffect(itemCount, self, damageReport);
}
}
}
public static int GetTotalBuffTime(int count)
{
return Convert.ToInt32(buffDuration + buffStackBonus * (float)count);
}
private static void ActivateEffect(int edgeOfNight_count, CharacterBody self, DamageReport damageReport)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: 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)
if (!self.HasBuff(activeBuff) || damageReport == null)
{
return;
}
for (int i = 0; i < BuffCatalog.eliteBuffIndices.Length; i++)
{
BuffIndex val = BuffCatalog.eliteBuffIndices[i];
if (damageReport.attackerBody.HasBuff(val))
{
self.AddTimedBuff(val, (float)GetTotalBuffTime(edgeOfNight_count));
self.RemoveBuff(activeBuff);
AddCooldownStacks(self, cooldownBuff, cooldownDuration);
}
}
}
public static void AddCooldownStacks(CharacterBody self, BuffDef cooldown, float duration)
{
for (float num = 1f; num <= duration; num += 1f)
{
self.AddTimedBuff(cooldown, num);
}
}
private static void UpdateBuff(CharacterBody self)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)self) && Object.op_Implicit((Object)(object)self.inventory) && self.inventory.GetItemCount(Assets.EdgeOfNightItemDef.itemIndex) > 0 && !self.HasBuff(activeBuff) && !self.HasBuff(cooldownBuff))
{
self.AddBuff(activeBuff);
}
}
private static string GetDisplayInformation()
{
return Language.GetString(Assets.EdgeOfNightItemDef.descriptionToken);
}
}
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);
}
}
}