using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [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("SillyValuablesFix")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SillyValuablesFix")] [assembly: AssemblyTitle("SillyValuablesFix")] [assembly: AssemblyMetadata("AI_Assisted_Creation", "This assembly was partially or fully created with the assistance of Generative AI (e.g., Code Suggestions, Refactoring, Documentation Generation).")] [assembly: AssemblyMetadata("AI_Model_Vendor", "Google/Gemini")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 SillyValuablesFix { [BepInPlugin("com.neko3004.sillyvaluablesfix", "SillyValuables Fix", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public static ManualLogSource Log; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("com.neko3004.sillyvaluablesfix"); val.PatchAll(); Log.LogInfo((object)"SillyValuables Fix aplicado com sucesso!"); } public static bool CheckIsEquipped(Component item) { if ((Object)(object)item == (Object)null) { return false; } FieldInfo field = ((object)item).GetType().GetField("isEquipped", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { object value = field.GetValue(item); bool flag = default(bool); int num; if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } PropertyInfo property = ((object)item).GetType().GetProperty("isEquipped", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property != null) { object value2 = property.GetValue(item); bool flag2 = default(bool); int num2; if (value2 is bool) { flag2 = (bool)value2; num2 = 1; } else { num2 = 0; } return (byte)((uint)num2 & (flag2 ? 1u : 0u)) != 0; } return false; } } [HarmonyPatch(typeof(GranadaJogavel), "Start")] public static class Patch_GranadaJogavel_Start { public static void Postfix(GranadaJogavel __instance) { if ((Object)(object)((Component)__instance).gameObject.GetComponent() == (Object)null) { GranadaFixer granadaFixer = ((Component)__instance).gameObject.AddComponent(); granadaFixer.Setup((MonoBehaviour)(object)__instance); } } } [HarmonyPatch(typeof(GranadaJogavelSemExplosao), "Start")] public static class Patch_GranadaJogavelSemExplosao_Start { public static void Postfix(GranadaJogavelSemExplosao __instance) { if ((Object)(object)((Component)__instance).gameObject.GetComponent() == (Object)null) { GranadaFixer granadaFixer = ((Component)__instance).gameObject.AddComponent(); granadaFixer.Setup((MonoBehaviour)(object)__instance); } } } public class GranadaFixer : MonoBehaviour { private MonoBehaviour granadaObj = null; private Traverse t = null; private float tickAudioTimer = 0f; private static AudioClip? cachedMineClip; private const float minePitch = 1.2f; public void Setup(MonoBehaviour granada) { granadaObj = granada; t = Traverse.Create((object)granadaObj); ((Behaviour)granadaObj).enabled = false; t.Field("soundSplinter").SetValue((object)null); FindGameMineSound(); ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("Original function broken, applying fix to: " + ((Object)((Component)granada).gameObject).name)); } } private void FindGameMineSound() { if (!((Object)(object)cachedMineClip != (Object)null)) { AudioClip[] source = Resources.FindObjectsOfTypeAll(); cachedMineClip = ((IEnumerable)source).FirstOrDefault((Func)((AudioClip c) => ((Object)c).name.Equals("item explosive mine warning beeps", StringComparison.OrdinalIgnoreCase))) ?? ((IEnumerable)source).FirstOrDefault((Func)((AudioClip c) => ((Object)c).name.Equals("grenade countdown", StringComparison.OrdinalIgnoreCase))) ?? ((IEnumerable)source).FirstOrDefault((Func)((AudioClip c) => ((Object)c).name.Equals("item explosive mine arm beep", StringComparison.OrdinalIgnoreCase))) ?? ((IEnumerable)source).FirstOrDefault((Func)((AudioClip c) => ((Object)c).name.Equals("snd_dirt_tracker_beep", StringComparison.OrdinalIgnoreCase))); } } private void PlayCustomMineTick(float pitchMultiplier) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0028: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)cachedMineClip != (Object)null) { GameObject val = new GameObject("MineTickAudio"); val.transform.position = ((Component)this).transform.position; AudioSource val2 = val.AddComponent(); val2.clip = cachedMineClip; val2.pitch = pitchMultiplier; val2.volume = 0.7f; val2.spatialBlend = 1f; val2.Play(); Object.Destroy((Object)(object)val, cachedMineClip.length + 0.1f); } } private void Update() { //IL_01bb: 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_0407: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)granadaObj == (Object)null) { return; } Component value = t.Field("itemEquippable").GetValue(); bool flag = Plugin.CheckIsEquipped(value); bool value2 = t.Field("isActive").GetValue(); bool value3 = t.Field("isThrownRocket").GetValue(); Component value4 = t.Field("physGrabObject").GetValue(); bool flag2 = false; if ((Object)(object)value4 != (Object)null) { FieldInfo field = ((object)value4).GetType().GetField("grabbed"); if (field != null) { flag2 = (bool)field.GetValue(value4); } } if ((Object)(object)value != (Object)null && flag) { if (value2) { t.Field("isActive").SetValue((object)false); t.Field("grenadeTimer").SetValue((object)0f); t.Field("splinterAnimationProgress").SetValue((object)0f); Component value5 = t.Field("itemToggle").GetValue(); if ((Object)(object)value5 != (Object)null) { ((object)value5).GetType().GetMethod("ToggleItem")?.Invoke(value5, new object[2] { false, -1 }); } Transform value6 = t.Field("splinterTransform").GetValue(); if ((Object)(object)value6 != (Object)null) { value6.localEulerAngles = Vector3.zero; } Material value7 = t.Field("grenadeEmissionMaterial").GetValue(); if ((Object)(object)value7 != (Object)null) { value7.SetColor("_EmissionColor", Color.black); } t.Field("isThrownRocket").SetValue((object)false); GameObject value8 = t.Field("throwLine").GetValue(); if ((Object)(object)value8 != (Object)null) { value8.SetActive(false); } } return; } if ((Object)(object)value != (Object)null && !flag && value2 && !value3 && (Object)(object)value4 != (Object)null && !flag2) { t.Field("isThrownRocket").SetValue((object)true); t.Method("LaunchAsRocket", Array.Empty()).GetValue(); } value2 = t.Field("isActive").GetValue(); if (value2) { tickAudioTimer += Time.deltaTime; if (tickAudioTimer >= 0.35f) { tickAudioTimer = 0f; PlayCustomMineTick(1.2f); } float value9 = t.Field("splinterAnimationProgress").GetValue(); if (value9 < 1f) { value9 += 5f * Time.deltaTime; t.Field("splinterAnimationProgress").SetValue((object)value9); AnimationCurve value10 = t.Field("splinterAnimationCurve").GetValue(); float num = ((value10 != null) ? value10.Evaluate(value9) : 0f); Transform value11 = t.Field("splinterTransform").GetValue(); if ((Object)(object)value11 != (Object)null) { value11.localEulerAngles = new Vector3(num * 90f, 0f, 0f); } } float num2 = Mathf.PingPong(Time.time * 8f, 1f); Color value12 = t.Field("blinkColor").GetValue(); Material value13 = t.Field("grenadeEmissionMaterial").GetValue(); if ((Object)(object)value13 != (Object)null) { value13.SetColor("_EmissionColor", value12 * Mathf.LinearToGammaSpace(num2)); } } Component value14 = t.Field("itemToggle").GetValue(); bool flag3 = false; if ((Object)(object)value14 != (Object)null) { FieldInfo field2 = ((object)value14).GetType().GetField("toggleState"); if (field2 != null) { flag3 = (bool)field2.GetValue(value14); } } if (SemiFunc.IsMasterClientOrSingleplayer() && (Object)(object)value14 != (Object)null && flag3 && !value2) { t.Field("isActive").SetValue((object)true); PlayCustomMineTick(1.2f); t.Method("TickStart", Array.Empty()).GetValue(); } } private void FixedUpdate() { //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_016d: Unknown result type (might be due to invalid IL or missing references) //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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)granadaObj == (Object)null) { return; } Component value = t.Field("itemEquippable").GetValue(); bool flag = Plugin.CheckIsEquipped(value); Rigidbody value2 = t.Field("rb").GetValue(); Component value3 = t.Field("physGrabObject").GetValue(); Vector3 value4 = t.Field("prevPosition").GetValue(); float num = t.Field("throwLineTimer").GetValue(); TrailRenderer value5 = t.Field("throwLineTrail").GetValue(); bool flag2 = false; if ((Object)(object)value3 != (Object)null) { FieldInfo field = ((object)value3).GetType().GetField("grabbed"); if (field != null) { flag2 = (bool)field.GetValue(value3); } } float num2 = 0f; if ((Object)(object)value != (Object)null) { FieldInfo field2 = ((object)value).GetType().GetField("wasEquippedTimer"); if (field2 != null) { num2 = (float)field2.GetValue(value); } } if ((Object)(object)value != (Object)null && (flag || num2 > 0f)) { if ((Object)(object)value2 != (Object)null) { t.Field("prevPosition").SetValue((object)value2.position); } } else if ((Object)(object)value2 != (Object)null && (Object)(object)value3 != (Object)null) { Vector3 val = (value2.position - value4) / Time.fixedDeltaTime; t.Field("prevPosition").SetValue((object)value2.position); if (!flag2 && ((Vector3)(ref val)).magnitude > 2f) { num = 0.2f; t.Field("throwLineTimer").SetValue((object)num); } if ((Object)(object)value5 != (Object)null) { value5.emitting = num > 0f; } if (num > 0f) { t.Field("throwLineTimer").SetValue((object)(num - Time.fixedDeltaTime)); } } } private void OnCollisionEnter(Collision collision) { if (!((Object)(object)granadaObj == (Object)null) && t.Field("isThrownRocket").GetValue() && SemiFunc.IsMasterClientOrSingleplayer()) { t.Method("TickEnd", Array.Empty()).GetValue(); } } } }