Decompiled source of ShamanDiveBind v1.1.1

ShamanBindBuff.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GlobalSettings;
using HarmonyLib;
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
using Microsoft.CodeAnalysis;
using ShamanBindBuff.Components;
using ShamanBindBuff.FSMEdits;
using Silksong.FsmUtil;
using TeamCherry.Localization;
using TeamCherry.SharedUtils;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ShamanBindBuff")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1")]
[assembly: AssemblyProduct("Shaman Bind Buff")]
[assembly: AssemblyTitle("ShamanBindBuff")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ShamanBindBuff
{
	[Harmony]
	internal static class ChangeShamanDiveSpeed
	{
		private static ToolItem quickbindTool;

		internal static void GetQuickbindTool(HeroController hc)
		{
			quickbindTool = ToolItemManager.GetToolByName("Quickbind");
		}

		[HarmonyPatch(typeof(HeroController), "GetMaxFallVelocity")]
		[HarmonyPostfix]
		private static void ChangeDiveSpeed(HeroController __instance, ref float __result)
		{
			if (__instance.spellControl.ActiveStateName == "Shaman Fall" && ((ToolBase)quickbindTool).IsEquipped)
			{
				__result *= 2f;
			}
		}
	}
	public static class Extensions
	{
		public static Transform FindIncludeInactive(this Transform self, string path)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			string[] array = path.Split('/');
			Transform val = self;
			string[] array2 = array;
			foreach (string text in array2)
			{
				bool flag = false;
				foreach (Transform item in val)
				{
					Transform val2 = item;
					if (((Object)val2).name == text)
					{
						val = val2;
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					return null;
				}
			}
			return val;
		}

		public static GameObject Duplicate(this GameObject self, bool active)
		{
			//IL_0033: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(self);
			val.SetActive(active);
			val.transform.parent = self.transform.parent;
			val.transform.position = self.transform.position;
			val.transform.rotation = self.transform.rotation;
			val.transform.localScale = self.transform.localScale;
			return val;
		}
	}
	[BepInPlugin("ShamanBindBuff", "Shaman Bind Buff", "1.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[Harmony]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("ShamanBindBuff");
			val.PatchAll();
			Logger.LogInfo((object)"Plugin ShamanBindBuff is loaded!");
		}

		[HarmonyPatch(typeof(PlayMakerFSM), "Start")]
		[HarmonyPostfix]
		private static void FSMEdits(PlayMakerFSM __instance)
		{
			NoDistanceLimit.RemoveDistanceLimitCondition(__instance);
		}

		[HarmonyPatch(typeof(FsmState), "OnEnter")]
		[HarmonyPostfix]
		private static void FSMStateHooksEnter(FsmState __instance)
		{
			DiveEffect.EnableAnimationAndDamager(__instance);
		}

		[HarmonyPatch(typeof(FsmState), "OnExit")]
		[HarmonyPrefix]
		private static void FSMStateHooksExit(FsmState __instance)
		{
			DiveEffect.DisableDamager(__instance);
		}

		[HarmonyPatch(typeof(HeroController), "Start")]
		[HarmonyPostfix]
		private static void OnHeroControllerStart(HeroController __instance)
		{
			ChangeShamanDiveSpeed.GetQuickbindTool(__instance);
			DiveEffect.SetupDive(__instance);
		}

		[HarmonyPatch(typeof(ToolItemManager), "Awake")]
		[HarmonyPostfix]
		private static void OverrideDescription()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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)
			LocalisedString val = default(LocalisedString);
			((LocalisedString)(ref val))..ctor("Mods.ShamanBindBuff", "CREST_SPELL_DESC");
			if (!((LocalisedString)(ref val)).Exists)
			{
				Logger.LogWarning((object)"SpellCrest descriptions could not be replaced as LocalizedString(Mods.ShamanBindBuff, CREST_SPELL_DESC) does not exist. The original descriptions will be used. To replace the descriptions, use the I18N mod. If you are already using the mod then there is a bug here.");
				return;
			}
			Gameplay.SpellCrest.description = val;
			Gameplay.SpellCrest.getPromptDesc = val;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ShamanBindBuff";

		public const string PLUGIN_NAME = "Shaman Bind Buff";

		public const string PLUGIN_VERSION = "1.1.1";
	}
}
namespace ShamanBindBuff.FSMEdits
{
	internal static class DiveEffect
	{
		internal static GameObject DiveBurstFX;

