using System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.UI; using Zorro.Core; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("FirstPersonCosmetics")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("First Person Cosmetics")] [assembly: AssemblyTitle("FirstPersonCosmetics")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace FirstPersonCosmetics { [BepInPlugin("firstpersoncosmetics", "First Person Cosmetics", "1.0.0")] public sealed class FirstPersonCosmeticsPlugin : BaseUnityPlugin { private enum AccessoryEffect { None, Eyepatch, Sunglasses, Aviator, BrokenGlasses } private enum HatEffect { None, PlagueDoctor, Astronaut, RacingHelmet, Pumpkin, SleepyGuy } private enum EyeEffect { None, Crying } public const string PluginGuid = "firstpersoncosmetics"; public const string PluginName = "First Person Cosmetics"; public const string PluginVersion = "1.0.0"; private const string EyepatchToken = "eyepatch"; private const string SunglassesToken = "sunglasses"; private const string AviatorToken = "aviator"; private const string BrokenGlassesToken = "glasses_broken"; private const string PlagueDoctorToken = "plaguedoctor"; private const string AstronautToken = "astronaut"; private const string RacingHelmetToken = "racinghelmet"; private const string SpeedHelmetToken = "speedhelmet"; private const string PumpkinToken = "pumpkin"; private const string SleepyGuyToken = "sleepyguy"; private const string CryingEyesToken = "eyes_cry"; private const string CrackResourceName = "FirstPersonCosmetics.broken_glasses_cracks.png"; private const string PumpkinResourceName = "FirstPersonCosmetics.pumpkin_face_overlay.png"; private static readonly Color AviatorTintColor = new Color(0.77254903f, 0.59607846f, 25f / 51f, 0.35f); private static readonly Color PlagueDoctorTintColor = new Color(19f / 85f, 1f, 4f / 51f, 0.35f); private static readonly Color AstronautTintColor = new Color(1f / 3f, 19f / 51f, 0.6039216f, 0.2f); private static readonly Color RacingHelmetTintColor = new Color(0.2509804f, 63f / 85f, 67f / 85f, 0.25f); private ConfigEntry _enabled; private ConfigEntry _opacity; private ConfigEntry _fadeWidth; private ConfigEntry _tinySunglassesOpacity; private ConfigEntry _showDebugLogs; private Texture2D _gradientTexture; private Texture2D _crackTexture; private Texture2D _pumpkinTexture; private Texture2D _sleepyTexture; private Canvas _overlayCanvas; private RawImage _eyepatchImage; private RawImage _sunglassesImage; private RawImage _aviatorImage; private RawImage _brokenGlassesImage; private RawImage _plagueDoctorImage; private RawImage _astronautImage; private RawImage _racingHelmetImage; private RawImage _pumpkinImage; private RawImage _sleepyImage; private RawImage _cryingBlurImage; private Camera _cryingBlurCamera; private RenderTexture _cryingRenderTexture; private AccessoryEffect _activeEffect; private HatEffect _activeHatEffect; private EyeEffect _activeEyeEffect; private float _lastScanTime; private float _nextHudLookupTime; private string _lastDetectedObject = ""; private void Awake() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_008e: 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_00d6: Expected O, but got Unknown _enabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Enable functional cosmetic screen effects."); _opacity = ((BaseUnityPlugin)this).Config.Bind("Effect", "Maximum opacity", 1f, new ConfigDescription("Blackness at the outside edge.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); _fadeWidth = ((BaseUnityPlugin)this).Config.Bind("Effect", "Center fade width", 0.1f, new ConfigDescription("Width of the soft fade as a fraction of the full screen.", (AcceptableValueBase)(object)new AcceptableValueRange(0.01f, 0.25f), Array.Empty())); _tinySunglassesOpacity = ((BaseUnityPlugin)this).Config.Bind("Tiny Sunglasses", "Black tint opacity", 0.75f, new ConfigDescription("Opacity of the Tiny Sunglasses black tint.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())); if (Mathf.Approximately(_tinySunglassesOpacity.Value, 0.5f)) { _tinySunglassesOpacity.Value = 0.75f; } _showDebugLogs = ((BaseUnityPlugin)this).Config.Bind("Debug", "Log cosmetic detection", false, "Write the selected cosmetics and active screen effects to the BepInEx log."); _gradientTexture = BuildGradientTexture(); _crackTexture = LoadEmbeddedTexture("FirstPersonCosmetics.broken_glasses_cracks.png", "FirstPersonCosmeticsBrokenGlassesCracks"); _pumpkinTexture = LoadEmbeddedTexture("FirstPersonCosmetics.pumpkin_face_overlay.png", "FirstPersonCosmeticsPumpkinFace"); _sleepyTexture = BuildSleepyTexture(); CreateOverlay(); CreateCryingBlurCamera(); SetActiveEffects(AccessoryEffect.None, HatEffect.None, EyeEffect.None); ((BaseUnityPlugin)this).Logger.LogInfo((object)"First Person Cosmetics 1.0.0 loaded."); } private void Update() { MatchStaminaHudLayer(); if (_enabled.Value && _activeEyeEffect == EyeEffect.Crying) { UpdateCryingBlurCamera(); } if (!_enabled.Value) { _activeEffect = AccessoryEffect.None; _activeHatEffect = HatEffect.None; _activeEyeEffect = EyeEffect.None; SetActiveEffects(_activeEffect, _activeHatEffect, _activeEyeEffect); } else if (!(Time.unscaledTime - _lastScanTime < 0.25f)) { _lastScanTime = Time.unscaledTime; _activeEffect = FindAccessoryEffect(out var objectName); _activeHatEffect = FindHatEffect(out var objectName2); _activeEyeEffect = FindEyeEffect(out var objectName3); SetActiveEffects(_activeEffect, _activeHatEffect, _activeEyeEffect); string text = objectName + "; " + objectName2 + "; " + objectName3; if (_showDebugLogs.Value && text != _lastDetectedObject) { _lastDetectedObject = text; ((BaseUnityPlugin)this).Logger.LogInfo((object)($"Accessory effect: {_activeEffect}; hat effect: {_activeHatEffect}; " + $"eye effect: {_activeEyeEffect}; " + "selected " + text + ".")); } } } private void CreateOverlay() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00ea: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("FirstPersonCosmeticsCanvas", new Type[2] { typeof(RectTransform), typeof(Canvas) }); ((Object)val).hideFlags = (HideFlags)61; val.transform.SetParent(((Component)this).transform, false); _overlayCanvas = val.GetComponent(); _overlayCanvas.renderMode = (RenderMode)0; _overlayCanvas.overrideSorting = true; _overlayCanvas.sortingOrder = -10000; _cryingBlurImage = CreateOverlayImage("CryingSceneBlur", Vector2.one, (Texture)(object)Texture2D.blackTexture, Color.white); _plagueDoctorImage = CreateOverlayImage("PlagueDoctorTint", Vector2.one, (Texture)(object)Texture2D.whiteTexture, PlagueDoctorTintColor); _astronautImage = CreateOverlayImage("AstronautTint", Vector2.one, (Texture)(object)Texture2D.whiteTexture, AstronautTintColor); _racingHelmetImage = CreateOverlayImage("RacingHelmetTint", Vector2.one, (Texture)(object)Texture2D.whiteTexture, RacingHelmetTintColor); _pumpkinImage = CreateOverlayImage("PumpkinFace", Vector2.one, (Texture)(object)_pumpkinTexture, Color.white); _sleepyImage = CreateOverlayImage("SleepySquint", Vector2.one, (Texture)(object)_sleepyTexture, Color.white); _eyepatchImage = CreateOverlayImage("LeftEyeObstruction", new Vector2(0.5f, 1f), (Texture)(object)_gradientTexture, Color.white); _sunglassesImage = CreateOverlayImage("SunglassesTint", Vector2.one, (Texture)(object)Texture2D.whiteTexture, new Color(0f, 0f, 0f, _tinySunglassesOpacity.Value)); _aviatorImage = CreateOverlayImage("AviatorTint", Vector2.one, (Texture)(object)Texture2D.whiteTexture, AviatorTintColor); _brokenGlassesImage = CreateOverlayImage("BrokenGlassesCracks", Vector2.one, (Texture)(object)_crackTexture, Color.white); } private void CreateCryingBlurCamera() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown GameObject val = new GameObject("FirstPersonCosmeticsCryingCamera", new Type[1] { typeof(Camera) }); ((Object)val).hideFlags = (HideFlags)61; val.transform.SetParent(((Component)this).transform, false); _cryingBlurCamera = val.GetComponent(); ((Behaviour)_cryingBlurCamera).enabled = false; } private void UpdateCryingBlurCamera() { //IL_0043: 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) if (!((Object)(object)_cryingBlurCamera == (Object)null)) { Camera val = FindSourceCamera(); if (!((Object)(object)val == (Object)null)) { EnsureCryingRenderTexture(); _cryingBlurCamera.CopyFrom(val); ((Component)_cryingBlurCamera).transform.SetPositionAndRotation(((Component)val).transform.position, ((Component)val).transform.rotation); _cryingBlurCamera.targetTexture = _cryingRenderTexture; _cryingBlurCamera.depth = val.depth - 100f; ((Behaviour)_cryingBlurCamera).enabled = true; _cryingBlurImage.texture = (Texture)(object)_cryingRenderTexture; } } } private Camera FindSourceCamera() { Camera main = Camera.main; if ((Object)(object)main != (Object)null && (Object)(object)main != (Object)(object)_cryingBlurCamera && ((Behaviour)main).isActiveAndEnabled && (Object)(object)main.targetTexture == (Object)null) { return main; } Camera[] allCameras = Camera.allCameras; foreach (Camera val in allCameras) { if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)_cryingBlurCamera && ((Behaviour)val).isActiveAndEnabled && (Object)(object)val.targetTexture == (Object)null) { return val; } } return null; } private void EnsureCryingRenderTexture() { //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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00c4: Expected O, but got Unknown int num = Mathf.Max(128, Screen.width / 10); int num2 = Mathf.Max(72, Screen.height / 10); if (!((Object)(object)_cryingRenderTexture != (Object)null) || ((Texture)_cryingRenderTexture).width != num || ((Texture)_cryingRenderTexture).height != num2) { if ((Object)(object)_cryingRenderTexture != (Object)null) { _cryingBlurCamera.targetTexture = null; _cryingRenderTexture.Release(); Object.Destroy((Object)(object)_cryingRenderTexture); } _cryingRenderTexture = new RenderTexture(num, num2, 24, (RenderTextureFormat)0) { name = "FirstPersonCosmeticsCryingScene", filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1, useMipMap = false, autoGenerateMips = false, antiAliasing = 1, hideFlags = (HideFlags)61 }; _cryingRenderTexture.Create(); _cryingBlurImage.texture = (Texture)(object)_cryingRenderTexture; } } private RawImage CreateOverlayImage(string objectName, Vector2 anchorMax, Texture texture, Color color) { //IL_0021: 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_002e: 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_004c: 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_005e: 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_007f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(objectName, new Type[2] { typeof(RectTransform), typeof(RawImage) }) { hideFlags = (HideFlags)61 }; val.transform.SetParent(((Component)_overlayCanvas).transform, false); RectTransform component = val.GetComponent(); component.anchorMin = Vector2.zero; component.anchorMax = anchorMax; component.offsetMin = Vector2.zero; component.offsetMax = Vector2.zero; RawImage component2 = val.GetComponent(); component2.texture = texture; ((Graphic)component2).color = color; ((Graphic)component2).raycastTarget = false; return component2; } private void SetActiveEffects(AccessoryEffect effect, HatEffect hatEffect, EyeEffect eyeEffect) { if (!((Object)(object)_overlayCanvas == (Object)null)) { ((Component)_eyepatchImage).gameObject.SetActive(effect == AccessoryEffect.Eyepatch); ((Component)_sunglassesImage).gameObject.SetActive(effect == AccessoryEffect.Sunglasses); ((Component)_aviatorImage).gameObject.SetActive(effect == AccessoryEffect.Aviator); ((Component)_brokenGlassesImage).gameObject.SetActive(effect == AccessoryEffect.BrokenGlasses); ((Component)_plagueDoctorImage).gameObject.SetActive(hatEffect == HatEffect.PlagueDoctor); ((Component)_astronautImage).gameObject.SetActive(hatEffect == HatEffect.Astronaut); ((Component)_racingHelmetImage).gameObject.SetActive(hatEffect == HatEffect.RacingHelmet); ((Component)_pumpkinImage).gameObject.SetActive(hatEffect == HatEffect.Pumpkin); ((Component)_sleepyImage).gameObject.SetActive(hatEffect == HatEffect.SleepyGuy); bool flag = eyeEffect == EyeEffect.Crying; if (flag) { UpdateCryingBlurCamera(); } else if ((Object)(object)_cryingBlurCamera != (Object)null) { ((Behaviour)_cryingBlurCamera).enabled = false; } ((Component)_cryingBlurImage).gameObject.SetActive(flag && (Object)(object)_cryingRenderTexture != (Object)null); ((Behaviour)_overlayCanvas).enabled = effect != AccessoryEffect.None || hatEffect != HatEffect.None || flag; } } private void MatchStaminaHudLayer() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Invalid comparison between Unknown and I4 //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Invalid comparison between Unknown and I4 if ((Object)(object)_overlayCanvas == (Object)null || Time.unscaledTime < _nextHudLookupTime) { return; } _nextHudLookupTime = Time.unscaledTime + 1f; StaminaBar val = Object.FindFirstObjectByType(); if (Object.op_Implicit((Object)(object)val)) { Canvas componentInParent = ((Component)val).GetComponentInParent(); if (Object.op_Implicit((Object)(object)componentInParent) && (int)componentInParent.renderMode != 2) { _overlayCanvas.renderMode = componentInParent.renderMode; _overlayCanvas.sortingLayerID = componentInParent.sortingLayerID; _overlayCanvas.sortingOrder = ((componentInParent.sortingOrder > -30000) ? (componentInParent.sortingOrder - 1) : (-30000)); _overlayCanvas.worldCamera = (((int)componentInParent.renderMode == 1) ? componentInParent.worldCamera : null); _overlayCanvas.planeDistance = componentInParent.planeDistance; } } } private Texture2D BuildGradientTexture() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(256, 2, (TextureFormat)4, false) { name = "FirstPersonCosmeticsEyepatchGradient", wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; Color val2 = default(Color); for (int i = 0; i < 256; i++) { float num = 1f - (float)i / 255f; float num2 = Mathf.Clamp01(_fadeWidth.Value * 2f); float num3 = ((num <= num2) ? (Mathf.InverseLerp(0f, num2, num) * _opacity.Value) : _opacity.Value); ((Color)(ref val2))..ctor(0f, 0f, 0f, num3); val.SetPixel(i, 0, val2); val.SetPixel(i, 1, val2); } val.Apply(); return val; } private Texture2D BuildSleepyTexture() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(2, 512, (TextureFormat)4, false) { name = "FirstPersonCosmeticsSleepyGradient", wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; Color val2 = default(Color); for (int i = 0; i < 512; i++) { float num = Mathf.Abs((float)i / 511f - 0.5f); float num2 = Mathf.InverseLerp(0.16f, 0.39f, num); float num3 = Mathf.SmoothStep(0f, 1f, num2); ((Color)(ref val2))..ctor(0f, 0f, 0f, num3); val.SetPixel(0, i, val2); val.SetPixel(1, i, val2); } val.Apply(false, true); return val; } private Texture2D LoadEmbeddedTexture(string resourceName, string textureName) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false) { name = textureName, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, hideFlags = (HideFlags)61 }; using Stream stream = typeof(FirstPersonCosmeticsPlugin).Assembly.GetManifestResourceStream(resourceName); if (stream == null) { ((BaseUnityPlugin)this).Logger.LogError((object)("Embedded texture '" + resourceName + "' was not found.")); val.SetPixel(0, 0, Color.clear); val.Apply(); return val; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); if (!ImageConversion.LoadImage(val, memoryStream.ToArray(), false)) { ((BaseUnityPlugin)this).Logger.LogError((object)("Embedded texture '" + resourceName + "' could not be loaded.")); val.SetPixel(0, 0, Color.clear); val.Apply(); return val; } val.Apply(false, true); return val; } private AccessoryEffect FindAccessoryEffect(out string objectName) { objectName = "local character unavailable"; Character localCharacter = Character.localCharacter; if (!Object.op_Implicit((Object)(object)localCharacter)) { return AccessoryEffect.None; } if (!GameHandler.Initialized) { objectName = "player data service unavailable"; return AccessoryEffect.None; } try { Player owner = ((MonoBehaviourPun)localCharacter).photonView.Owner; int accessoryIndex = CharacterCustomization.GetAccessoryIndex(GameHandler.GetService().GetPlayerData(owner)); CustomizationOption[] accessories = Singleton.Instance.accessories; if (accessories == null || accessoryIndex < 0 || accessoryIndex >= accessories.Length) { objectName = $"invalid accessory index {accessoryIndex}"; return AccessoryEffect.None; } CustomizationOption val = accessories[accessoryIndex]; if (!Object.op_Implicit((Object)(object)val)) { objectName = $"accessory #{accessoryIndex} is unavailable"; return AccessoryEffect.None; } string text = ((Object)val).name ?? string.Empty; string text2 = (Object.op_Implicit((Object)(object)val.texture) ? ((Object)val.texture).name : string.Empty); objectName = $"accessory #{accessoryIndex} '{text}' (texture '{text2}')"; if (ContainsToken(text, "eyepatch") || ContainsToken(text2, "eyepatch")) { return AccessoryEffect.Eyepatch; } if (ContainsToken(text, "glasses_broken") || ContainsToken(text2, "glasses_broken")) { return AccessoryEffect.BrokenGlasses; } if (ContainsToken(text, "aviator")) { return AccessoryEffect.Aviator; } if (ContainsToken(text, "sunglasses")) { return AccessoryEffect.Sunglasses; } return AccessoryEffect.None; } catch (Exception ex) { objectName = "detection error " + ex.GetType().Name + ": " + ex.Message; return AccessoryEffect.None; } } private HatEffect FindHatEffect(out string objectName) { objectName = "hat unavailable"; Character localCharacter = Character.localCharacter; if (!Object.op_Implicit((Object)(object)localCharacter) || !GameHandler.Initialized) { return HatEffect.None; } try { Player owner = ((MonoBehaviourPun)localCharacter).photonView.Owner; int currentHat = GameHandler.GetService().GetPlayerData(owner).customizationData.currentHat; CustomizationOption[] hats = Singleton.Instance.hats; if (hats == null || currentHat < 0 || currentHat >= hats.Length) { objectName = $"invalid hat index {currentHat}"; return HatEffect.None; } CustomizationOption val = hats[currentHat]; if (!Object.op_Implicit((Object)(object)val)) { objectName = $"hat #{currentHat} is unavailable"; return HatEffect.None; } string text = ((Object)val).name ?? string.Empty; string text2 = (Object.op_Implicit((Object)(object)val.texture) ? ((Object)val.texture).name : string.Empty); objectName = $"hat #{currentHat} '{text}' (texture '{text2}')"; if (ContainsToken(text, "plaguedoctor") || ContainsToken(text2, "plaguedoctor")) { return HatEffect.PlagueDoctor; } if (ContainsToken(text, "astronaut") || ContainsToken(text2, "astronaut")) { return HatEffect.Astronaut; } if (ContainsToken(text, "racinghelmet") || ContainsToken(text2, "racinghelmet") || ContainsToken(text2, "speedhelmet")) { return HatEffect.RacingHelmet; } if (ContainsToken(text, "pumpkin") || ContainsToken(text2, "pumpkin")) { return HatEffect.Pumpkin; } if (ContainsToken(text, "sleepyguy") || ContainsToken(text2, "sleepyguy")) { return HatEffect.SleepyGuy; } return HatEffect.None; } catch (Exception ex) { objectName = "hat detection error " + ex.GetType().Name + ": " + ex.Message; return HatEffect.None; } } private EyeEffect FindEyeEffect(out string objectName) { objectName = "eyes unavailable"; Character localCharacter = Character.localCharacter; if (!Object.op_Implicit((Object)(object)localCharacter) || !GameHandler.Initialized) { return EyeEffect.None; } try { Player owner = ((MonoBehaviourPun)localCharacter).photonView.Owner; int eyesIndex = CharacterCustomization.GetEyesIndex(GameHandler.GetService().GetPlayerData(owner)); CustomizationOption[] eyes = Singleton.Instance.eyes; if (eyes == null || eyesIndex < 0 || eyesIndex >= eyes.Length) { objectName = $"invalid eye index {eyesIndex}"; return EyeEffect.None; } CustomizationOption val = eyes[eyesIndex]; if (!Object.op_Implicit((Object)(object)val)) { objectName = $"eyes #{eyesIndex} are unavailable"; return EyeEffect.None; } string text = ((Object)val).name ?? string.Empty; string text2 = (Object.op_Implicit((Object)(object)val.texture) ? ((Object)val.texture).name : string.Empty); objectName = $"eyes #{eyesIndex} '{text}' (texture '{text2}')"; return (ContainsToken(text, "eyes_cry") || ContainsToken(text2, "eyes_cry")) ? EyeEffect.Crying : EyeEffect.None; } catch (Exception ex) { objectName = "eye detection error " + ex.GetType().Name + ": " + ex.Message; return EyeEffect.None; } } private static bool ContainsToken(string value, string token) { if (!string.IsNullOrEmpty(value)) { return value.IndexOf(token, StringComparison.OrdinalIgnoreCase) >= 0; } return false; } private void OnDestroy() { if ((Object)(object)_overlayCanvas != (Object)null) { Object.Destroy((Object)(object)((Component)_overlayCanvas).gameObject); } if ((Object)(object)_gradientTexture != (Object)null) { Object.Destroy((Object)(object)_gradientTexture); } if ((Object)(object)_crackTexture != (Object)null) { Object.Destroy((Object)(object)_crackTexture); } if ((Object)(object)_pumpkinTexture != (Object)null) { Object.Destroy((Object)(object)_pumpkinTexture); } if ((Object)(object)_sleepyTexture != (Object)null) { Object.Destroy((Object)(object)_sleepyTexture); } if ((Object)(object)_cryingBlurCamera != (Object)null) { _cryingBlurCamera.targetTexture = null; Object.Destroy((Object)(object)((Component)_cryingBlurCamera).gameObject); } if ((Object)(object)_cryingRenderTexture != (Object)null) { _cryingRenderTexture.Release(); Object.Destroy((Object)(object)_cryingRenderTexture); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "FirstPersonCosmetics"; public const string PLUGIN_NAME = "First Person Cosmetics"; public const string PLUGIN_VERSION = "1.0.0"; } }