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 FartMod v1.2.0
FartP.dll
Decompiled a year agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; 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.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; 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.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("MyName")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MyRepoMod")] [assembly: AssemblyTitle("MyRepoMod")] [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.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] [Microsoft.CodeAnalysis.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] [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 MyRepoMod { [HarmonyPatch(typeof(PlayerController))] internal static class ExamplePlayerControllerPatch { [HarmonyPrefix] [HarmonyPatch("Start")] private static void Start_Prefix(PlayerController __instance) { MyRepoMod.StaticLogger.LogDebug((object)$"{__instance} Start Prefix"); } [HarmonyPostfix] [HarmonyPatch("Start")] private static void Start_Postfix(PlayerController __instance) { MyRepoMod.StaticLogger.LogDebug((object)$"{__instance} Start Postfix"); } } [BepInPlugin("F1VE.FartPlugin", "FartPlugin", "1.0")] public class MyRepoMod : BaseUnityPlugin { private class FartInstance { public Vector3 Position; public Quaternion Rotation; public float StartTime; public float Duration; public int SoundIndex; public bool IsActive => Time.time - StartTime < Duration; } public class FartMarkerComponent : MonoBehaviour { public int SoundIndex; public bool Processed; } [CompilerGenerated] private sealed class <FadeOutObject>d__43 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Renderer renderer; public float duration; public MyRepoMod <>4__this; private Material <mat>5__1; private Color <startColor>5__2; private float <startAlpha>5__3; private float <elapsed>5__4; private float <normalizedTime>5__5; private Color <newColor>5__6; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <FadeOutObject>d__43(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <mat>5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; if ((Object)(object)renderer == (Object)null) { return false; } <mat>5__1 = renderer.material; <startColor>5__2 = <mat>5__1.color; <startAlpha>5__3 = <startColor>5__2.a; <elapsed>5__4 = 0f; break; case 1: <>1__state = -1; break; } if (<elapsed>5__4 < duration) { <elapsed>5__4 += Time.deltaTime; <normalizedTime>5__5 = Mathf.Clamp01(<elapsed>5__4 / duration); <newColor>5__6 = <startColor>5__2; <newColor>5__6.a = Mathf.Lerp(<startAlpha>5__3, 0f, <normalizedTime>5__5); <mat>5__1.color = <newColor>5__6; <>2__current = null; <>1__state = 1; return true; } renderer.enabled = false; return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <LoadAudioClipFromFile>d__28 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string filePath; public int index; public bool isTemp; public MyRepoMod <>4__this; private string <uri>5__1; private UnityWebRequest <www>5__2; private Exception <ex>5__3; private AudioClip <clip>5__4; private Exception <ex>5__5; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadAudioClipFromFile>d__28(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <uri>5__1 = null; <www>5__2 = null; <ex>5__3 = null; <clip>5__4 = null; <ex>5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Invalid comparison between Unknown and I4 switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (index < 0 || index >= <>4__this.fartSounds.Length) { StaticLogger.LogError((object)$"Invalid sound index in LoadAudioClipFromFile: {index}"); if (isTemp && File.Exists(filePath)) { try { File.Delete(filePath); } catch { } } return false; } <uri>5__1 = "file://" + filePath.Replace("\\", "/"); <www>5__2 = null; try { <www>5__2 = UnityWebRequestMultimedia.GetAudioClip(<uri>5__1, (AudioType)13); <www>5__2.SendWebRequest(); } catch (Exception ex) { <ex>5__3 = ex; StaticLogger.LogError((object)("Error creating web request for " + filePath + ": " + <ex>5__3.Message)); if (<www>5__2 != null) { <www>5__2.Dispose(); } if (isTemp && File.Exists(filePath)) { try { File.Delete(filePath); } catch { } } return false; } break; case 1: <>1__state = -1; break; } if (!<www>5__2.isDone) { <>2__current = null; <>1__state = 1; return true; } try { if ((int)<www>5__2.result != 1) { StaticLogger.LogError((object)$"Error loading sound {index + 1} from {filePath}: {<www>5__2.error}"); } else { <clip>5__4 = DownloadHandlerAudioClip.GetContent(<www>5__2); if ((Object)(object)<clip>5__4 != (Object)null) { ((Object)<clip>5__4).name = $"FartSound{index + 1}"; <>4__this.fartSounds[index] = <clip>5__4; StaticLogger.LogInfo((object)$"Successfully loaded sound {index + 1} from {filePath}: {<clip>5__4.length}s duration"); } else { StaticLogger.LogError((object)("Failed to get audio content from " + filePath)); } <clip>5__4 = null; } } catch (Exception ex) { <ex>5__5 = ex; StaticLogger.LogError((object)("Error processing sound from " + filePath + ": " + <ex>5__5.Message)); } finally { if (<www>5__2 != null) { <www>5__2.Dispose(); } if (isTemp && File.Exists(filePath)) { try { File.Delete(filePath); } catch { } } } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <LoadEmbeddedSoundAsCoroutine>d__27 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public int index; public MyRepoMod <>4__this; private string <resourceName>5__1; private string[] <resources>5__2; private string <tempFile>5__3; private Stream <stream>5__4; private Assembly <assembly>5__5; private Exception <ex>5__6; private Assembly <assembly>5__7; private string <tempDir>5__8; private FileStream <fileStream>5__9; private Exception <ex>5__10; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadEmbeddedSoundAsCoroutine>d__27(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <resourceName>5__1 = null; <resources>5__2 = null; <tempFile>5__3 = null; <stream>5__4 = null; <assembly>5__5 = null; <ex>5__6 = null; <assembly>5__7 = null; <tempDir>5__8 = null; <fileStream>5__9 = null; <ex>5__10 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (index < 0 || index >= embeddedSoundResources.Length) { StaticLogger.LogError((object)$"Invalid embedded sound index: {index}"); return false; } <resourceName>5__1 = embeddedSoundResources[index]; <resources>5__2 = null; try { <assembly>5__5 = Assembly.GetExecutingAssembly(); <resources>5__2 = <assembly>5__5.GetManifestResourceNames(); if (!<resources>5__2.Contains(<resourceName>5__1)) { StaticLogger.LogWarning((object)("Embedded resource not found: " + <resourceName>5__1)); return false; } <assembly>5__5 = null; } catch (Exception ex) { <ex>5__6 = ex; StaticLogger.LogError((object)("Error getting manifest resources: " + <ex>5__6.Message)); return false; } <tempFile>5__3 = ""; <stream>5__4 = null; try { <assembly>5__7 = Assembly.GetExecutingAssembly(); <stream>5__4 = <assembly>5__7.GetManifestResourceStream(<resourceName>5__1); if (<stream>5__4 == null) { StaticLogger.LogError((object)("Failed to get stream for resource: " + <resourceName>5__1)); return false; } <tempDir>5__8 = Path.Combine(Path.GetTempPath(), "FartPlugin"); Directory.CreateDirectory(<tempDir>5__8); <tempFile>5__3 = Path.Combine(<tempDir>5__8, $"fart{index + 1}.mp3"); <fileStream>5__9 = File.Create(<tempFile>5__3); try { <stream>5__4.CopyTo(<fileStream>5__9); } finally { if (<fileStream>5__9 != null) { ((IDisposable)<fileStream>5__9).Dispose(); } } <fileStream>5__9 = null; <stream>5__4.Close(); <assembly>5__7 = null; <tempDir>5__8 = null; } catch (Exception ex) { <ex>5__10 = ex; StaticLogger.LogError((object)("Error preparing embedded sound " + <resourceName>5__1 + ": " + <ex>5__10.Message)); if (<stream>5__4 != null) { try { <stream>5__4.Close(); } catch { } } return false; } if (!File.Exists(<tempFile>5__3)) { StaticLogger.LogError((object)("Temp file was not created successfully: " + <tempFile>5__3)); return false; } <>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.LoadAudioClipFromFile(<tempFile>5__3, index, isTemp: true)); <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <LoadFileSystemSoundAsCoroutine>d__25 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string soundsFolder; public int index; public MyRepoMod <>4__this; private string <filename>5__1; private string <filePath>5__2; private string <uri>5__3; private UnityWebRequest <www>5__4; private Exception <ex>5__5; private AudioClip <clip>5__6; private Exception <ex>5__7; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadFileSystemSoundAsCoroutine>d__25(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <filename>5__1 = null; <filePath>5__2 = null; <uri>5__3 = null; <www>5__4 = null; <ex>5__5 = null; <clip>5__6 = null; <ex>5__7 = null; <>1__state = -2; } private bool MoveNext() { //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Invalid comparison between Unknown and I4 switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (index < 0 || index >= <>4__this.fartSounds.Length) { StaticLogger.LogError((object)$"Invalid sound index: {index}"); return false; } <filename>5__1 = $"fart{index + 1}.mp3"; <filePath>5__2 = Path.Combine(soundsFolder, <filename>5__1); if (!File.Exists(<filePath>5__2)) { StaticLogger.LogError((object)("Could not find sound file at " + <filePath>5__2)); return false; } <uri>5__3 = "file://" + <filePath>5__2.Replace("\\", "/"); StaticLogger.LogInfo((object)("Loading sound file: " + <filePath>5__2)); <www>5__4 = null; try { <www>5__4 = UnityWebRequestMultimedia.GetAudioClip(<uri>5__3, (AudioType)13); <www>5__4.SendWebRequest(); } catch (Exception ex) { <ex>5__5 = ex; StaticLogger.LogError((object)("Error creating web request: " + <ex>5__5.Message)); if (<www>5__4 != null) { <www>5__4.Dispose(); } return false; } break; case 1: <>1__state = -1; break; } if (!<www>5__4.isDone) { <>2__current = null; <>1__state = 1; return true; } try { if ((int)<www>5__4.result != 1) { StaticLogger.LogError((object)$"Error loading sound {index + 1}: {<www>5__4.error}"); } else { <clip>5__6 = DownloadHandlerAudioClip.GetContent(<www>5__4); if ((Object)(object)<clip>5__6 != (Object)null) { ((Object)<clip>5__6).name = $"FartSound{index + 1}"; <>4__this.fartSounds[index] = <clip>5__6; StaticLogger.LogInfo((object)$"Successfully loaded fart sound {index + 1}: {<clip>5__6.length}s duration"); } else { StaticLogger.LogError((object)("Failed to get audio content from " + <filePath>5__2)); } <clip>5__6 = null; } } catch (Exception ex) { <ex>5__7 = ex; StaticLogger.LogError((object)("Error processing sound: " + <ex>5__7.Message)); } finally { if (<www>5__4 != null) { <www>5__4.Dispose(); } } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <LoadSoundsProcess>d__24 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public MyRepoMod <>4__this; private bool <success>5__1; private bool <embeddedResourcesFound>5__2; private Exception <ex>5__3; private int <i>5__4; private string <soundsFolder>5__5; private Exception <ex>5__6; private int <i>5__7; private int <loadedSounds>5__8; private Exception <ex>5__9; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadSoundsProcess>d__24(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <ex>5__3 = null; <soundsFolder>5__5 = null; <ex>5__6 = null; <ex>5__9 = null; <>1__state = -2; } private bool MoveNext() { //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <success>5__1 = false; <>4__this.fartSounds = (AudioClip[])(object)new AudioClip[embeddedSoundResources.Length]; <embeddedResourcesFound>5__2 = false; try { <embeddedResourcesFound>5__2 = <>4__this.CheckEmbeddedSounds(); } catch (Exception ex) { <ex>5__3 = ex; StaticLogger.LogError((object)("Error checking embedded resources: " + <ex>5__3.Message)); <embeddedResourcesFound>5__2 = false; } if (<embeddedResourcesFound>5__2) { StaticLogger.LogInfo((object)"Found embedded sound resources, loading them..."); <i>5__4 = 0; while (<i>5__4 < embeddedSoundResources.Length) { ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.LoadEmbeddedSoundAsCoroutine(<i>5__4)); <i>5__4++; } goto IL_0229; } <soundsFolder>5__5 = null; try { <soundsFolder>5__5 = <>4__this.FindSoundFolder(); } catch (Exception ex) { <ex>5__6 = ex; StaticLogger.LogError((object)("Error finding sound folder: " + <ex>5__6.Message)); } if (!string.IsNullOrEmpty(<soundsFolder>5__5)) { StaticLogger.LogInfo((object)("Attempting to load sounds from disk at: " + <soundsFolder>5__5)); <i>5__7 = 0; goto IL_01e1; } StaticLogger.LogError((object)"Could not find sounds folder in any of the expected locations!"); StaticLogger.LogInfo((object)"Please put your sound files in a 'sounds' folder inside the plugin directory."); goto IL_0221; case 1: <>1__state = -1; <i>5__7++; goto IL_01e1; case 2: { <>1__state = -1; try { <loadedSounds>5__8 = <>4__this.fartSounds.Count((AudioClip s) => (Object)(object)s != (Object)null); if (<loadedSounds>5__8 > 0) { <>4__this.soundsLoaded = true; StaticLogger.LogInfo((object)$"Sound loading complete. Successfully loaded {<loadedSounds>5__8} fart sounds!"); <success>5__1 = true; } else { StaticLogger.LogError((object)"Failed to load any fart sounds!"); } } catch (Exception ex) { <ex>5__9 = ex; StaticLogger.LogError((object)("Error in LoadSoundsProcess: " + <ex>5__9.Message + "\n" + <ex>5__9.StackTrace)); } if (!<success>5__1) { StaticLogger.LogError((object)"Sound loading process did not complete successfully!"); } return false; } IL_0221: <soundsFolder>5__5 = null; goto IL_0229; IL_01e1: if (<i>5__7 < <>4__this.fartSounds.Length) { ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.LoadFileSystemSoundAsCoroutine(<soundsFolder>5__5, <i>5__7)); <>2__current = (object)new WaitForEndOfFrame(); <>1__state = 1; return true; } goto IL_0221; IL_0229: <>2__current = (object)new WaitForSeconds(1f); <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static ManualLogSource StaticLogger; private AudioClip[] fartSounds; private bool soundPlaying = false; private float soundTimer = 0f; private float soundDuration = 1f; private float soundRadius = 30f; private AudioSource audioSource; private Random random; private bool soundsLoaded = false; private ParticleSystem fartEffect; private static List<FartInstance> activeFarts = new List<FartInstance>(); private static readonly string[] embeddedSoundResources = new string[8] { "MyRepoMod.Sounds.fart1.mp3", "MyRepoMod.Sounds.fart2.mp3", "MyRepoMod.Sounds.fart3.mp3", "MyRepoMod.Sounds.fart4.mp3", "MyRepoMod.Sounds.fart5.mp3", "MyRepoMod.Sounds.fart6.mp3", "MyRepoMod.Sounds.fart7.mp3", "MyRepoMod.Sounds.fart8.mp3" }; internal static MyRepoMod Instance { get; private set; } private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { try { Instance = this; StaticLogger = ((BaseUnityPlugin)this).Logger; StaticLogger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} is starting up..."); random = new Random(); ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; audioSource = ((Component)this).gameObject.AddComponent<AudioSource>(); audioSource.spatialBlend = 1f; audioSource.rolloffMode = (AudioRolloffMode)1; audioSource.maxDistance = soundRadius; audioSource.dopplerLevel = 0f; audioSource.priority = 128; fartSounds = (AudioClip[])(object)new AudioClip[8]; CreateFartEffect(); ((MonoBehaviour)this).StartCoroutine(LoadSoundsProcess()); TryConnectToGameNetworking(); Patch(); StaticLogger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } catch (Exception ex) { if (StaticLogger != null) { StaticLogger.LogError((object)("Failed to initialize plugin: " + ex.Message + "\n" + ex.StackTrace)); } else { Debug.LogError((object)("[FartPlugin] Failed to initialize plugin: " + ex.Message + "\n" + ex.StackTrace)); } throw; } } [IteratorStateMachine(typeof(<LoadSoundsProcess>d__24))] private IEnumerator LoadSoundsProcess() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadSoundsProcess>d__24(0) { <>4__this = this }; } [IteratorStateMachine(typeof(<LoadFileSystemSoundAsCoroutine>d__25))] private IEnumerator LoadFileSystemSoundAsCoroutine(string soundsFolder, int index) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadFileSystemSoundAsCoroutine>d__25(0) { <>4__this = this, soundsFolder = soundsFolder, index = index }; } private bool CheckEmbeddedSounds() { try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string[] resources = executingAssembly.GetManifestResourceNames(); StaticLogger.LogInfo((object)$"Found {resources.Length} embedded resources in assembly"); string[] array = resources; foreach (string text in array) { StaticLogger.LogInfo((object)("Found resource: " + text)); } return embeddedSoundResources.Any((string res) => resources.Contains(res)); } catch (Exception ex) { StaticLogger.LogError((object)("Error in CheckEmbeddedSounds: " + ex.Message)); return false; } } [IteratorStateMachine(typeof(<LoadEmbeddedSoundAsCoroutine>d__27))] private IEnumerator LoadEmbeddedSoundAsCoroutine(int index) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadEmbeddedSoundAsCoroutine>d__27(0) { <>4__this = this, index = index }; } [IteratorStateMachine(typeof(<LoadAudioClipFromFile>d__28))] private IEnumerator LoadAudioClipFromFile(string filePath, int index, bool isTemp = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadAudioClipFromFile>d__28(0) { <>4__this = this, filePath = filePath, index = index, isTemp = isTemp }; } private string FindSoundFolder() { try { string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); string[] array = new string[5] { Path.Combine(directoryName), Path.Combine(Paths.PluginPath), Path.Combine(Paths.PluginPath, "sounds"), Path.Combine(Paths.PluginPath, "FartP", "sounds"), Path.Combine(Paths.GameRootPath, "sounds") }; string[] array2 = array; foreach (string text in array2) { if (Directory.Exists(text)) { StaticLogger.LogInfo((object)("Found sounds folder at: " + text)); return text; } } return null; } catch (Exception ex) { StaticLogger.LogError((object)("Error in FindSoundFolder: " + ex.Message)); return null; } } internal void Patch() { //IL_001b: 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) //IL_0022: Expected O, but got Unknown //IL_0027: Expected O, but got Unknown try { if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); StaticLogger.LogInfo((object)"Harmony patches applied successfully"); } catch (Exception ex) { StaticLogger.LogError((object)("Failed to apply Harmony patches: " + ex.Message)); } } internal void Unpatch() { try { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } StaticLogger.LogInfo((object)"Harmony patches removed"); } catch (Exception ex) { StaticLogger.LogError((object)("Failed to remove Harmony patches: " + ex.Message)); } } private void Update() { try { if (!soundsLoaded) { return; } if (Time.frameCount % 2 == 0 && Input.GetKey((KeyCode)122) && !soundPlaying) { PlayFartSound(); } if (soundPlaying) { soundTimer += Time.deltaTime; if (soundTimer >= soundDuration) { soundPlaying = false; soundTimer = 0f; } } if (Time.frameCount % 10 == 0) { CheckForNewFartInstances(); } } catch (Exception ex) { StaticLogger.LogError((object)("Error in Update: " + ex.Message)); } } private void CheckForNewFartInstances() { //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) try { activeFarts.RemoveAll((FartInstance f) => !f.IsActive); if (Time.frameCount % 10 != 0) { return; } List<FartMarkerComponent> list = new List<FartMarkerComponent>(); try { if (Time.time % 3f < 0.1f) { FartMarkerComponent[] array = Object.FindObjectsOfType<FartMarkerComponent>(); FartMarkerComponent[] array2 = array; foreach (FartMarkerComponent fartMarkerComponent in array2) { if ((Object)(object)fartMarkerComponent != (Object)null && !fartMarkerComponent.Processed) { list.Add(fartMarkerComponent); } } } } catch (Exception ex) { StaticLogger.LogWarning((object)("Error finding fart markers: " + ex.Message)); } foreach (FartMarkerComponent item in list) { if ((Object)(object)item != (Object)null && !item.Processed) { PlayRemoteFartEffect(((Component)item).transform.position, ((Component)item).transform.rotation, item.SoundIndex); item.Processed = true; Object.Destroy((Object)(object)((Component)item).gameObject, 0.1f); } } } catch (Exception ex2) { StaticLogger.LogError((object)("Error in CheckForNewFartInstances: " + ex2.Message)); } } private bool HasRecentlyProcessedEffect(Vector3 position, int soundIndex, float maxTimeAgo = 1f) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) foreach (FartInstance activeFart in activeFarts) { if (Vector3.Distance(activeFart.Position, position) < 0.5f && activeFart.SoundIndex == soundIndex && Time.time - activeFart.StartTime < maxTimeAgo) { return true; } } return false; } private bool IsGameObjectNetworked(GameObject obj) { try { Component val = null; val = obj.GetComponent("NetworkIdentity"); if ((Object)(object)val != (Object)null) { return true; } val = obj.GetComponent("NetworkIdentity"); if ((Object)(object)val != (Object)null) { return true; } val = obj.GetComponent("PhotonView"); if ((Object)(object)val != (Object)null) { return true; } val = obj.GetComponent("NetworkObject"); if ((Object)(object)val != (Object)null) { return true; } val = obj.GetComponent("NetworkObject"); if ((Object)(object)val != (Object)null) { return true; } Component[] components = obj.GetComponents<Component>(); Component[] array = components; foreach (Component val2 in array) { if (((object)val2).GetType().Name.Contains("Network") || ((object)val2).GetType().Name.Contains("Photon")) { return true; } } return false; } catch { return false; } } private void PlayFartSound() { //IL_0096: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_0114: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) try { int num = 0; AudioClip[] array = fartSounds; foreach (AudioClip val in array) { if ((Object)(object)val != (Object)null) { num++; } } if (num == 0) { StaticLogger.LogError((object)"No fart sounds available to play!"); return; } if ((Object)(object)audioSource == (Object)null) { StaticLogger.LogError((object)"AudioSource component is null!"); return; } soundPlaying = true; soundTimer = 0f; Vector3 playerPosition = GetPlayerPosition(); Quaternion playerRotation = GetPlayerRotation(); ((Component)this).transform.position = playerPosition; PlayFartEffect(playerPosition, playerRotation); AudioClip val2 = null; int num2 = -1; int num3 = 0; while ((Object)(object)val2 == (Object)null && num3 < 10) { num2 = random.Next(0, fartSounds.Length); val2 = fartSounds[num2]; if ((Object)(object)val2 != (Object)null) { audioSource.PlayOneShot(val2, 0.5f); soundDuration = val2.length; if (!TryUseGameNetworking(playerPosition, playerRotation, num2)) { BroadcastFartEffect(playerPosition, playerRotation, num2); } StaticLogger.LogInfo((object)$"Playing fart sound {num2 + 1} with volume 0.5 at position {playerPosition}!"); break; } num3++; } if ((Object)(object)val2 == (Object)null) { StaticLogger.LogError((object)"Failed to select a valid sound after multiple attempts!"); } } catch (Exception ex) { StaticLogger.LogError((object)("Error in PlayFartSound: " + ex.Message)); } } private Vector3 GetPlayerPosition() { //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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) //IL_0100: 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) try { if ((Object)(object)Camera.main != (Object)null) { return ((Component)Camera.main).transform.position; } GameObject val = GameObject.FindGameObjectWithTag("Player"); if ((Object)(object)val != (Object)null) { return val.transform.position; } IEnumerable<GameObject> enumerable = from mb in Object.FindObjectsOfType<MonoBehaviour>() where ((object)mb).GetType().Name.Contains("Player") || ((object)mb).GetType().Name.Contains("Character") select ((Component)mb).gameObject; foreach (GameObject item in enumerable) { if (item.activeSelf) { return item.transform.position; } } StaticLogger.LogWarning((object)"Could not find player position, using fallback position"); return ((Component)this).transform.position; } catch (Exception ex) { StaticLogger.LogError((object)("Error finding player position: " + ex.Message)); return ((Component)this).transform.position; } } private Quaternion GetPlayerRotation() { //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)Camera.main != (Object)null) { return ((Component)Camera.main).transform.rotation; } GameObject val = GameObject.FindGameObjectWithTag("Player"); if ((Object)(object)val != (Object)null) { return val.transform.rotation; } IEnumerable<GameObject> enumerable = from mb in Object.FindObjectsOfType<MonoBehaviour>() where ((object)mb).GetType().Name.Contains("Player") || ((object)mb).GetType().Name.Contains("Character") select ((Component)mb).gameObject; foreach (GameObject item in enumerable) { if (item.activeSelf) { return item.transform.rotation; } } return Quaternion.identity; } catch (Exception ex) { StaticLogger.LogError((object)("Error finding player rotation: " + ex.Message)); return Quaternion.identity; } } private void NetworkPlayFartSound(Vector3 position) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) try { Collider[] array = Physics.OverlapSphere(position, soundRadius); StaticLogger.LogInfo((object)$"Found {array.Length} colliders in sound radius"); } catch (Exception ex) { StaticLogger.LogError((object)("Error in NetworkPlayFartSound: " + ex.Message)); } } private List<GameObject> FindNetworkedPlayers() { List<GameObject> list = new List<GameObject>(); try { Transform[] array = Object.FindObjectsOfType<Transform>(); StaticLogger.LogInfo((object)$"Found {array.Length} total objects in scene"); Transform[] array2 = array; foreach (Transform val in array2) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)null) { continue; } bool flag = false; if (((Object)val).name.ToLower().Contains("player") || ((Object)val).name.ToLower().Contains("character") || ((Object)val).name.ToLower().Contains("client")) { flag = true; } if (!flag && (Object)(object)val.parent != (Object)null && (((Object)val.parent).name.ToLower().Contains("player") || ((Object)val.parent).name.ToLower().Contains("character") || ((Object)val.parent).name.ToLower().Contains("client"))) { flag = true; } if (!flag) { Component[] components = ((Component)val).GetComponents<Component>(); Component[] array3 = components; foreach (Component val2 in array3) { if (!((Object)(object)val2 == (Object)null)) { string name = ((object)val2).GetType().Name; if (name.Contains("Network") || name.Contains("Photon") || name.Contains("Player") || name.Contains("Character")) { flag = true; break; } } } } if (flag) { list.Add(((Component)val).gameObject); StaticLogger.LogInfo((object)("Found potential networked player: " + ((Object)val).name)); } } } catch (Exception ex) { StaticLogger.LogError((object)("Error in FindNetworkedPlayers: " + ex.Message)); } return list; } private void BroadcastFartEffect(Vector3 position, Quaternion rotation, int soundIndex) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Expected O, but got Unknown //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Expected O, but got Unknown //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Expected O, but got Unknown //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_024a: 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) //IL_010c: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) try { activeFarts.Add(new FartInstance { Position = position, Rotation = rotation, StartTime = Time.time, Duration = soundDuration, SoundIndex = soundIndex }); AudioClip val = null; if (soundIndex >= 0 && soundIndex < fartSounds.Length) { val = fartSounds[soundIndex]; } if ((Object)(object)val == (Object)null) { StaticLogger.LogError((object)"Invalid sound index or sound not loaded"); return; } MonoBehaviour obj = Object.FindObjectOfType<MonoBehaviour>(); Component val2 = ((obj != null) ? ((Component)obj).GetComponent(GetNetworkManagerType()) : null); bool flag = false; if ((Object)(object)val2 != (Object)null) { try { MethodInfo method = ((object)val2).GetType().GetMethod("Spawn", BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { typeof(GameObject) }, null); if (method != null) { GameObject val3 = new GameObject("FartMarker_" + Time.time); val3.transform.position = position; val3.transform.rotation = rotation; FartMarkerComponent fartMarkerComponent = val3.AddComponent<FartMarkerComponent>(); fartMarkerComponent.SoundIndex = soundIndex; fartMarkerComponent.Processed = false; method.Invoke(val2, new object[1] { val3 }); StaticLogger.LogInfo((object)$"Created NETWORKED fart marker at position {position}"); flag = true; } } catch (Exception ex) { StaticLogger.LogWarning((object)("Failed to use reflection for networking: " + ex.Message)); } } if (!flag) { StaticLogger.LogInfo((object)"Trying backup network method: attaching to player objects"); List<GameObject> list = FindNetworkedPlayers(); if (list.Count > 0) { foreach (GameObject item in list) { if (!((Object)(object)item == (Object)null)) { try { GameObject val4 = new GameObject("FartEffect_" + Time.time); val4.transform.SetParent(item.transform, false); val4.transform.position = position; val4.transform.rotation = rotation; FartMarkerComponent fartMarkerComponent2 = val4.AddComponent<FartMarkerComponent>(); fartMarkerComponent2.SoundIndex = soundIndex; fartMarkerComponent2.Processed = false; AudioSource val5 = val4.AddComponent<AudioSource>(); val5.spatialBlend = 1f; val5.rolloffMode = (AudioRolloffMode)1; val5.maxDistance = soundRadius; val5.volume = 0.5f; val5.clip = val; val5.Play(); ParticleSystem ps = val4.AddComponent<ParticleSystem>(); ConfigureParticleSystem(ps, soundDuration); Object.Destroy((Object)(object)val4, Mathf.Max(3f, soundDuration * 1.5f)); StaticLogger.LogInfo((object)("Attached fart effect to player object: " + ((Object)item).name)); } catch (Exception ex2) { StaticLogger.LogWarning((object)("Failed to attach effect to player " + ((Object)item).name + ": " + ex2.Message)); } } } } else { StaticLogger.LogWarning((object)"No player objects found to attach effects to"); } } GameObject val6 = new GameObject("FartMarker_" + Time.time); val6.transform.position = position; val6.transform.rotation = rotation; FartMarkerComponent fartMarkerComponent3 = val6.AddComponent<FartMarkerComponent>(); fartMarkerComponent3.SoundIndex = soundIndex; fartMarkerComponent3.Processed = false; Object.DontDestroyOnLoad((Object)(object)val6); try { MeshFilter val7 = val6.AddComponent<MeshFilter>(); val7.mesh = CreateSimpleCube(); MeshRenderer val8 = val6.AddComponent<MeshRenderer>(); ((Renderer)val8).material = new Material(Shader.Find("Standard")); ((Renderer)val8).material.color = new Color(0.36f, 0.25f, 0.13f, 0.8f); val6.transform.localScale = new Vector3(0.05f, 0.05f, 0.05f); ((MonoBehaviour)this).StartCoroutine(FadeOutObject((Renderer)(object)val8, 1f)); } catch (Exception ex3) { StaticLogger.LogWarning((object)("Failed to make marker visible: " + ex3.Message)); } Object.Destroy((Object)(object)val6, 10f); StaticLogger.LogInfo((object)$"Created fallback fart marker at position {position}"); } catch (Exception ex4) { StaticLogger.LogError((object)("Error broadcasting fart effect: " + ex4.Message)); } } private Mesh CreateSimpleCube() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) Mesh val = new Mesh(); Vector3[] vertices = (Vector3[])(object)new Vector3[8] { new Vector3(-0.5f, -0.5f, -0.5f), new Vector3(0.5f, -0.5f, -0.5f), new Vector3(0.5f, 0.5f, -0.5f), new Vector3(-0.5f, 0.5f, -0.5f), new Vector3(-0.5f, -0.5f, 0.5f), new Vector3(0.5f, -0.5f, 0.5f), new Vector3(0.5f, 0.5f, 0.5f), new Vector3(-0.5f, 0.5f, 0.5f) }; int[] triangles = new int[36] { 0, 1, 2, 2, 3, 0, 1, 5, 6, 6, 2, 1, 5, 4, 7, 7, 6, 5, 4, 0, 3, 3, 7, 4, 3, 2, 6, 6, 7, 3, 4, 5, 1, 1, 0, 4 }; val.vertices = vertices; val.triangles = triangles; val.RecalculateNormals(); return val; } [IteratorStateMachine(typeof(<FadeOutObject>d__43))] private IEnumerator FadeOutObject(Renderer renderer, float duration) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <FadeOutObject>d__43(0) { <>4__this = this, renderer = renderer, duration = duration }; } private void ConfigureParticleSystem(ParticleSystem ps, float duration) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0051: 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_0096: 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_00ac: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ps == (Object)null)) { MainModule main = ps.main; ((MainModule)(ref main)).duration = duration; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(duration); ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0.3f); ((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.3f); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.36f, 0.25f, 0.13f, 0.8f)); ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).maxParticles = 30; EmissionModule emission = ps.emission; ((EmissionModule)(ref emission)).enabled = true; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(5f); ((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1] { new Burst(0f, (short)10) }); ShapeModule shape = ps.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4; ((ShapeModule)(ref shape)).angle = 20f; ((ShapeModule)(ref shape)).radius = 0.05f; ps.Play(); } } private void PlayRemoteFartEffect(Vector3 position, Quaternion rotation, int soundIndex) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0031: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0047: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) try { if (!(Vector3.Distance(((Component)this).transform.position, position) < 0.5f)) { ((Component)this).transform.position = position; Vector3 val = position - rotation * Vector3.forward * 0.5f; val.y -= 0.5f; ((Component)fartEffect).transform.position = val; ((Component)fartEffect).transform.rotation = rotation; MainModule main = fartEffect.main; AudioClip val2 = null; val2 = (AudioClip)((soundIndex < 0 || soundIndex >= fartSounds.Length) ? ((object)((IEnumerable<AudioClip>)fartSounds).FirstOrDefault((Func<AudioClip, bool>)((AudioClip s) => (Object)(object)s != (Object)null))) : ((object)fartSounds[soundIndex])); if ((Object)(object)val2 != (Object)null) { ((MainModule)(ref main)).duration = val2.length; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(val2.length * 1.2f); audioSource.PlayOneShot(val2, 0.5f); fartEffect.Stop(); fartEffect.Clear(); fartEffect.Play(); StaticLogger.LogInfo((object)$"Playing remote fart effect at position {val}"); } else { StaticLogger.LogError((object)"No valid sound clip found for remote fart effect"); } } } catch (Exception ex) { StaticLogger.LogError((object)("Error playing remote fart effect: " + ex.Message)); } } private void CreateFartEffect() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_0198: 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_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Expected O, but got Unknown //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0224: 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_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_028b: 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_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Expected O, but got Unknown try { GameObject val = new GameObject("FartEffect"); val.transform.parent = ((Component)this).transform; fartEffect = val.AddComponent<ParticleSystem>(); MainModule main = fartEffect.main; ((MainModule)(ref main)).duration = 1.5f; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(1.5f); ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0.3f); ((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.3f); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.36f, 0.25f, 0.13f, 0.8f)); ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).maxParticles = 30; EmissionModule emission = fartEffect.emission; ((EmissionModule)(ref emission)).enabled = true; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(5f); ((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1] { new Burst(0f, (short)10) }); ShapeModule shape = fartEffect.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4; ((ShapeModule)(ref shape)).angle = 20f; ((ShapeModule)(ref shape)).radius = 0.05f; SizeOverLifetimeModule sizeOverLifetime = fartEffect.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; AnimationCurve val2 = new AnimationCurve(); val2.AddKey(0f, 0.5f); val2.AddKey(0.3f, 1f); val2.AddKey(1f, 1.5f); ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, val2); ColorOverLifetimeModule colorOverLifetime = fartEffect.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val3 = new Gradient(); val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(new Color(0.36f, 0.25f, 0.13f), 0f), new GradientColorKey(new Color(0.29f, 0.18f, 0.07f), 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[3] { new GradientAlphaKey(0.9f, 0f), new GradientAlphaKey(0.7f, 0.5f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3); VelocityOverLifetimeModule velocityOverLifetime = fartEffect.velocityOverLifetime; ((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = false; ForceOverLifetimeModule forceOverLifetime = fartEffect.forceOverLifetime; ((ForceOverLifetimeModule)(ref forceOverLifetime)).enabled = false; NoiseModule noise = fartEffect.noise; ((NoiseModule)(ref noise)).enabled = false; CollisionModule collision = fartEffect.collision; ((CollisionModule)(ref collision)).enabled = false; ParticleSystemRenderer component = ((Component)fartEffect).GetComponent<ParticleSystemRenderer>(); if ((Object)(object)component != (Object)null) { ((Renderer)component).material = new Material(Shader.Find("Particles/Standard Unlit")); component.renderMode = (ParticleSystemRenderMode)0; component.maxParticleSize = 0.5f; component.minParticleSize = 0.1f; component.trailMaterial = null; } fartEffect.Stop(); StaticLogger.LogInfo((object)"Fart effect particle system created successfully with optimized settings"); } catch (Exception ex) { StaticLogger.LogError((object)("Error creating fart effect: " + ex.Message)); } } private void PlayFartEffect(Vector3 playerPosition, Quaternion playerRotation) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)fartEffect == (Object)null) { StaticLogger.LogWarning((object)"Fart effect is null, creating it now"); CreateFartEffect(); } if ((Object)(object)fartEffect == (Object)null) { StaticLogger.LogError((object)"Failed to create fart effect"); return; } Vector3 val = playerPosition - playerRotation * Vector3.forward * 0.5f; val.y -= 0.5f; ((Component)fartEffect).transform.position = val; ((Component)fartEffect).transform.rotation = playerRotation; MainModule main = fartEffect.main; ((MainModule)(ref main)).duration = soundDuration; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(soundDuration * 1.2f); fartEffect.Stop(); fartEffect.Clear(); fartEffect.Play(); StaticLogger.LogInfo((object)$"Playing fart effect at position {val}"); } catch (Exception ex) { StaticLogger.LogError((object)("Error playing fart effect: " + ex.Message)); } } private void TryConnectToGameNetworking() { try { MonoBehaviour[] array = Object.FindObjectsOfType<MonoBehaviour>(); StaticLogger.LogInfo((object)$"Searching through {array.Length} MonoBehaviours for networking system"); MonoBehaviour[] array2 = array; foreach (MonoBehaviour val in array2) { Type type = ((object)val).GetType(); if (!type.Name.Contains("Network") && !type.Name.Contains("Photon") && !type.Name.Contains("Steam") && (type.Namespace == null || (!type.Namespace.Contains("Network") && !type.Namespace.Contains("Photon") && !type.Namespace.Contains("Steam")))) { continue; } StaticLogger.LogInfo((object)("Potential networking type found: " + type.FullName)); MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public); foreach (MethodInfo methodInfo in methods) { if ((methodInfo.Name.Contains("Spawn") || methodInfo.Name.Contains("Instantiate") || methodInfo.Name.Contains("Create")) && methodInfo.GetParameters().Length != 0 && methodInfo.GetParameters()[0].ParameterType == typeof(GameObject)) { StaticLogger.LogInfo((object)("Potential network instantiation method found: " + methodInfo.Name)); } } } } catch (Exception ex) { StaticLogger.LogError((object)("Error analyzing networking system: " + ex.Message)); } } private bool TryUseGameNetworking(Vector3 position, Quaternion rotation, int soundIndex) { //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Expected O, but got Unknown //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Expected O, but got Unknown try { MonoBehaviour[] array = (from mb in Object.FindObjectsOfType<MonoBehaviour>() where ((object)mb).GetType().Name.Contains("Network") || ((object)mb).GetType().Name.Contains("Photon") || (((object)mb).GetType().Namespace != null && (((object)mb).GetType().Namespace.Contains("Network") || ((object)mb).GetType().Namespace.Contains("Photon"))) select mb).ToArray(); MonoBehaviour[] array2 = array; foreach (MonoBehaviour val in array2) { Type type = ((object)val).GetType(); MethodInfo methodInfo = null; string[] array3 = new string[4] { "Spawn", "Instantiate", "NetworkInstantiate", "InstantiateRoomObject" }; string[] array4 = array3; foreach (string methodName in array4) { MethodInfo[] array5 = (from m in type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public) where m.Name.Contains(methodName) select m).ToArray(); MethodInfo[] array6 = array5; foreach (MethodInfo methodInfo2 in array6) { ParameterInfo[] parameters = methodInfo2.GetParameters(); if (parameters.Length != 0 && (parameters[0].ParameterType == typeof(GameObject) || parameters[0].ParameterType == typeof(Object))) { methodInfo = methodInfo2; break; } } if (methodInfo != null) { break; } } if (!(methodInfo != null)) { continue; } GameObject val2 = new GameObject("FartMarker_" + Time.time); val2.transform.position = position; val2.transform.rotation = rotation; FartMarkerComponent fartMarkerComponent = val2.AddComponent<FartMarkerComponent>(); fartMarkerComponent.SoundIndex = soundIndex; fartMarkerComponent.Processed = false; try { ParameterInfo[] parameters2 = methodInfo.GetParameters(); object[] array7 = new object[parameters2.Length]; array7[0] = val2; for (int l = 1; l < parameters2.Length; l++) { array7[l] = (parameters2[l].ParameterType.IsValueType ? Activator.CreateInstance(parameters2[l].ParameterType) : null); if (parameters2[l].ParameterType == typeof(Vector3)) { array7[l] = position; } else if (parameters2[l].ParameterType == typeof(Quaternion)) { array7[l] = rotation; } } object obj = methodInfo.Invoke(methodInfo.IsStatic ? null : val, array7); StaticLogger.LogInfo((object)("Successfully used " + type.Name + "." + methodInfo.Name + " to spawn network object")); if (obj != null && obj is GameObject) { GameObject val3 = (GameObject)obj; if ((Object)(object)val3.GetComponent<FartMarkerComponent>() == (Object)null) { FartMarkerComponent fartMarkerComponent2 = val3.AddComponent<FartMarkerComponent>(); fartMarkerComponent2.SoundIndex = soundIndex; fartMarkerComponent2.Processed = false; } StaticLogger.LogInfo((object)("Successfully created networked fart marker via " + type.Name)); } return true; } catch (Exception ex) { StaticLogger.LogError((object)("Failed to invoke " + methodInfo.Name + ": " + ex.Message)); Object.Destroy((Object)(object)val2); } } return false; } catch (Exception ex2) { StaticLogger.LogError((object)("Error in TryUseGameNetworking: " + ex2.Message)); return false; } } private Type GetNetworkManagerType() { Type[] array = new Type[4] { Type.GetType("Mirror.NetworkManager, Mirror"), Type.GetType("UnityEngine.Networking.NetworkManager, UnityEngine"), Type.GetType("Photon.Pun.PhotonNetwork, Photon.Pun"), Type.GetType("Unity.Netcode.NetworkManager, Unity.Netcode.Runtime") }; Type[] array2 = array; foreach (Type type in array2) { if (type != null) { return type; } } Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); Assembly[] array3 = assemblies; foreach (Assembly assembly in array3) { try { Type[] types = assembly.GetTypes(); foreach (Type type2 in types) { if (type2.Name.Contains("NetworkManager") || type2.Name.Contains("PhotonNetwork")) { return type2; } } } catch { } } return null; } } }