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 Phase4Tweaks v1.0.2
Phase4Tweaks.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using On.RoR2; 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: AssemblyTitle("Phase4Tweaks")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Phase4Tweaks")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("5f0fb229-d211-403a-a99b-56b1ee2a20f7")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace R2API.Utils { [AttributeUsage(AttributeTargets.Assembly)] public class ManualNetworkRegistrationAttribute : Attribute { } } namespace Phase4Tweaks { public class GuaranteedItemReturnComponent : MonoBehaviour { private class AttackerCooldown { public GameObject attacker; private float cooldown; public AttackerCooldown(GameObject attacker, float cooldown) { this.attacker = attacker; this.cooldown = cooldown; } public void SetCooldown(float duration) { cooldown = duration; } public void ReduceCooldown(float duration) { if (cooldown > 0f) { cooldown -= duration; } } public bool CanSteal() { return cooldown <= 0f; } } public static float cooldownDuration = 30f; public static float closeRangeDistanceSqr = 900f; public static float closeRangeCooldownMult = 3f; private List<AttackerCooldown> cooldowns = new List<AttackerCooldown>(); private void FixedUpdate() { //IL_0056: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (!NetworkServer.active) { return; } float num = Time.fixedDeltaTime * closeRangeCooldownMult; foreach (AttackerCooldown cooldown in cooldowns) { bool flag = false; if (Object.op_Implicit((Object)(object)cooldown.attacker)) { Vector3 val = cooldown.attacker.transform.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude <= closeRangeDistanceSqr) { flag = true; } } cooldown.ReduceCooldown(flag ? num : Time.fixedDeltaTime); } cooldowns = cooldowns.Where((AttackerCooldown ac) => (Object)(object)ac.attacker != (Object)null).ToList(); } public void SetStealItemCooldown(GameObject attacker) { if (Object.op_Implicit((Object)(object)attacker)) { AttackerCooldown attackerCooldown = cooldowns.Find((AttackerCooldown c) => (Object)(object)c.attacker == (Object)(object)attacker); if (attackerCooldown != null) { attackerCooldown.SetCooldown(cooldownDuration); return; } attackerCooldown = new AttackerCooldown(attacker, cooldownDuration); cooldowns.Add(attackerCooldown); } } public bool ShouldGuaranteedSteal(GameObject attacker) { if (!Object.op_Implicit((Object)(object)attacker)) { return false; } AttackerCooldown attackerCooldown = cooldowns.Find((AttackerCooldown c) => (Object)(object)c.attacker == (Object)(object)attacker); if (attackerCooldown == null) { attackerCooldown = new AttackerCooldown(attacker, 0f); cooldowns.Add(attackerCooldown); } return attackerCooldown.CanSteal(); } } [BepInPlugin("com.Moffein.Phase4Tweaks", "Phase4Tweaks", "1.0.0")] public class Phase4TweaksPlugin : BaseUnityPlugin { private static BodyIndex brotherHurtIndex; private void Awake() { //IL_0026: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad)); GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Brother/BrotherHurtBody.prefab").WaitForCompletion(); val.AddComponent<GuaranteedItemReturnComponent>(); HealthComponent.TakeDamage += new hook_TakeDamage(HealthComponent_TakeDamage); } private void HealthComponent_TakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, damageInfo); if (!NetworkServer.active || damageInfo.rejected || !Object.op_Implicit((Object)(object)damageInfo.attacker) || self.body.bodyIndex != brotherHurtIndex) { return; } GuaranteedItemReturnComponent component = ((Component)self).GetComponent<GuaranteedItemReturnComponent>(); if (!Object.op_Implicit((Object)(object)component) || !component.ShouldGuaranteedSteal(damageInfo.attacker)) { return; } CharacterBody component2 = damageInfo.attacker.GetComponent<CharacterBody>(); if (Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)component2.inventory)) { ReturnStolenItemsOnGettingHit component3 = ((Component)self).GetComponent<ReturnStolenItemsOnGettingHit>(); if (Object.op_Implicit((Object)(object)component3) && Object.op_Implicit((Object)(object)component3.itemStealController) && component3.itemStealController.ReclaimItemForInventory(component2.inventory, int.MaxValue)) { Debug.Log((object)("Phase4Tweaks: Guaranteed item return for " + (object)component2)); component.SetStealItemCooldown(damageInfo.attacker); } } } private void OnLoad() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) brotherHurtIndex = BodyCatalog.FindBodyIndex("BrotherHurtBody"); } } }