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 SingingMachine v1.0.0
plugins/SingingMachine.dll
Decompiled 41 minutes ago
The result has been truncated due to the large size, download it to view full contents!
using 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.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using REPOLib.Modules; using REPOLib.Objects.Sdk; using UnityEngine; using UnityEngine.AI; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("SingingMachine")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.1.0")] [assembly: AssemblyInformationalVersion("0.1.1+a6281264dd1ea08ba8d136448a73868164368f38")] [assembly: AssemblyProduct("SingingMachine")] [assembly: AssemblyTitle("SingingMachine")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.1.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 SingingMachine { internal static class Assets { private const int SoundRate = 24000; private static readonly Dictionary<string, Mesh> meshes = new Dictionary<string, Mesh>(); private static readonly Dictionary<string, AudioClip> sounds = new Dictionary<string, AudioClip>(); private static readonly int[] AdpcmSteps = new int[89] { 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408, 449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282, 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, 32767 }; private static readonly int[] AdpcmIndex = new int[8] { -1, -1, -1, -1, 2, 4, 6, 8 }; private static AudioMixerGroup mixer; private static AudioMixerGroup Mixer { get { if (Object.op_Implicit((Object)(object)mixer) || !Object.op_Implicit((Object)(object)AudioManager.instance) || !Object.op_Implicit((Object)(object)AudioManager.instance.SoundMasterGroup)) { return mixer; } AudioMixerGroup[] array = AudioManager.instance.SoundMasterGroup.audioMixer.FindMatchingGroups("Sound Effects"); mixer = ((array.Length != 0) ? array[0] : AudioManager.instance.SoundMasterGroup); return mixer; } } internal static byte[] Bytes(string name) { using Stream stream = typeof(Assets).Assembly.GetManifestResourceStream("SingingMachine." + name); if (stream == null) { throw new FileNotFoundException("Embedded asset missing: " + name); } byte[] array = new byte[stream.Length]; for (int i = 0; i < array.Length; i += stream.Read(array, i, array.Length - i)) { } return array; } internal static Mesh LoadMesh(string name) { //IL_0082: 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_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_00fa: 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) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Expected O, but got Unknown if (meshes.TryGetValue(name, out var value) && Object.op_Implicit((Object)(object)value)) { return value; } byte[] array = Bytes(name + ".mesh"); int num = BitConverter.ToInt32(array, 0); int num2 = BitConverter.ToInt32(array, 4); int num3 = 8; Vector3[] array2 = (Vector3[])(object)new Vector3[num]; Vector3[] array3 = (Vector3[])(object)new Vector3[num]; Vector2[] array4 = (Vector2[])(object)new Vector2[num]; int[] array5 = new int[num2]; int num4 = 0; while (num4 < num) { array2[num4] = new Vector3(F(array, num3), F(array, num3 + 4), F(array, num3 + 8)); num4++; num3 += 12; } int num5 = 0; while (num5 < num) { array3[num5] = new Vector3(F(array, num3), F(array, num3 + 4), F(array, num3 + 8)); num5++; num3 += 12; } int num6 = 0; while (num6 < num) { array4[num6] = new Vector2(F(array, num3), F(array, num3 + 4)); num6++; num3 += 8; } int num7 = 0; while (num7 < num2) { array5[num7] = BitConverter.ToInt32(array, num3); num7++; num3 += 4; } Mesh val = new Mesh { name = name }; if (num > 65535) { val.indexFormat = (IndexFormat)1; } val.vertices = array2; val.normals = array3; val.uv = array4; val.triangles = array5; val.RecalculateBounds(); return meshes[name] = val; } private static float F(byte[] b, int o) { return BitConverter.ToSingle(b, o); } internal static Texture2D LoadTexture(string name) { //IL_0004: 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_0010: 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: Expected O, but got Unknown //IL_002f: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true) { name = name, wrapMode = (TextureWrapMode)1 }; ImageConversion.LoadImage(val, Bytes(name + ".png")); return val; } internal static Texture2D LoadPalette(string name) { //IL_0004: 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_0010: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0036: Expected O, but got Unknown Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false) { name = name, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)0 }; ImageConversion.LoadImage(val, Bytes(name + ".png")); return val; } internal static AudioClip LoadSound(string name) { if (sounds.TryGetValue(name, out var value) && Object.op_Implicit((Object)(object)value)) { return value; } float[] array; if (Has(name + ".adpcm")) { array = Adpcm(Bytes(name + ".adpcm")); } else { byte[] array2 = Bytes(name + ".pcm"); array = new float[array2.Length / 2]; for (int i = 0; i < array.Length; i++) { array[i] = (float)BitConverter.ToInt16(array2, i * 2) / 32768f; } } value = AudioClip.Create(name, array.Length, 1, 24000, false); value.SetData(array, 0); return sounds[name] = value; } private static bool Has(string name) { return typeof(Assets).Assembly.GetManifestResourceInfo("SingingMachine." + name) != null; } private static float[] Adpcm(byte[] b) { int num = BitConverter.ToInt32(b, 0); float[] array = new float[num]; int num2 = 0; int num3 = 0; for (int i = 0; i < num; i++) { int num4 = (b[4 + (i >> 1)] >> (i & 1) * 4) & 0xF; int num5 = AdpcmSteps[num3]; int num6 = num5 >> 3; if ((num4 & 4) != 0) { num6 += num5; } if ((num4 & 2) != 0) { num6 += num5 >> 1; } if ((num4 & 1) != 0) { num6 += num5 >> 2; } num2 = Mathf.Clamp(((num4 & 8) != 0) ? (num2 - num6) : (num2 + num6), -32768, 32767); num3 = Mathf.Clamp(num3 + AdpcmIndex[num4 & 7], 0, 88); array[i] = (float)num2 / 32768f; } return array; } private static AudioSource Source(string label, AudioClip clip, Transform parent, float volume, float maxDistance) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SingingMachine " + label + " " + (Object.op_Implicit((Object)(object)clip) ? ((Object)clip).name : "?")); val.transform.SetParent(parent, false); AudioSource obj = val.AddComponent<AudioSource>(); obj.clip = clip; obj.volume = volume; obj.spatialBlend = 1f; obj.rolloffMode = (AudioRolloffMode)1; obj.minDistance = 1.5f; obj.maxDistance = maxDistance; obj.dopplerLevel = 0f; obj.outputAudioMixerGroup = Mixer; return obj; } internal static void Play(AudioClip clip, Transform follow, float volume = 1f, float maxDistance = 15f) { if (Object.op_Implicit((Object)(object)clip)) { AudioSource obj = Source("Sound", clip, follow, volume, maxDistance); obj.Play(); Object.Destroy((Object)(object)((Component)obj).gameObject, clip.length + 0.2f); } } internal static AudioSource Loop(AudioClip clip, Transform follow, float volume = 1f, float maxDistance = 15f) { AudioSource val = Source("Loop", clip, follow, volume, maxDistance); val.loop = true; if (Object.op_Implicit((Object)(object)clip)) { val.time = Random.Range(0f, clip.length); val.Play(); } return val; } internal static Material MakeMaterial(Material baseMat, string name, Texture2D albedo, float smoothness = 0.15f) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) Material val = (Object.op_Implicit((Object)(object)baseMat) ? new Material(baseMat) : new Material(Shader.Find("Standard"))); ((Object)val).name = name; string[] array = new string[4] { "_BaseTexture", "_MainTex", "_BaseMap", "_AlbedoTexture" }; foreach (string text in array) { if (val.HasProperty(text)) { val.SetTexture(text, (Texture)(object)albedo); } } array = new string[2] { "_NormalTexture", "_BumpMap" }; foreach (string text2 in array) { if (val.HasProperty(text2)) { val.SetTexture(text2, (Texture)null); } } array = new string[3] { "_BaseColor", "_Color", "_AlbedoColor" }; foreach (string text3 in array) { if (val.HasProperty(text3)) { val.SetColor(text3, Color.white); } } array = new string[4] { "_MetallicTexture", "_SmoothnessTexture", "_MetallicGlossMap", "_SpecGlossMap" }; foreach (string text4 in array) { if (val.HasProperty(text4)) { val.SetTexture(text4, (Texture)null); } } val.DisableKeyword("_METALLICGLOSSMAP"); val.DisableKeyword("_SPECGLOSSMAP"); val.DisableKeyword("_NORMALMAP"); if (val.HasProperty("_SmoothnessTextureChannel")) { val.SetFloat("_SmoothnessTextureChannel", 0f); } if (val.HasProperty("_GlossMapScale")) { val.SetFloat("_GlossMapScale", 1f); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0f); } array = new string[2] { "_Smoothness", "_Glossiness" }; foreach (string text5 in array) { if (val.HasProperty(text5)) { val.SetFloat(text5, smoothness); } } if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", Color.black); } if (val.HasProperty("_EmissionTexture")) { val.SetTexture("_EmissionTexture", (Texture)null); } if (val.HasProperty("_TilingX")) { val.SetFloat("_TilingX", 1f); val.SetFloat("_TilingY", 1f); } if (val.HasProperty("_OffsetX")) { val.SetFloat("_OffsetX", 0f); val.SetFloat("_OffsetY", 0f); } return val; } } internal static class Builder { public const string PrefabName = "Enemy - Singing Machine"; public static EnemySetup Setup; private static bool tried; internal const float Height = 1.27f; internal static readonly Vector3 Hinge = new Vector3(-0.5165f, 0.8906f, 0f); internal static readonly Vector3 Trough = new Vector3(0.25f, 0.75f, 0f); public static void BuildAndRegister(EnemyDirector director) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Expected O, but got Unknown //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Expected O, but got Unknown //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Expected O, but got Unknown //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Expected O, but got Unknown //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Expected O, but got Unknown //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Expected O, but got Unknown //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Expected O, but got Unknown //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Expected O, but got Unknown //IL_0447: Unknown result type (might be due to invalid IL or missing references) if (tried) { return; } tried = true; EnemySetup val = director.enemiesDifficulty1.Concat(director.enemiesDifficulty2).Concat(director.enemiesDifficulty3).FirstOrDefault((Func<EnemySetup, bool>)((EnemySetup s) => Object.op_Implicit((Object)(object)s) && ((Object)s).name.Contains("Robe"))); if ((Object)(object)val == (Object)null) { throw new Exception("Could not find REPO's Robe enemy to build on. The game may have been updated."); } GameObject? obj = val.spawnObjects.Select((PrefabRef r) => ((PrefabRef<GameObject>)(object)r)?.Prefab).FirstOrDefault((Func<GameObject, bool>)((GameObject p) => Object.op_Implicit((Object)(object)p) && Object.op_Implicit((Object)(object)p.GetComponent<EnemyParent>()))); if ((Object)(object)obj == (Object)null) { throw new Exception("The Robe enemy has no prefab."); } GameObject val2 = new GameObject("Singing Machine Prefabs"); val2.SetActive(false); ((Object)val2).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val2); GameObject val3 = Object.Instantiate<GameObject>(obj, val2.transform); ((Object)val3).name = "Enemy - Singing Machine"; EnemyParent component = val3.GetComponent<EnemyParent>(); Enemy componentInChildren = val3.GetComponentInChildren<Enemy>(true); EnemyRigidbody componentInChildren2 = val3.GetComponentInChildren<EnemyRigidbody>(true); if (!Object.op_Implicit((Object)(object)componentInChildren) || !Object.op_Implicit((Object)(object)componentInChildren2)) { throw new Exception("The Robe prefab is missing its Enemy or EnemyRigidbody."); } Material baseMat = (from r in val3.GetComponentsInChildren<Renderer>(true) where !(r is ParticleSystemRenderer) select r.sharedMaterial).FirstOrDefault((Func<Material, bool>)((Material m) => Object.op_Implicit((Object)(object)m))); MonoBehaviour[] componentsInChildren = val3.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val4 in componentsInChildren) { if (Object.op_Implicit((Object)(object)val4) && ((object)val4).GetType().Name.StartsWith("EnemyRobe")) { Object.DestroyImmediate((Object)(object)val4); } } Animator[] componentsInChildren2 = val3.GetComponentsInChildren<Animator>(true); for (int num = 0; num < componentsInChildren2.Length; num++) { ((Behaviour)componentsInChildren2[num]).enabled = false; } Renderer[] componentsInChildren3 = val3.GetComponentsInChildren<Renderer>(true); for (int num = 0; num < componentsInChildren3.Length; num++) { componentsInChildren3[num].enabled = false; } Light[] componentsInChildren4 = val3.GetComponentsInChildren<Light>(true); for (int num = 0; num < componentsInChildren4.Length; num++) { ((Behaviour)componentsInChildren4[num]).enabled = false; } AudioSource[] componentsInChildren5 = val3.GetComponentsInChildren<AudioSource>(true); for (int num = 0; num < componentsInChildren5.Length; num++) { componentsInChildren5[num].playOnAwake = false; } EnemyStateDespawn component2 = ((Component)componentInChildren).GetComponent<EnemyStateDespawn>(); if (Object.op_Implicit((Object)(object)component2)) { component2.StuckDespawn = false; component2.ChaseDespawn = false; } EnemyStateSpawn component3 = ((Component)componentInChildren).GetComponent<EnemyStateSpawn>(); if (Object.op_Implicit((Object)(object)component3)) { component3.OnSpawn = new UnityEvent(); } EnemyVision component4 = ((Component)componentInChildren).GetComponent<EnemyVision>(); if (Object.op_Implicit((Object)(object)component4)) { component4.onVisionTriggered = new UnityEvent(); } EnemyStateInvestigate component5 = ((Component)componentInChildren).GetComponent<EnemyStateInvestigate>(); if (Object.op_Implicit((Object)(object)component5)) { component5.onInvestigateTriggered = new UnityEvent(); } EnemyHealth component6 = ((Component)componentInChildren).GetComponent<EnemyHealth>(); if (Object.op_Implicit((Object)(object)component6)) { component6.onHurt = new UnityEvent(); component6.onDeathStart = new UnityEvent(); component6.onDeath = new UnityEvent(); component6.onObjectHurt = new UnityEvent(); component6.health = Plugin.Health.Value; component6.impactHurt = true; component6.impactLightDamage = 0; component6.impactMediumDamage = 5; component6.impactHeavyDamage = 20; } FieldInfo[] fields = typeof(EnemyRigidbody).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.FieldType == typeof(UnityEvent)) { fieldInfo.SetValue(componentInChildren2, (object?)new UnityEvent()); } } RebuildBody(componentInChildren2); Transform lid; GameObject val5 = BuildModel(baseMat, ((Component)componentInChildren2).transform, out lid); if (Object.op_Implicit((Object)(object)component6)) { component6.meshParent = val5.transform; } MachineAI machineAI = ((Component)componentInChildren).gameObject.AddComponent<MachineAI>(); machineAI.model = val5.transform; machineAI.lid = lid; component.enemyName = "Singing Machine"; component.enemyNameLocalized = null; component.difficulty = (Difficulty)(Mathf.Clamp(Plugin.Difficulty.Value, 1, 3) - 1); component.SpawnedTimeMin = 3000f; component.SpawnedTimeMax = 3600f; component.DespawnedTimeMin = 60f; component.DespawnedTimeMax = 90f; Setup = Object.Instantiate<EnemySetup>(val); ((Object)Setup).name = "Enemy - Singing Machine"; RarityPreset val6 = ScriptableObject.CreateInstance<RarityPreset>(); ((Object)val6).name = "Rarity - Singing Machine"; val6.chance = Plugin.Rarity.Value; Setup.rarityPreset = val6; Object.DontDestroyOnLoad((Object)(object)Setup); Object.DontDestroyOnLoad((Object)(object)val6); EnemyContent val7 = ScriptableObject.CreateInstance<EnemyContent>(); AccessTools.Field(typeof(EnemyContent), "_setup").SetValue(val7, Setup); AccessTools.Field(typeof(EnemyContent), "_spawnObjects").SetValue(val7, new List<GameObject> { val3 }); Enemies.RegisterEnemy(val7); Plugin.Log.LogInfo((object)$"Registered the Singing Machine (difficulty tier {Plugin.Difficulty.Value})."); } private static void RebuildBody(EnemyRigidbody erb) { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: 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_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)erb).transform; int num = -1; Collider[] componentsInChildren = ((Component)transform).GetComponentsInChildren<Collider>(true); foreach (Collider val in componentsInChildren) { if (val.isTrigger || (Object)(object)val == (Object)(object)erb.playerCollision || !((Component)val).CompareTag("Phys Grab Object")) { continue; } if (num < 0) { num = ((Component)val).gameObject.layer; } GameObject gameObject = ((Component)val).gameObject; Object.DestroyImmediate((Object)(object)val); if (!Object.op_Implicit((Object)(object)gameObject.GetComponent<Collider>())) { PhysGrabObjectCollider component = gameObject.GetComponent<PhysGrabObjectCollider>(); if (Object.op_Implicit((Object)(object)component)) { Object.DestroyImmediate((Object)(object)component); } } } if (num < 0) { num = LayerMask.NameToLayer("PhysGrabObject"); } GameObject val2 = new GameObject("Singing Machine Body") { layer = num, tag = "Phys Grab Object" }; val2.transform.SetParent(transform, false); BoxCollider obj = val2.AddComponent<BoxCollider>(); obj.size = new Vector3(2f, 1.27f, 0.85f); obj.center = new Vector3(-0.1f, 0f, 0f); val2.AddComponent<PhysGrabObjectCollider>(); erb.gravity = true; erb.stunFromFall = false; erb.grabStun = false; Transform val3 = (Object.op_Implicit((Object)(object)erb.enemy) ? ((Component)erb.enemy).transform : null); if (Object.op_Implicit((Object)(object)erb.followTarget) && Object.op_Implicit((Object)(object)val3) && erb.followTarget.IsChildOf(val3)) { erb.followTarget.position = val3.position + Vector3.up * 0.685f; } Rigidbody component2 = ((Component)transform).GetComponent<Rigidbody>(); if (Object.op_Implicit((Object)(object)component2)) { component2.constraints = (RigidbodyConstraints)112; component2.linearDamping = 6f; component2.mass = Mathf.Max(component2.mass, 40f); component2.centerOfMass = Vector3.zero; } } private static GameObject BuildModel(Material baseMat, Transform body, out Transform lid) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_005b: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) int layer = ((Component)body).gameObject.layer; GameObject val = new GameObject("Singing Machine Model") { layer = layer }; val.transform.SetParent(body, false); val.transform.localPosition = new Vector3(0f, -0.635f, 0f); GameObject val2 = new GameObject("Base") { layer = layer }; val2.transform.SetParent(val.transform, false); val2.AddComponent<MeshFilter>().sharedMesh = Assets.LoadMesh("machine_base"); ((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = Assets.MakeMaterial(baseMat, "Singing Machine", Assets.LoadTexture("machine_base_albedo"), 0.35f); GameObject val3 = new GameObject("Lid") { layer = layer }; val3.transform.SetParent(val.transform, false); val3.transform.localPosition = Hinge; val3.AddComponent<MeshFilter>().sharedMesh = Assets.LoadMesh("machine_lid"); ((Renderer)val3.AddComponent<MeshRenderer>()).sharedMaterial = Assets.MakeMaterial(baseMat, "Singing Machine Lid", Assets.LoadTexture("machine_lid_albedo"), 0.35f); lid = val3.transform; return val; } } internal static class Charm { internal enum Mode { Walk, Carry } internal class Info { public Mode mode; public PlayerAvatar other; public bool carrying; public MachineAI machine; } private static readonly Dictionary<PlayerAvatar, Info> charmed = new Dictionary<PlayerAvatar, Info>(); private static PlayerAvatar swallowing; private static MachineAI swallowMachine; private static int tickedFrame = -1; private static float progress; private static float nextPath; private static float lastPress = -9f; private static float breakCooldown; private static readonly NavMeshPath path = new NavMeshPath(); private static Vector3[] corners = (Vector3[])(object)new Vector3[0]; private static int corner; private static float stunNext; private static float thrownUntil; internal static float CalmUntil; private static Rigidbody ghost; private static int lastHealth = -1; private static readonly string[] Arrow = new string[4] { "^", ">", "v", "<" }; private static int[] run = new int[0]; private static int at; private static int lastDir = -1; internal static List<KeyValuePair<PlayerAvatar, Info>> All() { Prune(); return new List<KeyValuePair<PlayerAvatar, Info>>(charmed); } internal static bool Is(PlayerAvatar p) { if (Object.op_Implicit((Object)(object)p)) { return charmed.ContainsKey(p); } return false; } internal static bool Carried(PlayerAvatar p) { foreach (Info value in charmed.Values) { if (value.carrying && (Object)(object)value.other == (Object)(object)p) { return true; } } return false; } internal static MachineAI MachineOf(PlayerAvatar p) { if (!Object.op_Implicit((Object)(object)p) || !charmed.TryGetValue(p, out var value)) { return null; } return value.machine; } internal static bool AnyCarrier() { foreach (KeyValuePair<PlayerAvatar, Info> item in charmed) { if (item.Value.mode == Mode.Carry) { return true; } } return false; } internal static void Prune() { List<PlayerAvatar> list = new List<PlayerAvatar>(); foreach (KeyValuePair<PlayerAvatar, Info> item in charmed) { if (!Object.op_Implicit((Object)(object)item.Key) || item.Key.deadSet) { list.Add(item.Key); } } foreach (PlayerAvatar item2 in list) { charmed.Remove(item2); if (Object.op_Implicit((Object)(object)item2)) { Eyes.Player(item2, show: false); } } } internal static void Set(PlayerAvatar p, Mode mode, PlayerAvatar other, MachineAI machine) { charmed[p] = new Info { mode = mode, other = other, machine = machine }; Eyes.Player(p, show: true); if (p.isLocal) { progress = 0f; run = new int[0]; nextPath = 0f; corners = (Vector3[])(object)new Vector3[0]; Tell.Local((mode == Mode.Walk) ? "You hear the most beautiful music. You have to get closer." : "The music is stuck in your head. Someone else has to hear it.", 2f); } } internal static void Clear(PlayerAvatar p) { if (Object.op_Implicit((Object)(object)p)) { if (charmed.Remove(p)) { Eyes.Player(p, show: false); } if (p.isLocal) { progress = 0f; run = new int[0]; CalmUntil = Time.time + Plugin.Cooldown.Value; Plugin.Log.LogInfo((object)"Singing Machine: you are free; your cooldown starts."); Tell.Local("You come to your senses."); } } } internal static void ClearAll() { foreach (PlayerAvatar key in charmed.Keys) { if (Object.op_Implicit((Object)(object)key)) { Eyes.Player(key, show: false); } } charmed.Clear(); swallowing = null; } internal static void Forget(MachineAI m) { List<PlayerAvatar> list = new List<PlayerAvatar>(); foreach (KeyValuePair<PlayerAvatar, Info> item in charmed) { if ((Object)(object)item.Value.machine == (Object)(object)m) { list.Add(item.Key); } } foreach (PlayerAvatar item2 in list) { charmed.Remove(item2); if (Object.op_Implicit((Object)(object)item2)) { Eyes.Player(item2, show: false); } } if ((Object)(object)swallowMachine == (Object)(object)m) { swallowing = null; } } internal static void PickUp(PlayerAvatar carrier, PlayerAvatar victim) { if (Object.op_Implicit((Object)(object)carrier) && charmed.TryGetValue(carrier, out var value)) { value.carrying = true; value.other = victim; if (Object.op_Implicit((Object)(object)victim) && victim.isLocal) { progress = 0f; run = new int[0]; Tell.Local("They've got you. Struggle!"); } if (carrier.isLocal) { nextPath = 0f; } } } internal static void Drop(PlayerAvatar carrier) { if (Object.op_Implicit((Object)(object)carrier) && charmed.TryGetValue(carrier, out var value)) { PlayerAvatar other = value.other; value.carrying = false; if (Object.op_Implicit((Object)(object)other) && other.isLocal) { progress = 0f; run = new int[0]; CalmUntil = Time.time + Plugin.Cooldown.Value; Plugin.Log.LogInfo((object)"Singing Machine: you wriggle free; your cooldown starts."); Tell.Local("You wriggle free."); } } } internal static void Swallow(PlayerAvatar p, MachineAI m) { Clear(p); swallowing = p; swallowMachine = m; if (p.isLocal) { Tell.Local("One's blood shall make wondrous chords.", 4f); } } internal static void Swallowed(MachineAI m) { } internal static void Tick(MachineAI any) { //IL_0085: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: 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_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: 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_020b: 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_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) if (tickedFrame == Time.frameCount) { return; } tickedFrame = Time.frameCount; Tell.Tick(); PlayerAvatar instance = PlayerAvatar.instance; PlayerController instance2 = PlayerController.instance; if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance2) || instance.deadSet || instance.isDisabled) { Solid(); if ((Object)(object)swallowing == (Object)(object)instance) { swallowing = null; } return; } if ((Object)(object)swallowing == (Object)(object)instance && Object.op_Implicit((Object)(object)swallowMachine)) { Vector3 inside = swallowMachine.Inside; Stun(instance); Rigidbody val = (Object.op_Implicit((Object)(object)instance.tumble) ? instance.tumble.rb : null); if (Object.op_Implicit((Object)(object)val) && instance.isTumbling) { if (val.detectCollisions) { val.detectCollisions = false; ghost = val; } val.position = inside; val.linearVelocity = Vector3.zero; val.angularVelocity = Vector3.zero; } else { HoldAt(instance2, inside); } return; } foreach (KeyValuePair<PlayerAvatar, Info> item in charmed) { if ((Object)(object)item.Value.other != (Object)(object)instance || !item.Value.carrying || !Object.op_Implicit((Object)(object)item.Key)) { continue; } Transform transform = ((Component)item.Key).transform; Stun(instance); Rigidbody val2 = (Object.op_Implicit((Object)(object)instance.tumble) ? instance.tumble.rb : null); if (Object.op_Implicit((Object)(object)val2) && instance.isTumbling) { if (val2.detectCollisions) { val2.detectCollisions = false; ghost = val2; } Vector3 val3 = transform.position + transform.forward * 0.9f + Vector3.up * 1f; val2.linearVelocity = (val3 - val2.position) * 10f; val2.angularVelocity *= 0.8f; } Struggle(instance, item.Value.machine); return; } Solid(); if (Time.time < thrownUntil) { Stun(instance); return; } if (!charmed.TryGetValue(instance, out var value) || !Object.op_Implicit((Object)(object)value.machine)) { lastHealth = -1; return; } int num = (Object.op_Implicit((Object)(object)instance.playerHealth) ? instance.playerHealth.health : (-1)); bool num2 = (lastHealth >= 0 && num >= 0 && num < lastHealth) || instance.isTumbling; lastHealth = num; if (num2 && Time.time >= breakCooldown) { breakCooldown = Time.time + 1.5f; Tell.Local("The blow knocks the music out of your head."); value.machine.AskFree(instance); return; } Vector3 val4 = ((value.mode == Mode.Carry && !value.carrying && Object.op_Implicit((Object)(object)value.other)) ? ((Component)value.other).transform.position : value.machine.Mouth); bool flag = value.mode != Mode.Carry || value.carrying || !Object.op_Implicit((Object)(object)value.other); if (flag && value.machine.Busy) { Vector3 val5 = ((Component)instance).transform.position - val4; val5.y = 0f; if (((Vector3)(ref val5)).magnitude < 3f) { instance2.InputDisable(0.2f); Struggle(instance, value.machine); return; } if (((Vector3)(ref val5)).sqrMagnitude > 0.01f) { val4 += ((Vector3)(ref val5)).normalized * 2.8f; } } Walk(instance2, ((Component)instance).transform.position, val4, flag ? Plugin.CharmedSpeed.Value : 2.3f); Struggle(instance, value.machine); } private static void Solid() { if (Object.op_Implicit((Object)(object)ghost)) { ghost.detectCollisions = true; } ghost = null; } private static void Stun(PlayerAvatar me) { PlayerController instance = PlayerController.instance; if (Object.op_Implicit((Object)(object)instance)) { instance.InputDisable(0.2f); } PlayerTumble tumble = me.tumble; if (Object.op_Implicit((Object)(object)tumble)) { if (!me.isTumbling) { tumble.TumbleRequest(true, false); } if (Time.time >= stunNext) { stunNext = Time.time + 0.4f; tumble.TumbleOverrideTime(1f); tumble.TumbleStunTime(1f); } } } internal static void Throw(PlayerAvatar carrier, PlayerAvatar victim, Vector3 mouth) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)carrier) && charmed.TryGetValue(carrier, out var value)) { value.carrying = false; } if (Object.op_Implicit((Object)(object)victim) && victim.isLocal) { Solid(); thrownUntil = Time.time + 1.6f; Tell.Local("Into the machine!", 2f); Rigidbody val = (Object.op_Implicit((Object)(object)victim.tumble) ? victim.tumble.rb : null); if (Object.op_Implicit((Object)(object)val)) { Vector3 linearVelocity = (mouth + Vector3.up * 0.3f - val.position) / 0.6f; linearVelocity.y += 0.5f * Mathf.Abs(Physics.gravity.y) * 0.6f; val.linearVelocity = linearVelocity; } } } private static void HoldAt(PlayerController pc, Vector3 at) { //IL_0011: 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_0036: 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_006e: Unknown result type (might be due to invalid IL or missing references) pc.InputDisable(0.2f); ((Component)pc).transform.position = at; if (Object.op_Implicit((Object)(object)pc.rb)) { pc.rb.position = at; pc.rb.linearVelocity = Vector3.zero; } PlayerAvatar playerAvatarScript = pc.playerAvatarScript; if (Object.op_Implicit((Object)(object)playerAvatarScript) && Object.op_Implicit((Object)(object)playerAvatarScript.rb)) { playerAvatarScript.rb.position = at; ((Component)playerAvatarScript).transform.position = at; } } private static void Walk(PlayerController pc, Vector3 from, Vector3 to, float speed) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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) //IL_00f8: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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_0143: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: 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_00d8: Unknown result type (might be due to invalid IL or missing references) if (Time.time >= nextPath) { nextPath = Time.time + 0.4f; corners = (Vector3[])(object)new Vector3[0]; corner = 0; NavMeshHit val = default(NavMeshHit); NavMeshHit val2 = default(NavMeshHit); if (NavMesh.SamplePosition(from, ref val, 2f, -1) && NavMesh.SamplePosition(to, ref val2, 3f, -1) && NavMesh.CalculatePath(((NavMeshHit)(ref val)).position, ((NavMeshHit)(ref val2)).position, -1, path) && path.corners.Length > 1) { corners = path.corners; corner = 1; } } Vector3 val3 = to; while (corner > 0 && corner < corners.Length) { Vector3 val4 = corners[corner]; Vector3 val5 = val4 - from; val5.y = 0f; if (((Vector3)(ref val5)).magnitude < 0.35f) { corner++; continue; } val3 = val4; break; } Vector3 val6 = val3 - from; val6.y = 0f; if (!(((Vector3)(ref val6)).sqrMagnitude < 0.01f)) { pc.InputDisable(0.2f); pc.MoveForce(((Vector3)(ref val6)).normalized, speed, 0.15f); if (Object.op_Implicit((Object)(object)CameraAim.Instance)) { CameraAim.Instance.AimTargetSoftSet(val3 + Vector3.up * 1.2f, 0.2f, 2f, 2f, ((Component)pc).gameObject, 50); } } } private static int DirNow() { InputManager instance = InputManager.instance; if (!Object.op_Implicit((Object)(object)instance)) { return -1; } float movementX = instance.GetMovementX(true); float movementY = instance.GetMovementY(true); if (Mathf.Max(Mathf.Abs(movementX), Mathf.Abs(movementY)) < 0.6f) { return -1; } if (!(Mathf.Abs(movementY) >= Mathf.Abs(movementX))) { if (!(movementX > 0f)) { return 3; } return 1; } if (!(movementY > 0f)) { return 2; } return 0; } private static void NewRun() { run = new int[Mathf.Clamp(Plugin.BreakPresses.Value, 3, 40)]; for (int i = 0; i < run.Length; i++) { run[i] = Random.Range(0, 4); } at = 0; } private static void Struggle(PlayerAvatar me, MachineAI machine) { if (Time.time < breakCooldown) { return; } if (run.Length == 0) { NewRun(); } int num = DirNow(); if (num >= 0 && num != lastDir) { if (num == run[at]) { at++; } else { NewRun(); breakCooldown = Time.time + 0.4f; } } lastDir = num; progress = (float)at / (float)run.Length; Ui.Minigame(run, at); if (at >= run.Length && Object.op_Implicit((Object)(object)machine)) { run = new int[0]; at = 0; progress = 0f; breakCooldown = Time.time + 1.5f; machine.AskFree(me); } } } internal static class Eyes { private class Billboard : MonoBehaviour { internal float size; internal Vector3 offset; private void LateUpdate() { //IL_009a: 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_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) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_005d: 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_009f: 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_00c8: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_0119: 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_0129: Unknown result type (might be due to invalid IL or missing references) Camera main = Camera.main; if (Object.op_Implicit((Object)(object)main) && Object.op_Implicit((Object)(object)((Component)this).transform.parent)) { Vector3 val = ((Component)this).transform.parent.TransformPoint(offset); Transform transform = ((Component)this).transform; Vector3 val2 = ((Component)main).transform.position - val; transform.position = val + ((Vector3)(ref val2)).normalized * size * 0.5f; } Vector3 val3 = (Object.op_Implicit((Object)(object)((Component)this).transform.parent) ? ((Component)this).transform.parent.lossyScale : Vector3.one); ((Component)this).transform.localScale = new Vector3(size / Mathf.Max(0.001f, val3.x), size / Mathf.Max(0.001f, val3.y), size / Mathf.Max(0.001f, val3.z)); if (Object.op_Implicit((Object)(object)main)) { ((Component)this).transform.rotation = Quaternion.LookRotation(((Component)this).transform.position - ((Component)main).transform.position, ((Component)main).transform.up); } } } private static readonly Dictionary<Object, GameObject[]> on = new Dictionary<Object, GameObject[]>(); private static Mesh quad; internal static void Player(PlayerAvatar p, bool show) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)p)) { return; } if (!show) { Remove((Object)(object)p); } else if (!on.ContainsKey((Object)(object)p) && !p.isLocal) { PlayerEyes val = (Object.op_Implicit((Object)(object)p.playerAvatarVisuals) ? p.playerAvatarVisuals.playerEyes : null); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.eyeLeft) && Object.op_Implicit((Object)(object)val.eyeRight)) { on[(Object)(object)p] = (GameObject[])(object)new GameObject[2] { Make(val.eyeLeft, Vector3.zero, 0.11f), Make(val.eyeRight, Vector3.zero, 0.11f) }; } } } internal static bool HasEnemy(Enemy e) { if (Object.op_Implicit((Object)(object)e)) { return on.ContainsKey((Object)(object)e); } return false; } internal static void Enemy(Enemy e, bool show) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)e)) { return; } if (!show) { Remove((Object)(object)e); } else { if (on.ContainsKey((Object)(object)e)) { return; } List<GameObject> list = new List<GameObject>(); Transform[] componentsInChildren = ((Component)(Object.op_Implicit((Object)(object)e.EnemyParent) ? ((Component)e.EnemyParent).transform : ((Component)e).transform)).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (list.Count >= 8) { break; } if (IsEye(val) && (!Object.op_Implicit((Object)(object)val.parent) || !IsEye(val.parent))) { list.Add(Make(val, Vector3.zero, EyeSize(val))); } } if (list.Count > 0) { Plugin.Log.LogInfo((object)$"Singing Machine: {Name(e)}: its {list.Count} eye(s) turn yellow."); on[(Object)(object)e] = list.ToArray(); return; } Plugin.Log.LogInfo((object)("Singing Machine: " + Name(e) + " has no eyes to find; it glows instead.")); Transform val2 = (Object.op_Implicit((Object)(object)e.CenterTransform) ? e.CenterTransform : ((Component)e).transform); GameObject val3 = new GameObject("Singing Machine Glow"); val3.transform.SetParent(val2, false); Light obj = val3.AddComponent<Light>(); obj.type = (LightType)2; obj.color = new Color(1f, 0.85f, 0.25f); obj.range = 3f; obj.intensity = 0.8f; obj.shadows = (LightShadows)0; Halo(val3.transform, Size(e)); on[(Object)(object)e] = (GameObject[])(object)new GameObject[1] { val3 }; } } private static float Size(Enemy e) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) Transform obj = (Object.op_Implicit((Object)(object)e.EnemyParent) ? ((Component)e.EnemyParent).transform : ((Component)e).transform); bool flag = false; Bounds val = default(Bounds); Renderer[] componentsInChildren = ((Component)obj).GetComponentsInChildren<Renderer>(); foreach (Renderer val2 in componentsInChildren) { if (val2.enabled && !(val2 is ParticleSystemRenderer)) { if (!flag) { val = val2.bounds; flag = true; } else { ((Bounds)(ref val)).Encapsulate(val2.bounds); } } } if (!flag) { return 2f; } return Mathf.Clamp(Mathf.Max(new float[3] { ((Bounds)(ref val)).size.x, ((Bounds)(ref val)).size.y, ((Bounds)(ref val)).size.z }) * 1.4f, 1f, 5f); } private static void Halo(Transform at, float size) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0028: 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_0051: 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_006f: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Expected O, but got Unknown //IL_0175: 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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Singing Machine Halo"); val.transform.SetParent(at, false); ParticleSystem val2 = val.AddComponent<ParticleSystem>(); val2.Stop(true, (ParticleSystemStopBehavior)0); MainModule main = val2.main; ((MainModule)(ref main)).loop = true; ((MainModule)(ref main)).prewarm = true; ((MainModule)(ref main)).duration = 3f; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(3f); ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f); ((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(size); ((MainModule)(ref main)).maxParticles = 4; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(1f, 0.85f, 0.25f, 0.3f)); ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)0; ((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)2; EmissionModule emission = val2.emission; ((EmissionModule)(ref emission)).enabled = true; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(1f); ShapeModule shape = val2.shape; ((ShapeModule)(ref shape)).enabled = false; SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3] { new Keyframe(0f, 0.3f), new Keyframe(0.5f, 0.8f), new Keyframe(1f, 1f) })); ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; Gradient val3 = new Gradient(); val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[4] { new GradientAlphaKey(0f, 0f), new GradientAlphaKey(1f, 0.25f), new GradientAlphaKey(0.6f, 0.66f), new GradientAlphaKey(0f, 1f) }); ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3); ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>(); component.renderMode = (ParticleSystemRenderMode)0; component.alignment = (ParticleSystemRenderSpace)0; ((Renderer)component).sharedMaterial = Fx.Mat("machine_halo"); ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; component.maxParticleSize = 5f; val2.Play(); } private static string Name(Enemy e) { if (!Object.op_Implicit((Object)(object)e.EnemyParent)) { return ((Object)e).name; } return e.EnemyParent.enemyName; } private static bool IsEye(Transform t) { string text = ((Object)t).name.ToLowerInvariant(); if (!text.Contains("eye") || text.StartsWith("singing machine")) { return false; } string[] array = new string[8] { "brow", "lid", "lash", "socket", "target", "look", "vision", "eyeline" }; foreach (string value in array) { if (text.Contains(value)) { return false; } } return true; } private static float EyeSize(Transform t) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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) Renderer componentInChildren = ((Component)t).GetComponentInChildren<Renderer>(); if (!Object.op_Implicit((Object)(object)componentInChildren)) { return 0.15f; } Bounds bounds = componentInChildren.bounds; Vector3 size = ((Bounds)(ref bounds)).size; return Mathf.Clamp(Mathf.Max(new float[3] { size.x, size.y, size.z }) * 1.3f, 0.06f, 0.45f); } internal static void ClearEnemies() { List<Object> list = new List<Object>(); foreach (Object key in on.Keys) { if (!(key is PlayerAvatar)) { list.Add(key); } } foreach (Object item in list) { Remove(item); } } private static void Remove(Object k) { if (!on.TryGetValue(k, out var value)) { return; } GameObject[] array = value; foreach (GameObject val in array) { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } } on.Remove(k); } private static GameObject Make(Transform parent, Vector3 offset, float size) { //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: 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_01cb: Expected O, but got Unknown //IL_000f: 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_0024: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0056: 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_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_00a3: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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) if (!Object.op_Implicit((Object)(object)quad)) { quad = new Mesh { name = "Singing Machine Eye" }; quad.vertices = (Vector3[])(object)new Vector3[4] { new Vector3(-0.5f, -0.5f), new Vector3(0.5f, -0.5f), new Vector3(0.5f, 0.5f), new Vector3(-0.5f, 0.5f) }; quad.uv = (Vector2[])(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(0f, 1f) }; quad.triangles = new int[6] { 0, 2, 1, 0, 3, 2 }; quad.RecalculateNormals(); quad.RecalculateBounds(); } GameObject val = new GameObject("Singing Machine Eye"); val.transform.SetParent(parent, false); val.transform.localPosition = offset; val.AddComponent<MeshFilter>().sharedMesh = quad; MeshRenderer obj = val.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = Fx.Mat("machine_eye"); ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; Billboard billboard = val.AddComponent<Billboard>(); billboard.size = size; billboard.offset = offset; Light obj2 = val.AddComponent<Light>(); obj2.type = (LightType)2; obj2.color = new Color(1f, 0.85f, 0.25f); obj2.range = size * 6f; obj2.intensity = 1.2f; obj2.shadows = (LightShadows)0; return val; } } internal static class Fx { private static readonly Dictionary<string, Material> mats = new Dictionary<string, Material>(); private static readonly string[] TexProps = new string[4] { "_MainTex", "_BaseMap", "_BaseTexture", "_AlbedoTexture" }; private static Material template; private static bool templateTried; private static Material Template { get { if (templateTried) { return template; } templateTried = true; List<Material> list = new List<Material>(); string[] array = new string[4] { "Items/Item Gun Laser", "Items/Item Gun Handgun", "Items/Item Gun Shotgun", "Items/Item Melee Stun Baton" }; for (int i = 0; i < array.Length; i++) { GameObject val = Resources.Load<GameObject>(array[i]); if (!Object.op_Implicit((Object)(object)val)) { continue; } ItemGun component = val.GetComponent<ItemGun>(); List<GameObject> list2 = new List<GameObject> { val }; if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.muzzleFlashPrefab)) { list2.Add(component.muzzleFlashPrefab); } if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.bulletPrefab)) { list2.Add(component.bulletPrefab); } foreach (GameObject item in list2) { ParticleSystemRenderer[] componentsInChildren = item.GetComponentsInChildren<ParticleSystemRenderer>(true); for (int j = 0; j < componentsInChildren.Length; j++) { Material sharedMaterial = ((Renderer)componentsInChildren[j]).sharedMaterial; if (Object.op_Implicit((Object)(object)sharedMaterial) && Object.op_Implicit((Object)(object)sharedMaterial.shader) && sharedMaterial.shader.isSupported && HasTex(sharedMaterial) && !list.Contains(sharedMaterial)) { list.Add(sharedMaterial); } } } } if (list.Count == 0) { Plugin.Log.LogWarning((object)"No REPO particle material found, building one."); return null; } list.Sort((Material a, Material b) => Score(b).CompareTo(Score(a))); template = list[0]; Plugin.Log.LogDebug((object)("Effects draw with REPO's \"" + ((Object)template).name + "\" (shader " + ((Object)template.shader).name + ").")); return template; static int Score(Material m) { int num = 0; if (((Object)m.shader).name.Contains("Unlit")) { num += 4; } if (m.HasProperty("_DstBlend") && Mathf.Approximately(m.GetFloat("_DstBlend"), 1f)) { num += 2; } if (((Object)m.shader).name.Contains("Surface")) { num -= 4; } return num; } } } private static bool HasTex(Material m) { string[] texProps = TexProps; foreach (string text in texProps) { if (m.HasProperty(text)) { return true; } } return false; } internal static Material Mat(string tex) { //IL_0034: 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_004b: Expected O, but got Unknown //IL_01de: 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_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown //IL_0072: 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_00a5: 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_00cc: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) if (mats.TryGetValue(tex, out var value) && Object.op_Implicit((Object)(object)value)) { return value; } Texture2D val = Assets.LoadTexture(tex); if (Object.op_Implicit((Object)(object)Template)) { value = new Material(Template) { name = "Singing Machine FX " + tex }; string[] texProps = TexProps; foreach (string text in texProps) { if (value.HasProperty(text)) { value.SetTexture(text, (Texture)(object)val); value.SetTextureScale(text, Vector2.one); value.SetTextureOffset(text, Vector2.zero); } } Shader shader = value.shader; for (int j = 0; j < shader.GetPropertyCount(); j++) { if ((int)shader.GetPropertyType(j) == 0) { string propertyName = shader.GetPropertyName(j); if (!propertyName.Contains("Emission")) { Color color = value.GetColor(propertyName); float num = Mathf.Max(color.r, Mathf.Max(color.g, color.b)); value.SetColor(propertyName, new Color(num, num, num, color.a)); } } } if (value.HasProperty("_TilingX")) { value.SetFloat("_TilingX", 1f); value.SetFloat("_TilingY", 1f); } if (value.HasProperty("_OffsetX")) { value.SetFloat("_OffsetX", 0f); value.SetFloat("_OffsetY", 0f); } if (value.HasProperty("_EmissionColor")) { value.SetColor("_EmissionColor", Color.black); } if (value.HasProperty("_EmissionMap")) { value.SetTexture("_EmissionMap", (Texture)null); } value.DisableKeyword("_EMISSION"); return mats[tex] = value; } value = new Material(Shader.Find("Particles/Standard Unlit") ?? Shader.Find("Sprites/Default")) { name = "Singing Machine FX " + tex, mainTexture = (Texture)(object)val }; if (value.HasProperty("_Mode")) { value.SetFloat("_Mode", 4f); value.SetFloat("_SrcBlend", 5f); value.SetFloat("_DstBlend", 1f); value.SetFloat("_ZWrite", 0f); value.EnableKeyword("_ALPHABLEND_ON"); value.SetOverrideTag("RenderType", "Transparent"); } value.renderQueue = 3100; return mats[tex] = value; } } [DefaultExecutionOrder(10000)] internal class Lure : MonoBehaviour { private Enemy enemy; private Vector3 target; private float until; internal static void Hold(Enemy e, Vector3 to) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) Lure lure = ((Component)e).GetComponent<Lure>(); if (!Object.op_Implicit((Object)(object)lure)) { lure = ((Component)e).gameObject.AddComponent<Lure>(); } lure.enemy = e; NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(to, ref val, 3f, -1)) { to = ((NavMeshHit)(ref val)).position; } lure.target = to; lure.until = Time.time + 0.4f; } internal static void Release(Enemy e) { Lure lure = (Object.op_Implicit((Object)(object)e) ? ((Component)e).GetComponent<Lure>() : null); if (Object.op_Implicit((Object)(object)lure)) { Object.Destroy((Object)(object)lure); } } private void Update() { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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) //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) if (!Object.op_Implicit((Object)(object)enemy) || Time.time > until || !enemy.HasNavMeshAgent || !Object.op_Implicit((Object)(object)enemy.NavMeshAgent)) { Object.Destroy((Object)(object)this); return; } EnemyNavMeshAgent navMeshAgent = enemy.NavMeshAgent; if (!Object.op_Implicit((Object)(object)navMeshAgent.Agent)) { return; } if (navMeshAgent.IsDisabled()) { navMeshAgent.Enable(); } if (navMeshAgent.IsStopped()) { navMeshAgent.Stop(0f); } navMeshAgent.OverrideAgent(Mathf.Max(1.5f, navMeshAgent.DefaultSpeed * 0.7f), Mathf.Max(4f, navMeshAgent.DefaultAcceleration), 0.3f); if (!((Behaviour)navMeshAgent.Agent).enabled || !navMeshAgent.Agent.isOnNavMesh) { return; } Vector3 destination = navMeshAgent.Agent.destination; if (navMeshAgent.Agent.hasPath || navMeshAgent.Agent.pathPending) { Vector3 val = destination - target; if (!(((Vector3)(ref val)).sqrMagnitude > 0.25f)) { return; } } navMeshAgent.SetDestination(target); } } public class MachineAI : MonoBehaviour { private enum State { Idle, Eating, Grinding } [SerializeField] internal Transform model; [SerializeField] internal Transform lid; private State state; private Enemy enemy; private PhotonView view; private float lidAngle; private float lidTarget; private float shake; private AudioSource song; private AudioSource grind; private Light glow; private readonly Dictionary<int, float> nearSince = new Dictionary<int, float>(); private readonly Dictionary<Enemy, float> enemyHeard = new Dictionary<Enemy, float>(); private readonly Dictionary<int, float> immuneUntil = new Dictionary<int, float>(); private float stateUntil; private float nextSuck; private PlayerAvatar meal; private Enemy mealEnemy; private float lastBusy; private bool fed; private bool leaving; private float unseenFor; private float nextSeenCheck; private bool seen = true; private bool warnMe; private readonly HashSet<int> ticking = new HashSet<int>(); private Collider[] rooms; private bool open; private bool enemyCharmed; private float nextTouch; private Collider[] body; private Enemy pinned; private Rigidbody pinnedRb; private bool pinnedKinematic; private bool anchored; private Vector3 anchor; private readonly List<(Collider, Collider)> ignored = new List<(Collider, Collider)>(); private Vector3 Feet { get { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)model)) { return ((Component)this).transform.position; } return model.position; } } private Vector3 TroughWorld { get { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_001d: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)model)) { return ((Component)this).transform.position + Vector3.up; } return model.TransformPoint(Builder.Trough); } } internal Vector3 Mouth => TroughWorld; internal bool Busy { get { if (state != State.Eating) { return state == State.Grinding; } return true; } } internal Vector3 Inside => TroughWorld - Vector3.up * 0.35f; private void Awake() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown enemy = ((Component)this).GetComponent<Enemy>(); view = ((Component)this).GetComponent<PhotonView>(); EnemyStateSpawn component = ((Component)this).GetComponent<EnemyStateSpawn>(); if (Object.op_Implicit((Object)(object)component)) { component.OnSpawn.AddListener(new UnityAction(OnSpawn)); } EnemyHealth component2 = ((Component)this).GetComponent<EnemyHealth>(); if (Object.op_Implicit((Object)(object)component2)) { component2.onDeath.AddListener(new UnityAction(OnDeath)); } } private void OnEnable() { if (Object.op_Implicit((Object)(object)view)) { view.RefreshRpcMonoBehaviourCache(); } state = State.Idle; lidTarget = 0f; open = false; nearSince.Clear(); ticking.Clear(); warnMe = false; } public void OnSpawn() { lastBusy = Time.time; fed = false; leaving = false; if (SemiFunc.IsMasterClientOrSingleplayer()) { SemiFunc.EnemySpawn(enemy); } } public void OnDeath() { Send("SM_ReleaseAllRPC", (RpcTarget)0); if (SemiFunc.IsMasterClientOrSingleplayer() && Object.op_Implicit((Object)(object)enemy.EnemyParent)) { enemy.EnemyParent.Despawn(); } } private void Update() { Charm.Tick(this); WarnMe(); Visuals(); if (SemiFunc.IsMasterClientOrSingleplayer()) { Host(); } } private void Host() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_00ad: 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_0446: Unknown result type (might be due to invalid IL or missing references) //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: 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_025a: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.RunIsLevel() || !Object.op_Implicit((Object)(object)LevelGenerator.Instance) || !LevelGenerator.Instance.Generated) { return; } float time = Time.time; Vector3 feet = Feet; Leave(time, feet); Rigidbody val = ((Object.op_Implicit((Object)(object)enemy) && enemy.HasRigidbody && Object.op_Implicit((Object)(object)enemy.Rigidbody)) ? enemy.Rigidbody.rb : null); if (Busy && Object.op_Implicit((Object)(object)val)) { if (!anchored) { anchored = true; anchor = val.position; } val.position = anchor; val.linearVelocity = Vector3.zero; } else { anchored = false; } if (Object.op_Implicit((Object)(object)mealEnemy) && (state == State.Eating || state == State.Grinding)) { Pin(mealEnemy); } if ((state == State.Eating || state == State.Grinding) && time > stateUntil + 10f) { Plugin.Log.LogWarning((object)"Singing Machine: a meal never finished; it stops."); ((MonoBehaviour)this).StopAllCoroutines(); Unpin(); meal = null; mealEnemy = null; fed = true; Send("SM_CloseRPC", (RpcTarget)0); SetState(State.Idle); } foreach (KeyValuePair<PlayerAvatar, Charm.Info> item in Charm.All()) { PlayerAvatar key = item.Key; Charm.Info value = item.Value; if (!Object.op_Implicit((Object)(object)key) || key.deadSet || key.isDisabled) { Free(key, calm: false); } else { if (state != State.Idle) { continue; } if (value.mode == Charm.Mode.Carry && Object.op_Implicit((Object)(object)value.other)) { if (!value.carrying && Flat(((Component)key).transform.position, ((Component)value.other).transform.position) < 1.4f) { Send("SM_PickUpRPC", (RpcTarget)0, Id(key), Id(value.other)); } else if (value.carrying && Flat(((Component)key).transform.position, feet) < 3.5f) { PlayerAvatar other = value.other; Send("SM_ThrowRPC", (RpcTarget)0, Id(key), Id(other)); Free(key, calm: true); ((MonoBehaviour)this).StartCoroutine(Landing(other)); return; } } else if (value.mode == Charm.Mode.Walk && Flat(((Component)key).transform.position, feet) < 1.6f) { Eat(key); return; } } } if (state == State.Idle) { bool flag = enemyCharmed; foreach (KeyValuePair<PlayerAvatar, Charm.Info> item2 in Charm.All()) { if ((Object)(object)item2.Value.machine == (Object)(object)this) { flag = true; } } if (flag != open) { open = flag; Send(open ? "SM_OpenRPC" : "SM_CloseRPC", (RpcTarget)0); } if (open && time >= nextTouch) { nextTouch = time + 0.1f; if (Touching()) { return; } } } if (state != State.Idle && ticking.Count > 0) { foreach (int item3 in new List<int>(ticking)) { Ticking(item3, on: false); } } switch (state) { case State.Eating: case State.Grinding: if (time >= nextSuck) { nextSuck = time + 0.1f; Suck(feet, wait: true); } break; case State.Idle: Approach(time, feet); if (time >= nextSuck) { nextSuck = time + 0.1f; Suck(feet); } break; } } private void Leave(float now, Vector3 feet) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Invalid comparison between Unknown and I4 //IL_00f6: Unknown result type (might be due to invalid IL or missing references) bool flag = state != State.Idle; foreach (KeyValuePair<PlayerAvatar, Charm.Info> item in Charm.All()) { if ((Object)(object)item.Value.machine == (Object)(object)this) { flag = true; } } if (leaving && (int)enemy.CurrentState == 11 && Object.op_Implicit((Object)(object)enemy.EnemyParent) && enemy.EnemyParent.Spawned) { enemy.EnemyParent.Despawn(); } else if (flag) { lastBusy = now; unseenFor = 0f; } else { if (leaving) { return; } EnemyParent val = (Object.op_Implicit((Object)(object)enemy) ? enemy.EnemyParent : null); if (!Object.op_Implicit((Object)(object)val)) { return; } if (now >= nextSeenCheck) { nextSeenCheck = now + 0.25f; seen = SeenByAnyone(feet); } unseenFor = (seen ? 0f : (unseenFor + Time.deltaTime)); bool num; if (!fed) { if (!(now - lastBusy > Plugin.IdleLeave.Value)) { return; } num = !seen; } else { num = unseenFor >= Plugin.AfterMeal.Value; } if (num) { leaving = true; Plugin.Log.LogInfo((object)("Singing Machine: moves on (" + (fed ? "fed" : "no one came") + ").")); val.SpawnedTimerSet(0f); } } } private bool SeenByAnyone(Vector3 feet) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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) //IL_0010: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_005d: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) Vector3 val = feet + Vector3.up * 0.7f; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (Object.op_Implicit((Object)(object)item) && !item.deadSet && !item.isDisabled) { Vector3 val2 = ((Component)item).transform.position + Vector3.up * 1.5f; float num = Vector3.Distance(val2, val); if (num < 6f) { return true; } if (num < 30f && !Physics.Linecast(val2, val, LayerMask.op_Implicit(SemiFunc.LayerMaskGetVisionObstruct()), (QueryTriggerInteraction)1)) { return true; } } } return false; } private float Outside(Vector3 at, Vector3 feet) { //IL_0000: 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_001f: 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_0033: 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_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) if (Mathf.Abs(at.y - feet.y) > 2.5f) { return 999f; } float num = Flat(at, feet) - Plugin.NearRange.Value; Collider[] array = MyRooms(feet); foreach (Collider val in array) { if (Object.op_Implicit((Object)(object)val)) { num = Mathf.Min(num, Vector3.Distance(val.ClosestPoint(at), at) - Plugin.BeyondRoom.Value); } } return num; } private float Hearing() { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_0045: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) Vector3 feet = Feet; float num = Plugin.NearRange.Value; Collider[] array = MyRooms(feet); foreach (Collider val in array) { if (!Object.op_Implicit((Object)(object)val)) { continue; } Bounds bounds = val.bounds; float[] array2 = new float[2] { ((Bounds)(ref bounds)).min.x, ((Bounds)(ref bounds)).max.x }; foreach (float num2 in array2) { float[] array3 = new float[2] { ((Bounds)(ref bounds)).min.z, ((Bounds)(ref bounds)).max.z }; foreach (float num3 in array3) { num = Mathf.Max(num, Flat(new Vector3(num2, feet.y, num3), feet) + Plugin.BeyondRoom.Value); } } } return num * 1.15f; } private Collider[] MyRooms(Vector3 feet) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //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) if (rooms == null) { List<Collider> list = new List<Collider>(); Collider[] array = Physics.OverlapSphere(feet + Vector3.up * 0.5f, 0.3f, -1, (QueryTriggerInteraction)2); foreach (Collider val in array) { if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent<RoomVolume>())) { list.Add(val); } } rooms = list.ToArray(); } return rooms; } private void WarnMe() { PlayerAvatar instance = PlayerAvatar.instance; if (!Object.op_Implicit((Object)(object)instance) || instance.deadSet || instance.isDisabled || !SemiFunc.RunIsLevel()) { return; } if (Charm.Is(instance)) { if ((Object)(object)Charm.MachineOf(instance) == (Object)(object)this) { Ui.Warning(1f, sound: false); } } else if (warnMe && state != State.Eating && state != State.Grinding && !(Time.time < Charm.CalmUntil)) { Ui.Warning(1f); } } private void Ticking(int id, bool on) { if (!(on ? (!ticking.Add(id)) : (!ticking.Remove(id)))) { Plugin.Log.LogInfo((object)("Singing Machine: charm " + (on ? "starts" : "stops") + " building on " + (Object.op_Implicit((Object)(object)WhoIs(id)) ? ((Object)WhoIs(id)).name : id.ToString()) + ".")); Send("SM_WarnRPC", (RpcTarget)0, id, on); } } [PunRPC] public void SM_WarnRPC(int who, bool on) { PlayerAvatar val = WhoIs(who); if (Object.op_Implicit((Object)(object)val) && val.isLocal) { warnMe = on; } } private bool Reaches(Vector3 at, Vector3 feet, float range) { //IL_0000: 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_001b: 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_0035: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if (Mathf.Abs(at.y - feet.y) > 2.5f) { return false; } if (Flat(at, feet) < range) { return true; } Collider[] array; if (rooms == null) { List<Collider> list = new List<Collider>(); array = Physics.OverlapSphere(feet + Vector3.up * 0.5f, 0.3f, -1, (QueryTriggerInteraction)2); foreach (Collider val in array) { if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent<RoomVolume>())) { list.Add(val); } } rooms = list.ToArray(); } array = rooms; foreach (Collider val2 in array) { if (Object.op_Implicit((Object)(object)val2)) { Vector3 val3 = val2.ClosestPoint(at) - at; if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f) { return true; } } } return false; } private static float Flat(Vector3 a, Vector3 b) { //IL_0016: 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) a.y = (b.y = 0f); return Vector3.Distance(a, b); } private static int Id(PlayerAvatar p) { if (!Object.op_Implicit((Object)(object)p) || !Object.op_Implicit((Object)(object)p.photonView)) { return -1; } return p.photonView.ViewID; } private bool Immune(PlayerAvatar p) { if (immuneUntil.TryGetValue(Id(p), out var value)) { return Time.time < value; } return false; } private void Approach(float now, Vector3 feet) { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) float deltaTime = Time.deltaTime; foreach (PlayerAvatar item in SemiFunc.PlayerGetList()) { if (!Object.op_Implicit((Object)(object)item) || item.deadSet || item.isDisabled || Charm.Is(item) || Immune(item)) { if (Object.op_Implicit((Object)(object)item)) { nearSince.Remove(Id(item)); Ticking(Id(item), on: false); } continue; } int num = Id(item); nearSince.TryGetValue(num, out var value); bool flag = Outside(((Component)item).transform.position, feet) <= 0f; Ticking(num, flag); value = (flag ? (value + deltaTime) : (value - deltaTime * 0.5f)); if (value <= 0f) { nearSince.Remove(num); } else if (value >= Plugin.NearSeconds.Value) { nearSince.Remove(num); Ticking(num, on: false); Take(item); } else { nearSince[num] = value; } } } private void Suck(Vector3 feet, bool wait = false) { //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: 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_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_039b: 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_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) EnemyDirector instance = EnemyDirector.instance; enemyCharmed = false; if (!Object.op_Implicit((Object)(object)instance) || instance.enemiesSpawned == null) { return; } foreach (EnemyParent item in instance.enemiesSpawned) { Enemy val = (Object.op_Implicit((Object)(object)item) ? item.Enemy : null); if (!Object.op_Implicit((Object)(object)val) || (Object)(object)val == (Object)(object)enemy || !item.Spawned || !val.HasRigidbody || !Object.op_Implicit((Object)(object)val.Rigidbody) || !Object.op_Implicit((Object)(object)val.Rigidbody.rb) || (val.HasHealth && Object.op_Implicit((Object)(object)val.Health) && val.Health.dead) || Object.op_Implicit((Object)(object)((Component)val).GetComponent<MachineAI>()) || (Object)(object)val == (Object)(object)mealEnemy) { continue; } Vector3 position = val.Rigidbody.rb.position; float num = Flat(position, feet); enemyHeard.TryGetValue(val, out var value); bool num2 = Reaches(position, feet, Plugin.SuckRange.Value); value = (num2 ? (value + 0.1f) : (value - 0.05f)); if (value <= 0f) { enemyHeard.Remove(val); } else { enemyHeard[val] = Mathf.Min(value, Plugin.NearSeconds.Value * 0.5f); } if (!num2 || value < Plugin.NearSeconds.Value * 0.5f) { if (Eyes.HasEnemy(val)) { Send("SM_EnemyEyesRPC", (RpcTarget)0, Object.op_Implicit((Object)(object)((MonoBehaviourPun)val).photonView) ? ((MonoBehaviourPun)val).photonView.ViewID : (-1), false); } continue; } if (!Eyes.HasEnemy(val)) { Send("SM_EnemyEyesRPC", (RpcTarget)0, Object.op_Implicit((Object)(object)((MonoBehaviourPun)val).photonView) ? ((MonoBehaviourPun)val).photonView.ViewID : (-1), true); } enemyCharmed = true; if (wait) { Vector3 val2 = position - TroughWorld; val2.y = 0f; Vector3 to = TroughWorld + ((((Vector3)(ref val2)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val2)).normalized : Vector3.forward) * 3f; if (val.HasNavMeshAgent && Object.op_Implicit((Object)(object)val.NavMeshAgent)) { Lure.Hold(val, to); } else if (val.HasStateStunned && Object.op_Implicit((Object)(object)val.StateStunned)) { val.StateStunned.Set(0.5f); } continue; } if (val.HasNavMeshAgent && Object.op_Implicit((Object)(object)val.NavMeshAgent)) { Lure.Hold(val, TroughWorld); float num3 = Vector3.Distance(position, TroughWorld); float num4 = Vector3.Distance(((Component)val).transform.position, TroughWorld); if (!(num3 < 2.5f) || !(num4 < 3f)) { continue; } Plugin.Log.LogInfo((object)$"Singing Machine: {((Object)val).name} reaches it ({num3:F1} m from the trough); eaten."); Lure.Release(val); EatEnemy(val); break; } if (val.HasStateStunned && Object.op_Implicit