		internal static GameObject DiveBonkFX;

		internal static GameObject BloomFX;

		internal static GameObject Dive;

		internal static GameObject DiveShockwave;

		internal static GameObject DiveContainer;

		internal static ToolItemSkill DiveTool;

		internal static SpriteRenderer DiveBurstSprite;

		internal static tk2dSprite DiveBonkSprite;

		internal static EmissionModule ZapEmission;

		internal static AudioFadeOut ZapFadeOut;

		internal static void EnableAnimationAndDamager(FsmState state)
		{
			//IL_0056: 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_005b: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			if (state.fsm.Name == "Bind" && state.Name == "Shaman Impact")
			{
				Dive.SetActive(true);
				Color color = (((ToolBase)Gameplay.ZapImbuementTool).IsEquipped ? Gameplay.ZapDamageTintColour : Color.white);
				DiveBurstSprite.color = color;
				((tk2dBaseSprite)DiveBonkSprite).color = color;
				DiveBonkFX.SetActive(true);
				DiveBurstFX.SetActive(true);
				if (((ToolBase)Gameplay.ZapImbuementTool).IsEquipped)
				{
					((EmissionModule)(ref ZapEmission)).enabled = true;
					((Component)ZapFadeOut).gameObject.SetActive(true);
				}
				HeroController.instance.parryInvulnTimer = 0.4f;
			}
		}

		internal static void DisableDamager(FsmState state)
		{
			if (state.fsm.Name == "Bind" && state.Name == "Bind Ground" && Dive.activeSelf)
			{
				Dive.SetActive(false);
				DiveShockwave.SetActive(true);
				((EmissionModule)(ref ZapEmission)).enabled = false;
				ZapFadeOut.StartFadeout();
			}
		}

