using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using R2API; using R2API.Networking; using R2API.Networking.Interfaces; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2.ConVar; using RoR2.Projectile; using TMPro; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.AddressableAssets.ResourceLocators; using UnityEngine.EventSystems; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [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 HatKidAcolyte { [BepInPlugin("com.chaz.hatkidacolyte", "HatKidAcolyte", "1.1.6")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class HatKidAcolytePlugin : BaseUnityPlugin { public const string PluginGUID = "com.chaz.hatkidacolyte"; public const string PluginName = "HatKidAcolyte"; public const string PluginVersion = "1.1.6"; private const string SkinNameToken = "CHAZ_HATKIDACOLYTE_SKIN_NAME"; internal static ManualLogSource Log; internal static ConfigEntry playVoice; internal static ConfigEntry debugLogging; internal static ConfigEntry voiceVolume; internal static ConfigEntry hearingRange; internal static ConfigEntry voiceKey; internal static bool PlayVoice => playVoice.Value; internal static float VoiceVolume => voiceVolume.Value; internal static float HearingRange => hearingRange.Value; internal static KeyboardShortcut VoiceKey => voiceKey.Value; internal static bool DebugLogging => debugLogging.Value; private void Awake() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; playVoice = ((BaseUnityPlugin)this).Config.Bind("Snatcher", "PlayVoice", true, "Play the Snatcher's \"FOOOOOOOOL\" when a Hat Kid transforms into him, and a random Hat Kid line when she turns back (yours, and nearby players' within HearingRange)."); voiceVolume = ((BaseUnityPlugin)this).Config.Bind("Snatcher", "VoiceVolume", 0.45f, new ConfigDescription("Voice line volume (0-1), multiplied by the game's Master and SFX volume.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); hearingRange = ((BaseUnityPlugin)this).Config.Bind("Snatcher", "HearingRange", 60f, new ConfigDescription("How far away (metres) you can hear other players' Hat Kid / Snatcher voice lines. Full volume within 10 m, fading evenly to silence at this distance; your own always play at full volume.", (AcceptableValueBase)(object)new AcceptableValueRange(15f, 200f), Array.Empty())); voiceKey = ((BaseUnityPlugin)this).Config.Bind("Snatcher", "VoiceLineKey", new KeyboardShortcut((KeyCode)104, Array.Empty()), "Press to say a random Hat Kid line (while playing Acolyte in the Hat Kid skin). Nearby players hear it too."); debugLogging = ((BaseUnityPlugin)this).Config.Bind("Debug", "LogTransformations", false, "Write extra diagnostic information to the BepInEx log."); try { LanguageAPI.Add("CHAZ_HATKIDACOLYTE_SKIN_NAME", "Hat Kid"); HatKidAcolyte.VoiceKey.Register(); RiskOfOptionsSupport.TrySetup(); AddSkin(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Failed to add Hat Kid skin: " + ex)); } } private void Update() { Voice.Cleanup(); HatKidAcolyte.VoiceKey.Update(); } private void OnDestroy() { Voice.StopAll(); } private void AddSkin() { //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0244: 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_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0433: Expected O, but got Unknown GameObject val = Load("RoR2/DLC4/Acolyte/AcolyteBody.prefab"); GameObject gameObject = ((Component)val.GetComponent().modelTransform).gameObject; ModelSkinController component = gameObject.GetComponent(); SkinnedMeshRenderer val2 = FindRenderer(gameObject, "mdlAcolyte/acolyte_geo"); SkinnedMeshRenderer val3 = FindRenderer(gameObject, "mdlAcolyte/acolyte_eyes"); SkinnedMeshRenderer val4 = FindRenderer(gameObject, "mdlAcolyte/Acolyte_Weapon_geo"); Dictionary bindposes = Assets.ReadBindposes("bindposes.bin"); Mesh mesh = Assets.ReadSkinnedMesh("hatkid_body.hkm", val2, bindposes); Mesh mesh2 = Assets.ReadSkinnedMesh("hatkid_face.hkm", val3, bindposes); Mesh val5 = Assets.ReadSkinnedMesh("umbrella.hkm", val4, bindposes); Material template = Load("RoR2/DLC4/Acolyte/matAcolyteBody.mat"); Material m = Assets.MakeMaterial(template, "matHatKidBody", Assets.ReadTexture("hatkid_body.png"), cutout: false); Texture2D val6 = Assets.ReadTexture("hatkid_face.png"); Material m2 = Assets.MakeMaterial(template, "matHatKidFace", val6, cutout: true); HatKidController.normalFace = val6; HatKidController.smugFace = Assets.ReadTexture("hatkid_face_smug.png"); Material val7 = Assets.MakeMaterial(template, "matHatKidUmbrella", Assets.ReadTexture("umbrella.png"), cutout: false); GameObject val8 = Load("RoR2/DLC4/Acolyte/GlaiveProjectile.prefab"); GameObject val9 = UmbrellaGhost.Create(Load("RoR2/DLC4/Acolyte/GlaiveProjectileGhost.prefab"), val5, val7); Purple.All(val9); GameObject val10 = Load("RoR2/DLC4/Acolyte/JavelinProjectile.prefab"); GameObject val11 = UmbrellaGhost.CreateJavelin(Load("RoR2/DLC4/Acolyte/JavelinGhost.prefab"), val5, val7); Purple.All(val11); ProjectileGhostReplacement[] second = PurpleEffects.Setup(new Harmony("com.chaz.hatkidacolyte"), (ICollection)(object)new GameObject[2] { val8, val10 }); SkinDef val12 = Skins.CreateNewSkinDef(new SkinDefParamsInfo { Name = "skinAcolyteHatKid", NameToken = "CHAZ_HATKIDACOLYTE_SKIN_NAME", Icon = Skins.CreateSkinIcon(Color32.op_Implicit(new Color32((byte)98, (byte)84, (byte)138, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)240, (byte)188, (byte)55, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)70, (byte)56, (byte)112, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)252, (byte)214, (byte)96, byte.MaxValue))), RootObject = gameObject, BaseSkins = (SkinDef[])(object)new SkinDef[1] { component.skins[0] }, RendererInfos = (RendererInfo[])(object)new RendererInfo[3] { RendererInfo((Renderer)(object)val2, m), RendererInfo((Renderer)(object)val3, m2), RendererInfo((Renderer)(object)val4, val7) }, MeshReplacements = (MeshReplacement[])(object)new MeshReplacement[3] { new MeshReplacement { renderer = (Renderer)(object)val2, mesh = mesh }, new MeshReplacement { renderer = (Renderer)(object)val3, mesh = mesh2 }, new MeshReplacement { renderer = (Renderer)(object)val4, mesh = val5 } }, ProjectileGhostReplacements = ((IEnumerable)(object)new ProjectileGhostReplacement[2] { new ProjectileGhostReplacement { projectilePrefab = val8, projectileGhostReplacementPrefab = val9 }, new ProjectileGhostReplacement { projectilePrefab = val10, projectileGhostReplacementPrefab = val11 } }).Concat(second).ToArray(), GameObjectActivations = Array.Empty(), MinionSkinReplacements = Array.Empty() }); if (!Skins.AddSkinToCharacter(val, val12)) { throw new Exception("R2API refused the skin"); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Added Hat Kid skin to Acolyte"); SkinnedMeshRenderer target = FindRenderer(gameObject, "mdlHarvester/Harvester_Body"); HatKidController.skin = val12; HatKidController.snatcherMesh = Assets.ReadSkinnedMesh("snatcher.hkm", target, Assets.ReadBindposes("harvester_bindposes.bin")); Material val13 = Assets.MakeMaterial(template, "matSnatcher", Assets.ReadTexture("snatcher_albedo.png"), cutout: false); val13.SetTexture("_EmTex", (Texture)(object)Assets.ReadTexture("snatcher_glow.png")); val13.SetColor("_EmColor", Color.white); val13.SetFloat("_EmPower", 2f); Texture texture = val13.GetTexture("_FresnelRamp"); if (Object.op_Implicit((Object)(object)texture)) { val13.SetTexture("_FresnelRamp", Purple.Texture(texture)); } HatKidController.snatcherMaterial = val13; HatKidController.emptyMesh = new Mesh { name = "HatKidAcolyteEmpty" }; HatKidController.hiddenHarvesterParts = new string[11] { "cyrstals", "horns", "inner_cloak", "Harvester_Head_Main", "Harvester_Head_Main_Eyes", "Harvester_Head_False", "Harvester_Head_False_Eyes", "Harvester_Weapon", "Harvester_Weapon_blade", "Symbol", "ring" }; HatKidController.snatcherVoice = ReadVoice("snatcher_fool.wav"); HatKidController.hatKidVoices = (from i in Enumerable.Range(0, 6) select ReadVoice($"hatkid_back_{i}.wav")).ToArray(); gameObject.AddComponent(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Snatcher form ready"); } private static byte[] ReadVoice(string name) { using Stream s = typeof(Assets).Assembly.GetManifestResourceStream(name); return Voice.Load(s); } private static T Load(string key) where T : Object { //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) T val = Addressables.LoadAssetAsync((object)key).WaitForCompletion(); if (!Object.op_Implicit((Object)(object)val)) { throw new Exception("Missing addressable " + key); } return val; } private static SkinnedMeshRenderer FindRenderer(GameObject model, string path) { Transform val = model.transform.Find(path); SkinnedMeshRenderer obj = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent() : null); if (!Object.op_Implicit((Object)(object)obj)) { throw new Exception("Renderer not found: " + path); } return obj; } private static RendererInfo RendererInfo(Renderer r, Material m) { //IL_0002: 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_0028: Unknown result type (might be due to invalid IL or missing references) return new RendererInfo { renderer = r, defaultMaterial = m, defaultShadowCastingMode = (ShadowCastingMode)1, ignoreOverlays = false }; } } internal static class Assets { private static Stream Open(string name) { return typeof(Assets).Assembly.GetManifestResourceStream(name) ?? throw new FileNotFoundException("Embedded resource missing: " + name); } public static Dictionary ReadBindposes(string name) { //IL_0027: 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) using BinaryReader binaryReader = new BinaryReader(Open(name)); Dictionary dictionary = new Dictionary(); int num = binaryReader.ReadInt32(); for (int i = 0; i < num; i++) { string key = ReadString(binaryReader); Matrix4x4 value = default(Matrix4x4); for (int j = 0; j < 16; j++) { ((Matrix4x4)(ref value))[j / 4, j % 4] = binaryReader.ReadSingle(); } dictionary[key] = value; } return dictionary; } public static Mesh ReadSkinnedMesh(string name, SkinnedMeshRenderer target, Dictionary bindposes) { //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_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_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown using BinaryReader binaryReader = new BinaryReader(Open(name)); if (new string(binaryReader.ReadChars(4)) != "HKM1") { throw new InvalidDataException(name); } int num = binaryReader.ReadInt32(); string[] array = new string[num]; for (int i = 0; i < num; i++) { array[i] = ReadString(binaryReader); } Transform[] bones = target.bones; Dictionary byName = new Dictionary(); for (int j = 0; j < bones.Length; j++) { if (Object.op_Implicit((Object)(object)bones[j]) && !byName.ContainsKey(((Object)bones[j]).name)) { byName[((Object)bones[j]).name] = j; } } Matrix4x4 value; int[] array2 = array.Select(delegate(string b) { if (!byName.TryGetValue(b, out value)) { throw new Exception(name + ": bone " + b + " not on " + ((Object)target).name); } return value; }).ToArray(); int num2 = binaryReader.ReadInt32(); Vector3[] array3 = (Vector3[])(object)new Vector3[num2]; Vector3[] array4 = (Vector3[])(object)new Vector3[num2]; Vector2[] array5 = (Vector2[])(object)new Vector2[num2]; for (int num3 = 0; num3 < num2; num3++) { array3[num3] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); } for (int num4 = 0; num4 < num2; num4++) { array4[num4] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); } for (int num5 = 0; num5 < num2; num5++) { array5[num5] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } int[] array6 = new int[num2 * 4]; for (int num6 = 0; num6 < array6.Length; num6++) { array6[num6] = array2[binaryReader.ReadInt32()]; } BoneWeight[] array7 = (BoneWeight[])(object)new BoneWeight[num2]; for (int num7 = 0; num7 < num2; num7++) { float weight = binaryReader.ReadSingle(); float weight2 = binaryReader.ReadSingle(); float weight3 = binaryReader.ReadSingle(); float weight4 = binaryReader.ReadSingle(); int num8 = num7; BoneWeight val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = array6[num7 * 4]; ((BoneWeight)(ref val)).boneIndex1 = array6[num7 * 4 + 1]; ((BoneWeight)(ref val)).boneIndex2 = array6[num7 * 4 + 2]; ((BoneWeight)(ref val)).boneIndex3 = array6[num7 * 4 + 3]; ((BoneWeight)(ref val)).weight0 = weight; ((BoneWeight)(ref val)).weight1 = weight2; ((BoneWeight)(ref val)).weight2 = weight3; ((BoneWeight)(ref val)).weight3 = weight4; array7[num8] = val; } int num9 = binaryReader.ReadInt32(); int[] array8 = new int[num9]; for (int num10 = 0; num10 < num9; num10++) { array8[num10] = binaryReader.ReadInt32(); } Mesh val2 = new Mesh { name = Path.GetFileNameWithoutExtension(name) }; if (num2 > 65535) { val2.indexFormat = (IndexFormat)1; } val2.vertices = array3; val2.normals = array4; val2.uv = array5; val2.SetIndices(array8, (MeshTopology)0, 0); val2.boneWeights = array7; val2.bindposes = bones.Select((Transform b) => (!Object.op_Implicit((Object)(object)b) || !bindposes.TryGetValue(((Object)b).name, out value)) ? Matrix4x4.identity : value).ToArray(); val2.RecalculateTangents(); val2.RecalculateBounds(); return val2; } public static Texture2D ReadTexture(string name) { //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) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //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_004d: Expected O, but got Unknown using Stream stream = Open(name); using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true) { name = Path.GetFileNameWithoutExtension(name) }; ImageConversion.LoadImage(val, memoryStream.ToArray()); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)2; val.Apply(true, true); return val; } public static Sprite ReadSprite(string name) { //IL_0020: 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) Texture2D val = ReadTexture(name); return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } public static Material MakeMaterial(Material template, string name, Texture2D tex, bool cutout) { //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_000e: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(template) { name = name }; val.SetTexture("_MainTex", (Texture)(object)tex); val.SetTexture("_NormalTex", (Texture)null); val.SetFloat("_NormalStrength", 0f); val.SetColor("_EmColor", Color.black); val.SetTexture("_EmTex", (Texture)null); val.SetFloat("_LimbRemovalOn", 0f); val.DisableKeyword("LIMBREMOVAL"); val.SetFloat("_EnableCutout", cutout ? 1f : 0f); if (cutout) { val.EnableKeyword("CUTOUT"); } else { val.DisableKeyword("CUTOUT"); } return val; } private static string ReadString(BinaryReader r) { return Encoding.UTF8.GetString(r.ReadBytes(r.ReadInt32())); } } [DefaultExecutionOrder(10000)] public class HatKidController : MonoBehaviour { internal static SkinDef skin; internal static Mesh snatcherMesh; internal static Mesh emptyMesh; internal static Material snatcherMaterial; internal static string[] hiddenHarvesterParts; internal static byte[] snatcherVoice; internal static byte[][] hatKidVoices; internal static Texture2D normalFace; internal static Texture2D smugFace; private const float HatKidScale = 0.9f; private static readonly string[] spectralParts = new string[5] { "mdlAcolyte/left_arm", "mdlAcolyte/right_arm", "mdlAcolyte/horns", "mdlAcolyte/Harvester_Weapon_blade", "mdlAcolyte/Harvester_Weapon_low" }; private static readonly string[] blockColours = new string[5] { "_EmColor", "_Color", "_TintColor", "_FlashColor", "_EmissionColor" }; private static readonly string[] blockTextures = new string[4] { "_FresnelRamp", "_RemapTex", "_EmTex", "_MainTex" }; private ModelSkinController skinController; private CharacterModel characterModel; private SkinnedMeshRenderer harvesterBody; private SkinnedMeshRenderer[] hidden; private Renderer[] alwaysPurple; private Renderer umbrella; private Renderer face; private MonoBehaviour emoteRig; private Transform hatKidForm; private readonly Dictionary hitboxes = new Dictionary(); private float nextEmoteRigSearch; private bool smug; private bool emoting; private MaterialPropertyBlock block; private bool initialised; private bool wasSnatcher; private bool capeReady; private float lastVoiceTime = -999f; private float nextEffectScan; private int lastHatKidLine = -1; private readonly HashSet recoloured = new HashSet(); private const float FullVolumeDistance = 10f; private const float MaxPan = 0.35f; private bool SkinActive { get { if (!Object.op_Implicit((Object)(object)skinController) || !Object.op_Implicit((Object)(object)skin)) { return false; } int currentSkinIndex = skinController.currentSkinIndex; if (currentSkinIndex >= 0 && currentSkinIndex < skinController.skins.Length) { return (Object)(object)skinController.skins[currentSkinIndex] == (Object)(object)skin; } return false; } } internal bool InSnatcherForm { get { if (Object.op_Implicit((Object)(object)harvesterBody)) { return IsShown((Renderer)(object)harvesterBody); } return false; } } public static bool IsHatKid(CharacterBody body) { Transform val = ((Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.modelLocator)) ? body.modelLocator.modelTransform : null); HatKidController hatKidController = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent() : null); if (Object.op_Implicit((Object)(object)hatKidController)) { return hatKidController.SkinActive; } return false; } private void Awake() { skinController = ((Component)this).GetComponent(); characterModel = ((Component)this).GetComponent(); harvesterBody = Find("mdlHarvester/Harvester_Body"); hidden = (from n in hiddenHarvesterParts select Find("mdlHarvester/" + n) into r where Object.op_Implicit((Object)(object)r) select r).ToArray(); umbrella = (Renderer)(object)Find("mdlAcolyte/Acolyte_Weapon_geo"); face = (Renderer)(object)Find("mdlAcolyte/acolyte_eyes"); alwaysPurple = (from r in (from p in spectralParts select ((Component)this).transform.Find(p) into t where Object.op_Implicit((Object)(object)t) select ((Component)t).GetComponent()).Concat((IEnumerable)(object)new Renderer[1] { (Renderer)harvesterBody }) where Object.op_Implicit((Object)(object)r) select r).ToArray(); } private SkinnedMeshRenderer Find(string path) { Transform val = ((Component)this).transform.Find(path); if (!Object.op_Implicit((Object)(object)val)) { return null; } return ((Component)val).GetComponent(); } private void LateUpdate() { if (!SkinActive) { return; } if (!capeReady) { capeReady = true; SetUpCapePhysics(); SetUpScale(); } KeepScale(); KeepSnatcher(); Renderer[] array = alwaysPurple; foreach (Renderer r in array) { KeepPurple(r); } UpdateEmotes(); if (Time.time >= nextEffectScan) { nextEffectScan = Time.time + 0.2f; RecolourAttachedEffects(); } if (!Object.op_Implicit((Object)(object)harvesterBody)) { return; } bool flag = IsShown((Renderer)(object)harvesterBody); if (!initialised) { initialised = true; wasSnatcher = flag; return; } if (flag != wasSnatcher && Time.time - lastVoiceTime > 1.5f && Audible(out var volume, out var pan)) { lastVoiceTime = Time.time; if (flag) { Voice.Play(snatcherVoice, volume, pan); } else { Voice.Play(RandomHatKidLine(), volume, pan); } } wasSnatcher = flag; } private void KeepSnatcher() { if (!Object.op_Implicit((Object)(object)harvesterBody)) { return; } if ((Object)(object)harvesterBody.sharedMesh != (Object)(object)snatcherMesh) { harvesterBody.sharedMesh = snatcherMesh; } SkinnedMeshRenderer[] array = hidden; foreach (SkinnedMeshRenderer val in array) { if ((Object)(object)val.sharedMesh != (Object)(object)emptyMesh) { val.sharedMesh = emptyMesh; } } RendererInfo[] array2 = (Object.op_Implicit((Object)(object)characterModel) ? characterModel.baseRendererInfos : null); if (array2 == null) { return; } for (int j = 0; j < array2.Length; j++) { if ((Object)(object)array2[j].renderer == (Object)(object)harvesterBody && (Object)(object)array2[j].defaultMaterial != (Object)(object)snatcherMaterial) { array2[j].defaultMaterial = snatcherMaterial; ((Renderer)harvesterBody).sharedMaterial = snatcherMaterial; } } } private void SetUpScale() { //IL_002a: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) hatKidForm = ((Component)this).transform.Find("mdlAcolyte"); if (!Object.op_Implicit((Object)(object)hatKidForm)) { return; } hatKidForm.localScale = Vector3.one * 0.9f; List list = new List { hatKidForm }; Transform val = hatKidForm.Find("mdlAcolyteBackpack"); if (Object.op_Implicit((Object)(object)val)) { list.Add(val); } foreach (Transform item in list) { foreach (Transform item2 in item) { Transform val2 = item2; if ((Object)(object)val2 != (Object)(object)val && ((Object)val2).name != "Armature" && Object.op_Implicit((Object)(object)((Component)val2).GetComponentInChildren(true))) { hitboxes[val2] = (Vector3.positiveInfinity, Vector3.positiveInfinity); } } } } private void KeepScale() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_007c: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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) if (!Object.op_Implicit((Object)(object)hatKidForm)) { return; } if (hatKidForm.localScale.x != 0.9f) { hatKidForm.localScale = Vector3.one * 0.9f; } foreach (Transform item in new List(hitboxes.Keys)) { if (Object.op_Implicit((Object)(object)item)) { var (val, val2) = hitboxes[item]; if (item.localPosition != val) { item.localPosition /= 0.9f; } if (item.localScale != val2) { item.localScale /= 0.9f; } hitboxes[item] = (item.localPosition, item.localScale); } } if (!Object.op_Implicit((Object)(object)emoteRig) && Time.time >= nextEmoteRigSearch) { nextEmoteRigSearch = Time.time + 1f; emoteRig = SmugDance.FindEmoteRig(((Component)this).transform); } if (Object.op_Implicit((Object)(object)emoteRig) && ((Component)emoteRig).transform.localScale.x != 0.9f) { ((Component)emoteRig).transform.localScale = Vector3.one * 0.9f; } } private void UpdateEmotes() { bool flag = SmugDance.IsEmoting(emoteRig); if (flag != emoting) { emoting = flag; if (Object.op_Implicit((Object)(object)umbrella)) { umbrella.forceRenderingOff = emoting; } } if (SmugDance.Installed) { bool flag2 = SmugDance.IsDancing(emoteRig); if (flag2 != smug) { smug = flag2; SetFace(smug ? smugFace : normalFace); } else if (smug) { SetFace(smugFace); } } } private void SetFace(Texture2D texture) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)face) && Object.op_Implicit((Object)(object)texture)) { block = (MaterialPropertyBlock)(((object)block) ?? ((object)new MaterialPropertyBlock())); face.GetPropertyBlock(block); block.SetTexture("_MainTex", (Texture)(object)texture); face.SetPropertyBlock(block); } } private void KeepPurple(Renderer r) { //IL_006b: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) Material[] sharedMaterials = r.sharedMaterials; bool flag = false; for (int i = 0; i < sharedMaterials.Length; i++) { if (Object.op_Implicit((Object)(object)sharedMaterials[i]) && !((Object)(object)sharedMaterials[i] == (Object)(object)snatcherMaterial)) { Material val = Purple.Material(sharedMaterials[i]); if ((Object)(object)val != (Object)(object)sharedMaterials[i]) { sharedMaterials[i] = val; flag = true; } } } if (flag) { r.sharedMaterials = sharedMaterials; } if (!r.HasPropertyBlock()) { return; } block = (MaterialPropertyBlock)(((object)block) ?? ((object)new MaterialPropertyBlock())); r.GetPropertyBlock(block); bool flag2 = false; string[] array = blockColours; foreach (string text in array) { if (block.HasColor(text)) { Color color = block.GetColor(text); if (Purple.IsGreen(color)) { block.SetColor(text, Purple.Shift(color)); flag2 = true; } } } array = blockTextures; foreach (string text2 in array) { if (block.HasTexture(text2)) { Texture texture = block.GetTexture(text2); Texture val2 = Purple.Texture(texture); if ((Object)(object)val2 != (Object)(object)texture) { block.SetTexture(text2, val2); flag2 = true; } } } if (flag2) { r.SetPropertyBlock(block); } } private byte[] RandomHatKidLine() { int num = NextHatKidLine(); if (num < 0) { return null; } return hatKidVoices[num]; } internal int NextHatKidLine() { if (hatKidVoices == null || hatKidVoices.Length == 0) { return -1; } int num = Random.Range(0, hatKidVoices.Length); if (num == lastHatKidLine && hatKidVoices.Length > 1) { num = (num + 1) % hatKidVoices.Length; } lastHatKidLine = num; return num; } internal void PlayHatKidLine(int index) { if (hatKidVoices != null && index >= 0 && index < hatKidVoices.Length) { lastHatKidLine = index; if (Audible(out var volume, out var pan)) { Voice.Play(hatKidVoices[index], volume, pan); } } } internal static HatKidController For(CharacterBody body) { Transform val = ((Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.modelLocator)) ? body.modelLocator.modelTransform : null); HatKidController hatKidController = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent() : null); if (!Object.op_Implicit((Object)(object)hatKidController) || !hatKidController.SkinActive) { return null; } return hatKidController; } private void SetUpCapePhysics() { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) Transform tail = ((Component)this).transform.Find("mdlAcolyte/Armature/ROOT/base/pelvis/tail_M"); if (!Object.op_Implicit((Object)(object)tail)) { HatKidAcolytePlugin.Log.LogWarning((object)"Cape physics: tail_M not found"); return; } if (((Component)this).GetComponentsInChildren(true).Any((DynamicBone d) => Object.op_Implicit((Object)(object)d.m_Root) && ((Object)(object)d.m_Root == (Object)(object)tail || tail.IsChildOf(d.m_Root)))) { HatKidAcolytePlugin.Log.LogInfo((object)"Cape physics: using Acolyte's own cloth simulation on tail_M"); return; } DynamicBone obj = ((Component)(((Component)this).transform.Find("mdlAcolyte") ?? ((Component)this).transform)).gameObject.AddComponent(); obj.m_Root = tail; obj.m_UpdateRate = 60f; obj.m_Damping = 0.18f; obj.m_Elasticity = 0.06f; obj.m_Stiffness = 0.25f; obj.m_Inert = 0.35f; obj.m_Radius = 0.08f; obj.m_Gravity = new Vector3(0f, -0.04f, 0f); HatKidAcolytePlugin.Log.LogInfo((object)"Cape physics: added a DynamicBone to tail_M"); } private void RecolourAttachedEffects() { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) CharacterBody val = (Object.op_Implicit((Object)(object)characterModel) ? characterModel.body : null); Transform val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).transform : ((Component)this).transform); Renderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren(true); foreach (Renderer val3 in componentsInChildren) { if (recoloured.Add(((Object)val3).GetInstanceID()) && !Object.op_Implicit((Object)(object)((Component)val3).GetComponentInParent()) && (val3 is ParticleSystemRenderer || val3 is TrailRenderer || val3 is LineRenderer || Object.op_Implicit((Object)(object)((Component)val3).GetComponentInParent()) || Object.op_Implicit((Object)(object)((Component)val3).GetComponentInParent()))) { Purple.All(((Component)val3).gameObject); } } Light[] componentsInChildren2 = ((Component)val2).GetComponentsInChildren(true); foreach (Light val4 in componentsInChildren2) { if (recoloured.Add(((Object)val4).GetInstanceID()) && !Object.op_Implicit((Object)(object)((Component)val4).GetComponentInParent()) && Purple.IsGreen(val4.color)) { val4.color = Purple.Shift(val4.color); } } } private static bool IsShown(Renderer r) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) if (((Component)r).gameObject.activeInHierarchy && r.enabled && !r.forceRenderingOff) { return ((Component)r).transform.lossyScale.y > 0.05f; } return false; } private bool Audible(out float volume, out float pan) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_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) //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) volume = 1f; pan = 0f; if (IsLocalPlayer()) { return true; } CharacterBody val = (Object.op_Implicit((Object)(object)characterModel) ? characterModel.body : null); Vector3 val2 = (Object.op_Implicit((Object)(object)val) ? val.corePosition : ((Component)this).transform.position); Camera main = Camera.main; LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); CharacterBody val3 = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null); Vector3 val4 = (Object.op_Implicit((Object)(object)val3) ? val3.corePosition : (Object.op_Implicit((Object)(object)main) ? ((Component)main).transform.position : val2)); float num = Vector3.Distance(val2, val4); float num2 = Mathf.Max(HatKidAcolytePlugin.HearingRange, 11f); if (num >= num2) { return false; } volume = 1f - Mathf.Clamp01((num - 10f) / (num2 - 10f)); if (Object.op_Implicit((Object)(object)main) && num > 3f) { Vector3 val5 = val2 - val4; val5.y = 0f; if (((Vector3)(ref val5)).sqrMagnitude > 0.01f) { pan = Mathf.Clamp(Vector3.Dot(((Vector3)(ref val5)).normalized, ((Component)main).transform.right), -1f, 1f) * 0.35f; } } return volume > 0.01f; } private bool IsLocalPlayer() { CharacterBody val = (Object.op_Implicit((Object)(object)characterModel) ? characterModel.body : null); if (Object.op_Implicit((Object)(object)val) && val.isPlayerControlled) { return val.hasEffectiveAuthority; } return false; } } internal static class Purple { private const float TargetHue = 0.78f; private const float GreenMin = 0.19f; private const float GreenMax = 0.47f; private static readonly Dictionary textures = new Dictionary(); private static readonly Dictionary materials = new Dictionary(); public static bool IsGreen(Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(c, ref num, ref num2, ref num3); if (num2 > 0.25f && num3 > 0.03f && num > 0.19f) { return num < 0.47f; } return false; } public static Color Shift(Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0026: 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_0008: Unknown result type (might be due to invalid IL or missing references) if (!IsGreen(c)) { return c; } float num = default(float); float num2 = default(float); float num3 = default(float); Color.RGBToHSV(c, ref num, ref num2, ref num3); Color result = Color.HSVToRGB(0.78f, num2, num3, true); result.a = c.a; return result; } public static Gradient Shift(Gradient g) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0072: Expected O, but got Unknown if (g == null) { return null; } GradientColorKey[] colorKeys = g.colorKeys; bool flag = false; for (int i = 0; i < colorKeys.Length; i++) { if (IsGreen(colorKeys[i].color)) { colorKeys[i].color = Shift(colorKeys[i].color); flag = true; } } if (!flag) { return g; } Gradient val = new Gradient { mode = g.mode }; val.SetKeys(colorKeys, g.alphaKeys); return val; } public static MinMaxGradient Shift(MinMaxGradient m) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected I4, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_00a1: Unknown result type (might be due to invalid IL or missing references) ParticleSystemGradientMode mode = ((MinMaxGradient)(ref m)).mode; switch ((int)mode) { case 0: return new MinMaxGradient(Shift(((MinMaxGradient)(ref m)).color)); case 2: return new MinMaxGradient(Shift(((MinMaxGradient)(ref m)).colorMin), Shift(((MinMaxGradient)(ref m)).colorMax)); case 1: return new MinMaxGradient(Shift(((MinMaxGradient)(ref m)).gradient)); case 3: return new MinMaxGradient(Shift(((MinMaxGradient)(ref m)).gradientMin), Shift(((MinMaxGradient)(ref m)).gradientMax)); case 4: { MinMaxGradient result = default(MinMaxGradient); ((MinMaxGradient)(ref result))..ctor(Shift(((MinMaxGradient)(ref m)).gradient)); ((MinMaxGradient)(ref result)).mode = (ParticleSystemGradientMode)4; return result; } default: return m; } } public static Texture Texture(Texture t) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Invalid comparison between Unknown and I4 //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_004e: 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_005c: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00b5: 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_00c1: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)t) || !(t is Texture2D) || (int)t.dimension != 2) { return t; } if (textures.TryGetValue(t, out var value)) { return value; } Texture val = t; try { int w; int h; Color32[] array = Read(t, out w, out h); int num = 0; for (int i = 0; i < array.Length; i++) { Color c = Color32.op_Implicit(array[i]); if (IsGreen(c)) { array[i] = Color32.op_Implicit(Shift(c)); num++; } } if (num > array.Length / 200) { Texture2D val2 = new Texture2D(w, h, (TextureFormat)4, t.mipmapCount > 1) { name = ((Object)t).name + "_Purple", wrapMode = t.wrapMode, filterMode = t.filterMode, anisoLevel = t.anisoLevel }; val2.SetPixels32(array); val2.Apply(true, true); val = (Texture)val2; } } catch (Exception ex) { HatKidAcolytePlugin.Log.LogWarning((object)("Couldn't recolour " + ((Object)t).name + ": " + ex.Message)); } textures[t] = val; return val; } private static Color32[] Read(Texture t, out int w, out int h) { //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) Color32[] array = Blit(t, 64, 64); bool flag = false; Color32[] array2 = array; for (int i = 0; i < array2.Length; i++) { if (IsGreen(Color32.op_Implicit(array2[i]))) { flag = true; break; } } if (!flag) { w = 64; h = 64; return (Color32[])(object)new Color32[0]; } w = Mathf.Min(t.width, 1024); h = Mathf.Min(t.height, 1024); return Blit(t, w, h); } private static Color32[] Blit(Texture t, int w, int h) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0042: 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_0060: Expected O, but got Unknown RenderTexture temporary = RenderTexture.GetTemporary(w, h, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2); Graphics.Blit(t, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val = new Texture2D(w, h, (TextureFormat)4, false); val.ReadPixels(new Rect(0f, 0f, (float)w, (float)h), 0, 0); val.Apply(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); Color32[] pixels = val.GetPixels32(); Object.Destroy((Object)val); return pixels; } public static Material Material(Material m) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0053: 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) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Invalid comparison between Unknown and I4 //IL_0086: 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_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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)m)) { return m; } if (materials.TryGetValue(m, out var value)) { return value; } Material val = null; Shader shader = m.shader; for (int i = 0; i < shader.GetPropertyCount(); i++) { string propertyName = shader.GetPropertyName(i); ShaderPropertyType propertyType = shader.GetPropertyType(i); if ((int)propertyType != 0) { if ((int)propertyType == 4 && !propertyName.Contains("Normal") && !propertyName.Contains("Bump")) { Texture texture = m.GetTexture(propertyName); Texture val2 = Texture(texture); if ((Object)(object)val2 != (Object)(object)texture) { val = (Material)(((object)val) ?? ((object)new Material(m) { name = ((Object)m).name + "_Purple" })); val.SetTexture(propertyName, val2); } } } else { Color color = m.GetColor(propertyName); if (IsGreen(color)) { val = (Material)(((object)val) ?? ((object)new Material(m) { name = ((Object)m).name + "_Purple" })); val.SetColor(propertyName, Shift(color)); } } } materials[m] = val ?? m; materials[val ?? m] = val ?? m; return val ?? m; } public static bool All(GameObject root) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) bool flag = false; Renderer[] componentsInChildren = root.GetComponentsInChildren(true); foreach (Renderer r in componentsInChildren) { flag |= Renderer(r); } ParticleSystem[] componentsInChildren2 = root.GetComponentsInChildren(true); foreach (ParticleSystem ps in componentsInChildren2) { flag |= Particles(ps); } Light[] componentsInChildren3 = root.GetComponentsInChildren(true); foreach (Light val in componentsInChildren3) { if (IsGreen(val.color)) { val.color = Shift(val.color); flag = true; } } return flag; } public static bool Renderer(Renderer r) { bool flag = false; Material[] sharedMaterials = r.sharedMaterials; for (int i = 0; i < sharedMaterials.Length; i++) { Material val = Material(sharedMaterials[i]); if ((Object)(object)val != (Object)(object)sharedMaterials[i]) { sharedMaterials[i] = val; flag = true; } } if (flag) { r.sharedMaterials = sharedMaterials; } ParticleSystemRenderer val2 = (ParticleSystemRenderer)(object)((r is ParticleSystemRenderer) ? r : null); if (val2 != null && Object.op_Implicit((Object)(object)val2.trailMaterial)) { Material val3 = Material(val2.trailMaterial); if ((Object)(object)val3 != (Object)(object)val2.trailMaterial) { val2.trailMaterial = val3; flag = true; } } TrailRenderer val4 = (TrailRenderer)(object)((r is TrailRenderer) ? r : null); if (val4 != null) { Gradient val5 = Shift(val4.colorGradient); if (val5 != val4.colorGradient) { val4.colorGradient = val5; flag = true; } } LineRenderer val6 = (LineRenderer)(object)((r is LineRenderer) ? r : null); if (val6 != null) { Gradient val7 = Shift(val6.colorGradient); if (val7 != val6.colorGradient) { val6.colorGradient = val7; flag = true; } } return flag; } private static bool Particles(ParticleSystem ps) { //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_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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_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_0074: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) MainModule main = ps.main; ((MainModule)(ref main)).startColor = Shift(((MainModule)(ref main)).startColor); ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime; if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled) { ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = Shift(((ColorOverLifetimeModule)(ref colorOverLifetime)).color); } ColorBySpeedModule colorBySpeed = ps.colorBySpeed; if (((ColorBySpeedModule)(ref colorBySpeed)).enabled) { ((ColorBySpeedModule)(ref colorBySpeed)).color = Shift(((ColorBySpeedModule)(ref colorBySpeed)).color); } TrailModule trails = ps.trails; if (((TrailModule)(ref trails)).enabled) { ((TrailModule)(ref trails)).colorOverLifetime = Shift(((TrailModule)(ref trails)).colorOverLifetime); ((TrailModule)(ref trails)).colorOverTrail = Shift(((TrailModule)(ref trails)).colorOverTrail); } return true; } } internal static class PurpleEffects { internal class PurpleProjectile : MonoBehaviour { private float until; private bool doneSelf; private ProjectileController pc; private void OnEnable() { until = Time.time + 2f; doneSelf = false; pc = ((Component)this).GetComponent(); } private void LateUpdate() { if (!Object.op_Implicit((Object)(object)pc) || Time.time > until) { ((Behaviour)this).enabled = false; } else { if (!Object.op_Implicit((Object)(object)pc.owner)) { return; } CharacterBody component = pc.owner.GetComponent(); if (!Object.op_Implicit((Object)(object)component) || !HatKidController.IsHatKid(component)) { ((Behaviour)this).enabled = false; return; } if (!doneSelf) { doneSelf = true; Purple.All(((Component)this).gameObject); } if (Object.op_Implicit((Object)(object)pc.ghost)) { Purple.All(((Component)pc.ghost).gameObject); ((Behaviour)this).enabled = false; } } } } [HarmonyPatch] private static class SpawnPatches { [HarmonyPatch(typeof(EffectManager), "SpawnEffect", new Type[] { typeof(GameObject), typeof(EffectData), typeof(bool) })] [HarmonyPrefix] private static void ByPrefab(ref GameObject effectPrefab, EffectData effectData) { if (Object.op_Implicit((Object)(object)effectPrefab) && purpleByPrefab.TryGetValue(effectPrefab, out var value) && OwnedByHatKid(effectData)) { effectPrefab = value; } } [HarmonyPatch(typeof(EffectManager), "SpawnEffect", new Type[] { typeof(EffectIndex), typeof(EffectData), typeof(bool) })] [HarmonyPrefix] private static void ByIndex(ref EffectIndex effectIndex, EffectData effectData) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected I4, but got Unknown if (purpleByIndex.TryGetValue(effectIndex, out var value) && OwnedByHatKid(effectData)) { effectIndex = (EffectIndex)(int)value; } } } private static readonly string[] Prefixes = new string[2] { "RoR2/DLC4/Acolyte", "RoR2/DLC4/LilReaper" }; private static readonly HashSet trackedProjectiles = new HashSet(); private static readonly HashSet trackedProjectileIndices = new HashSet(); private static BodyIndex lilReaperIndex = (BodyIndex)(-1); private static readonly Dictionary purpleByPrefab = new Dictionary(); private static readonly Dictionary purpleByIndex = new Dictionary(); private static BodyIndex acolyteIndex = (BodyIndex)(-1); public static ProjectileGhostReplacement[] Setup(Harmony harmony, ICollection skip) { //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_0122: 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) List list = new List(); int num = 0; Stopwatch stopwatch = Stopwatch.StartNew(); foreach (string item in AcolyteKeys()) { GameObject val; try { val = Addressables.LoadAssetAsync((object)item).WaitForCompletion(); } catch { continue; } if (!Object.op_Implicit((Object)(object)val)) { continue; } if (Object.op_Implicit((Object)(object)val.GetComponent()) && !purpleByPrefab.ContainsKey(val) && HasGreen(val)) { GameObject val2 = PrefabAPI.InstantiateClone(val, ((Object)val).name + "HatKidPurple", false); Purple.All(val2); if (ContentAddition.AddEffect(val2)) { purpleByPrefab[val] = val2; num++; } } ProjectileController component = val.GetComponent(); if (Object.op_Implicit((Object)(object)component)) { trackedProjectiles.Add(val); } if (Object.op_Implicit((Object)(object)component) && !skip.Contains(val)) { GameObject val3 = Ghost(component); if (Object.op_Implicit((Object)(object)val3) && HasGreen(val3)) { GameObject val4 = PrefabAPI.InstantiateClone(val3, ((Object)val3).name + "HatKidPurple", false); Purple.All(val4); list.Add(new ProjectileGhostReplacement { projectilePrefab = val, projectileGhostReplacementPrefab = val4 }); } } } harmony.PatchAll(typeof(SpawnPatches)); PatchProjectileSpawn(harmony); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ResolveIndices)); HatKidAcolytePlugin.Log.LogInfo((object)$"Purple effects: {num} effects, {list.Count} projectile ghosts ({stopwatch.ElapsedMilliseconds} ms)"); return list.ToArray(); } private static IEnumerable AcolyteKeys() { HashSet hashSet = new HashSet(); foreach (IResourceLocator resourceLocator in Addressables.ResourceLocators) { foreach (object key in resourceLocator.Keys) { string s = key as string; if (s != null && s.EndsWith(".prefab") && Prefixes.Any((string p) => s.StartsWith(p + "/"))) { hashSet.Add(s); } } } return hashSet.OrderBy((string k) => k); } private static GameObject Ghost(ProjectileController pc) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)pc.ghostPrefab)) { return pc.ghostPrefab; } FieldInfo[] fields = typeof(ProjectileController).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.Name.IndexOf("ghost", StringComparison.OrdinalIgnoreCase) >= 0) { object? value = fieldInfo.GetValue(pc); AssetReference val = (AssetReference)((value is AssetReference) ? value : null); if (val != null && val.RuntimeKeyIsValid()) { return Addressables.LoadAssetAsync(val.RuntimeKey).WaitForCompletion(); } } } return null; } private static bool HasGreen(GameObject go) { //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_00a6: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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) Renderer[] componentsInChildren = go.GetComponentsInChildren(true); foreach (Renderer val in componentsInChildren) { Material[] sharedMaterials = val.sharedMaterials; foreach (Material val2 in sharedMaterials) { if (Object.op_Implicit((Object)(object)val2) && (Object)(object)Purple.Material(val2) != (Object)(object)val2) { return true; } } ParticleSystemRenderer val3 = (ParticleSystemRenderer)(object)((val is ParticleSystemRenderer) ? val : null); if (val3 != null && Object.op_Implicit((Object)(object)val3.trailMaterial) && (Object)(object)Purple.Material(val3.trailMaterial) != (Object)(object)val3.trailMaterial) { return true; } } ParticleSystem[] componentsInChildren2 = go.GetComponentsInChildren(true); foreach (ParticleSystem val4 in componentsInChildren2) { MainModule main = val4.main; if (Green(((MainModule)(ref main)).startColor)) { return true; } ColorOverLifetimeModule colorOverLifetime = val4.colorOverLifetime; if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled) { colorOverLifetime = val4.colorOverLifetime; if (Green(((ColorOverLifetimeModule)(ref colorOverLifetime)).color)) { return true; } } } Light[] componentsInChildren3 = go.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren3.Length; i++) { if (Purple.IsGreen(componentsInChildren3[i].color)) { return true; } } return false; } private static bool Green(MinMaxGradient g) { //IL_0002: 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_0024: Unknown result type (might be due to invalid IL or missing references) if (!Purple.IsGreen(((MinMaxGradient)(ref g)).color) && !Purple.IsGreen(((MinMaxGradient)(ref g)).colorMin) && !Purple.IsGreen(((MinMaxGradient)(ref g)).colorMax) && (((MinMaxGradient)(ref g)).gradient == null || !((MinMaxGradient)(ref g)).gradient.colorKeys.Any((GradientColorKey k) => Purple.IsGreen(k.color)))) { if (((MinMaxGradient)(ref g)).gradientMax != null) { return ((MinMaxGradient)(ref g)).gradientMax.colorKeys.Any((GradientColorKey k) => Purple.IsGreen(k.color)); } return false; } return true; } private static void ResolveIndices() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0019: 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_008b: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Invalid comparison between Unknown and I4 //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Invalid comparison between Unknown and I4 //IL_00a1: 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) acolyteIndex = BodyCatalog.FindBodyIndex("AcolyteBody"); lilReaperIndex = BodyCatalog.FindBodyIndex("LilReaperBody"); foreach (GameObject trackedProjectile in trackedProjectiles) { int projectileIndex = ProjectileCatalog.GetProjectileIndex(trackedProjectile); if (projectileIndex >= 0) { trackedProjectileIndices.Add(projectileIndex); } } foreach (KeyValuePair item in purpleByPrefab) { EffectIndex val = EffectCatalog.FindEffectIndexFromPrefab(item.Key); EffectIndex val2 = EffectCatalog.FindEffectIndexFromPrefab(item.Value); if ((int)val != -1 && (int)val2 != -1) { purpleByIndex[val] = val2; } } } private static bool OwnedByHatKid(EffectData data) { //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_009e: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) if (data == null) { return false; } GameObject rootObject = data.rootObject; if (Object.op_Implicit((Object)(object)rootObject)) { CharacterBody val = rootObject.GetComponent() ?? rootObject.GetComponentInParent(); if (!Object.op_Implicit((Object)(object)val)) { CharacterModel componentInParent = rootObject.GetComponentInParent(); val = (Object.op_Implicit((Object)(object)componentInParent) ? componentInParent.body : null); } if (Object.op_Implicit((Object)(object)val)) { return HatKidController.IsHatKid(val); } } CharacterBody val2 = null; float num = float.MaxValue; foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList) { if (Object.op_Implicit((Object)(object)readOnlyInstances) && (readOnlyInstances.bodyIndex == acolyteIndex || readOnlyInstances.bodyIndex == lilReaperIndex)) { Vector3 val3 = readOnlyInstances.corePosition - data.origin; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; val2 = readOnlyInstances; } } } if (Object.op_Implicit((Object)(object)val2)) { return HatKidController.IsHatKid(val2); } return false; } private static void PatchProjectileSpawn(Harmony harmony) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown HarmonyMethod val = new HarmonyMethod(typeof(PurpleEffects).GetMethod("OnProjectileSpawned", BindingFlags.Static | BindingFlags.NonPublic)); string[] array = new string[3] { "Start", "OnEnable", "Awake" }; foreach (string text in array) { MethodInfo methodInfo = AccessTools.Method(typeof(ProjectileController), text, (Type[])null, (Type[])null); if (!(methodInfo == null)) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); HatKidAcolytePlugin.Log.LogInfo((object)("Purple projectiles: hooked ProjectileController." + text)); return; } } HatKidAcolytePlugin.Log.LogWarning((object)"Purple projectiles: no ProjectileController spawn method to hook"); } private static void OnProjectileSpawned(ProjectileController __instance) { if (Object.op_Implicit((Object)(object)__instance) && trackedProjectileIndices.Contains(__instance.catalogIndex) && !Object.op_Implicit((Object)(object)((Component)__instance).GetComponent())) { ((Component)__instance).gameObject.AddComponent(); } } } internal static class RiskOfOptionsSupport { private const string GUID = "com.rune580.riskofoptions"; public static void TrySetup() { if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions")) { Setup(); } } [MethodImpl(MethodImplOptions.NoInlining)] private static void Setup() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown ModSettingsManager.SetModDescription("Hat Kid skin for Acolyte. Voice line settings for Hat Kid and the Snatcher."); try { ModSettingsManager.SetModIcon(Assets.ReadSprite("skin_icon.png")); } catch { } ModSettingsManager.AddOption((BaseOption)new KeyBindOption(HatKidAcolytePlugin.voiceKey)); ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(HatKidAcolytePlugin.playVoice)); ModSettingsManager.AddOption((BaseOption)new SliderOption(HatKidAcolytePlugin.voiceVolume, new SliderConfig { min = 0f, max = 1f, formatString = "{0:0%}" })); ModSettingsManager.AddOption((BaseOption)new SliderOption(HatKidAcolytePlugin.hearingRange, new SliderConfig { min = 15f, max = 200f, formatString = "{0:0} m" })); } } internal static class SmugDance { private const string EmoteGUID = "com.themysticsword.smugdanceemote"; private const string MusicGUID = "com.chaz.smugdancemusic"; private const string EmoteName = "Smug"; private static bool? installed; private static FieldInfo clipNameField; private static FieldInfo animatorField; public static bool Installed { get { bool? flag = installed; if (!flag.HasValue) { bool? flag2 = (installed = Chainloader.PluginInfos.ContainsKey("com.themysticsword.smugdanceemote") || Chainloader.PluginInfos.ContainsKey("com.chaz.smugdancemusic")); return flag2.Value; } return flag == true; } } public static MonoBehaviour FindEmoteRig(Transform model) { MonoBehaviour[] componentsInChildren = ((Component)model).GetComponentsInChildren(true); foreach (MonoBehaviour val in componentsInChildren) { if (Object.op_Implicit((Object)(object)val) && ((object)val).GetType().Name == "BoneMapper") { return val; } } return null; } public static bool IsDancing(MonoBehaviour emoteRig) { string text = CurrentEmote(emoteRig); if (text != null) { return text.IndexOf("Smug", StringComparison.OrdinalIgnoreCase) >= 0; } return false; } public static bool IsEmoting(MonoBehaviour emoteRig) { return CurrentEmote(emoteRig) != null; } private static string CurrentEmote(MonoBehaviour emoteRig) { if (!Object.op_Implicit((Object)(object)emoteRig)) { return null; } try { Type type = ((object)emoteRig).GetType(); clipNameField = clipNameField ?? type.GetField("currentClipName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); animatorField = animatorField ?? type.GetField("a2", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (clipNameField == null) { return null; } object? obj = animatorField?.GetValue(emoteRig); Animator val = (Animator)((obj is Animator) ? obj : null); if (animatorField != null && (!Object.op_Implicit((Object)(object)val) || !((Behaviour)val).enabled)) { return null; } string text = clipNameField.GetValue(emoteRig) as string; return (string.IsNullOrEmpty(text) || text == "none") ? null : text; } catch { return null; } } } internal static class UmbrellaGhost { private const float JavelinScale = 0.8f; public static GameObject Create(GameObject original, Mesh skinnedUmbrella, Material material) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) GameObject val = PrefabAPI.InstantiateClone(original, "HatKidUmbrellaGhost", false); Transform val2 = val.transform.Find("Transform") ?? val.transform; Transform val3 = val2.Find("Weapon"); ParticleSystemRenderer val4 = default(ParticleSystemRenderer); if (Object.op_Implicit((Object)(object)val3) && ((Component)val3).TryGetComponent(ref val4)) { ((Renderer)val4).enabled = false; } GameObject val5 = new GameObject("Umbrella"); val5.transform.SetParent(val2, false); val5.AddComponent().sharedMesh = StaticCopy(skinnedUmbrella); ((Renderer)val5.AddComponent()).sharedMaterial = material; val5.AddComponent(); return val; } public static GameObject CreateJavelin(GameObject original, Mesh skinnedUmbrella, Material material) { //IL_004c: 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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0168: 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_0187: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: 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_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) GameObject val = PrefabAPI.InstantiateClone(original, "HatKidUmbrellaJavelinGhost", false); MeshFilter componentInChildren = val.GetComponentInChildren(true); MeshRenderer val2 = (Object.op_Implicit((Object)(object)componentInChildren) ? ((Component)componentInChildren).GetComponent() : null); if (!Object.op_Implicit((Object)(object)componentInChildren) || !Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)componentInChildren.sharedMesh)) { return val; } Bounds bounds = componentInChildren.sharedMesh.bounds; float num = float.MaxValue; float num2 = float.MinValue; Vector3 val3 = default(Vector3); for (int i = 0; i < 8; i++) { ((Vector3)(ref val3))..ctor(((i & 1) == 0) ? ((Bounds)(ref bounds)).min.x : ((Bounds)(ref bounds)).max.x, ((i & 2) == 0) ? ((Bounds)(ref bounds)).min.y : ((Bounds)(ref bounds)).max.y, ((i & 4) == 0) ? ((Bounds)(ref bounds)).min.z : ((Bounds)(ref bounds)).max.z); float z = val.transform.InverseTransformPoint(((Component)componentInChildren).transform.TransformPoint(val3)).z; num = Mathf.Min(num, z); num2 = Mathf.Max(num2, z); } Material val4 = ((((Renderer)val2).sharedMaterials.Length > 1) ? ((Renderer)val2).sharedMaterials[1] : null); ((Renderer)val2).enabled = false; float length; Mesh sharedMesh = TipForward(skinnedUmbrella, out length); Transform transform = new GameObject("Umbrella").transform; transform.SetParent(val.transform, false); transform.localPosition = new Vector3(0f, 0f, num2); transform.localScale = Vector3.one * ((num2 - num) * 0.8f / length); ((Component)transform).gameObject.AddComponent().sharedMesh = sharedMesh; ((Renderer)((Component)transform).gameObject.AddComponent()).sharedMaterial = material; if (Object.op_Implicit((Object)(object)val4)) { Transform transform2 = new GameObject("UmbrellaGlow").transform; transform2.SetParent(transform, false); transform2.localPosition = new Vector3(0f, 0f, (0f - length) * 0.02f); transform2.localScale = Vector3.one * 1.04f; ((Component)transform2).gameObject.AddComponent().sharedMesh = sharedMesh; ((Renderer)((Component)transform2).gameObject.AddComponent()).sharedMaterial = val4; } return val; } private static Mesh TipForward(Mesh src, out float length) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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) //IL_005a: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown Vector3[] vertices = src.vertices; Vector3[] normals = src.normals; Quaternion val = Quaternion.Euler(90f, 0f, 0f); float num = float.MinValue; float num2 = float.MaxValue; for (int i = 0; i < vertices.Length; i++) { int num3 = i; Vector3 val2 = vertices[i]; Bounds bounds = src.bounds; vertices[num3] = val * (val2 - ((Bounds)(ref bounds)).center); normals[i] = val * normals[i]; num = Mathf.Max(num, vertices[i].z); num2 = Mathf.Min(num2, vertices[i].z); } for (int j = 0; j < vertices.Length; j++) { vertices[j].z -= num; } length = num - num2; Mesh val3 = new Mesh { name = "UmbrellaJavelin", vertices = vertices, normals = normals, uv = src.uv }; val3.SetIndices(src.GetIndices(0), (MeshTopology)0, 0); val3.RecalculateTangents(); val3.RecalculateBounds(); return val3; } private static Mesh StaticCopy(Mesh src) { //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_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) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_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_0057: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_007c: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown Vector3[] vertices = src.vertices; Vector3[] normals = src.normals; Bounds bounds = src.bounds; Vector3 center = ((Bounds)(ref bounds)).center; Quaternion val = Quaternion.Euler(0f, 0f, -90f); for (int i = 0; i < vertices.Length; i++) { vertices[i] = val * (vertices[i] - center); normals[i] = val * normals[i]; } Mesh val2 = new Mesh { name = "UmbrellaThrown", vertices = vertices, normals = normals, uv = src.uv }; val2.SetIndices(src.GetIndices(0), (MeshTopology)0, 0); val2.RecalculateTangents(); val2.RecalculateBounds(); return val2; } } public class Spinner : MonoBehaviour { public float degreesPerSecond = 1080f; private void Update() { ((Component)this).transform.Rotate(0f, degreesPerSecond * Time.deltaTime, 0f, (Space)1); } } internal static class Voice { private struct WaveFormat { public short wFormatTag; public short nChannels; public int nSamplesPerSec; public int nAvgBytesPerSec; public short nBlockAlign; public short wBitsPerSample; public short cbSize; } private struct WaveHeader { public IntPtr lpData; public int dwBufferLength; public int dwBytesRecorded; public IntPtr dwUser; public int dwFlags; public int dwLoops; public IntPtr lpNext; public IntPtr reserved; } private class Playing { public IntPtr handle; public IntPtr header; public IntPtr data; } private const int MaxVoices = 24; private const int WAVE_MAPPER = -1; private const int WHDR_DONE = 1; private static readonly List playing = new List(); private static readonly int headerSize = Marshal.SizeOf(typeof(WaveHeader)); private static readonly int flagsOffset = (int)Marshal.OffsetOf(typeof(WaveHeader), "dwFlags"); [DllImport("winmm.dll")] private static extern int waveOutOpen(out IntPtr handle, int deviceId, ref WaveFormat format, IntPtr callback, IntPtr instance, int flags); [DllImport("winmm.dll")] private static extern int waveOutPrepareHeader(IntPtr handle, IntPtr header, int size); [DllImport("winmm.dll")] private static extern int waveOutWrite(IntPtr handle, IntPtr header, int size); [DllImport("winmm.dll")] private static extern int waveOutUnprepareHeader(IntPtr handle, IntPtr header, int size); [DllImport("winmm.dll")] private static extern int waveOutReset(IntPtr handle); [DllImport("winmm.dll")] private static extern int waveOutClose(IntPtr handle); public static byte[] Load(Stream s) { using MemoryStream memoryStream = new MemoryStream(); s.CopyTo(memoryStream); return memoryStream.ToArray(); } public static void Play(byte[] wav, float distanceVolume = 1f, float pan = 0f) { if (wav == null || !HatKidAcolytePlugin.PlayVoice) { return; } float num = distanceVolume * HatKidAcolytePlugin.VoiceVolume * GameVolume("volume_master") * GameVolume("volume_sfx"); if (num <= 0.001f) { return; } try { Cleanup(); if (Voice.playing.Count >= 24) { Stop(Voice.playing[0]); } float num2 = (Math.Max(-1f, Math.Min(1f, pan)) + 1f) * (float)Math.PI / 4f; float num3 = Math.Min(1f, (float)Math.Cos(num2) * 1.4142135f); float num4 = Math.Min(1f, (float)Math.Sin(num2) * 1.4142135f); ReadFormat(wav, out var format, out var dataStart, out var dataLength); byte[] array = Scaled(wav, dataStart, dataLength, format.nChannels, num * num3, num * num4); Playing playing = new Playing(); if (waveOutOpen(out playing.handle, -1, ref format, IntPtr.Zero, IntPtr.Zero, 0) == 0) { playing.data = Marshal.AllocHGlobal(array.Length); Marshal.Copy(array, 0, playing.data, array.Length); playing.header = Marshal.AllocHGlobal(headerSize); Marshal.StructureToPtr(new WaveHeader { lpData = playing.data, dwBufferLength = array.Length }, playing.header, fDeleteOld: false); waveOutPrepareHeader(playing.handle, playing.header, headerSize); waveOutWrite(playing.handle, playing.header, headerSize); Voice.playing.Add(playing); } } catch (Exception ex) { HatKidAcolytePlugin.Log.LogWarning((object)("Couldn't play a voice line: " + ex.Message)); } } public static void Cleanup() { for (int num = playing.Count - 1; num >= 0; num--) { if ((Marshal.ReadInt32(playing[num].header, flagsOffset) & 1) != 0) { Stop(playing[num]); } } } public static void StopAll() { for (int num = playing.Count - 1; num >= 0; num--) { Stop(playing[num]); } } private static void Stop(Playing p) { waveOutReset(p.handle); waveOutUnprepareHeader(p.handle, p.header, headerSize); waveOutClose(p.handle); Marshal.FreeHGlobal(p.header); Marshal.FreeHGlobal(p.data); playing.Remove(p); } private static void ReadFormat(byte[] b, out WaveFormat format, out int dataStart, out int dataLength) { format = new WaveFormat { wFormatTag = 1, nChannels = 2, nSamplesPerSec = 44100, wBitsPerSample = 16 }; dataStart = 44; dataLength = b.Length - 44; int num; for (int i = 12; i + 8 <= b.Length; i += 8 + num + (num & 1)) { num = BitConverter.ToInt32(b, i + 4); if (b[i] == 102 && b[i + 1] == 109 && b[i + 2] == 116) { format.wFormatTag = BitConverter.ToInt16(b, i + 8); format.nChannels = BitConverter.ToInt16(b, i + 10); format.nSamplesPerSec = BitConverter.ToInt32(b, i + 12); format.wBitsPerSample = BitConverter.ToInt16(b, i + 22); } else if (b[i] == 100 && b[i + 1] == 97 && b[i + 2] == 116 && b[i + 3] == 97) { dataStart = i + 8; dataLength = Math.Min(num, b.Length - dataStart); break; } } format.nBlockAlign = (short)(format.nChannels * format.wBitsPerSample / 8); format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign; } private static byte[] Scaled(byte[] wav, int start, int length, int channels, float left, float right) { byte[] array = new byte[length]; for (int i = 0; i + 1 < length; i += 2) { float num = ((channels == 2 && i / 2 % 2 == 1) ? right : ((channels == 2) ? left : ((left + right) * 0.5f))); int val = (int)((float)BitConverter.ToInt16(wav, start + i) * num); val = Math.Max(-32768, Math.Min(32767, val)); array[i] = (byte)val; array[i + 1] = (byte)(val >> 8); } return array; } private static float GameVolume(string name) { try { BaseConVar val = (Object.op_Implicit((Object)(object)Console.instance) ? Console.instance.FindConVar(name) : null); if (val != null && float.TryParse(val.GetString(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return Math.Max(0f, Math.Min(1f, result / 100f)); } } catch { } return 1f; } } internal static class VoiceKey { public class VoiceToServer : INetMessage, ISerializableObject { private NetworkInstanceId netId; private int line; public VoiceToServer() { } public VoiceToServer(NetworkInstanceId netId, int line) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) this.netId = netId; this.line = line; } public void Serialize(NetworkWriter writer) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) writer.Write(netId); writer.Write(line); } public void Deserialize(NetworkReader reader) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) netId = reader.ReadNetworkId(); line = reader.ReadInt32(); } public void OnReceived() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (NetworkServer.active) { NetMessageExtensions.Send((INetMessage)(object)new VoiceToClients(netId, line), (NetworkDestination)1); } } } public class VoiceToClients : INetMessage, ISerializableObject { private NetworkInstanceId netId; private int line; public VoiceToClients() { } public VoiceToClients(NetworkInstanceId netId, int line) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) this.netId = netId; this.line = line; } public void Serialize(NetworkWriter writer) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) writer.Write(netId); writer.Write(line); } public void Deserialize(NetworkReader reader) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) netId = reader.ReadNetworkId(); line = reader.ReadInt32(); } public void OnReceived() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Play(netId, line); } } public static void Register() { NetworkingAPI.RegisterMessageType(); NetworkingAPI.RegisterMessageType(); } public static void Update() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (!Pressed(HatKidAcolytePlugin.VoiceKey) || !HatKidAcolytePlugin.PlayVoice || !Object.op_Implicit((Object)(object)Run.instance) || PauseManager.isPaused || Typing()) { return; } LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null); HatKidController hatKidController = HatKidController.For(val); NetworkIdentity val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent() : null); if (Object.op_Implicit((Object)(object)hatKidController) && Object.op_Implicit((Object)(object)val2) && !hatKidController.InSnatcherForm) { int num = hatKidController.NextHatKidLine(); if (num >= 0) { NetMessageExtensions.Send((INetMessage)(object)new VoiceToServer(val2.netId, num), (NetworkDestination)2); } } } private static bool Pressed(KeyboardShortcut shortcut) { //IL_0002: 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_0029: Unknown result type (might be due to invalid IL or missing references) if ((int)((KeyboardShortcut)(ref shortcut)).MainKey == 0 || !Input.GetKeyDown(((KeyboardShortcut)(ref shortcut)).MainKey)) { return false; } foreach (KeyCode modifier in ((KeyboardShortcut)(ref shortcut)).Modifiers) { if (!Input.GetKey(modifier)) { return false; } } return true; } private static bool Typing() { GameObject val = (Object.op_Implicit((Object)(object)EventSystem.current) ? EventSystem.current.currentSelectedGameObject : null); if (Object.op_Implicit((Object)(object)val)) { if (!Object.op_Implicit((Object)(object)val.GetComponent())) { return Object.op_Implicit((Object)(object)val.GetComponent()); } return true; } return false; } private static void Play(NetworkInstanceId netId, int line) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GameObject val = Util.FindNetworkObject(netId); HatKidController hatKidController = HatKidController.For(Object.op_Implicit((Object)(object)val) ? val.GetComponent() : null); if (Object.op_Implicit((Object)(object)hatKidController)) { hatKidController.PlayHatKidLine(line); } } } }