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 BetterHexes v1.0.0
BetterHexes.dll
Decompiled a day agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; 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 BetterHexes.Changes; using BetterHexes.Modules; using HarmonyLib; using IL.RoR2; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using On.RoR2; using R2API; using RoR2; using RoR2.ContentManagement; using RoR2.Items; using RoR2BepInExPack.GameAssetPaths.Version_1_39_0; 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: IgnoresAccessChecksTo("RoR2")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BetterHexes")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BetterHexes")] [assembly: AssemblyTitle("BetterHexes")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 BetterHexes { [BepInPlugin("com.Bloonjitsu7.BetterHexes", "BetterHexes", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BaseMain : BaseUnityPlugin { public void Awake() { Log.Init(((BaseUnityPlugin)this).Logger); new ContentPacks().Initialize(); Main main = new Main(); main.SetupConfig(((BaseUnityPlugin)this).Config); main.Initialize(); } } 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); } } } namespace BetterHexes.Modules { public static class DamageTypes { } public static class Buffs { internal static List<BuffDef> buffDefs = new List<BuffDef>(); internal static BuffDef AddNewBuff(string buffName, Sprite buffIcon, Color buffColor, bool canStack, bool isDebuff, bool isCooldown, bool isHidden) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) BuffDef val = ScriptableObject.CreateInstance<BuffDef>(); ((Object)val).name = buffName; val.buffColor = buffColor; val.canStack = canStack; val.isDebuff = isDebuff; val.eliteDef = null; val.iconSprite = buffIcon; val.isCooldown = isCooldown; val.isHidden = isHidden; buffDefs.Add(val); return val; } } public static class Effects { private static GameObject finder = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_Mushroom.MushroomWard_prefab).WaitForCompletion(); public static List<EffectDef> effectDefs = new List<EffectDef>(); internal static void RegisterEffects() { } private static GameObject CreateTracer() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) GameObject val = CloneTracer("RoR2/Base/Huntress/TracerHuntressSnipe.prefab", "TracerStormboundAurelioniteLaser", Color.red, new Color(1f, 0.04f, 0.04f, 1f), 2f); Object.Destroy((Object)(object)((Component)val.transform.Find("TracerHead")).gameObject); return val; } private static GameObject CloneObject(string originalObjectName, string newObjectName, Color color1, Color color2, float scaleMult = 1f, float colorTemp = 0f, bool colorMesh = true, string soundName = "", bool parentToTransform = false, bool recolor = true) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) GameObject val = Addressables.LoadAssetAsync<GameObject>((object)originalObjectName).WaitForCompletion(); if ((Object)(object)val == (Object)null) { Log.Warning(originalObjectName + " is null!"); return null; } Component[] componentsInChildren = val.GetComponentsInChildren(typeof(Component)); foreach (Component data in componentsInChildren) { Log.Message(data); } GameObject val2 = PrefabAPI.InstantiateClone(val, newObjectName, false); if ((Object)(object)val2.GetComponent<EffectComponent>() == (Object)null) { val2.AddComponent<EffectComponent>(); } if ((Object)(object)val2.GetComponent<VFXAttributes>() == (Object)null) { val2.AddComponent<VFXAttributes>(); } val2.GetComponent<VFXAttributes>().vfxPriority = (VFXPriority)2; val2.GetComponent<VFXAttributes>().DoNotPool = true; if (recolor) { val2.Recolor(color1, color2, scaleMult, colorTemp, colorMesh); } CreateEffectFromObject(val2, soundName, parentToTransform); return val2; } private static GameObject CloneTracer(string originalTracerName, string newTracerName, Color color1, Color color2, float widthMult = 1f, float? speed = null, float? length = null) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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) GameObject val = Addressables.LoadAssetAsync<GameObject>((object)originalTracerName).WaitForCompletion(); if ((Object)(object)val == (Object)null) { Log.Warning(originalTracerName + " is null!"); return null; } GameObject val2 = PrefabAPI.InstantiateClone(val, newTracerName, false); if (!Object.op_Implicit((Object)(object)val2.GetComponent<EffectComponent>())) { val2.AddComponent<EffectComponent>(); } if (!Object.op_Implicit((Object)(object)val2.GetComponent<VFXAttributes>())) { val2.AddComponent<VFXAttributes>(); } val2.GetComponent<VFXAttributes>().vfxPriority = (VFXPriority)2; val2.GetComponent<VFXAttributes>().DoNotPool = true; if (!Object.op_Implicit((Object)(object)val2.GetComponent<NetworkIdentity>())) { val2.AddComponent<NetworkIdentity>(); } val2.GetComponent<Tracer>().speed = (speed.HasValue ? speed.Value : val2.GetComponent<Tracer>().speed); val2.GetComponent<Tracer>().length = (length.HasValue ? length.Value : val2.GetComponent<Tracer>().length); val2.Recolor(color1, color2, widthMult); CreateAndAddEffectDef(val2); return val2; } private static void Recolor(this GameObject thingToColor, Color color1, Color color2, float widthMult = 1f, float colorTemp = 0f, bool colorMesh = true) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00c7: Expected O, but got Unknown //IL_00d7: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: 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_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) bool flag = true; LineRenderer[] componentsInChildren = thingToColor.GetComponentsInChildren<LineRenderer>(); foreach (LineRenderer val in componentsInChildren) { bool flag2 = true; val.startColor = color1; val.endColor = color2; if (widthMult != 1f) { val.widthMultiplier *= widthMult; } } ParticleSystem[] componentsInChildren2 = thingToColor.GetComponentsInChildren<ParticleSystem>(); foreach (ParticleSystem val2 in componentsInChildren2) { MainModule main = val2.main; MinMaxCurve startSize = ((MainModule)(ref main)).startSize; ((MainModule)(ref main)).startSize = new MinMaxCurve(((MinMaxCurve)(ref startSize)).constant * widthMult); ((MainModule)(ref main)).startColor = new MinMaxGradient(color1); TrailModule trails = val2.trails; if (((TrailModule)(ref trails)).enabled) { Gradient val3 = new Gradient(); GradientColorKey[] array = (GradientColorKey[])(object)new GradientColorKey[2]; array[0].color = color1; array[0].time = 0f; array[1].color = color2; array[1].time = 1f; GradientAlphaKey[] array2 = (GradientAlphaKey[])(object)new GradientAlphaKey[2]; array2[0].alpha = color1.a; array2[0].time = 0f; array2[1].alpha = color2.a; array2[1].time = 1f; val3.SetKeys(array, array2); ((TrailModule)(ref trails)).colorOverLifetime = new MinMaxGradient(val3); } } Light[] componentsInChildren3 = thingToColor.GetComponentsInChildren<Light>(); foreach (Light val4 in componentsInChildren3) { if (colorTemp > 0f) { val4.colorTemperature = colorTemp; val4.useColorTemperature = true; } else { val4.useColorTemperature = false; } val4.color = color1; Transform transform = ((Component)val4).transform; transform.localScale *= widthMult; } ParticleSystemRenderer[] componentsInChildren4 = thingToColor.GetComponentsInChildren<ParticleSystemRenderer>(); foreach (ParticleSystemRenderer val5 in componentsInChildren4) { ((Renderer)val5).material.SetColor("_MainColor", color1); ((Renderer)val5).material.SetColor("_Color", color1); ((Renderer)val5).material.SetColor("_TintColor", color2); } if (colorMesh) { MeshRenderer[] componentsInChildren5 = thingToColor.GetComponentsInChildren<MeshRenderer>(); foreach (MeshRenderer val6 in componentsInChildren5) { ((Renderer)val6).material.SetColor("_MainColor", color1); ((Renderer)val6).material.SetColor("_Color", color1); ((Renderer)val6).material.SetColor("_TintColor", color2); } } } internal static void AddEffectDef(EffectDef effectDef) { effectDefs.Add(effectDef); } internal static EffectDef CreateAndAddEffectDef(GameObject effectPrefab, bool donotPool = false) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown if (donotPool) { VFXAttributes val = effectPrefab.GetComponent<VFXAttributes>(); if ((Object)(object)val == (Object)null) { val = effectPrefab.AddComponent<VFXAttributes>(); } val.DoNotPool = true; } EffectDef val2 = new EffectDef(effectPrefab); AddEffectDef(val2); return val2; } internal static void CreateEffectFromObject(GameObject newEffect, string soundName, bool parentToTransform) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) newEffect.AddComponent<DestroyOnTimer>().duration = 6f; newEffect.AddComponent<NetworkIdentity>(); if (!Object.op_Implicit((Object)(object)newEffect.GetComponent<VFXAttributes>())) { newEffect.AddComponent<VFXAttributes>().vfxPriority = (VFXPriority)2; } EffectComponent component = newEffect.GetComponent<EffectComponent>(); if (!Object.op_Implicit((Object)(object)component)) { component = newEffect.AddComponent<EffectComponent>(); component.applyScale = true; component.effectIndex = (EffectIndex)(-1); component.parentToReferencedTransform = parentToTransform; component.positionAtReferencedTransform = true; component.soundName = soundName; } CreateAndAddEffectDef(newEffect); } } internal class ContentPacks : IContentPackProvider { internal ContentPack contentPack = new ContentPack(); public string identifier => "com.Bloonjitsu7.BloonModpackBaseMod"; public void Initialize() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown Effects.RegisterEffects(); ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders); } private void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider) { addContentPackProvider.Invoke((IContentPackProvider)(object)this); } public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { contentPack.identifier = identifier; contentPack.effectDefs.Add(Effects.effectDefs.ToArray()); contentPack.buffDefs.Add(Buffs.buffDefs.ToArray()); args.ReportProgress(1f); yield break; } public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { ContentPack.Copy(contentPack, args.output); args.ReportProgress(1f); yield break; } public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { args.ReportProgress(1f); yield break; } } } namespace BetterHexes.Changes { public class Main { public class BlindnessHexBehaviour : ItemBehavior { public float stopwatch; public float timer; public float blindnessRange = float.PositiveInfinity; public bool blindStopped; private void OnEnable() { if (blindEnable.Value) { Stage.onStageStartGlobal += OnBlindStart; TeleporterInteraction.onTeleporterBeginChargingGlobal += OnBlindClear; } } private void OnDisable() { if (blindEnable.Value) { Stage.onStageStartGlobal -= OnBlindStart; TeleporterInteraction.onTeleporterBeginChargingGlobal -= OnBlindClear; } } private void Start() { stopwatch = 0f; UpdateTimer(); } private void UpdateTimer() { timer = 300f / ConvertReductionIntoStackingDivision(0.3f, base.stack); } public void FixedUpdate() { if ((Object)(object)base.body == (Object)null || base.stack <= 0 || !blindEnable.Value || !Object.op_Implicit((Object)(object)Stage.instance) || !Object.op_Implicit((Object)(object)Stage.instance.sceneDef)) { return; } if (!Stage.instance.sceneDef.preventStageAdvanceCounter && !blindStopped) { if (blindnessRange > 150f) { UpdateTimer(); stopwatch += Time.fixedDeltaTime; if (stopwatch >= timer) { Util.PlaySound("Play_Hex_Rain", ((Component)RoR2Application.instance).gameObject); blindnessRange = 150f; stopwatch = 0f; } } else { blindnessRange -= Time.fixedDeltaTime / 2f; blindnessRange = Mathf.Max(25f, blindnessRange); } } else { blindnessRange = float.PositiveInfinity; } base.body.visionDistance = blindnessRange; } private void OnBlindStart(Stage stage) { blindnessRange = float.PositiveInfinity; stopwatch = 0f; UpdateTimer(); blindStopped = false; } private void OnBlindClear(TeleporterInteraction interaction) { blindStopped = true; if ((Object)(object)base.body != (Object)null) { base.body.visionDistance = float.PositiveInfinity; } } } public class LightningHexBehaviour : ItemBehavior { public static GameObject lightningPrefab = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC2_meridian_DisableSkillsLightning.LightningStrikeInstance_prefab).WaitForCompletion(), "BloonLightningHexPrefab"); public float stopwatch; public float interval; private void Start() { stopwatch = 0f; UpdateInterval(); } private void UpdateInterval() { interval = 6f / ConvertReductionIntoStackingDivision(0.25f, base.stack); } public void FixedUpdate() { if (!((Object)(object)base.body == (Object)null) && base.body.isPlayerControlled && base.stack > 0 && rainEnable.Value) { stopwatch += Time.fixedDeltaTime; if ((Object)(object)base.body != (Object)null && stopwatch >= interval) { stopwatch = 0f; UpdateInterval(); FireLightning(); } } } public void FireLightning() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_006d: 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_0074: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown //IL_0089: 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) //IL_009c: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00c3: 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) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) BlastAttack val = new BlastAttack { attacker = lightningPrefab, baseDamage = 3f * base.body.damage, damageColorIndex = (DamageColorIndex)16, baseForce = 0f, procCoefficient = 0f, radius = 7f, damageType = new DamageTypeCombo(DamageTypeCombo.op_Implicit((DamageType)131072), (DamageTypeExtended)8192, (DamageSource)16), falloffModel = (FalloffModel)0, attackerFiltering = (AttackerFiltering)1, teamIndex = (TeamIndex)0 }; _ = base.body.footPosition; Vector3 val2 = base.body.footPosition; Ray val3 = new Ray(val2 + Vector3.up * 2f, Vector3.down); LayerIndex world = LayerIndex.world; RaycastHit val4 = default(RaycastHit); if (Physics.Raycast(val3, ref val4, 200f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask) | LayerMask.op_Implicit(CommonMasks.characterBodiesOrDefault), (QueryTriggerInteraction)1)) { val2 = ((RaycastHit)(ref val4)).point; } Object.Instantiate<GameObject>(lightningPrefab, val2, base.body.transform.rotation).GetComponent<LightningStrikeInstance>().Initialize(val2, val, 1.5f, true); } } private static Hook misfortuneHook; private static Hook famineHook; public static ConfigEntry<bool> reworkEnable { get; set; } public static ConfigEntry<bool> painEnable { get; set; } public static ConfigEntry<bool> blindEnable { get; set; } public static ConfigEntry<bool> rainEnable { get; set; } public static ConfigEntry<bool> famineEnable { get; set; } public static ConfigEntry<bool> patienceEnable { get; set; } public static ConfigEntry<bool> misfortuneEnable { get; set; } public void SetupConfig(ConfigFile cfg) { painEnable = cfg.Bind<bool>("Hex of Pain", "Enable Changes", true, "Enables the changes to this Hex."); blindEnable = cfg.Bind<bool>("Hex of Blindness", "Enable Changes", true, "Enables the changes to this Hex."); rainEnable = cfg.Bind<bool>("Hex of Rain", "Enable Changes", true, "Enables the changes to this Hex."); famineEnable = cfg.Bind<bool>("Hex of Famine", "Enable Changes", true, "Enables the changes to this Hex."); misfortuneEnable = cfg.Bind<bool>("Hex of Misfortune", "Enable Changes", true, "Enables the changes to this Hex."); } public void Initialize() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Expected O, but got Unknown CreateBuffs(); CharacterBody.OnInventoryChanged += new hook_OnInventoryChanged(AddNewHexBehaviour); RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(OnRecalcStats); HealthComponent.TakeDamage += new hook_TakeDamage(OnTakeDamage); if (painEnable.Value) { CharacterBody.RecalculateStats += new Manipulator(IL_RecalcStatsPain); string text = "10% chance for incoming damage to <style=cDeath>bleed you</style> based on the amount of damage dealt."; LanguageAPI.Add("ITEM_HEXCURSE_PICKUP", text); string text2 = "Any damage you take from foes has a <style=cIsDamage>10% chance</style> to <style=cDeath>bleed you</style>, dealing an additional <style=cIsDamage>120%</style> <style=cStack>(+60% per stack)</style> TOTAL damage over the course of <style=cIsUtility>3s</style>."; LanguageAPI.Add("ITEM_HEXCURSE_DESC", text2); } if (blindEnable.Value) { CharacterBody.RecalculateStats += new Manipulator(IL_RecalcStatsBlind); string text3 = "Spending too long in a stage causes your vision to <style=cDeath>rapidly decrease</style>."; LanguageAPI.Add("ITEM_BLINDNESS_PICKUP", text3); string text4 = "After holding this item for <style=cIsUtility>5 minutes</style> <style=cStack>(-30% per stack)</style> in a single stage, your sight range is limited to <style=cDeath>150m</style>. This range is reduced by <style=cDeath>0.5m</style> every second, down to a minimum of <style=cDeath>25m</style>. Starting the teleporter event <style=cIsHealing>clears this effect for the rest of the stage</style>."; LanguageAPI.Add("ITEM_BLINDNESS_DESC", text4); } if (rainEnable.Value) { Run.RecalculateDifficultyCoefficentInternal += new Manipulator(IL_RecalcDifficulty); string text5 = "Lightning periodically <style=cDeath>strikes at your position</style>."; LanguageAPI.Add("ITEM_INCREASEDDIFFICULTY_PICKUP", text5); string text6 = "A <style=cIsDamage>bolt of lightning</style> strikes on your position every <style=cIsUtility>6s</style> <style=cStack>(-20% per stack)</style>, dealing <style=cIsDamage>300%</style> base damage if it hits."; LanguageAPI.Add("ITEM_INCREASEDDIFFICULTY_DESC", text6); } if (famineEnable.Value) { MethodInfo methodInfo = AccessTools.Method(typeof(LowerHealingUtils), "GetLowerHealingCoefficient", (Type[])null, (Type[])null); famineHook = new Hook((MethodBase)methodInfo, (Delegate)new Func<Func<int, float>, int, float>(RemoveOldFamineBehaviour)); string text7 = "For a brief time after taking damage, you <style=cDeath>cannot heal</style>."; LanguageAPI.Add("ITEM_LOWERHEALING_PICKUP", text7); string text8 = "Your <style=cIsHealing>healing</style> is <style=cDeath>disabled for 3s</style> <style=cStack>(+1s per stack)</style> after taking damage."; LanguageAPI.Add("ITEM_LOWERHEALING_DESC", text8); } if (misfortuneEnable.Value) { MethodInfo methodInfo2 = AccessTools.Method(typeof(RandomDebuffOnInteractBehaviour), "GetItemDef", (Type[])null, (Type[])null); misfortuneHook = new Hook((MethodBase)methodInfo2, (Delegate)new Func<Func<ItemDef>, ItemDef>(RemoveItemBehaviour)); PickupDropletController.CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 += new hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3(OnCreatePickup); string text9 = "Dropped items have a chance to be <style=cDeath>transformed into scrap</style>."; LanguageAPI.Add("ITEM_RANDOMDEBUFFONSUCCESSFULROLL_PICKUP", text9); string text10 = "All standard item drops have a <style=cIsUtility>30%</style> <style=cStack>(+10% per stack)</style> chance to be transformed into scrap of equal rarity."; LanguageAPI.Add("ITEM_RANDOMDEBUFFONSUCCESSFULROLL_DESC", text10); } } private void OnRecalcStats(CharacterBody sender, StatHookEventArgs args) { } private void AddNewHexBehaviour(orig_OnInventoryChanged orig, CharacterBody self) { if (NetworkServer.active) { if (rainEnable.Value) { self.AddItemBehavior<LightningHexBehaviour>(self.inventory.GetItemCountEffective(Items.IncreasedDifficulty)); } if (blindEnable.Value) { self.AddItemBehavior<BlindnessHexBehaviour>(self.inventory.GetItemCountEffective(Items.Blindness)); } } orig.Invoke(self); } private void OnTakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo info) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Invalid comparison between Unknown and I4 //IL_0055: 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_0064: Invalid comparison between Unknown and I4 //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, info); if (painEnable.Value && info.damage > 0f && Object.op_Implicit((Object)(object)self.body) && Object.op_Implicit((Object)(object)self.body.inventory) && (int)DamageTypeCombo.op_Implicit(info.damageType) != 67108864 && (int)DamageTypeCombo.op_Implicit(info.damageType) != 2048 && (Object)(object)info.attacker != (Object)null) { CharacterBody component = info.attacker.GetComponent<CharacterBody>(); int itemCountEffective = self.body.inventory.GetItemCountEffective(Items.HexCurse); if ((Object)(object)component != (Object)null && itemCountEffective > 0 && Util.CheckRoll(10f, 0f, (CharacterMaster)null)) { float num = info.damage / component.damage; num *= 0.5f + 0.25f * (float)itemCountEffective; DotController.InflictDot(((Component)self).gameObject, info.attacker, self.body.mainHurtBox, default(ProcChainMask), (DotIndex)0, 3f, num, (uint?)null); } } if (famineEnable.Value && info.damage > 0f && Object.op_Implicit((Object)(object)self.body) && Object.op_Implicit((Object)(object)self.body.inventory) && (!Object.op_Implicit((Object)(object)info.attacker) || !((Object)(object)info.attacker.GetComponent<CharacterBody>() != (Object)null) || !((Object)(object)info.attacker.GetComponent<CharacterBody>() == (Object)(object)self.body))) { int itemCountEffective2 = self.body.inventory.GetItemCountEffective(Items.LowerHealing); if (itemCountEffective2 > 0) { float num2 = 2f + 1f * (float)itemCountEffective2; self.body.AddTimedBuff(Buffs.HealingDisabled, num2); } } } public void IL_RecalcStatsPain(ILContext il) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_007b: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); MoveType val2 = (MoveType)2; int loc1 = -1; if (val.TryGotoNext(val2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "HexCurse") })) { if (val.TryGotoNext(val2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref loc1) })) { val.Emit(OpCodes.Ldc_I4_0); val.Emit(OpCodes.Stloc, loc1); } else { Log.Error(((MemberReference)il.Method).Name + " Hook 2 failed!"); } } else { Log.Error(((MemberReference)il.Method).Name + " Hook 1 failed!"); } } public void IL_RecalcStatsBlind(ILContext il) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_007b: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); MoveType val2 = (MoveType)2; int loc1 = -1; if (val.TryGotoNext(val2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "Blindness") })) { if (val.TryGotoNext(val2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref loc1) })) { val.Emit(OpCodes.Ldc_I4_0); val.Emit(OpCodes.Stloc, loc1); } else { Log.Error(((MemberReference)il.Method).Name + " Hook 2 failed!"); } } else { Log.Error(((MemberReference)il.Method).Name + " Hook 1 failed!"); } } public void IL_RecalcDifficulty(ILContext il) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_007b: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); MoveType val2 = (MoveType)2; int loc1 = -1; if (val.TryGotoNext(val2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "IncreasedDifficulty") })) { if (val.TryGotoNext(val2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref loc1) })) { val.Emit(OpCodes.Ldc_I4_0); val.Emit(OpCodes.Stloc, loc1); } else { Log.Error(((MemberReference)il.Method).Name + " Hook 2 failed!"); } } else { Log.Error(((MemberReference)il.Method).Name + " Hook 1 failed!"); } } private ItemDef RemoveItemBehaviour(Func<ItemDef> orig) { return null; } private float RemoveOldFamineBehaviour(Func<int, float> orig, int count) { return 1f; } private void OnCreatePickup(orig_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 orig, CreatePickupInfo pickupInfo, Vector3 position, Vector3 velocity) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Invalid comparison between Unknown and I4 //IL_00d7: 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) //IL_00e5: Invalid comparison between Unknown and I4 //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Invalid comparison between Unknown and I4 //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Invalid comparison between Unknown and I4 //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Invalid comparison between Unknown and I4 //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_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Invalid comparison between Unknown and I4 //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) if (!pickupInfo.duplicated && !pickupInfo.recycled) { GetTotalItemCountFromTeamArgs val = default(GetTotalItemCountFromTeamArgs); ((GetTotalItemCountFromTeamArgs)(ref val))..ctor(Items.RandomDebuffOnInteract.itemIndex); val.requiresAlive = false; val.requiredTeam = (TeamIndex)1; val.requiresConnected = true; val.onlyPlayerControlledCharacters = true; val.queryCountRegardlessOfInventoryOrItemDisabled = true; int totalItemCountFromTeam = Util.GetTotalItemCountFromTeam(val); if (totalItemCountFromTeam > 0) { _ = ((CreatePickupInfo)(ref pickupInfo)).pickup; _ = ((CreatePickupInfo)(ref pickupInfo)).pickup; UniquePickup pickup = ((CreatePickupInfo)(ref pickupInfo)).pickup; if (!((UniquePickup)(ref pickup)).isTempItem && Util.CheckRoll(20f + 10f * (float)totalItemCountFromTeam, 0f, (CharacterMaster)null)) { PickupDef pickupDef = PickupCatalog.GetPickupDef(((CreatePickupInfo)(ref pickupInfo)).pickup.pickupIndex); if (pickupDef != null) { _ = pickupDef.equipmentIndex; if ((int)pickupDef.equipmentIndex == -1) { _ = pickupDef.itemIndex; if ((int)pickupDef.itemIndex != -1) { if ((int)pickupDef.itemTier == 0) { pickup = ((CreatePickupInfo)(ref pickupInfo)).pickup; ((CreatePickupInfo)(ref pickupInfo)).pickup = ((UniquePickup)(ref pickup)).WithPickupIndex(PickupCatalog.FindPickupIndex(Items.ScrapWhite.itemIndex)); EffectManager.SimpleSoundEffect(RandomDebuffOnInteractBehaviour.nseRandomDebuff.index, position, true); } if ((int)pickupDef.itemTier == 1) { pickup = ((CreatePickupInfo)(ref pickupInfo)).pickup; ((CreatePickupInfo)(ref pickupInfo)).pickup = ((UniquePickup)(ref pickup)).WithPickupIndex(PickupCatalog.FindPickupIndex(Items.ScrapGreen.itemIndex)); EffectManager.SimpleSoundEffect(RandomDebuffOnInteractBehaviour.nseRandomDebuff.index, position, true); } if ((int)pickupDef.itemTier == 2) { pickup = ((CreatePickupInfo)(ref pickupInfo)).pickup; ((CreatePickupInfo)(ref pickupInfo)).pickup = ((UniquePickup)(ref pickup)).WithPickupIndex(PickupCatalog.FindPickupIndex(Items.ScrapRed.itemIndex)); EffectManager.SimpleSoundEffect(RandomDebuffOnInteractBehaviour.nseRandomDebuff.index, position, true); } if ((int)pickupDef.itemTier == 4) { pickup = ((CreatePickupInfo)(ref pickupInfo)).pickup; ((CreatePickupInfo)(ref pickupInfo)).pickup = ((UniquePickup)(ref pickup)).WithPickupIndex(PickupCatalog.FindPickupIndex(Items.ScrapYellow.itemIndex)); EffectManager.SimpleSoundEffect(RandomDebuffOnInteractBehaviour.nseRandomDebuff.index, position, true); } } } } } } } orig.Invoke(pickupInfo, position, velocity); } public static List<MethodInfo> GetAnonymousMethods(Type t, string methodName) { List<MethodInfo> list = new List<MethodInfo>(); Type[] nestedTypes = t.GetNestedTypes((BindingFlags)(-1)); Type[] array = nestedTypes; foreach (Type type in array) { if (!type.Name.Contains("<>")) { continue; } MethodInfo[] methods = type.GetMethods((BindingFlags)(-1)); foreach (MethodInfo methodInfo in methods) { if (methodInfo.Name.Contains(methodName)) { list.Add(methodInfo); } } } MethodInfo[] methods2 = t.GetMethods((BindingFlags)(-1)); foreach (MethodInfo methodInfo2 in methods2) { if (methodInfo2.Name.Contains("<") && methodInfo2.Name.Contains(methodName)) { list.Add(methodInfo2); } } return list.OrderBy((MethodInfo m) => m.Name).ToList(); } private void CreateBuffs() { } public static string GetStackDesc(float num, string type) { if (num > 0f) { return $" <style=cStack>(+{num}{type} per stack)</style>"; } if (num < 0f) { return $" <style=cStack>({num}{type} per stack)</style>"; } return ""; } public static float GetStackedStats(float baseStat, float stackStat, int itemCount) { return baseStat - stackStat + stackStat * (float)itemCount; } public static int GetStackedStatsInt(int baseStat, int stackStat, int itemCount) { return baseStat - stackStat + stackStat * itemCount; } public static float ConvertReductionIntoStackingDivision(float baseFraction, int itemCount) { float num = 1f - baseFraction; float num2 = (1f + num) / num - 2f; num2 *= (float)(itemCount - 1); return num2 + 1f; } public static void DumpComponents(GameObject gameObject) { Component[] componentsInChildren = gameObject.GetComponentsInChildren(typeof(Component)); foreach (Component data in componentsInChildren) { Log.Message(data); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }