Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Edge Of Night v0.3.0
EdgeOfNight.dll
Decompiled 2 years agousing System; using System.Collections.Generic; 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 RoR2; using RoR2.UI; 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.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 GameObject EdgeOfNightSpherePrefab; 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.Assets.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"); EdgeOfNightSpherePrefab = val.LoadAsset<GameObject>("Assets/AssetsBundlesWanted/Edge_of_Night_Sphere.prefab"); } 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 damaged by an Elite enemy, temporarily gain that Elite's power."); LanguageAPI.Add("EDGEOFNIGHT_DESC", $"Upon being damaged 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_BUFF", "<style=cIsUtility>Active</style>"); LanguageAPI.Add("EDGEOFNIGHT_COOLDOWN", "<style=cIsUtility>On cooldown</style>"); LanguageAPI.Add("EDGEOFNIGHT_LORE", "It's just a cool-looking cape..? Surely there must be some use for this."); } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("George.EdgeofNightMod", "EdgeofNightMod", "0.3.0")] public class EdgeOfNight : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_OnTakeDamageServer <>9__15_0; public static hook_RecalculateStats <>9__15_1; public static hook_SetItemIndex <>9__15_2; internal void <HooksContainer>b__15_0(orig_OnTakeDamageServer orig, CharacterBody self, DamageReport damageReport) { ActivateEffect(self, damageReport); orig.Invoke(self, damageReport); } internal void <HooksContainer>b__15_1(orig_RecalculateStats orig, CharacterBody self) { UpdateBuff(self); orig.Invoke(self); } internal void <HooksContainer>b__15_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(); } } } public const string ModVer = "0.3.0"; 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 static uint procSoundEventID = 4094061087u; public static uint offCooldownSoundEventID = 3231506196u; public static Dictionary<NetworkInstanceId, GameObject> sphereInstanceDict = new Dictionary<NetworkInstanceId, GameObject>(); 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 = "EDGEOFNIGHT_BUFF"; 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 = "EDGEOFNIGHT_COOLDOWN"; 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__15_0; if (obj == null) { hook_OnTakeDamageServer val = delegate(orig_OnTakeDamageServer orig, CharacterBody self, DamageReport damageReport) { ActivateEffect(self, damageReport); orig.Invoke(self, damageReport); }; <>c.<>9__15_0 = val; obj = (object)val; } CharacterBody.OnTakeDamageServer += (hook_OnTakeDamageServer)obj; object obj2 = <>c.<>9__15_1; if (obj2 == null) { hook_RecalculateStats val2 = delegate(orig_RecalculateStats orig, CharacterBody self) { UpdateBuff(self); orig.Invoke(self); }; <>c.<>9__15_1 = val2; obj2 = (object)val2; } CharacterBody.RecalculateStats += (hook_RecalculateStats)obj2; object obj3 = <>c.<>9__15_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__15_2 = val3; obj3 = (object)val3; } ItemIcon.SetItemIndex += (hook_SetItemIndex)obj3; } public static int GetTotalBuffTime(int count) { return Convert.ToInt32(buffDuration + buffStackBonus * (float)count); } private static void ActivateEffect(CharacterBody self, DamageReport damageReport) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)damageReport.attackerBody == (Object)null || !Object.op_Implicit((Object)(object)self) || !self.isPlayerControlled || !self.HasBuff(activeBuff)) { return; } int itemCount = self.inventory.GetItemCount(Assets.EdgeOfNightItemDef); if (itemCount <= 0 || !damageReport.attackerBody.isElite) { 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(itemCount)); self.RemoveBuff(activeBuff); AddCooldownStacks(self, cooldownBuff, cooldownDuration); AkSoundEngine.PostEvent(procSoundEventID, ((Component)self).gameObject); DeactivateSphere(self); } } } 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_002e: 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)) { return; } if (self.inventory.GetItemCount(Assets.EdgeOfNightItemDef.itemIndex) <= 0) { if (self.HasBuff(activeBuff)) { self.RemoveBuff(activeBuff); DeactivateSphere(self); } } else if (!self.HasBuff(activeBuff) && !self.HasBuff(cooldownBuff)) { self.AddBuff(activeBuff); AkSoundEngine.PostEvent(offCooldownSoundEventID, ((Component)self).gameObject); ActivateSphere(self); } } private static string GetDisplayInformation() { return Language.GetString(Assets.EdgeOfNightItemDef.descriptionToken); } private static void CreateSphereInstance(CharacterBody self) { //IL_0039: 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_0084: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(Assets.EdgeOfNightSpherePrefab); TemporaryVisualEffect val2 = val.AddComponent<TemporaryVisualEffect>(); val2.enterComponents = (MonoBehaviour[])(object)new MonoBehaviour[0]; val2.exitComponents = (MonoBehaviour[])(object)new MonoBehaviour[0]; val2.parentTransform = self.coreTransform; val2.visualState = (VisualState)0; val2.healthComponent = self.healthComponent; float num = (float)((double)self.bestFitRadius * 1.5); val.transform.localScale = new Vector3(num, num, num); val.SetActive(true); sphereInstanceDict.Add(((NetworkBehaviour)self.master).netId, val); } private static void ActivateSphere(CharacterBody self) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (sphereInstanceDict.TryGetValue(((NetworkBehaviour)self.master).netId, out var value)) { value.SetActive(true); } else { CreateSphereInstance(self); } } private static void DeactivateSphere(CharacterBody self) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (sphereInstanceDict.TryGetValue(((NetworkBehaviour)self.master).netId, out var value)) { value.SetActive(false); } } } 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); } } }