		internal static void SetupDive(HeroController hc)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0079: 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_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Expected O, but got Unknown
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Expected O, but got Unknown
			//IL_0304: 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_04c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04db: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0504: Unknown result type (might be due to invalid IL or missing references)
			//IL_0510: Unknown result type (might be due to invalid IL or missing references)
			//IL_0515: Unknown result type (might be due to invalid IL or missing references)
			//IL_0527: Unknown result type (might be due to invalid IL or missing references)
			//IL_0534: Unknown result type (might be due to invalid IL or missing references)
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_054f: Unknown result type (might be due to invalid IL or missing references)
			//IL_055f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_05de: Unknown result type (might be due to invalid IL or missing references)
			DiveTool = new ToolItemSkill();
			((ToolItem)DiveTool).type = (ToolItemType)3;
			((ToolItem)DiveTool).zapDamageTicks = 1;
			((ToolItem)DiveTool).name = "Shaman Dive";
			DiveContainer = new GameObject("Shaman Dive");
			DiveContainer.transform.parent = hc.transform.Find("Attacks");
			DiveContainer.transform.localPosition = new Vector3(0f, -0.885f, 0f);
			DiveContainer.layer = 17;
			DiveContainer.SetActive(true);
			DiveBurstFX = ((Component)hc.transform.FindIncludeInactive("Special Attacks/Silk Charge DashBurst")).gameObject.Duplicate(active: false);
			((Object)DiveBurstFX).name = "Dive Burst FX";
			DiveBurstFX.transform.localEulerAngles = new Vector3(0f, 0f, 90f);
			DiveBurstFX.transform.localPosition = new Vector3(-0.17f, 5f, 0f);
			DiveBurstFX.transform.GetChild(1).localPosition = new Vector3(0f, 0f, 0.003f);
			DiveBurstFX.transform.GetChild(0).localPosition = new Vector3(-3f, 0f, 0f);
			DiveBurstFX.transform.parent = DiveContainer.transform;
			DiveBonkFX = ((Component)hc.transform.FindIncludeInactive("Special Attacks/Silk Charge WallBonk")).gameObject.Duplicate(active: true);
			((Object)DiveBonkFX).name = "Dive Bonk FX";
			DiveBonkFX.transform.localEulerAngles = new Vector3(0f, 0f, 90f);
			DiveBonkFX.transform.localPosition = new Vector3(0.125f, -0.7f, -0.008f);
			DiveBonkFX.transform.localScale = Vector3.one;
			DiveBonkFX.transform.parent = DiveContainer.transform;
			DiveBonkFX = ((Component)DiveBonkFX.transform.GetChild(0)).gameObject;
			DiveBonkFX.SetActive(false);
			Dive = new GameObject("Dive");
			Dive.transform.parent = DiveContainer.transform;
			Dive.transform.localPosition = Vector3.zero;
			Dive.layer = 17;
			Dive.SetActive(false);
			SetupCollider(Dive.AddComponent<PolygonCollider2D>(), 1f);
			SetupDamager(Dive.AddComponent<DamageEnemies>(), 0.75f);
			DiveShockwave = new GameObject("Shockwave");
			DiveShockwave.transform.parent = DiveContainer.transform;
			DiveShockwave.transform.localPosition = Vector3.zero;
			DiveShockwave.layer = 17;
			DiveShockwave.SetActive(false);
			SetupCollider(DiveShockwave.AddComponent<PolygonCollider2D>(), 1.5f);
			SetupDamager(DiveShockwave.AddComponent<DamageEnemies>(), 2.5f);
			DisableAfterTime val = DiveShockwave.AddComponent<DisableAfterTime>();
			val.waitTime = 0.2f;
			val.isRealtime = false;
			BloomFX = ((Component)hc.transform.FindIncludeInactive("Special Attacks/Silk Charge Damager/Shaman Rune/Shaman Rune Camera Bloom")).gameObject.Duplicate(active: false);
			((Object)BloomFX).name = "Bloom Effect";
			BloomFX.transform.parent = DiveContainer.transform;
			BloomFX.transform.localPosition = new Vector3(1f, 0f, -0.0017f);
			DisableAfterTime val2 = BloomFX.AddComponent<DisableAfterTime>();
			val2.waitTime = 1.25f;
			val2.isRealtime = false;
			SetupRuneEffect(Dive.AddComponent<HeroShamanRuneEffect>(), Dive.GetComponent<DamageEnemies>(), BloomFX, (SpriteRenderer[])(object)new SpriteRenderer[1] { BloomFX.GetComponent<SpriteRenderer>() });
			SetupRuneEffect(DiveShockwave.AddComponent<HeroShamanRuneEffect>(), DiveShockwave.GetComponent<DamageEnemies>());
			DiveBurstSprite = ((Component)DiveBurstFX.transform.FindIncludeInactive("sprint_fall_dash_effect0002")).GetComponent<SpriteRenderer>();
			DiveBonkSprite = DiveBonkFX.GetComponent<tk2dSprite>();
			GameObject val3 = ((Component)hc.transform.FindIncludeInactive("Effects/Silk Charge Particles Zap")).gameObject.Duplicate(active: true);
			((Object)val3).name = "Zap Particles";
			val3.transform.parent = DiveContainer.transform;
			val3.transform.localPosition = new Vector3(0f, -0.57f, 0.056f);
			ParticleSystem component = val3.GetComponent<ParticleSystem>();
			ZapEmission = component.emission;
			((EmissionModule)(ref ZapEmission)).rateOverDistance = MinMaxCurve.op_Implicit(0f);
			((EmissionModule)(ref ZapEmission)).rateOverTime = MinMaxCurve.op_Implicit(100f);
			MainModule main = component.main;
			((MainModule)(ref main)).playOnAwake = true;
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0f);
			MinMaxCurve startSize = ((MainModule)(ref main)).startSize;
			((MinMaxCurve)(ref startSize)).constant = 3.2f;
			MinMaxCurve startSpeed = ((MainModule)(ref main)).startSpeed;
			((MinMaxCurve)(ref startSpeed)).constant = 3f;
			ShapeModule shape = component.shape;
			((ShapeModule)(ref shape)).angle = 0f;
			((ShapeModule)(ref shape)).arc = 180f;
			((ShapeModule)(ref shape)).radius = 2.6f;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)2;
			GameObject val4 = ((Component)hc.transform.FindIncludeInactive("Special Attacks/Sphere Ball/Ball/thread_sphere_effect_zap/Zap Loop")).gameObject.Duplicate(active: false);
			((Object)val4).name = "Zap Loop";
			val4.transform.parent = DiveContainer.transform;
			val4.transform.localPosition = Vector3.zero;
			val4.GetComponent<AudioSource>().pitch = 1.2f;
			ZapFadeOut = val4.AddComponent<AudioFadeOut>();
			ZapFadeOut.FadeSpeedMultiplier = 3f;
		}

		private static void SetupRuneEffect(HeroShamanRuneEffect runeEffect, DamageEnemies damager, GameObject rune = null, SpriteRenderer[] runeSprites = null)
		{
			runeEffect.damager = damager;
			runeEffect.rune = rune;
			runeEffect.zapTintSprites = new List<SpriteRenderer>();
			runeEffect.zapTintParticles = new List<ParticleSystem>();
			if (runeSprites != null)
			{
				runeEffect.zapTintSprites.AddRange(runeSprites);
			}
		}

		private static void SetupDamager(DamageEnemies dmg, float mult)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			//IL_00e6: 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)
			dmg.attackType = (AttackTypes)16;
			dmg.useNailDamage = true;
			dmg.nailDamageMultiplier = mult;
			dmg.damageMultiplier = 1f;
			dmg.representingTool = (ToolItem)(object)DiveTool;
			dmg.slashEffectOverrides = Array.Empty<GameObject>();
			dmg.damageFSMEvent = string.Empty;
			dmg.deathEvent = string.Empty;
			dmg.targetRecordedFSMEvent = string.Empty;
			dmg.contactFSMEvent = string.Empty;
			dmg.dealtDamageFSMEvent = string.Empty;
			dmg.silkGeneration = (HitSilkGeneration)2;
			dmg.specialType = (SpecialTypes)192;
			dmg.corpseDirection = new OverrideFloat();
			dmg.corpseMagnitudeMult = new OverrideFloat();
			dmg.currencyMagnitudeMult = new OverrideFloat();
			dmg.sourceIsHero = false;
			dmg.damageDealt = 15;
			dmg.damageMultPerHit = Array.Empty<float>();
			dmg.ignoreInvuln = false;
			dmg.magnitudeMult = 1.25f;
			dmg.DealtDamage = new UnityEvent();
			dmg.Tinked = new UnityEvent();
			dmg.allowedTinkFlags = (TinkFlags)2;
			dmg.doesNotTink = true;
			dmg.directionSourceOverride = (DirectionSourceOverrides)1;
			dmg.useHeroDamageAffectors = true;
			dmg.hitOnceUntilEnd = true;
		}

		private static void SetupCollider(PolygonCollider2D col, float mult)
		{
			//IL_001d: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0055: 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_0071: 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_008d: 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_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_00af: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: 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)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			((Collider2D)col).isTrigger = true;
			col.points = (Vector2[])(object)new Vector2[9]
			{
				new Vector2(0f, 3.85f) * mult,
				new Vector2(-1.75f, 3.25f) * mult,
				new Vector2(-2.5f, 2.25f) * mult,
				new Vector2(-3f, -1f) * mult,
				new Vector2(-2.5f, -1.5f) * mult,
				new Vector2(2.5f, -1.5f) * mult,
				new Vector2(3f, -1f) * mult,
				new Vector2(2.5f, 2.25f) * mult,
				new Vector2(1.75f, 3.25f) * mult
			};
		}
	}
	internal static class NoDistanceLimit
	{
		internal static void RemoveDistanceLimitCondition(PlayMakerFSM fsm)
		{
			if (!(fsm.FsmName != "Bind"))
			{
				FsmState state = FsmUtil.GetState(fsm, "Shaman Fall");
				FsmStateAction stateAction = FsmUtil.GetStateAction(state, 8);
				FloatTestToBool val = (FloatTestToBool)(object)((stateAction is FloatTestToBool) ? stateAction : null);
				val.greaterThanBool = val.lessThanBool;
			}
		}
	}
}
namespace ShamanBindBuff.Components
{
	internal class AudioFadeOut : MonoBehaviour
	{
		private AudioSource source;

		private float initialVolume;

		private bool isFadingOut = false;

		public bool UseUnscaledTime = false;

		public float FadeSpeedMultiplier = 1f;

		private void Start()
		{
			source = ((Component)this).GetComponent<AudioSource>();
			initialVolume = source.volume;
			isFadingOut = false;
		}

		private void OnEnable()
		{
			source.volume = initialVolume;
			isFadingOut = false;
		}

		private void Update()
		{
			if (isFadingOut)
			{
				float num = (UseUnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime);
				AudioSource obj = source;
				obj.volume -= num * FadeSpeedMultiplier;
				if (source.volume <= 0f)
				{
					source.volume = 0f;
					((Component)this).gameObject.SetActive(false);
				}
			}
		}

		public void StartFadeout()
		{
			source.volume = initialVolume;
			isFadingOut = true;
		}
	}
}