using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("LaudMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LaudMod")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a3c1d2e4-5b6f-4a7d-9e80-1f2a3b4c5d6e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LaudMod;
[BepInPlugin("com.vikingdmike.musicmod", "MusicMod", "1.1.1")]
public class LaudPlugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(PrefabsDirectory), "Start")]
private static class ParcheDirectorio
{
private static void Prefix(PrefabsDirectory __instance)
{
InsertarTodos(__instance);
}
}
public static Instrumento Laud;
public static Instrumento Flauta;
public static Instrumento Nacaires;
public static Instrumento Zanfona;
public static Instrumento[] Todos = new Instrumento[0];
public static Type TipoAttachable;
public static PropertyInfo PropPosicionColgado;
public static PropertyInfo PropGiroColgado;
private ConfigEntry<KeyCode> teclaLocalizar;
private static ConfigEntry<bool> todoA1;
private static ManualLogSource Log;
private float proximaRevisionPrecios;
private const string islaInicio = "island 21 M (siren song)";
private const string raizInicio = "island 21 M (siren song) scenery";
private void Awake()
{
//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
//IL_04da: Expected O, but got Unknown
//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
//IL_06fa: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Logger.LogInfo((object)"MusicMod cargado correctamente: laud, flauta xiao, nacaires y zanfona");
Instrumento instrumento = new Instrumento();
instrumento.Clave = "laud";
instrumento.NombrePrefab = "laud";
instrumento.NombreObjeto = "lute";
instrumento.Prefijo = "Lute - ";
instrumento.Indice = 20391;
instrumento.Precio = 150;
instrumento.Masa = 2f;
instrumento.AlturaMueble = 0.15f;
instrumento.Sostenido = false;
instrumento.Sonidos = new string[8] { "nota1_do", "nota2_re", "nota3_mi", "nota_fa", "nota4_sol", "nota5_la", "nota_si", "nota_do_alto" };
instrumento.SonidosSuaves = new string[8] { "nota1_do_suave", "nota2_re_suave", "nota3_mi_suave", "nota_fa_suave", "nota4_sol_suave", "nota5_la_suave", "nota_si_suave", "nota_do_alto_suave" };
instrumento.NombresNotas = new string[8] { "C", "D", "E", "F", "G", "A", "B", "HighC" };
Instrumento instrumento2 = instrumento;
KeyCode[] array = new KeyCode[8];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
instrumento2.TeclasDefecto = (KeyCode[])(object)array;
instrumento.DefTocar = new float[6] { 0.44f, -0.38f, 0.125f, 300f, 180f, 0f };
instrumento.DefMano = new float[5] { 0.5f, 0f, 8f, 240f, 90f };
instrumento.DefEscena = "island 21 M (siren song)";
instrumento.DefRaiz = "island 21 M (siren song) scenery";
instrumento.DefTienda = new float[5] { 28.444f, 2.28f, 30f, 25f, 0f };
instrumento.DefColgado = new float[6] { -0.004f, -0.39f, -0.15f, 0f, -90f, 90f };
Laud = instrumento;
instrumento = new Instrumento();
instrumento.Clave = "flauta";
instrumento.NombrePrefab = "flauta";
instrumento.NombreObjeto = "xiao flute";
instrumento.Prefijo = "Flute - ";
instrumento.Indice = 20392;
instrumento.Precio = 80;
instrumento.Masa = 0.5f;
instrumento.AlturaMueble = 0.05f;
instrumento.Sostenido = true;
instrumento.Sonidos = new string[8] { "flauta_nota1_re", "flauta_nota2_mi", "flauta_nota3_fa_sost", "flauta_nota4_sol", "flauta_nota5_la", "flauta_nota6_si", "flauta_nota7_do_sost", "flauta_nota8_re_alto" };
instrumento.NombresNotas = new string[8] { "D", "E", "FSharp", "G", "A", "B", "CSharp", "HighD" };
Instrumento instrumento3 = instrumento;
KeyCode[] array2 = new KeyCode[8];
RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
instrumento3.TeclasDefecto = (KeyCode[])(object)array2;
instrumento.DefTocar = new float[6] { 0.3f, -0.1f, 0f, 270f, 90f, 90f };
instrumento.DefMano = new float[5] { 0.45f, -0.2f, 180f, 0f, 0f };
instrumento.DefEscena = "island 11 E (Crab Beach)";
instrumento.DefRaiz = "island 11 E (crab beach) scenery";
instrumento.DefTienda = new float[5] { 384.554f, 12.714f, -216.758f, 0f, 90f };
instrumento.DefColgado = new float[6] { 0f, -0.1f, -0.1f, 0f, 0f, 0f };
Flauta = instrumento;
instrumento = new Instrumento();
instrumento.Clave = "nacaires";
instrumento.NombrePrefab = "nacaires";
instrumento.NombreObjeto = "nakers";
instrumento.Prefijo = "Nakers - ";
instrumento.Indice = 20393;
instrumento.Precio = 120;
instrumento.Masa = 3f;
instrumento.AlturaMueble = 0.12f;
instrumento.Sostenido = false;
instrumento.Sonidos = new string[4] { "nacaires_golpe1_grande_centro", "nacaires_golpe2_grande_borde", "nacaires_golpe3_pequeno_centro", "nacaires_golpe4_pequeno_borde" };
instrumento.NombresNotas = new string[4] { "BigCenter", "BigEdge", "SmallCenter", "SmallEdge" };
Instrumento instrumento4 = instrumento;
KeyCode[] array3 = new KeyCode[4];
RuntimeHelpers.InitializeArray(array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
instrumento4.TeclasDefecto = (KeyCode[])(object)array3;
instrumento.DefTocar = new float[6] { 0.5f, -0.45f, 0f, 0f, 0f, 0f };
instrumento.DefMano = new float[5] { 0.45f, -0.1f, 0f, 0f, 0f };
instrumento.DefEscena = "island 3 A Neverdin";
instrumento.DefRaiz = "island 3 A (neverdin) scenery";
instrumento.DefTienda = new float[5] { 106.973f, 10.6f, -18.371f, 0f, 0f };
instrumento.Colgable = false;
Nacaires = instrumento;
ConfigFile val = new ConfigFile(Path.Combine(Paths.ConfigPath, "musicmod_interno_no_usado.cfg"), false);
val.SaveOnConfigSet = false;
KeyCode val2 = (KeyCode)0;
instrumento = new Instrumento();
instrumento.Clave = "zanfona";
instrumento.NombrePrefab = "zanfona";
instrumento.NombreObjeto = "hurdy gurdy";
instrumento.Prefijo = "Hurdy Gurdy - ";
instrumento.Indice = 20394;
instrumento.Precio = 200;
instrumento.Masa = 3f;
instrumento.AlturaMueble = 0.12f;
instrumento.Sostenido = true;
instrumento.Colgable = false;
instrumento.Sonidos = new string[10] { "zanfona_nota01_mi", "zanfona_nota02_fa_sost", "zanfona_nota03_sol_sost", "zanfona_nota04_la", "zanfona_nota05_si", "zanfona_nota06_do_sost", "zanfona_nota07_re_sost", "zanfona_nota08_mi", "zanfona_nota09_fa_sost", "zanfona_nota10_sol_sost" };
instrumento.SonidoFondo = "zanfona_bordon";
instrumento.NombresNotas = new string[10] { "E", "FSharp", "GSharp", "A", "B", "CSharp", "DSharp", "HighE", "HighFSharp", "HighGSharp" };
Instrumento instrumento5 = instrumento;
KeyCode[] array4 = new KeyCode[10];
RuntimeHelpers.InitializeArray(array4, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
instrumento5.TeclasDefecto = (KeyCode[])(object)array4;
instrumento.DefTocar = new float[6] { 0.5f, -0.3f, 0.125f, 350f, 180f, 0f };
instrumento.DefMano = new float[5] { 0.5f, 0f, 8f, 240f, 90f };
instrumento.DefEscena = "island 34 M (monastery)";
instrumento.DefRaiz = "_scenery";
instrumento.DefTienda = new float[5] { 420.158f, 4.386f, 391.355f, 0f, 0f };
instrumento.DefColgado = new float[6];
Zanfona = instrumento;
Todos = new Instrumento[4] { Laud, Flauta, Nacaires, Zanfona };
Instrumento[] todos = Todos;
for (int i = 0; i < todos.Length; i++)
{
todos[i].Atar(((BaseUnityPlugin)this).Config, val);
}
teclaLocalizar = val.Bind<KeyCode>("Pruebas", "TeclaLocalizar", val2, "Al pulsarla escribe en el log la isla, la raiz y la posicion del punto al que miras (para colocar tiendas). None = desactivada");
todoA1 = val.Bind<bool>("Pruebas", "PreciosDePrueba", false, "Si esta activado, los instrumentos sin vender cuestan casi nada (para probarlos). Desactivalo para jugar normal");
SceneManager.sceneLoaded += AlCargarEscena;
CargarPaquete();
todos = Todos;
foreach (Instrumento instrumento6 in todos)
{
if ((Object)(object)instrumento6.Prefab != (Object)null)
{
PrepararPrefab(instrumento6);
}
}
Harmony.CreateAndPatchAll(typeof(ParcheDirectorio), "com.vikingdmike.musicmod");
if ((Object)(object)PrefabsDirectory.instance != (Object)null)
{
InsertarTodos(PrefabsDirectory.instance);
AccessTools.Method(typeof(PrefabsDirectory), "PopulateShipItems", (Type[])null, (Type[])null).Invoke(PrefabsDirectory.instance, null);
}
((MonoBehaviour)this).StartCoroutine(Comprobar());
}
private void Update()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
if ((int)teclaLocalizar.Value != 0 && Input.GetKeyDown(teclaLocalizar.Value))
{
Localizar();
}
Instrumento[] todos;
if (Time.time >= proximaRevisionPrecios)
{
proximaRevisionPrecios = Time.time + 1f;
InstrumentoItem[] array = Object.FindObjectsOfType<InstrumentoItem>();
foreach (InstrumentoItem instrumentoItem in array)
{
if (!((ShipItem)instrumentoItem).sold && instrumentoItem.Datos != null)
{
((ShipItem)instrumentoItem).value = Precio(instrumentoItem.Datos);
}
}
todos = Todos;
foreach (Instrumento instrumento in todos)
{
if ((Object)(object)instrumento.Prefab != (Object)null && instrumento.Registrado)
{
ShipItem component = instrumento.Prefab.GetComponent<ShipItem>();
if ((Object)(object)component != (Object)null)
{
component.value = Precio(instrumento);
}
}
}
}
todos = Todos;
foreach (Instrumento ins in todos)
{
MoverPuesto(ins);
}
}
private static int Precio(Instrumento ins)
{
if (!todoA1.Value)
{
return ins.Precio;
}
return 2;
}
private void MoverPuesto(Instrumento ins)
{
//IL_0037: 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_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_0088: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: 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)
if ((Object)(object)ins.Puesto == (Object)null)
{
return;
}
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(ins.TiendaX.Value, ins.TiendaY.Value, ins.TiendaZ.Value);
if (val == ins.UltimaPos && ins.TiendaGiro.Value == ins.UltimoGiro && ins.TiendaInclinacion.Value == ins.UltimaInclinacion)
{
return;
}
Vector3 position = ins.Puesto.transform.position;
ins.Puesto.transform.localPosition = val;
ins.Puesto.transform.localRotation = Quaternion.Euler(ins.TiendaInclinacion.Value, ins.TiendaGiro.Value, 0f);
Vector3 val2 = ins.Puesto.transform.position - position;
InstrumentoItem[] array = Object.FindObjectsOfType<InstrumentoItem>();
foreach (InstrumentoItem instrumentoItem in array)
{
if (instrumentoItem.Datos == ins && !((ShipItem)instrumentoItem).sold && (Object)(object)((PickupableItem)instrumentoItem).held == (Object)null)
{
Vector3 val3 = ((Component)instrumentoItem).transform.position - position;
if (((Vector3)(ref val3)).sqrMagnitude < 4f)
{
Transform transform = ((Component)instrumentoItem).transform;
transform.position += val2;
((Component)instrumentoItem).transform.rotation = ins.Puesto.transform.rotation;
}
}
}
ins.UltimaPos = val;
ins.UltimoGiro = ins.TiendaGiro.Value;
ins.UltimaInclinacion = ins.TiendaInclinacion.Value;
}
private void Localizar()
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: 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_0053: 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_0076: Unknown result type (might be due to invalid IL or missing references)
Camera main = Camera.main;
if (!((Object)(object)main == (Object)null))
{
RaycastHit val = default(RaycastHit);
if (Physics.Raycast(((Component)main).transform.position, ((Component)main).transform.forward, ref val, 20f, -1, (QueryTriggerInteraction)1))
{
Transform root = ((RaycastHit)(ref val)).transform.root;
Vector3 val2 = root.InverseTransformPoint(((RaycastHit)(ref val)).point);
ManualLogSource logger = ((BaseUnityPlugin)this).Logger;
string[] obj = new string[13]
{
"LOCALIZAR: escena '", null, null, null, null, null, null, null, null, null,
null, null, null
};
Scene scene = ((Component)root).gameObject.scene;
obj[1] = ((Scene)(ref scene)).name;
obj[2] = "', raiz '";
obj[3] = ((Object)root).name;
obj[4] = "', objeto '";
obj[5] = ((Object)((RaycastHit)(ref val)).transform).name;
obj[6] = "', punto respecto a la raiz (";
obj[7] = val2.x.ToString("F3");
obj[8] = ", ";
obj[9] = val2.y.ToString("F3");
obj[10] = ", ";
obj[11] = val2.z.ToString("F3");
obj[12] = ")";
logger.LogInfo((object)string.Concat(obj));
}
else
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"LOCALIZAR: no estas mirando a nada cercano");
}
}
}
private void AlCargarEscena(Scene escena, LoadSceneMode modo)
{
Instrumento[] todos = Todos;
foreach (Instrumento instrumento in todos)
{
if (((Scene)(ref escena)).name == instrumento.TiendaEscena.Value)
{
((MonoBehaviour)this).StartCoroutine(PonerEnTienda(instrumento));
}
}
}
private void CargarPaquete()
{
string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "laud_bundle");
if (!File.Exists(text))
{
((BaseUnityPlugin)this).Logger.LogError((object)("No encuentro laud_bundle en: " + text));
return;
}
AssetBundle val = AssetBundle.LoadFromFile(text);
if ((Object)(object)val == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"No he podido abrir laud_bundle");
return;
}
Instrumento[] todos = Todos;
foreach (Instrumento instrumento in todos)
{
instrumento.Prefab = val.LoadAsset<GameObject>(instrumento.NombrePrefab);
if ((Object)(object)instrumento.Prefab == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)("No encuentro el prefab '" + instrumento.NombrePrefab + "' dentro del paquete"));
continue;
}
instrumento.Clips = (AudioClip[])(object)new AudioClip[instrumento.Sonidos.Length];
int num = 0;
for (int j = 0; j < instrumento.Sonidos.Length; j++)
{
instrumento.Clips[j] = val.LoadAsset<AudioClip>(instrumento.Sonidos[j]);
if ((Object)(object)instrumento.Clips[j] == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("Falta el sonido '" + instrumento.Sonidos[j] + "'"));
}
else
{
num++;
}
}
((BaseUnityPlugin)this).Logger.LogInfo((object)(instrumento.Clave + ": sonidos cargados " + num + " de " + instrumento.Sonidos.Length));
if (instrumento.SonidosSuaves != null)
{
instrumento.ClipsSuaves = (AudioClip[])(object)new AudioClip[instrumento.SonidosSuaves.Length];
int num2 = 0;
for (int k = 0; k < instrumento.SonidosSuaves.Length; k++)
{
instrumento.ClipsSuaves[k] = val.LoadAsset<AudioClip>(instrumento.SonidosSuaves[k]);
if ((Object)(object)instrumento.ClipsSuaves[k] != (Object)null)
{
num2++;
}
}
((BaseUnityPlugin)this).Logger.LogInfo((object)(instrumento.Clave + ": sonidos suaves cargados " + num2 + " de " + instrumento.SonidosSuaves.Length));
}
if (instrumento.SonidoFondo != null)
{
instrumento.ClipFondo = val.LoadAsset<AudioClip>(instrumento.SonidoFondo);
((BaseUnityPlugin)this).Logger.LogInfo((object)(instrumento.Clave + ": sonido de fondo " + (((Object)(object)instrumento.ClipFondo != (Object)null) ? "cargado" : ("NO encontrado (" + instrumento.SonidoFondo + ")"))));
}
}
}
private IEnumerator Comprobar()
{
while ((Object)(object)PrefabsDirectory.instance == (Object)null)
{
yield return (object)new WaitForSeconds(1f);
}
RegistrarColgado();
Instrumento[] todos = Todos;
foreach (Instrumento instrumento in todos)
{
if (instrumento.Registrado)
{
Scene sceneByName = SceneManager.GetSceneByName(instrumento.TiendaEscena.Value);
if (((Scene)(ref sceneByName)).isLoaded)
{
((MonoBehaviour)this).StartCoroutine(PonerEnTienda(instrumento));
}
}
}
while (GameState.currentlyLoading || GameState.justStarted || !GameState.playing)
{
yield return (object)new WaitForSeconds(1f);
}
yield return (object)new WaitForSeconds(5f);
todos = Todos;
foreach (Instrumento instrumento2 in todos)
{
if (instrumento2.Registrado && (PrefabsDirectory.instance.directory.Length <= instrumento2.Indice || (Object)(object)PrefabsDirectory.instance.directory[instrumento2.Indice] != (Object)(object)instrumento2.Prefab))
{
((BaseUnityPlugin)this).Logger.LogError((object)("AVISO: otro mod ha pisado la posicion " + instrumento2.Indice + " (" + instrumento2.Clave + ")"));
}
}
}
private void PrepararPrefab(Instrumento ins)
{
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
GameObject prefab = ins.Prefab;
AudioSource obj = prefab.AddComponent<AudioSource>();
obj.playOnAwake = false;
obj.loop = ins.Sostenido;
obj.spatialBlend = 1f;
obj.rolloffMode = (AudioRolloffMode)0;
obj.minDistance = 2f;
obj.maxDistance = 60f;
InstrumentoItem instrumentoItem = ((ins == Flauta) ? prefab.AddComponent<FlautaItem>() : ((ins == Nacaires) ? prefab.AddComponent<NacairesItem>() : ((ins != Zanfona) ? ((InstrumentoItem)prefab.AddComponent<LaudItem>()) : ((InstrumentoItem)prefab.AddComponent<ZanfonaItem>()))));
((PickupableItem)instrumentoItem).holdDistance = ins.ManoDistancia.Value;
((PickupableItem)instrumentoItem).furniturePlaceHeight = ins.AlturaMueble;
((ShipItem)instrumentoItem).mass = ins.Masa;
((ShipItem)instrumentoItem).value = Precio(ins);
((ShipItem)instrumentoItem).name = ins.NombreObjeto;
((ShipItem)instrumentoItem).category = (TransactionCategory)3;
((ShipItem)instrumentoItem).inventoryScale = 1f;
((ShipItem)instrumentoItem).floaterHeight = 1.6f;
((GoPointerButton)instrumentoItem).allowPlacingItems = true;
((PickupableItem)instrumentoItem).big = false;
prefab.AddComponent<SaveablePrefab>().prefabIndex = ins.Indice;
}
private static void InsertarTodos(PrefabsDirectory directorio)
{
Instrumento[] todos = Todos;
foreach (Instrumento instrumento in todos)
{
if ((Object)(object)instrumento.Prefab != (Object)null)
{
Insertar(directorio, instrumento);
}
}
}
private static void Insertar(PrefabsDirectory directorio, Instrumento ins)
{
int indice = ins.Indice;
if (indice < directorio.directory.Length && (Object)(object)directorio.directory[indice] != (Object)null)
{
if ((Object)(object)directorio.directory[indice] != (Object)(object)ins.Prefab)
{
Log.LogError((object)("La posicion " + indice + " ya esta ocupada por otro objeto: no registro " + ins.Clave + " para no pisarlo"));
}
}
else
{
GameObject[] array = (GameObject[])(object)new GameObject[Mathf.Max(directorio.directory.Length, indice + 1)];
directorio.directory.CopyTo(array, 0);
array[indice] = ins.Prefab;
directorio.directory = array;
ins.Registrado = true;
Log.LogInfo((object)(ins.Clave + " registrado en la posicion " + indice));
}
}
private void RegistrarColgado()
{
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
try
{
Type type = null;
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
for (int i = 0; i < assemblies.Length; i++)
{
type = assemblies[i].GetType("HooksHangMore.HHM_Plugin");
if (type != null)
{
break;
}
}
if (type == null)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"COLGAR: HooksHangMore no esta instalado, los instrumentos no se podran colgar");
return;
}
assemblies = AppDomain.CurrentDomain.GetAssemblies();
for (int i = 0; i < assemblies.Length; i++)
{
TipoAttachable = assemblies[i].GetType("HooksHangMore.AttachableItem");
if (TipoAttachable != null)
{
break;
}
}
if (TipoAttachable != null)
{
PropPosicionColgado = TipoAttachable.GetProperty("PositionOffset", BindingFlags.Instance | BindingFlags.Public);
PropGiroColgado = TipoAttachable.GetProperty("RotationOffset", BindingFlags.Instance | BindingFlags.Public);
}
MethodInfo method = type.GetMethod("AddAttachedOffset", BindingFlags.Static | BindingFlags.Public);
if (method == null)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"COLGAR: esta version de HooksHangMore no tiene AddAttachedOffset");
return;
}
Instrumento[] todos = Todos;
Vector3 val = default(Vector3);
Vector3 val2 = default(Vector3);
foreach (Instrumento instrumento in todos)
{
if (instrumento.Registrado && instrumento.Colgable)
{
((Vector3)(ref val))..ctor(instrumento.ColgPosX.Value, instrumento.ColgPosY.Value, instrumento.ColgPosZ.Value);
((Vector3)(ref val2))..ctor(instrumento.ColgRotX.Value, instrumento.ColgRotY.Value, instrumento.ColgRotZ.Value);
object obj = method.Invoke(null, new object[3] { instrumento.NombreObjeto, val, val2 });
((BaseUnityPlugin)this).Logger.LogInfo((object)("COLGAR: AddAttachedOffset('" + instrumento.NombreObjeto + "') -> " + obj));
}
}
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("COLGAR: no se pudo registrar el colgado: " + ex.Message));
}
}
private IEnumerator PonerEnTienda(Instrumento ins)
{
while (!ins.Registrado)
{
yield return (object)new WaitForSeconds(1f);
}
GameObject raiz = null;
for (int i = 0; i < 30; i++)
{
Scene sceneByName = SceneManager.GetSceneByName(ins.TiendaEscena.Value);
if (((Scene)(ref sceneByName)).isLoaded)
{
GameObject[] rootGameObjects = ((Scene)(ref sceneByName)).GetRootGameObjects();
foreach (GameObject val in rootGameObjects)
{
if (((Object)val).name == ins.TiendaRaiz.Value)
{
raiz = val;
break;
}
}
}
if ((Object)(object)raiz == (Object)null)
{
raiz = GameObject.Find(ins.TiendaRaiz.Value);
if ((Object)(object)raiz != (Object)null)
{
Scene scene = raiz.scene;
if (((Scene)(ref scene)).name != ins.TiendaEscena.Value && ((Scene)(ref sceneByName)).isLoaded)
{
raiz = null;
}
}
}
if ((Object)(object)raiz != (Object)null)
{
break;
}
yield return (object)new WaitForSeconds(1f);
}
if ((Object)(object)raiz == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)("TIENDA: no encuentro " + ins.TiendaRaiz.Value));
yield break;
}
string text = ins.Clave + " spawner";
if (!((Object)(object)raiz.transform.Find(text) != (Object)null))
{
GameObject val2 = new GameObject(text);
val2.transform.parent = raiz.transform;
val2.transform.localPosition = new Vector3(ins.TiendaX.Value, ins.TiendaY.Value, ins.TiendaZ.Value);
val2.transform.localRotation = Quaternion.Euler(ins.TiendaInclinacion.Value, ins.TiendaGiro.Value, 0f);
ins.Puesto = val2;
ins.UltimaPos = val2.transform.localPosition;
ins.UltimoGiro = ins.TiendaGiro.Value;
ins.UltimaInclinacion = ins.TiendaInclinacion.Value;
val2.AddComponent<MeshFilter>().sharedMesh = ins.Prefab.GetComponent<MeshFilter>().sharedMesh;
val2.AddComponent<MeshRenderer>();
val2.AddComponent<ShopItemSpawner>().itemPrefab = ins.Prefab;
((BaseUnityPlugin)this).Logger.LogInfo((object)("TIENDA: spawner de " + ins.Clave + " creado en " + ins.TiendaRaiz.Value));
}
}
}
[DefaultExecutionOrder(1000)]
public class LaudItem : InstrumentoItem
{
public override Instrumento Datos => LaudPlugin.Laud;
}
public class Instrumento
{
public string Clave;
public string NombrePrefab;
public string NombreObjeto;
public string Prefijo;
public int Indice;
public int Precio;
public float Masa;
public float AlturaMueble;
public bool Sostenido;
public bool Colgable = true;
public string[] Sonidos;
public string[] SonidosSuaves;
public string SonidoFondo;
public string[] NombresNotas;
public KeyCode[] TeclasDefecto;
public float[] DefTocar;
public float[] DefMano;
public string DefEscena;
public string DefRaiz;
public float[] DefTienda;
public float[] DefColgado;
public ConfigEntry<KeyCode>[] Teclas;
public ConfigEntry<float> Volumen;
public ConfigEntry<float> VolumenFondo;
public ConfigEntry<float> TocarDistancia;
public ConfigEntry<float> TocarAltura;
public ConfigEntry<float> TocarLateral;
public ConfigEntry<float> TocarGiroX;
public ConfigEntry<float> TocarGiroY;
public ConfigEntry<float> TocarGiroZ;
public ConfigEntry<float> ManoDistancia;
public ConfigEntry<float> ManoAltura;
public ConfigEntry<float> ReposoGiroX;
public ConfigEntry<float> ReposoGiroY;
public ConfigEntry<float> ReposoGiroZ;
public ConfigEntry<string> TiendaEscena;
public ConfigEntry<string> TiendaRaiz;
public ConfigEntry<float> TiendaX;
public ConfigEntry<float> TiendaY;
public ConfigEntry<float> TiendaZ;
public ConfigEntry<float> TiendaGiro;
public ConfigEntry<float> TiendaInclinacion;
public ConfigEntry<float> ColgPosX;
public ConfigEntry<float> ColgPosY;
public ConfigEntry<float> ColgPosZ;
public ConfigEntry<float> ColgRotX;
public ConfigEntry<float> ColgRotY;
public ConfigEntry<float> ColgRotZ;
public AudioClip[] Clips = (AudioClip[])(object)new AudioClip[0];
public AudioClip ClipFondo;
public AudioClip[] ClipsSuaves = (AudioClip[])(object)new AudioClip[0];
public GameObject Prefab;
public bool Registrado;
public GameObject Puesto;
public Vector3 UltimaPos;
public float UltimoGiro;
public float UltimaInclinacion;
private string Sec(string seccion)
{
return Prefijo + seccion;
}
public void Atar(ConfigFile publico, ConfigFile interno)
{
Teclas = new ConfigEntry<KeyCode>[Sonidos.Length];
for (int i = 0; i < Sonidos.Length; i++)
{
Teclas[i] = publico.Bind<KeyCode>(Sec("Keys"), "Note" + (i + 1) + "_" + NombresNotas[i], TeclasDefecto[i], "Key for note " + (i + 1) + " (" + NombresNotas[i] + "). Examples: Alpha6, Y, Z, Keypad1, F5");
}
Volumen = publico.Bind<float>(Sec("Sound"), "Volume", 1f, "Volume (0 to 1)");
if (SonidoFondo != null)
{
VolumenFondo = publico.Bind<float>(Sec("Sound"), "DroneVolume", 0.6f, "Volume of the drone that plays in the background while you play (0 to 1)");
}
TocarDistancia = interno.Bind<float>(Sec("Posicion al tocar"), "Distancia", DefTocar[0], "Distancia a la camara en modo tocar");
TocarAltura = interno.Bind<float>(Sec("Posicion al tocar"), "Altura", DefTocar[1], "Altura respecto a la posicion normal en modo tocar");
TocarLateral = interno.Bind<float>(Sec("Posicion al tocar"), "Lateral", DefTocar[2], "Desplazamiento a la derecha (negativo = izquierda)");
TocarGiroX = interno.Bind<float>(Sec("Posicion al tocar"), "GiroX", DefTocar[3], "Giro en grados, eje X");
TocarGiroY = interno.Bind<float>(Sec("Posicion al tocar"), "GiroY", DefTocar[4], "Giro en grados, eje Y");
TocarGiroZ = interno.Bind<float>(Sec("Posicion al tocar"), "GiroZ", DefTocar[5], "Giro en grados, eje Z");
ManoDistancia = interno.Bind<float>(Sec("Posicion en la mano"), "Distancia", DefMano[0], "Distancia a la camara al llevarlo en la mano (menor = mas cerca de ti)");
ManoAltura = interno.Bind<float>(Sec("Posicion en la mano"), "Altura", DefMano[1], "Altura respecto a la posicion normal al llevarlo en la mano");
ReposoGiroX = interno.Bind<float>(Sec("Posicion en la mano"), "GiroX", DefMano[2], "Giro en grados al llevarlo en la mano, eje X");
ReposoGiroY = interno.Bind<float>(Sec("Posicion en la mano"), "GiroY", DefMano[3], "Giro en grados al llevarlo en la mano, eje Y");
ReposoGiroZ = interno.Bind<float>(Sec("Posicion en la mano"), "GiroZ", DefMano[4], "Giro en grados al llevarlo en la mano, eje Z");
TiendaEscena = interno.Bind<string>(Sec("Tienda"), "Escena", DefEscena, "Escena (isla) de la tienda. Se aplica al reiniciar el juego");
TiendaRaiz = interno.Bind<string>(Sec("Tienda"), "Raiz", DefRaiz, "Objeto raiz de la isla donde se coloca. Se aplica al reiniciar el juego");
TiendaX = interno.Bind<float>(Sec("Tienda"), "PosicionX", DefTienda[0], "Posicion X en la tienda");
TiendaY = interno.Bind<float>(Sec("Tienda"), "PosicionY", DefTienda[1], "Posicion Y en la tienda");
TiendaZ = interno.Bind<float>(Sec("Tienda"), "PosicionZ", DefTienda[2], "Posicion Z en la tienda");
TiendaGiro = interno.Bind<float>(Sec("Tienda"), "Giro", DefTienda[3], "Giro en la tienda, en grados");
TiendaInclinacion = interno.Bind<float>(Sec("Tienda"), "Inclinacion", DefTienda[4], "Inclinacion en la tienda, en grados (90 = tumbado)");
if (Colgable)
{
ColgPosX = interno.Bind<float>(Sec("Colgar en gancho"), "PosicionX", DefColgado[0], "Desplazamiento X respecto al gancho (mod HooksHangMore)");
ColgPosY = interno.Bind<float>(Sec("Colgar en gancho"), "PosicionY", DefColgado[1], "Desplazamiento Y respecto al gancho");
ColgPosZ = interno.Bind<float>(Sec("Colgar en gancho"), "PosicionZ", DefColgado[2], "Desplazamiento Z respecto al gancho");
ColgRotX = interno.Bind<float>(Sec("Colgar en gancho"), "GiroX", DefColgado[3], "Giro en grados, eje X");
ColgRotY = interno.Bind<float>(Sec("Colgar en gancho"), "GiroY", DefColgado[4], "Giro en grados, eje Y");
ColgRotZ = interno.Bind<float>(Sec("Colgar en gancho"), "GiroZ", DefColgado[5], "Giro en grados, eje Z");
}
}
}
public abstract class InstrumentoItem : ShipItem
{
private const float velocidadCambio = 4f;
protected AudioSource fuente;
protected bool tocando;
private bool pulsadoEsteFotograma;
private bool pulsadoAntes;
private bool botonLiberado = true;
private float mezcla;
private Component colgable;
public abstract Instrumento Datos { get; }
public override void OnLoad()
{
fuente = ((Component)this).GetComponent<AudioSource>();
Debug.Log((object)(((object)this).GetType().Name + " cargado. AudioSource encontrado: " + ((Object)(object)fuente != (Object)null)));
}
public override void OnBuy()
{
botonLiberado = false;
}
public override void OnAltHeld()
{
pulsadoEsteFotograma = true;
}
public override void ExtraLateUpdate()
{
//IL_0281: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_0310: Unknown result type (might be due to invalid IL or missing references)
//IL_0316: Unknown result type (might be due to invalid IL or missing references)
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
Instrumento datos = Datos;
if (datos == null)
{
return;
}
bool flag = pulsadoEsteFotograma;
pulsadoEsteFotograma = false;
bool flag2 = flag && !pulsadoAntes;
pulsadoAntes = flag;
if (!flag)
{
botonLiberado = true;
}
if (datos.Colgable && LaudPlugin.TipoAttachable != null && LaudPlugin.PropPosicionColgado != null && LaudPlugin.PropGiroColgado != null)
{
if ((Object)(object)colgable == (Object)null)
{
colgable = ((Component)this).GetComponent(LaudPlugin.TipoAttachable);
}
if ((Object)(object)colgable != (Object)null)
{
LaudPlugin.PropPosicionColgado.SetValue(colgable, (object)new Vector3(datos.ColgPosX.Value, datos.ColgPosY.Value, datos.ColgPosZ.Value), null);
LaudPlugin.PropGiroColgado.SetValue(colgable, (object)new Vector3(datos.ColgRotX.Value, datos.ColgRotY.Value, datos.ColgRotZ.Value), null);
}
}
if ((Object)(object)((PickupableItem)this).held == (Object)null)
{
tocando = false;
mezcla = 0f;
((PickupableItem)this).holdDistance = datos.ManoDistancia.Value;
((PickupableItem)this).holdHeight = datos.ManoAltura.Value;
((PickupableItem)this).heldRotationOffset = 0f;
LeerTeclas(activo: false);
return;
}
if (flag2 && base.sold && botonLiberado)
{
tocando = !tocando;
Debug.Log((object)(((object)this).GetType().Name + ": modo tocar " + (tocando ? "activado" : "desactivado")));
}
LeerTeclas(tocando);
mezcla = Mathf.MoveTowards(mezcla, tocando ? 1f : 0f, Time.deltaTime * 4f);
float num = mezcla * mezcla * (3f - 2f * mezcla);
((PickupableItem)this).holdDistance = Mathf.Lerp(datos.ManoDistancia.Value, datos.TocarDistancia.Value, num);
((PickupableItem)this).holdHeight = Mathf.Lerp(datos.ManoAltura.Value, datos.TocarAltura.Value, num);
Vector3 val = new Vector3(datos.ReposoGiroX.Value, datos.ReposoGiroY.Value, datos.ReposoGiroZ.Value);
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor(datos.TocarGiroX.Value, datos.TocarGiroY.Value, datos.TocarGiroZ.Value);
Vector3 val3 = Vector3.Lerp(val, val2, num);
if (((Vector3)(ref val3)).sqrMagnitude > 0.0001f)
{
((Component)this).transform.Rotate(val3, (Space)1);
}
Camera main = Camera.main;
if ((Object)(object)main != (Object)null && num > 0.001f)
{
Transform transform = ((Component)this).transform;
transform.position += ((Component)main).transform.right * datos.TocarLateral.Value * num;
}
}
protected virtual void LeerTeclas(bool activo)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
if (!activo)
{
return;
}
Instrumento datos = Datos;
for (int i = 0; i < datos.Teclas.Length; i++)
{
if (datos.Teclas[i] != null && Input.GetKeyDown(datos.Teclas[i].Value))
{
Golpe(i);
}
}
}
protected void Golpe(int nota)
{
Instrumento datos = Datos;
if (datos.Clips == null || nota >= datos.Clips.Length || (Object)(object)datos.Clips[nota] == (Object)null)
{
return;
}
if ((Object)(object)fuente == (Object)null)
{
fuente = ((Component)this).GetComponent<AudioSource>();
}
if (!((Object)(object)fuente == (Object)null))
{
AudioClip val = datos.Clips[nota];
float num;
if (datos.ClipsSuaves != null && nota < datos.ClipsSuaves.Length && (Object)(object)datos.ClipsSuaves[nota] != (Object)null && Random.value < 0.45f)
{
val = datos.ClipsSuaves[nota];
num = Random.Range(0.6f, 0.85f);
}
else
{
num = Random.Range(0.8f, 1f);
}
fuente.PlayOneShot(val, datos.Volumen.Value * num);
}
}
}
[DefaultExecutionOrder(1000)]
public class NacairesItem : InstrumentoItem
{
public override Instrumento Datos => LaudPlugin.Nacaires;
}
public class RampaVolumen : MonoBehaviour
{
[NonSerialized]
public volatile float objetivo;
private volatile float actual;
public float Actual => actual;
private void OnAudioFilterRead(float[] datos, int canales)
{
float num = objetivo;
int num2 = ((canales > 0) ? (datos.Length / canales) : 0);
if (num2 <= 0)
{
return;
}
float num3 = actual;
float num4 = (num - num3) / (float)num2;
for (int i = 0; i < num2; i++)
{
num3 += num4;
int num5 = i * canales;
for (int j = 0; j < canales; j++)
{
datos[num5 + j] *= num3;
}
}
actual = num;
}
public static AudioSource CrearVoz(GameObject padre, AudioSource modelo, string nombre, out RampaVolumen rampa)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject(nombre);
val.transform.SetParent(padre.transform, false);
AudioSource val2 = val.AddComponent<AudioSource>();
val2.playOnAwake = false;
val2.loop = true;
val2.volume = 1f;
if ((Object)(object)modelo != (Object)null)
{
val2.spatialBlend = modelo.spatialBlend;
val2.rolloffMode = modelo.rolloffMode;
val2.minDistance = modelo.minDistance;
val2.maxDistance = modelo.maxDistance;
val2.outputAudioMixerGroup = modelo.outputAudioMixerGroup;
}
rampa = val.AddComponent<RampaVolumen>();
rampa.objetivo = 0f;
return val2;
}
}
[DefaultExecutionOrder(1000)]
public class FlautaItem : InstrumentoItem
{
private const int numFuentes = 6;
private const float subida = 12f;
private const float bajada = 7f;
private const float cruce = 16f;
private const float salida = 6f;
private const float tiempoDeslizar = 0.06f;
private static readonly int[] semitonos = new int[10] { 0, 2, 4, 5, 7, 9, 11, 12, 14, 16 };
private AudioSource[] fuentes;
private RampaVolumen[] rampas;
private readonly float[] vols = new float[6];
private int activa;
private int notaActual = -1;
private int notaSonando = -1;
private float deslizar = 0.06f;
private float tonoInicio = 1f;
public override Instrumento Datos => LaudPlugin.Flauta;
private bool PrepararFuentes()
{
if (fuentes != null && (Object)(object)fuentes[0] != (Object)null)
{
return true;
}
AudioSource component = ((Component)this).GetComponent<AudioSource>();
if ((Object)(object)component == (Object)null)
{
return false;
}
fuentes = (AudioSource[])(object)new AudioSource[6];
rampas = new RampaVolumen[6];
for (int i = 0; i < 6; i++)
{
fuentes[i] = RampaVolumen.CrearVoz(((Component)this).gameObject, component, "voz " + i, out rampas[i]);
}
return true;
}
private int FuenteLibre()
{
int num = -1;
float num2 = float.MaxValue;
for (int i = 0; i < 6; i++)
{
if ((i != activa || !(vols[i] > 0.001f)) && vols[i] < num2)
{
num2 = vols[i];
num = i;
}
}
if (num >= 0)
{
return num;
}
return activa;
}
protected override void LeerTeclas(bool activo)
{
//IL_0038: 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_009b: Unknown result type (might be due to invalid IL or missing references)
if (!PrepararFuentes())
{
return;
}
Instrumento datos = Datos;
int num = datos.Teclas.Length;
if (activo)
{
for (int i = 0; i < num; i++)
{
if (datos.Teclas[i] != null && Input.GetKeyDown(datos.Teclas[i].Value))
{
notaActual = i;
}
}
if (notaActual >= 0 && !Input.GetKey(datos.Teclas[notaActual].Value))
{
notaActual = -1;
for (int num2 = num - 1; num2 >= 0; num2--)
{
if (datos.Teclas[num2] != null && Input.GetKey(datos.Teclas[num2].Value))
{
notaActual = num2;
break;
}
}
}
}
else
{
notaActual = -1;
}
bool flag = notaActual >= 0 && notaActual < datos.Clips.Length && (Object)(object)datos.Clips[notaActual] != (Object)null;
if (flag && notaActual != notaSonando)
{
int num3 = notaSonando;
activa = FuenteLibre();
AudioSource val = fuentes[activa];
if ((Object)(object)val.clip != (Object)(object)datos.Clips[notaActual] || !val.isPlaying)
{
val.Stop();
val.clip = datos.Clips[notaActual];
val.loop = true;
vols[activa] = 0f;
rampas[activa].objetivo = 0f;
val.Play();
}
if (num3 >= 0 && num3 < semitonos.Length && notaActual < semitonos.Length)
{
float num4 = Mathf.Clamp((float)(semitonos[num3] - semitonos[notaActual]) * 0.5f, -1.5f, 1.5f);
tonoInicio = Mathf.Pow(2f, num4 / 12f);
deslizar = 0f;
}
else
{
tonoInicio = 1f;
deslizar = 0.06f;
}
val.pitch = tonoInicio;
notaSonando = notaActual;
}
if (!flag)
{
notaSonando = -1;
}
if (deslizar < 0.06f)
{
deslizar += Time.deltaTime;
float num5 = Mathf.Clamp01(deslizar / 0.06f);
num5 = num5 * num5 * (3f - 2f * num5);
fuentes[activa].pitch = Mathf.Lerp(tonoInicio, 1f, num5);
}
else
{
fuentes[activa].pitch = 1f;
}
float num6 = Mathf.Max(datos.Volumen.Value, 0.01f);
bool flag2 = false;
for (int j = 0; j < 6; j++)
{
if (j != activa && vols[j] > 0.001f)
{
flag2 = true;
}
}
for (int k = 0; k < 6; k++)
{
bool flag3 = k == activa;
float num7 = ((flag3 && flag) ? datos.Volumen.Value : 0f);
float num8 = ((!(num7 > vols[k])) ? (flag3 ? 7f : 6f) : (flag2 ? 16f : 12f));
vols[k] = Mathf.MoveTowards(vols[k], num7, Time.deltaTime * num8 * num6);
rampas[k].objetivo = vols[k];
if (vols[k] <= 0.0001f && num7 <= 0f && rampas[k].Actual <= 0.0001f && fuentes[k].isPlaying)
{
fuentes[k].Stop();
fuentes[k].pitch = 1f;
}
}
}
}
[DefaultExecutionOrder(1000)]
public class ZanfonaItem : FlautaItem
{
private const float velocidadFondo = 2.5f;
private const float vueltasPorSegundo = 1.2f;
private AudioSource fondo;
private RampaVolumen rampaFondo;
private float volFondo;
private Transform manivela;
private bool buscadaManivela;
public override Instrumento Datos => LaudPlugin.Zanfona;
protected override void LeerTeclas(bool activo)
{
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
base.LeerTeclas(activo);
Instrumento datos = Datos;
if (datos != null && !((Object)(object)datos.ClipFondo == (Object)null))
{
if ((Object)(object)fondo == (Object)null)
{
fondo = RampaVolumen.CrearVoz(((Component)this).gameObject, ((Component)this).GetComponent<AudioSource>(), "bordon", out rampaFondo);
fondo.clip = datos.ClipFondo;
}
float num = datos.Volumen.Value * ((datos.VolumenFondo != null) ? datos.VolumenFondo.Value : 0.6f);
float num2 = (activo ? num : 0f);
volFondo = Mathf.MoveTowards(volFondo, num2, Time.deltaTime * 2.5f * Mathf.Max(num, 0.01f));
rampaFondo.objetivo = volFondo;
if (volFondo > 0.0001f && !fondo.isPlaying)
{
fondo.Play();
}
else if (volFondo <= 0.0001f && num2 <= 0f && rampaFondo.Actual <= 0.0001f && fondo.isPlaying)
{
fondo.Stop();
}
if (!buscadaManivela)
{
manivela = ((Component)this).transform.Find("manivela");
buscadaManivela = true;
}
if ((Object)(object)manivela != (Object)null && num > 0.0001f)
{
float num3 = volFondo / num;
manivela.Rotate(Vector3.right, 432.00003f * num3 * Time.deltaTime, (Space)1);
}
}
}
}