Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of MonsterCosmetics v1.1.2
plugins/Xuaun.RepoMonstersCosmetics.dll
Decompiled 3 days agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Networking; using Xuaun.RepoMonstersCosmetics.Behaviours; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Xuaun.RepoMonstersCosmetics")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Comportamentos dos cosméticos de monstro: bomba (cresce/encolhe) e bexiga (explode após hits e volta depois de um tempo).")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Repo Monsters Cosmetics Behaviour")] [assembly: AssemblyTitle("Xuaun.RepoMonstersCosmetics")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace RepoMonstersCosmetics { public static class MyPluginInfo { public const string PLUGIN_GUID = "Xuaun.RepoMonstersCosmetics"; public const string PLUGIN_NAME = "Repo Monsters Cosmetics Behaviour"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace Xuaun.RepoMonstersCosmetics { internal static class Config { public static readonly string[] BombAssetIds = new string[2] { "repomonsterscosmetics:btbangbomb", "repomonsterscosmetics:bbbangdynamite" }; public static readonly string[] BalloonAssetIds = new string[1] { "repomonsterscosmetics:btbirthdayboyballoon" }; public static readonly string[] BombAssetNames = new string[2] { "Banger - bomb", "Banger - dynamite" }; public static readonly string[] BalloonAssetNames = new string[1] { "Birthday Boy - balloon" }; public static ConfigEntry<bool> Enabled; public static ConfigEntry<bool> Debug; public static ConfigEntry<float> BombPulseSpeed; public static ConfigEntry<float> BombPulseAmount; public static ConfigEntry<int> BalloonHitsToPop; public static ConfigEntry<int> BalloonDamageToPop; public static ConfigEntry<float> BalloonRespawnTime; public static ConfigEntry<float> BalloonReinflateTime; public static ConfigEntry<bool> BalloonPopParticles; public static readonly string[] SoundBalloonPop = new string[3] { "balloon_pop1.ogg", "balloon_pop2.ogg", "balloon_pop3.ogg" }; public static void Init(ConfigFile cfg) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Expected O, but got Unknown Enabled = cfg.Bind<bool>("General", "BehavioursEnabled", true, "Master switch for all monster-cosmetic behaviours."); Debug = cfg.Bind<bool>("General", "Debug", false, "Log events to the console (verbose). Keep off for normal play."); BombPulseSpeed = cfg.Bind<float>("Bomb & Dynamite", "PulseSpeed", 0.6f, new ConfigDescription("Breathing frequency in cycles per second (not a duration). Lower = slower.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 4f), Array.Empty<object>())); BombPulseAmount = cfg.Bind<float>("Bomb & Dynamite", "PulseStrength", 0.1f, new ConfigDescription("Breathing size change as a ratio (0.10 = grows/shrinks ±10%).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.5f), Array.Empty<object>())); BalloonHitsToPop = cfg.Bind<int>("Balloon", "HitsToPop", 3, new ConfigDescription("Pops when reaching this number of hits (0 = ignore hits, damage only).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), Array.Empty<object>())); BalloonDamageToPop = cfg.Bind<int>("Balloon", "DamageToPop", 60, new ConfigDescription("Pops when reaching this total accumulated damage (0 = ignore damage, hits only). Hits and damage work together: whichever is reached first pops the balloon.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 500), Array.Empty<object>())); BalloonRespawnTime = cfg.Bind<float>("Balloon", "RespawnSeconds", 8f, new ConfigDescription("Seconds until the balloon comes back after popping.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 60f), Array.Empty<object>())); BalloonReinflateTime = cfg.Bind<float>("Balloon", "ReinflateSeconds", 0.6f, new ConfigDescription("Duration in seconds of the inflate animation when it returns.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); BalloonPopParticles = cfg.Bind<bool>("Balloon", "PopParticles", true, new ConfigDescription("Spawn a colored particle burst when the balloon pops (matches the balloon color).", (AcceptableValueBase)null, Array.Empty<object>())); } } internal static class CosmeticUtil { public static bool IsAnyTarget(Cosmetic cosmetic, string[] assetIds, string[] assetNames) { CosmeticAsset val = cosmetic?.cosmeticAsset; if ((Object)(object)val == (Object)null) { return false; } if (!ContainsExact(assetIds, val.assetId) && !ContainsExact(assetNames, val.assetName)) { return ContainsExact(assetNames, ((Object)val).name); } return true; } private static bool ContainsExact(string[] values, string value) { if (values == null || string.IsNullOrWhiteSpace(value)) { return false; } for (int i = 0; i < values.Length; i++) { if (string.Equals(values[i], value, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } } [BepInPlugin("com.xuaun.monstercosmetics", "MonsterCosmetics", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private class Runner : MonoBehaviour { } public const string Guid = "com.xuaun.monstercosmetics"; public const string Name = "MonsterCosmetics"; public const string Version = "1.1.0"; internal static ManualLogSource Log; private void Awake() { //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_0026: Expected O, but got Unknown //IL_0026: 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) Log = ((BaseUnityPlugin)this).Logger; Config.Init(((BaseUnityPlugin)this).Config); GameObject val = new GameObject("RepoMonstersCosmetics_Runner"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; Runner runner = val.AddComponent<Runner>(); SoundManager.Init(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), (MonoBehaviour)(object)runner); new Harmony("com.xuaun.monstercosmetics").PatchAll(Assembly.GetExecutingAssembly()); Log.LogInfo((object)string.Format("{0} {1} loaded. Bomb/dynamite={2} IDs, balloon={3} ID", "MonsterCosmetics", "1.1.0", Config.BombAssetIds.Length, Config.BalloonAssetIds.Length)); } } internal static class PopParticle { private static Shader _shader; private static bool _shaderResolved; public static void Spawn(Vector3 position, Color color) { //IL_003d: 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_0048: 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_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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Expected O, but got Unknown //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) if (!Config.BalloonPopParticles.Value) { return; } Shader val = ResolveShader(); if ((Object)(object)val == (Object)null) { if (Config.Debug.Value) { Plugin.Log.LogWarning((object)"PopParticle: no usable particle shader found, skipping burst."); } return; } GameObject val2 = new GameObject("BalloonPopParticle"); val2.transform.position = position; ParticleSystem val3 = val2.AddComponent<ParticleSystem>(); val3.Stop(true, (ParticleSystemStopBehavior)0); MainModule main = val3.main; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).playOnAwake = false; ((MainModule)(ref main)).duration = 1f; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(0.6f); ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(3f); ((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.06f); ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(1.2f); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(color); ((MainModule)(ref main)).maxParticles = 100; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; EmissionModule emission = val3.emission; ((EmissionModule)(ref emission)).enabled = false; ShapeModule shape = val3.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = 0.08f; ParticleSystemRenderer component = val2.GetComponent<ParticleSystemRenderer>(); component.renderMode = (ParticleSystemRenderMode)0; Material val4 = new Material(val); SetMaterialColor(val4, color); ((Renderer)component).material = val4; val3.Emit(30); Object.Destroy((Object)val2, 0.90000004f); if (Config.Debug.Value) { Plugin.Log.LogInfo((object)$"PopParticle: burst at {position} color {color}"); } } private static Shader ResolveShader() { if (_shaderResolved) { return _shader; } _shaderResolved = true; string[] array = new string[5] { "Particles/Standard Unlit", "Universal Render Pipeline/Particles/Unlit", "Sprites/Default", "Legacy Shaders/Particles/Alpha Blended Premultiply", "Particles/Additive" }; for (int i = 0; i < array.Length; i++) { Shader val = Shader.Find(array[i]); if ((Object)(object)val != (Object)null) { _shader = val; break; } } return _shader; } private static void SetMaterialColor(Material mat, Color color) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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) if (mat.HasProperty("_BaseColor")) { mat.SetColor("_BaseColor", color); } if (mat.HasProperty("_Color")) { mat.SetColor("_Color", color); } if (mat.HasProperty("_TintColor")) { mat.SetColor("_TintColor", color); } mat.color = color; } } internal static class SoundManager { private static readonly Dictionary<string, AudioClip> _clips = new Dictionary<string, AudioClip>(); private static string _soundsDir; private static MonoBehaviour _runner; public static void Init(string pluginDir, MonoBehaviour runner) { _soundsDir = Path.Combine(pluginDir, "sounds"); _runner = runner; if (Config.SoundBalloonPop != null) { string[] soundBalloonPop = Config.SoundBalloonPop; for (int i = 0; i < soundBalloonPop.Length; i++) { Preload(soundBalloonPop[i]); } } } private static AudioType TypeFor(string fileName) { if (fileName.EndsWith(".ogg", StringComparison.OrdinalIgnoreCase)) { return (AudioType)14; } return (AudioType)20; } private static void Preload(string fileName) { if (!string.IsNullOrEmpty(fileName) && !_clips.ContainsKey(fileName)) { _runner.StartCoroutine(LoadClip(fileName)); } } private static IEnumerator LoadClip(string fileName) { string text = Path.Combine(_soundsDir, fileName); if (!File.Exists(text)) { Plugin.Log.LogWarning((object)("Sound file not found: " + text)); yield break; } string absoluteUri = new Uri(text).AbsoluteUri; UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip(absoluteUri, TypeFor(fileName)); try { yield return req.SendWebRequest(); if ((int)req.result != 1) { Plugin.Log.LogWarning((object)("Failed to load " + fileName + ": " + req.error)); yield break; } AudioClip content = DownloadHandlerAudioClip.GetContent(req); if ((Object)(object)content != (Object)null && content.length > 0f) { ((Object)content).name = fileName; _clips[fileName] = content; if (Config.Debug.Value) { Plugin.Log.LogInfo((object)$"Loaded sound: {fileName} ({content.length:0.00}s)"); } } else { Plugin.Log.LogWarning((object)("Empty/invalid clip: " + fileName)); } } finally { ((IDisposable)req)?.Dispose(); } } public static void PlayAt(string fileName, Vector3 position) { //IL_003c: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(fileName)) { return; } if (!_clips.TryGetValue(fileName, out var value) || (Object)(object)value == (Object)null) { Plugin.Log.LogWarning((object)("Sound requested but not loaded: " + fileName)); return; } GameObject val = new GameObject("MonsterCosmeticSound"); val.transform.position = position; AudioSource val2 = val.AddComponent<AudioSource>(); val2.clip = value; val2.spatialBlend = 1f; val2.minDistance = 1f; val2.maxDistance = 25f; val2.rolloffMode = (AudioRolloffMode)1; AudioMixerGroup val3 = (((Object)(object)AudioManager.instance != (Object)null) ? AudioManager.instance.SoundMasterGroup : null); if ((Object)(object)val3 != (Object)null) { val2.outputAudioMixerGroup = val3; } val2.Play(); if (Config.Debug.Value) { Plugin.Log.LogInfo((object)$"Playing monster cosmetic sound: {fileName} at {position}"); } Object.Destroy((Object)val, value.length + 0.2f); } public static void PlayRandomAt(string[] fileNames, Vector3 position) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (fileNames != null && fileNames.Length != 0) { PlayAt((fileNames.Length == 1) ? fileNames[0] : fileNames[Random.Range(0, fileNames.Length)], position); } } } } namespace Xuaun.RepoMonstersCosmetics.Patches { [HarmonyPatch(typeof(PlayerCosmetics))] internal static class ColorMirrorPatch { [HarmonyPostfix] [HarmonyPatch("SetupColorsLogic")] private static void AfterColorsLogic(PlayerCosmetics __instance) { Activate(__instance); } [HarmonyPostfix] [HarmonyPatch("SetupColorsAllLogic")] private static void AfterColorsAll(PlayerCosmetics __instance) { Activate(__instance); } private static void Activate(PlayerCosmetics cosmetics) { if (!((Object)(object)cosmetics == (Object)null)) { BalloonColorMirror[] componentsInChildren = (((Object)(object)cosmetics.playerAvatarVisuals != (Object)null) ? ((Component)cosmetics.playerAvatarVisuals).gameObject : ((Component)cosmetics).gameObject).GetComponentsInChildren<BalloonColorMirror>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].Activate(); } } } } [HarmonyPatch(typeof(Cosmetic), "Setup")] internal static class CosmeticSetupPatch { [HarmonyPostfix] private static void Postfix(Cosmetic __instance) { if ((Object)(object)__instance == (Object)null || __instance.iconCreation || __instance.iconCreationAvatar) { return; } bool num = CosmeticUtil.IsAnyTarget(__instance, Config.BombAssetIds, Config.BombAssetNames); bool flag = CosmeticUtil.IsAnyTarget(__instance, Config.BalloonAssetIds, Config.BalloonAssetNames); if (num && (Object)(object)((Component)__instance).GetComponent<BombPulse>() == (Object)null) { LogTarget("bomb/dynamite", __instance); ((Component)__instance).gameObject.AddComponent<BombPulse>(); } if (flag) { if ((Object)(object)((Component)__instance).GetComponent<BalloonColorMirror>() == (Object)null) { LogTarget("balloon", __instance); ((Component)__instance).gameObject.AddComponent<BalloonColorMirror>(); } if ((Object)(object)((Component)__instance).GetComponent<BalloonPop>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<BalloonPop>(); } } } private static void LogTarget(string kind, Cosmetic cosmetic) { if (Config.Debug.Value) { CosmeticAsset cosmeticAsset = cosmetic.cosmeticAsset; Plugin.Log.LogInfo((object)("Behaviour attached (" + kind + ") on '" + ((Object)((Component)cosmetic).gameObject).name + "' (assetId='" + cosmeticAsset.assetId + "', assetName='" + cosmeticAsset.assetName + "', name='" + ((Object)cosmeticAsset).name + "')")); } } } [HarmonyPatch(typeof(PlayerHealth), "Hurt")] internal static class HurtPatch { [HarmonyPostfix] private static void Postfix(PlayerHealth __instance, int damage) { if (!((Object)(object)__instance == (Object)null) && damage > 0) { PlayerAvatar val = __instance.playerAvatar; if ((Object)(object)val == (Object)null) { val = ((Component)__instance).GetComponent<PlayerAvatar>(); } if ((Object)(object)val == (Object)null) { val = PlayerAvatar.instance; } BalloonRouter.RouteDamage(val, damage); } } } internal static class BalloonRouter { public static void RouteDamage(PlayerAvatar avatar, int damage) { if (!((Object)(object)avatar == (Object)null) && damage > 0) { BalloonPop[] array = null; if ((Object)(object)avatar.playerAvatarVisuals != (Object)null) { array = ((Component)avatar.playerAvatarVisuals).GetComponentsInChildren<BalloonPop>(true); } if (array == null || array.Length == 0) { array = ((Component)avatar).GetComponentsInChildren<BalloonPop>(true); } BalloonPop[] array2 = array; for (int i = 0; i < array2.Length; i++) { array2[i].RegisterDamage(damage); } } } } [HarmonyPatch(typeof(PlayerHealth), "UpdateHealthRPC")] internal static class HurtRemotePatch { [HarmonyPrefix] private static void Prefix(PlayerHealth __instance, out int __state) { __state = (((Object)(object)__instance != (Object)null) ? __instance.health : 0); } [HarmonyPostfix] private static void Postfix(PlayerHealth __instance, int healthNew, bool effect, int __state) { if ((Object)(object)__instance == (Object)null || !effect || __instance.health != healthNew) { return; } int num = __state - healthNew; if (num > 0) { PlayerAvatar val = __instance.playerAvatar; if ((Object)(object)val == (Object)null) { val = ((Component)__instance).GetComponent<PlayerAvatar>(); } BalloonRouter.RouteDamage(val, num); } } } } namespace Xuaun.RepoMonstersCosmetics.Behaviours { public class BalloonColorMirror : MonoBehaviour { private static readonly int AlbedoId = Shader.PropertyToID("_AlbedoColor"); private static readonly int ColorId = Shader.PropertyToID("_Color"); private static readonly int EmissionId = Shader.PropertyToID("_EmissionColor"); private Material _source; private readonly List<Material> _targets = new List<Material>(); private bool _active; private void Start() { Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { Material val2 = (((Object)(object)val != (Object)null) ? val.material : null); if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.shader == (Object)null)) { if (((Object)val2.shader).name.Contains("Hurtable")) { _source = val2; } else { _targets.Add(val2); } } } } public void Activate() { _active = true; Mirror(); } private void LateUpdate() { if (_active) { Mirror(); } } private void Mirror() { //IL_001a: 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_0022: 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) //IL_002e: 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_006f: 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) if ((Object)(object)_source == (Object)null) { return; } Color color = _source.GetColor(AlbedoId); Color val = default(Color); ((Color)(ref val))..ctor(color.r, color.g, color.b, 1f); foreach (Material target in _targets) { if (!((Object)(object)target == (Object)null)) { target.SetColor(ColorId, val); target.SetColor(EmissionId, val * 0.28f); } } } } public class BalloonPop : MonoBehaviour { private readonly List<Renderer> _renderers = new List<Renderer>(); private readonly List<Transform> _meshTransforms = new List<Transform>(); private readonly List<Vector3> _baseScales = new List<Vector3>(); private int _hits; private int _accumulatedDamage; private bool _popped; private void Start() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true); foreach (Renderer item in componentsInChildren) { _renderers.Add(item); } MeshFilter[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val in componentsInChildren2) { _meshTransforms.Add(((Component)val).transform); _baseScales.Add(((Component)val).transform.localScale); } } public void RegisterDamage(int damage) { if (!_popped && Config.Enabled.Value && damage > 0) { _hits++; _accumulatedDamage += damage; int value = Config.BalloonHitsToPop.Value; int value2 = Config.BalloonDamageToPop.Value; bool num = value > 0 && _hits >= value; bool flag = value2 > 0 && _accumulatedDamage >= value2; if (num || flag) { Pop(); } } } private void Pop() { //IL_002f: 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_0042: 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_008f: 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_005e: Unknown result type (might be due to invalid IL or missing references) _popped = true; Vector3 val = ((_meshTransforms.Count > 0 && (Object)(object)_meshTransforms[0] != (Object)null) ? _meshTransforms[0].position : ((Component)this).transform.position); if (Config.Debug.Value) { Plugin.Log.LogInfo((object)$"BalloonPop: popping balloon at {val} (hits={_hits}, damage={_accumulatedDamage})"); } SoundManager.PlayRandomAt(Config.SoundBalloonPop, val); PopParticle.Spawn(val, ReadBalloonColor()); SetVisible(visible: false); ((MonoBehaviour)this).StartCoroutine(RespawnRoutine()); } private IEnumerator RespawnRoutine() { yield return (object)new WaitForSeconds(Config.BalloonRespawnTime.Value); SetVisible(visible: true); float reinflate = Mathf.Max(0.0001f, Config.BalloonReinflateTime.Value); float t = 0f; while (t < reinflate) { t += Time.deltaTime; float num = Mathf.Clamp01(t / reinflate); for (int i = 0; i < _meshTransforms.Count; i++) { if ((Object)(object)_meshTransforms[i] != (Object)null) { _meshTransforms[i].localScale = _baseScales[i] * num; } } yield return null; } for (int j = 0; j < _meshTransforms.Count; j++) { if ((Object)(object)_meshTransforms[j] != (Object)null) { _meshTransforms[j].localScale = _baseScales[j]; } } _hits = 0; _accumulatedDamage = 0; _popped = false; } private void SetVisible(bool visible) { foreach (Renderer renderer in _renderers) { if ((Object)(object)renderer != (Object)null) { renderer.enabled = visible; } } } private Color ReadBalloonColor() { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) foreach (Renderer renderer in _renderers) { Material val = (((Object)(object)renderer != (Object)null) ? renderer.material : null); if (!((Object)(object)val == (Object)null) && !((Object)(object)val.shader == (Object)null) && !((Object)val.shader).name.Contains("Hurtable") && val.HasProperty("_Color")) { Color color = val.GetColor("_Color"); return new Color(color.r, color.g, color.b, 1f); } } return Color.white; } } public class BombPulse : MonoBehaviour { private readonly List<Transform> _t = new List<Transform>(); private readonly List<Vector3> _basePos = new List<Vector3>(); private readonly List<Vector3> _baseScale = new List<Vector3>(); private Vector3 _centroid; private float _phase; private bool _ready; private IEnumerator Start() { yield return (object)new WaitForSeconds(0.6f); MeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<MeshRenderer>(true); foreach (MeshRenderer val in componentsInChildren) { _t.Add(((Component)val).transform); _basePos.Add(((Component)val).transform.localPosition); _baseScale.Add(((Component)val).transform.localScale); } if (_t.Count == 0) { yield break; } Vector3 val2 = Vector3.zero; foreach (Vector3 basePo in _basePos) { val2 += basePo; } _centroid = val2 / (float)_basePos.Count; _phase = Random.Range(0f, MathF.PI * 2f); _ready = true; } private void Update() { //IL_007a: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) if (!_ready || !Config.Enabled.Value) { return; } float num = 1f + Mathf.Sin(Time.time * Config.BombPulseSpeed.Value * MathF.PI * 2f + _phase) * Config.BombPulseAmount.Value; for (int i = 0; i < _t.Count; i++) { if (!((Object)(object)_t[i] == (Object)null)) { _t[i].localScale = _baseScale[i] * num; _t[i].localPosition = _centroid + (_basePos[i] - _centroid) * num; } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }