using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using System.Threading; using Bardheim.Assets; using Bardheim.Audio; using Bardheim.Config; using Bardheim.Instruments; using Bardheim.Items; using Bardheim.Network; using Bardheim.Notes; using Bardheim.PlayMode; using Bardheim.Songs; using Bardheim.UI; using Bardheim.Visuals; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("Bardheim")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.7.0.0")] [assembly: AssemblyInformationalVersion("0.7.0+bbb433bb04fd122a08b7d7af9f7876c4021e01ca")] [assembly: AssemblyProduct("Bardheim")] [assembly: AssemblyTitle("Bardheim")] [assembly: AssemblyVersion("0.7.0.0")] [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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 Bardheim { [BepInPlugin("com.valheimmodlab.bardheim", "Bardheim", "0.7.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [DefaultExecutionOrder(-1000)] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.valheimmodlab.bardheim"; public const string PluginName = "Bardheim"; public const string PluginVersion = "0.7.0"; private LyreConfig? _config; private LyreItemRegistration? _lyreItemRegistration; private DrumItemRegistration? _drumItemRegistration; private FluteItemRegistration? _fluteItemRegistration; private LyrePlayMode? _playMode; private LyreInputRouter? _inputRouter; private LocalNotePlayback? _playback; private LocalDrumPlayback? _drumPlayback; private LocalFlutePlayback? _flutePlayback; private RemoteNotePlayback? _remotePlayback; private RemoteDrumPlayback? _remoteDrumPlayback; private RemoteFlutePlayback? _remoteFlutePlayback; private ILyreNetworkNoteEmitter? _noteEmitter; private ValheimRoutedLyreNetwork? _network; private MidiSongController? _songController; private PlayerFeedback? _feedback; private readonly HudVisibilityState _hudVisibility = new HudVisibilityState(); private void Awake() { //IL_0223: Unknown result type (might be due to invalid IL or missing references) _config = LyreConfig.Bind(((BaseUnityPlugin)this).Config); _feedback = new PlayerFeedback(((BaseUnityPlugin)this).Logger); _playMode = new LyrePlayMode(); LyreNoteClipCache clipCache = new LyreNoteClipCache(((BaseUnityPlugin)this).Logger); _playback = new LocalNotePlayback(((BaseUnityPlugin)this).Logger, clipCache); _drumPlayback = new LocalDrumPlayback(((BaseUnityPlugin)this).Logger); _flutePlayback = new LocalFlutePlayback(((BaseUnityPlugin)this).Logger); _remotePlayback = new RemoteNotePlayback(((BaseUnityPlugin)this).Logger, clipCache); _remoteDrumPlayback = new RemoteDrumPlayback(((BaseUnityPlugin)this).Logger); _remoteFlutePlayback = new RemoteFlutePlayback(((BaseUnityPlugin)this).Logger); _network = new ValheimRoutedLyreNetwork(_remotePlayback, _remoteDrumPlayback, _remoteFlutePlayback, ((BaseUnityPlugin)this).Logger, _config.EnableMultiplayerAudio.Value, _config.RemoteNoteVolume.Value, _config.RemoteMaxSimultaneousNotes.Value, _config.RemoteMaxNoteEventsPerSecond.Value, _config.RemoteAudibleDistance.Value); _noteEmitter = _network; _songController = new MidiSongController(PathForSongs(), _playback, _drumPlayback, _flutePlayback, _noteEmitter, _feedback, ((BaseUnityPlugin)this).Logger); _inputRouter = new LyreInputRouter(new NoteSetSelector(NoteSetCatalog.CreateDefaultSets()), _playMode, _playback, _drumPlayback, _flutePlayback, _noteEmitter, _feedback, ((BaseUnityPlugin)this).Logger); _lyreItemRegistration = new LyreItemRegistration(((BaseUnityPlugin)this).Logger); _drumItemRegistration = new DrumItemRegistration(((BaseUnityPlugin)this).Logger); _fluteItemRegistration = new FluteItemRegistration(((BaseUnityPlugin)this).Logger); _inputRouter.RegisterButtons(); _network.RegisterReceiver(); _lyreItemRegistration.Register(); _drumItemRegistration.Register(); _fluteItemRegistration.Register(); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} {1} loaded. Equip the lyre, drum, or flute and press {2} to toggle play mode.", "Bardheim", "0.7.0", _config.PlayModeToggle.Value)); } private void Update() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) _hudVisibility.Update(IsControlHeld(), Input.GetKeyDown((KeyCode)284)); if (_config == null || _playMode == null || _inputRouter == null || _feedback == null || _songController == null) { return; } Player localPlayer = Player.m_localPlayer; string equippedInstrumentId = GetEquippedInstrumentId(localPlayer); bool canPlay = equippedInstrumentId != null; if (_playMode.UpdateEligibility(canPlay)) { _songController.StopIfPlaying(); _feedback.Center("Instrument play mode off."); } KeyboardShortcut value = _config.PlayModeToggle.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { if (_playMode.Toggle(canPlay)) { if (!_playMode.IsActive) { _songController.StopIfPlaying(); } _feedback.Center(_playMode.IsActive ? (GetInstrumentDisplayName(equippedInstrumentId) + " play mode on.") : "Instrument play mode off."); } else { _feedback.Center("Equip the lyre, drum, or flute to play."); } } _inputRouter.Update(localPlayer, equippedInstrumentId, _config.MaxSimultaneousNotes.Value, _config.NoteVolume.Value); if (_playMode.IsActive && localPlayer != null) { _songController.Update(localPlayer, equippedInstrumentId, _config.MaxSimultaneousMidiNotes.Value, _config.MaxFluteMidiNotesPerSecond.Value, _config.NoteVolume.Value); } LyrePlayModeVisualPose.UpdateCalibration(_config.EnablePlayPoseCalibration.Value, ((BaseUnityPlugin)this).Logger); DrumPlayModeVisualPose.UpdateCalibration(_config.EnablePlayPoseCalibration.Value, equippedInstrumentId, ((BaseUnityPlugin)this).Logger); FlutePlayModeVisualPose.UpdateCalibration(_config.EnablePlayPoseCalibration.Value, equippedInstrumentId, ((BaseUnityPlugin)this).Logger); } private void OnGUI() { MidiSongController? songController = _songController; if (songController != null) { LyrePlayMode? playMode = _playMode; songController.DrawHud(playMode != null && playMode.IsActive && !_hudVisibility.IsHidden); } } private static bool IsControlHeld() { return Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305); } private static string? GetEquippedInstrumentId(Player? player) { object obj; if (player == null) { obj = null; } else { Inventory inventory = ((Humanoid)player).GetInventory(); obj = ((inventory != null) ? inventory.GetEquippedItems() : null); } List list = (List)obj; if (list == null) { return null; } foreach (ItemData item in list) { if (item?.m_dropPrefab != null) { if (((Object)item.m_dropPrefab).name == "Bardheim_Lyre") { return "lyre"; } if (((Object)item.m_dropPrefab).name == "Bardheim_Drum") { return "drums"; } if (((Object)item.m_dropPrefab).name == "Bardheim_Flute") { return "flute"; } } } return null; } private static string GetInstrumentDisplayName(string? instrumentId) { if (1 == 0) { } string result = instrumentId switch { "lyre" => "Lyre", "drums" => "Drum", "flute" => "Flute", _ => "Instrument", }; if (1 == 0) { } return result; } private static string PathForSongs() { return Path.Combine(Paths.PluginPath, "Bardheim", "songs"); } } } namespace Bardheim.Visuals { internal sealed class DrumPlayModeVisualPose : MonoBehaviour { private static readonly HashSet Instances = new HashSet(); private static readonly Vector3 DefaultCarryLocalPosition = new Vector3(0.05f, 0.1f, 0.3f); private static readonly Vector3 DefaultCarryLocalEuler = new Vector3(-15f, -55f, 85f); private const float PositionStep = 0.05f; private const float RotationStep = 5f; private const string PoseDirectoryName = "Bardheim"; private const string PoseFilename = "drum-hand-visual-pose.txt"; private Vector3 _baseLocalPosition; private Quaternion _baseLocalRotation; private Vector3 _baseLocalScale; private Vector3 _carryLocalPosition = DefaultCarryLocalPosition; private Vector3 _carryLocalEuler = DefaultCarryLocalEuler; private bool _capturedBasePose; private bool _loadedPose; public static void UpdateCalibration(bool enabled, string? activeInstrumentId, ManualLogSource logger) { if (!enabled || activeInstrumentId != "drums") { return; } foreach (DrumPlayModeVisualPose instance in Instances) { if (instance != null && instance.CanApplyPose()) { instance.UpdateCalibrationInput(logger); } } } private void Awake() { CaptureBasePose(); LoadPoseIfNeeded(); ApplyCarryPose(); } private void OnEnable() { CaptureBasePose(); LoadPoseIfNeeded(); ApplyCarryPose(); Instances.Add(this); } private void OnDisable() { Instances.Remove(this); } private bool CanApplyPose() { return ((Component)this).gameObject.activeInHierarchy && ((Component)this).transform.root != null && !((Object)((Component)this).transform.root).name.Equals("Bardheim_Drum", StringComparison.Ordinal); } private void CaptureBasePose() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (!_capturedBasePose) { _baseLocalPosition = ((Component)this).transform.localPosition; _baseLocalRotation = ((Component)this).transform.localRotation; _baseLocalScale = ((Component)this).transform.localScale; _capturedBasePose = true; } } private void LoadPoseIfNeeded() { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) if (_loadedPose) { return; } _loadedPose = true; string path = PosePath(); if (!File.Exists(path)) { return; } try { string[] array = File.ReadAllLines(path); foreach (string text in array) { if (text.StartsWith("position=", StringComparison.Ordinal)) { _carryLocalPosition = ParseVector3(text.Substring("position=".Length), _carryLocalPosition); } else if (text.StartsWith("euler=", StringComparison.Ordinal)) { _carryLocalEuler = ParseVector3(text.Substring("euler=".Length), _carryLocalEuler); } } } catch (Exception) { _carryLocalPosition = DefaultCarryLocalPosition; _carryLocalEuler = DefaultCarryLocalEuler; } } private void ApplyCarryPose() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (_capturedBasePose) { ((Component)this).transform.localPosition = _baseLocalPosition + _carryLocalPosition; ((Component)this).transform.localRotation = _baseLocalRotation * Quaternion.Euler(_carryLocalEuler); ((Component)this).transform.localScale = _baseLocalScale; } } private void UpdateCalibrationInput(ManualLogSource logger) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; Vector3 zero2 = Vector3.zero; bool flag = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303); if (Input.GetKeyDown((KeyCode)260)) { if (flag) { zero2.y -= 5f; } else { zero.x -= 0.05f; } } if (Input.GetKeyDown((KeyCode)262)) { if (flag) { zero2.y += 5f; } else { zero.x += 0.05f; } } if (Input.GetKeyDown((KeyCode)264)) { if (flag) { zero2.x -= 5f; } else { zero.y += 0.05f; } } if (Input.GetKeyDown((KeyCode)258)) { if (flag) { zero2.x += 5f; } else { zero.y -= 0.05f; } } if (Input.GetKeyDown((KeyCode)263)) { if (flag) { zero2.z -= 5f; } else { zero.z -= 0.05f; } } if (Input.GetKeyDown((KeyCode)265)) { if (flag) { zero2.z += 5f; } else { zero.z += 0.05f; } } if (Input.GetKeyDown((KeyCode)91)) { zero2.y -= 5f; } if (Input.GetKeyDown((KeyCode)93)) { zero2.y += 5f; } if (Input.GetKeyDown((KeyCode)59)) { zero2.z -= 5f; } if (Input.GetKeyDown((KeyCode)39)) { zero2.z += 5f; } if (Input.GetKeyDown((KeyCode)44)) { zero2.x -= 5f; } if (Input.GetKeyDown((KeyCode)46)) { zero2.x += 5f; } if (!(zero == Vector3.zero) || !(zero2 == Vector3.zero)) { _carryLocalPosition += zero; _carryLocalEuler += zero2; ApplyCarryPose(); SavePose(logger); } } private void SavePose(ManualLogSource logger) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) string text = PosePath(); Directory.CreateDirectory(Path.GetDirectoryName(text)); File.WriteAllLines(text, new string[2] { "position=" + FormatVector(_carryLocalPosition), "euler=" + FormatVector(_carryLocalEuler) }); logger.LogInfo((object)("Drum visual pose saved: position=" + FormatVector(_carryLocalPosition) + " euler=" + FormatVector(_carryLocalEuler) + " file=" + text)); } private static string PosePath() { return Path.Combine(Paths.ConfigPath, "Bardheim", "drum-hand-visual-pose.txt"); } private static string FormatVector(Vector3 value) { return string.Join(",", value.x.ToString("F3", CultureInfo.InvariantCulture), value.y.ToString("F3", CultureInfo.InvariantCulture), value.z.ToString("F3", CultureInfo.InvariantCulture)); } private static Vector3 ParseVector3(string value, Vector3 fallback) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) string[] array = value.Split(new char[1] { ',' }); if (array.Length != 3) { return fallback; } float result; float result2; float result3; return (Vector3)((float.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out result) && float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out result2) && float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out result3)) ? new Vector3(result, result2, result3) : fallback); } } internal sealed class FlutePlayModeVisualPose : MonoBehaviour { private static readonly HashSet Instances = new HashSet(); private static readonly Vector3 DefaultCarryLocalPosition = new Vector3(0.03f, 0.03f, 0.08f); private static readonly Vector3 DefaultCarryLocalEuler = new Vector3(0f, -70f, 90f); private const float PositionStep = 0.05f; private const float RotationStep = 5f; private const string PoseDirectoryName = "Bardheim"; private const string PoseFilename = "flute-hand-visual-pose.txt"; private Vector3 _baseLocalPosition; private Quaternion _baseLocalRotation; private Vector3 _baseLocalScale; private Vector3 _carryLocalPosition = DefaultCarryLocalPosition; private Vector3 _carryLocalEuler = DefaultCarryLocalEuler; private bool _capturedBasePose; private bool _loadedPose; public static void UpdateCalibration(bool enabled, string? activeInstrumentId, ManualLogSource logger) { if (!enabled || activeInstrumentId != "flute") { return; } foreach (FlutePlayModeVisualPose instance in Instances) { if (instance != null && instance.CanApplyPose()) { instance.UpdateCalibrationInput(logger); } } } private void Awake() { CaptureBasePose(); LoadPoseIfNeeded(); ApplyCarryPose(); } private void OnEnable() { CaptureBasePose(); LoadPoseIfNeeded(); ApplyCarryPose(); Instances.Add(this); } private void OnDisable() { Instances.Remove(this); } private bool CanApplyPose() { return ((Component)this).gameObject.activeInHierarchy && ((Component)this).transform.root != null && !((Object)((Component)this).transform.root).name.Equals("Bardheim_Flute", StringComparison.Ordinal); } private void CaptureBasePose() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (!_capturedBasePose) { _baseLocalPosition = ((Component)this).transform.localPosition; _baseLocalRotation = ((Component)this).transform.localRotation; _baseLocalScale = ((Component)this).transform.localScale; _capturedBasePose = true; } } private void LoadPoseIfNeeded() { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) if (_loadedPose) { return; } _loadedPose = true; string path = PosePath(); if (!File.Exists(path)) { return; } try { string[] array = File.ReadAllLines(path); foreach (string text in array) { if (text.StartsWith("position=", StringComparison.Ordinal)) { _carryLocalPosition = ParseVector3(text.Substring("position=".Length), _carryLocalPosition); } else if (text.StartsWith("euler=", StringComparison.Ordinal)) { _carryLocalEuler = ParseVector3(text.Substring("euler=".Length), _carryLocalEuler); } } } catch (Exception) { _carryLocalPosition = DefaultCarryLocalPosition; _carryLocalEuler = DefaultCarryLocalEuler; } } private void ApplyCarryPose() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (_capturedBasePose) { ((Component)this).transform.localPosition = _baseLocalPosition + _carryLocalPosition; ((Component)this).transform.localRotation = _baseLocalRotation * Quaternion.Euler(_carryLocalEuler); ((Component)this).transform.localScale = _baseLocalScale; } } private void UpdateCalibrationInput(ManualLogSource logger) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; Vector3 zero2 = Vector3.zero; bool flag = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303); if (Input.GetKeyDown((KeyCode)260)) { if (flag) { zero2.y -= 5f; } else { zero.x -= 0.05f; } } if (Input.GetKeyDown((KeyCode)262)) { if (flag) { zero2.y += 5f; } else { zero.x += 0.05f; } } if (Input.GetKeyDown((KeyCode)264)) { if (flag) { zero2.x -= 5f; } else { zero.y += 0.05f; } } if (Input.GetKeyDown((KeyCode)258)) { if (flag) { zero2.x += 5f; } else { zero.y -= 0.05f; } } if (Input.GetKeyDown((KeyCode)263)) { if (flag) { zero2.z -= 5f; } else { zero.z -= 0.05f; } } if (Input.GetKeyDown((KeyCode)265)) { if (flag) { zero2.z += 5f; } else { zero.z += 0.05f; } } if (Input.GetKeyDown((KeyCode)91)) { zero2.y -= 5f; } if (Input.GetKeyDown((KeyCode)93)) { zero2.y += 5f; } if (Input.GetKeyDown((KeyCode)59)) { zero2.z -= 5f; } if (Input.GetKeyDown((KeyCode)39)) { zero2.z += 5f; } if (Input.GetKeyDown((KeyCode)44)) { zero2.x -= 5f; } if (Input.GetKeyDown((KeyCode)46)) { zero2.x += 5f; } if (!(zero == Vector3.zero) || !(zero2 == Vector3.zero)) { _carryLocalPosition += zero; _carryLocalEuler += zero2; ApplyCarryPose(); SavePose(logger); } } private void SavePose(ManualLogSource logger) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) string text = PosePath(); Directory.CreateDirectory(Path.GetDirectoryName(text)); File.WriteAllLines(text, new string[2] { "position=" + FormatVector(_carryLocalPosition), "euler=" + FormatVector(_carryLocalEuler) }); logger.LogInfo((object)("Flute visual pose saved: position=" + FormatVector(_carryLocalPosition) + " euler=" + FormatVector(_carryLocalEuler) + " file=" + text)); } private static string PosePath() { return Path.Combine(Paths.ConfigPath, "Bardheim", "flute-hand-visual-pose.txt"); } private static string FormatVector(Vector3 value) { return string.Join(",", value.x.ToString("F3", CultureInfo.InvariantCulture), value.y.ToString("F3", CultureInfo.InvariantCulture), value.z.ToString("F3", CultureInfo.InvariantCulture)); } private static Vector3 ParseVector3(string value, Vector3 fallback) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) string[] array = value.Split(new char[1] { ',' }); if (array.Length != 3) { return fallback; } float result; float result2; float result3; return (Vector3)((float.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out result) && float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out result2) && float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out result3)) ? new Vector3(result, result2, result3) : fallback); } } internal sealed class LyrePlayModeVisualPose : MonoBehaviour { private static readonly HashSet Instances = new HashSet(); private static readonly Vector3 CarryLocalPosition = new Vector3(0.05f, 0f, -0.05f); private static readonly Vector3 CarryLocalEuler = new Vector3(10f, -15f, 10f); private const float PositionStep = 0.05f; private const float RotationStep = 5f; private Vector3 _baseLocalPosition; private Quaternion _baseLocalRotation; private Vector3 _baseLocalScale; private Vector3 _carryLocalPosition = CarryLocalPosition; private Vector3 _carryLocalEuler = CarryLocalEuler; private bool _capturedBasePose; public static void UpdateCalibration(bool enabled, ManualLogSource logger) { if (!enabled) { return; } foreach (LyrePlayModeVisualPose instance in Instances) { if (instance != null && instance.CanApplyPose()) { instance.UpdateCalibrationInput(logger); } } } private void Awake() { CaptureBasePose(); ApplyCarryPose(); } private void OnEnable() { CaptureBasePose(); ApplyCarryPose(); Instances.Add(this); } private void OnDisable() { Instances.Remove(this); } private bool CanApplyPose() { return ((Component)this).gameObject.activeInHierarchy && ((Component)this).transform.root != null && !((Object)((Component)this).transform.root).name.Equals("Bardheim_Lyre", StringComparison.Ordinal); } private void ApplyCarryPose() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (_capturedBasePose) { ((Component)this).transform.localPosition = _baseLocalPosition + _carryLocalPosition; ((Component)this).transform.localRotation = _baseLocalRotation * Quaternion.Euler(_carryLocalEuler); ((Component)this).transform.localScale = _baseLocalScale; } } private void CaptureBasePose() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (!_capturedBasePose) { _baseLocalPosition = ((Component)this).transform.localPosition; _baseLocalRotation = ((Component)this).transform.localRotation; _baseLocalScale = ((Component)this).transform.localScale; _capturedBasePose = true; } } private void UpdateCalibrationInput(ManualLogSource logger) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; Vector3 zero2 = Vector3.zero; if (Input.GetKeyDown((KeyCode)260)) { zero.x -= 0.05f; } if (Input.GetKeyDown((KeyCode)262)) { zero.x += 0.05f; } if (Input.GetKeyDown((KeyCode)264)) { zero.y += 0.05f; } if (Input.GetKeyDown((KeyCode)258)) { zero.y -= 0.05f; } if (Input.GetKeyDown((KeyCode)263)) { zero.z -= 0.05f; } if (Input.GetKeyDown((KeyCode)265)) { zero.z += 0.05f; } if (Input.GetKeyDown((KeyCode)91)) { zero2.y -= 5f; } if (Input.GetKeyDown((KeyCode)93)) { zero2.y += 5f; } if (Input.GetKeyDown((KeyCode)59)) { zero2.z -= 5f; } if (Input.GetKeyDown((KeyCode)39)) { zero2.z += 5f; } if (Input.GetKeyDown((KeyCode)44)) { zero2.x -= 5f; } if (Input.GetKeyDown((KeyCode)46)) { zero2.x += 5f; } if (!(zero == Vector3.zero) || !(zero2 == Vector3.zero)) { _carryLocalPosition += zero; _carryLocalEuler += zero2; ApplyCarryPose(); LogCalibrationConstants(logger); } } private void LogCalibrationConstants(ManualLogSource logger) { logger.LogInfo((object)("Lyre carry pose calibration constants: " + $"CarryLocalPosition = new Vector3({_carryLocalPosition.x:F2}f, {_carryLocalPosition.y:F2}f, {_carryLocalPosition.z:F2}f); " + $"CarryLocalEuler = new Vector3({_carryLocalEuler.x:F1}f, {_carryLocalEuler.y:F1}f, {_carryLocalEuler.z:F1}f)")); } } } namespace Bardheim.UI { public sealed class HudVisibilityState { public bool IsHidden { get; private set; } public void Update(bool controlHeld, bool f3Pressed) { if (controlHeld && f3Pressed) { IsHidden = !IsHidden; } } } public sealed class PlayerFeedback { private readonly ManualLogSource _logger; public PlayerFeedback(ManualLogSource logger) { _logger = logger; } public void Center(string message) { _logger.LogInfo((object)message); if (MessageHud.instance != null) { MessageHud.instance.ShowMessage((MessageType)2, message, 0, (Sprite)null, false); } } } } namespace Bardheim.Songs { public static class DrumMidiMapper { private const int PercussionChannel = 9; public static bool TryMap(MidiNoteEvent note, out string? hitId) { hitId = null; if (note.Channel != 9) { return false; } int midiNote = note.MidiNote; if (1 == 0) { } string text; switch (midiNote) { case 27: case 28: case 29: case 30: case 31: case 32: case 33: case 34: text = "rim"; break; case 35: text = "low_kick"; break; case 36: text = "kick"; break; case 38: text = "snare"; break; case 40: text = "electric_snare"; break; case 37: text = "rim"; break; case 39: text = "clap"; break; case 42: text = "muted"; break; case 44: text = "pedal_hat"; break; case 46: text = "pedal_hat"; break; case 49: case 52: case 55: case 57: text = "crash"; break; case 51: case 53: case 59: case 73: text = "ride"; break; case 41: case 43: text = "low_tom"; break; case 45: case 47: text = "mid_tom"; break; case 48: case 50: text = "high_tom"; break; case 54: case 70: case 72: case 74: case 83: text = "tambourine"; break; case 56: case 58: case 84: text = "cowbell"; break; case 60: case 65: case 67: case 81: text = "high_tom"; break; case 61: case 64: case 68: case 77: case 80: text = "low_tom"; break; case 62: case 63: case 78: case 79: case 82: text = "muted"; break; case 66: text = "mid_tom"; break; case 69: text = "clap"; break; case 71: text = "pedal_hat"; break; case 75: case 76: text = "rim"; break; case 85: case 86: case 87: text = "open"; break; default: text = null; break; } if (1 == 0) { } hitId = text; return hitId != null; } public static bool HasMappedPercussion(IEnumerable events) { foreach (MidiNoteEvent @event in events) { if (TryMap(@event, out string _)) { return true; } } return false; } public static bool TryMapMelodicFallback(MidiNoteEvent note, out string hitId) { int midiNote = note.MidiNote; if (1 == 0) { } string text = ((midiNote < 54) ? ((midiNote < 40) ? ((midiNote >= 30) ? "kick" : "low_kick") : ((midiNote >= 47) ? "mid_tom" : "low_tom")) : ((midiNote < 69) ? ((midiNote >= 61) ? "high_tom" : "snare") : ((midiNote >= 78) ? "tambourine" : "rim"))); if (1 == 0) { } hitId = text; return true; } } public static class FluteMidiArranger { private const double MelodyBucketSeconds = 0.05; public static IEnumerable SelectPlayableEvents(IEnumerable dueNotes, MidiSongProfile profile) { MidiSongProfile profile2 = profile; MidiNoteEvent[] array = dueNotes.Where(profile2.Allows).ToArray(); if (profile2.ArrangementMode == MidiArrangementMode.Full) { return array; } return (from note in array group note by Math.Floor(note.StartSeconds / 0.05) into @group orderby @group.Min((MidiNoteEvent note) => note.StartSeconds) select @group).SelectMany((IGrouping group) => (from note in @group orderby profile2.ApplyOctaveOffset(note) descending, note.Velocity descending select note).Take(profile2.MaxSimultaneousMelodyNotes)); } } public static class FluteMidiMapper { private static readonly (int MidiNote, string Name)[] FluteBank = new(int, string)[22] { (62, "D4"), (63, "D#4"), (64, "E4"), (65, "F4"), (66, "F#4"), (67, "G4"), (68, "G#4"), (69, "A4"), (70, "Bb4"), (71, "B4"), (72, "C5"), (73, "C#5"), (74, "D5"), (75, "D#5"), (76, "E5"), (77, "F5"), (78, "F#5"), (79, "G5"), (80, "G#5"), (81, "A5"), (82, "Bb5"), (83, "B5") }; public static NoteDefinition MapToFluteNote(int midiNote) { int i; for (i = midiNote; i < FluteBank[0].MidiNote; i += 12) { } while (i > FluteBank[FluteBank.Length - 1].MidiNote) { i -= 12; } (int, string) tuple = FluteBank[0]; int num = Math.Abs(i - tuple.Item1); (int, string)[] fluteBank = FluteBank; for (int j = 0; j < fluteBank.Length; j++) { (int, string) tuple2 = fluteBank[j]; int num2 = Math.Abs(i - tuple2.Item1); if (num2 < num) { tuple = tuple2; num = num2; } } return new NoteDefinition(0, tuple.Item2, GetFrequency(tuple.Item1)); } private static float GetFrequency(int midiNote) { return (float)(440.0 * Math.Pow(2.0, (double)(midiNote - 69) / 12.0)); } } public sealed class FluteMidiRateLimiter { [CompilerGenerated] private sealed class d__2 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private MidiNoteEvent <>2__current; private int <>l__initialThreadId; private IEnumerable dueNotes; public IEnumerable <>3__dueNotes; private MidiSongProfile profile; public MidiSongProfile <>3__profile; private int maxNoteStartsPerSecond; public int <>3__maxNoteStartsPerSecond; public FluteMidiRateLimiter <>4__this; private IEnumerator <>s__1; private MidiNoteEvent 5__2; MidiNoteEvent IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>s__1 = null; 5__2 = null; <>1__state = -2; } private bool MoveNext() { try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>s__1 = dueNotes.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; 5__2 = null; break; } while (<>s__1.MoveNext()) { 5__2 = <>s__1.Current; if (!profile.Allows(5__2) || (<>4__this._plannedEvents != null && !<>4__this._plannedEvents.Contains(5__2))) { continue; } <>2__current = 5__2; <>1__state = 1; return true; } <>m__Finally1(); <>s__1 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>s__1 != null) { <>s__1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__2 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__2(0) { <>4__this = <>4__this }; } d__.dueNotes = <>3__dueNotes; d__.profile = <>3__profile; d__.maxNoteStartsPerSecond = <>3__maxNoteStartsPerSecond; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private HashSet? _plannedEvents; public void Prepare(IEnumerable songEvents, MidiSongProfile profile, int maxNoteStartsPerSecond) { MidiSongProfile profile2 = profile; int maxStarts = Math.Max(1, maxNoteStartsPerSecond); _plannedEvents = (from note in songEvents.Where(profile2.Allows) group note by (int)Math.Floor(note.StartSeconds)).SelectMany((IGrouping group) => from note in @group.OrderByDescending(profile2.ApplyOctaveOffset).ThenByDescending((MidiNoteEvent note) => note.Velocity).ThenBy((MidiNoteEvent note) => note.StartSeconds) .Take(maxStarts) orderby note.StartSeconds select note).ToHashSet(); } [IteratorStateMachine(typeof(d__2))] public IEnumerable SelectPlayableEvents(IEnumerable dueNotes, MidiSongProfile profile, int maxNoteStartsPerSecond) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(-2) { <>4__this = this, <>3__dueNotes = dueNotes, <>3__profile = profile, <>3__maxNoteStartsPerSecond = maxNoteStartsPerSecond }; } public void Reset() { _plannedEvents = null; } } public enum MidiArrangementMode { Full, Melody } public static class MidiFileParser { private sealed class TimedMidiEvent { public int Tick { get; } public TimedMidiEventKind Kind { get; } public int Channel { get; } public int Note { get; } public int Velocity { get; } public bool IsNoteOn { get; } public int TempoMicrosecondsPerQuarterNote { get; } public int SortOrder => (Kind != 0) ? ((!IsNoteOn) ? 1 : 2) : 0; private TimedMidiEvent(int tick, TimedMidiEventKind kind, int channel, int note, int velocity, bool isNoteOn, int tempo) { Tick = tick; Kind = kind; Channel = channel; Note = note; Velocity = velocity; IsNoteOn = isNoteOn; TempoMicrosecondsPerQuarterNote = tempo; } public static TimedMidiEvent Tempo(int tick, int tempo) { return new TimedMidiEvent(tick, TimedMidiEventKind.Tempo, 0, 0, 0, isNoteOn: false, tempo); } public static TimedMidiEvent NoteEvent(int tick, bool isNoteOn, int channel, int note, int velocity) { return new TimedMidiEvent(tick, TimedMidiEventKind.Note, channel, note, velocity, isNoteOn, 0); } } private enum TimedMidiEventKind { Tempo, Note } private const int DefaultMicrosecondsPerQuarterNote = 500000; public static MidiSong Parse(string displayName, byte[] data, string? sourcePath = null) { using MemoryStream memoryStream = new MemoryStream(data); using BinaryReader reader = new BinaryReader(memoryStream, Encoding.ASCII); Require(ReadAscii(reader, 4) == "MThd", "Missing MIDI header."); Require(ReadInt32(reader) == 6, "Unsupported MIDI header length."); int num = ReadInt16(reader); int num2 = ReadInt16(reader); int num3 = ReadInt16(reader); Require(num == 0 || num == 1, $"Unsupported MIDI format {num}."); Require(num2 > 0, "MIDI file has no tracks."); Require(num3 > 0 && (num3 & 0x8000) == 0, "SMPTE time division is not supported."); List events = new List(); for (int i = 0; i < num2; i++) { Require(ReadAscii(reader, 4) == "MTrk", "Missing MIDI track header."); int num4 = ReadInt32(reader); long num5 = memoryStream.Position + num4; ParseTrack(reader, num5, events); memoryStream.Position = num5; } return new MidiSong(displayName, BuildNoteEvents(events, num3), sourcePath); } private static void ParseTrack(BinaryReader reader, long trackEnd, List events) { int num = 0; byte b = 0; while (reader.BaseStream.Position < trackEnd) { num += ReadVariableLength(reader); byte b2 = reader.ReadByte(); byte b3; byte b4; if ((b2 & 0x80) == 0) { Require(b != 0, "Running status appeared before any status byte."); b3 = b; b4 = b2; } else { b3 = b2; b4 = 0; if (b3 < 240) { b = b3; } } switch (b3) { case byte.MaxValue: { byte b6 = reader.ReadByte(); int count = ReadVariableLength(reader); byte[] array = reader.ReadBytes(count); if (b6 == 81 && array.Length == 3) { int tempo = (array[0] << 16) | (array[1] << 8) | array[2]; events.Add(TimedMidiEvent.Tempo(num, tempo)); } if (b6 == 47) { return; } break; } default: if (b3 != 247) { int num2 = b3 & 0xF0; int channel = b3 & 0xF; byte note = (((b2 & 0x80) == 0) ? b4 : reader.ReadByte()); if (num2 != 192 && num2 != 208) { byte b5 = reader.ReadByte(); if (num2 == 144 || num2 == 128) { events.Add(TimedMidiEvent.NoteEvent(num, num2 == 144 && b5 > 0, channel, note, b5)); } } break; } goto case 240; case 240: { int num3 = ReadVariableLength(reader); reader.BaseStream.Position += num3; break; } } } } private static IEnumerable BuildNoteEvents(List events, int ticksPerQuarterNote) { events.Sort((TimedMidiEvent left, TimedMidiEvent right) => (left.Tick == right.Tick) ? left.SortOrder.CompareTo(right.SortOrder) : left.Tick.CompareTo(right.Tick)); int num = 500000; int num2 = 0; double num3 = 0.0; Dictionary<(int, int), Queue<(double, int)>> dictionary = new Dictionary<(int, int), Queue<(double, int)>>(); List list = new List(); foreach (TimedMidiEvent @event in events) { int num4 = @event.Tick - num2; num3 += (double)num4 * ((double)num / 1000000.0) / (double)ticksPerQuarterNote; num2 = @event.Tick; if (@event.Kind == TimedMidiEventKind.Tempo) { num = @event.TempoMicrosecondsPerQuarterNote; continue; } (int, int) key = (@event.Channel, @event.Note); Queue<(double, int)> value2; if (@event.IsNoteOn) { if (!dictionary.TryGetValue(key, out var value)) { value = new Queue<(double, int)>(); dictionary.Add(key, value); } value.Enqueue((num3, @event.Velocity)); } else if (dictionary.TryGetValue(key, out value2) && value2.Count > 0) { (double, int) tuple = value2.Dequeue(); list.Add(new MidiNoteEvent(@event.Note, @event.Channel, tuple.Item1, Math.Max(0.03, num3 - tuple.Item1), tuple.Item2)); } } return from item in list orderby item.StartSeconds, item.Velocity descending select item; } private static int ReadVariableLength(BinaryReader reader) { int num = 0; for (int i = 0; i < 4; i++) { byte b = reader.ReadByte(); num = (num << 7) | (b & 0x7F); if ((b & 0x80) == 0) { return num; } } throw new InvalidDataException("Invalid MIDI variable-length value."); } private static string ReadAscii(BinaryReader reader, int length) { return Encoding.ASCII.GetString(reader.ReadBytes(length)); } private static int ReadInt16(BinaryReader reader) { byte[] array = reader.ReadBytes(2); Require(array.Length == 2, "Unexpected end of MIDI file."); return (array[0] << 8) | array[1]; } private static int ReadInt32(BinaryReader reader) { byte[] array = reader.ReadBytes(4); Require(array.Length == 4, "Unexpected end of MIDI file."); return (array[0] << 24) | (array[1] << 16) | (array[2] << 8) | array[3]; } private static void Require(bool condition, string message) { if (!condition) { throw new InvalidDataException(message); } } } public sealed class MidiNoteEvent { public int MidiNote { get; } public int Channel { get; } public double StartSeconds { get; } public double DurationSeconds { get; } public int Velocity { get; } public MidiNoteEvent(int midiNote, int channel, double startSeconds, double durationSeconds, int velocity) { MidiNote = midiNote; Channel = channel; StartSeconds = startSeconds; DurationSeconds = durationSeconds; Velocity = velocity; } } public static class MidiNoteMapper { private static readonly string[] NoteNames = new string[12] { "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" }; public static NoteDefinition MapToLyreNote(int midiNote) { int i; for (i = midiNote; i < 50; i += 12) { } while (i > 74) { i -= 12; } i = Math.Max(50, Math.Min(74, i)); int num = i / 12 - 1; string name = $"{NoteNames[i % 12]}{num}"; return new NoteDefinition(0, name, GetFrequency(i)); } private static float GetFrequency(int midiNote) { return (float)(440.0 * Math.Pow(2.0, (double)(midiNote - 69) / 12.0)); } } public sealed class MidiPlaybackSession { private const double MinSpeedMultiplier = 0.25; private const double MaxSpeedMultiplier = 3.0; private MidiSong? _song; private double _startTimeSeconds; private double _baseSongSeconds; private int _nextEventIndex; public bool IsPlaying => _song != null; public MidiSong? CurrentSong => _song; public double SpeedMultiplier { get; private set; } = 1.0; public double ElapsedSongSeconds { get; private set; } public bool LoopEnabled { get; private set; } public void Start(MidiSong song, double startTimeSeconds) { _song = song; _startTimeSeconds = startTimeSeconds; _baseSongSeconds = 0.0; ElapsedSongSeconds = 0.0; _nextEventIndex = 0; } public void Stop() { _song = null; _nextEventIndex = 0; _startTimeSeconds = 0.0; _baseSongSeconds = 0.0; ElapsedSongSeconds = 0.0; } public IReadOnlyList CollectDueNotes(double nowSeconds) { if (_song == null) { return Array.Empty(); } double num = GetElapsedSongSeconds(nowSeconds); if (_song.LengthSeconds > 0.0 && LoopEnabled) { while (num > _song.LengthSeconds) { num -= _song.LengthSeconds; _baseSongSeconds -= _song.LengthSeconds; _nextEventIndex = 0; } } ElapsedSongSeconds = num; List list = new List(); while (_nextEventIndex < _song.Events.Count && _song.Events[_nextEventIndex].StartSeconds <= num) { list.Add(_song.Events[_nextEventIndex]); _nextEventIndex++; } if (_nextEventIndex >= _song.Events.Count && num > _song.LengthSeconds) { Stop(); } return list; } public void SetSpeed(double speedMultiplier, double? nowSeconds = null) { double speedMultiplier2 = Math.Max(0.25, Math.Min(3.0, speedMultiplier)); if (_song != null && nowSeconds.HasValue) { _baseSongSeconds = GetElapsedSongSeconds(nowSeconds.Value); _startTimeSeconds = nowSeconds.Value; ElapsedSongSeconds = _baseSongSeconds; } SpeedMultiplier = speedMultiplier2; } public void SetLoopEnabled(bool loopEnabled) { LoopEnabled = loopEnabled; } public bool ToggleLoopEnabled() { LoopEnabled = !LoopEnabled; return LoopEnabled; } private double GetElapsedSongSeconds(double nowSeconds) { return _baseSongSeconds + (nowSeconds - _startTimeSeconds) * SpeedMultiplier; } } public sealed class MidiSong { public string DisplayName { get; } public string? SourcePath { get; } public IReadOnlyList Events { get; } public double LengthSeconds { get; } public MidiSong(string displayName, IEnumerable events, string? sourcePath = null) { DisplayName = displayName; SourcePath = sourcePath; Events = events.OrderBy((MidiNoteEvent item) => item.StartSeconds).ToArray(); LengthSeconds = ((Events.Count == 0) ? 0.0 : Events.Max((MidiNoteEvent item) => item.StartSeconds + item.DurationSeconds)); } } public sealed class MidiSongController { private readonly MidiSongLibrary _library; private readonly MidiPlaybackSession _session = new MidiPlaybackSession(); private readonly LocalNotePlayback _playback; private readonly LocalDrumPlayback _drumPlayback; private readonly LocalFlutePlayback _flutePlayback; private readonly FluteMidiRateLimiter _fluteMidiRateLimiter = new FluteMidiRateLimiter(); private readonly ILyreNetworkNoteEmitter _noteEmitter; private readonly PlayerFeedback _feedback; private readonly ManualLogSource _logger; private readonly GUIStyle _mutedStyle = new GUIStyle(); private readonly GUIStyle _selectedStyle = new GUIStyle(); private readonly GUIStyle _playingStyle = new GUIStyle(); private MidiSongProfile _profile = MidiSongProfile.Default; private int _lastLoadedCount = -1; private string _activeInstrumentId = "lyre"; private MidiSong? _drumAnalysisSong; private bool _drumAnalysisHasMappedPercussion; private bool _stylesInitialized; public bool IsPlaying => _session.IsPlaying; public MidiSong? CurrentSong => _session.CurrentSong; public MidiSongLibrary Library => _library; public MidiSongController(LocalNotePlayback playback, PlayerFeedback feedback, ManualLogSource logger) : this(Path.Combine(Paths.PluginPath, "Bardheim", "songs"), playback, new LocalDrumPlayback(logger), new LocalFlutePlayback(logger), DisabledLyreNetworkNoteEmitter.Instance, feedback, logger) { } public MidiSongController(string songsDirectory, LocalNotePlayback playback, LocalDrumPlayback drumPlayback, LocalFlutePlayback flutePlayback, ILyreNetworkNoteEmitter noteEmitter, PlayerFeedback feedback, ManualLogSource logger) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown _library = new MidiSongLibrary(songsDirectory); _playback = playback; _drumPlayback = drumPlayback; _flutePlayback = flutePlayback; _noteEmitter = noteEmitter; _feedback = feedback; _logger = logger; RefreshSongs(); } public void Update(Player player, string? activeInstrumentId, int maxSimultaneousNotes, int maxFluteMidiNotesPerSecond, float volume) { _activeInstrumentId = activeInstrumentId ?? "lyre"; if (Input.GetKeyDown((KeyCode)111)) { TogglePlayback(maxFluteMidiNotesPerSecond); } if (Input.GetKeyDown((KeyCode)91)) { SelectPrevious(); } if (Input.GetKeyDown((KeyCode)93)) { SelectNext(); } if (Input.GetKeyDown((KeyCode)45)) { ChangeSpeed(-0.25); } if (Input.GetKeyDown((KeyCode)61)) { ChangeSpeed(0.25); } if (Input.GetKeyDown((KeyCode)48)) { ResetSpeed(); } if (Input.GetKeyDown((KeyCode)108)) { ToggleLoop(); } IReadOnlyList readOnlyList = _session.CollectDueNotes(Time.timeAsDouble); if (activeInstrumentId == "flute") { IEnumerable dueNotes = FluteMidiArranger.SelectPlayableEvents(readOnlyList, _profile); { foreach (MidiNoteEvent item in _fluteMidiRateLimiter.SelectPlayableEvents(dueNotes, _profile, maxFluteMidiNotesPerSecond)) { PlayFluteMidiEvent(player, item, maxSimultaneousNotes, volume); } return; } } foreach (MidiNoteEvent item2 in readOnlyList) { if (activeInstrumentId == "lyre") { if (_profile.Allows(item2)) { PlayLyreMidiEvent(player, item2, maxSimultaneousNotes, volume); } } else if (activeInstrumentId == "drums") { PlayDrumMidiEvent(player, item2, maxSimultaneousNotes, volume); } } } public void StopIfPlaying() { if (_session.IsPlaying) { _session.Stop(); _fluteMidiRateLimiter.Reset(); _feedback.Center(GetSongLabel() + " stopped."); } } public void DrawHud(bool visible) { //IL_0058: 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) if (!visible) { return; } EnsureStyles(); int num = Mathf.Min(10, Mathf.Max(1, _library.Songs.Count)); Rect val = default(Rect); ((Rect)(ref val))..ctor(24f, 100f, 520f, 142f + (float)num * 24f); GUI.Box(val, string.Empty); GUILayout.BeginArea(new Rect(((Rect)(ref val)).x + 14f, ((Rect)(ref val)).y + 10f, ((Rect)(ref val)).width - 28f, ((Rect)(ref val)).height - 20f)); GUILayout.Label(GetHudTitle(), _playingStyle, Array.Empty()); GUILayout.Label(GetStatusLine(), Array.Empty()); GUILayout.Label("O play/stop [ previous ] next - slower = faster 0 reset L loop", _mutedStyle, Array.Empty()); GUILayout.Space(4f); if (_library.Songs.Count == 0) { GUILayout.Label("No .mid files in Bardheim/songs for " + GetInstrumentName().ToLowerInvariant(), _mutedStyle, Array.Empty()); } else { int num2 = Mathf.Max(0, Mathf.Min(_library.SelectedIndex - 4, Mathf.Max(0, _library.Songs.Count - num))); int num3 = Mathf.Min(_library.Songs.Count, num2 + num); for (int i = num2; i < num3; i++) { MidiSong midiSong = _library.Songs[i]; bool flag = i == _library.SelectedIndex; bool flag2 = _session.CurrentSong == midiSong && _session.IsPlaying; string arg = (flag2 ? ">" : (flag ? "*" : " ")); GUIStyle val2 = (GUIStyle)(flag2 ? _playingStyle : (flag ? ((object)_selectedStyle) : ((object)GUI.skin.label))); GUILayout.Label($"{arg} {i + 1:00}. {midiSong.DisplayName}", val2, Array.Empty()); } } GUILayout.EndArea(); } private void TogglePlayback(int maxFluteMidiNotesPerSecond) { RefreshSongs(); if (_session.IsPlaying) { _session.Stop(); _fluteMidiRateLimiter.Reset(); _feedback.Center(GetSongLabel() + " stopped."); return; } MidiSong selectedSong = _library.SelectedSong; if (selectedSong == null) { _feedback.Center("No " + GetInstrumentName().ToLowerInvariant() + " songs found."); return; } _profile = MidiSongProfile.LoadFor(selectedSong, _activeInstrumentId); if (_activeInstrumentId == "flute") { _logger.LogInfo((object)("Flute MIDI profile for " + selectedSong.DisplayName + ": " + _profile.DescribeChannelSelection())); } _session.Start(selectedSong, Time.timeAsDouble); _fluteMidiRateLimiter.Prepare(FluteMidiArranger.SelectPlayableEvents(selectedSong.Events, _profile), _profile, maxFluteMidiNotesPerSecond); _feedback.Center(GetSongLabel() + ": " + selectedSong.DisplayName); } private void SelectNext() { RefreshSongs(); MidiSong song = _library.SelectNext(); AnnounceSelection(song); } private void SelectPrevious() { RefreshSongs(); MidiSong song = _library.SelectPrevious(); AnnounceSelection(song); } private void AnnounceSelection(MidiSong? song) { if (song == null) { _feedback.Center("No " + GetInstrumentName().ToLowerInvariant() + " songs found."); return; } if (_session.IsPlaying) { _session.Stop(); _fluteMidiRateLimiter.Reset(); } _feedback.Center("Selected " + GetSongLabel().ToLowerInvariant() + ": " + song.DisplayName); } private void RefreshSongs() { _library.Refresh(); if (_library.Songs.Count != _lastLoadedCount) { _lastLoadedCount = _library.Songs.Count; _logger.LogInfo((object)$"Loaded {_library.Songs.Count} MIDI song(s)."); } foreach (string skippedFile in _library.SkippedFiles) { _logger.LogWarning((object)("Skipped unsupported MIDI file: " + Path.GetFileName(skippedFile))); } } private void ChangeSpeed(double delta) { _session.SetSpeed(_session.SpeedMultiplier + delta, Time.timeAsDouble); _feedback.Center($"{GetSongLabel()} speed: {_session.SpeedMultiplier:0.00}x"); } private void ResetSpeed() { _session.SetSpeed(1.0, Time.timeAsDouble); _feedback.Center(GetSongLabel() + " speed: 1.00x"); } private void ToggleLoop() { bool flag = _session.ToggleLoopEnabled(); _feedback.Center(flag ? (GetSongLabel() + " loop on.") : (GetSongLabel() + " loop off.")); } private void PlayLyreMidiEvent(Player player, MidiNoteEvent noteEvent, int maxSimultaneousNotes, float volume) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) NoteDefinition note = MidiNoteMapper.MapToLyreNote(_profile.ApplyOctaveOffset(noteEvent)); NoteRequest request = new NoteRequest(note, ((Component)player).transform.position); if (_playback.Play(request, maxSimultaneousNotes, volume)) { _noteEmitter.Emit(request, LyreNetworkNoteSource.Midi, volume); } } private void PlayDrumMidiEvent(Player player, MidiNoteEvent noteEvent, int maxSimultaneousHits, float volume) { //IL_0065: 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) if (((DrumMidiMapper.TryMap(noteEvent, out string hitId) && hitId != null) || (!CurrentDrumSongHasMappedPercussion() && DrumMidiMapper.TryMapMelodicFallback(noteEvent, out hitId))) && hitId != null) { float volume2 = volume * Mathf.Clamp01((float)noteEvent.Velocity / 127f); if (_drumPlayback.Play(hitId, ((Component)player).transform.position, maxSimultaneousHits, volume2)) { _noteEmitter.Emit("drums", hitId, ((Component)player).transform.position, LyreNetworkNoteSource.Midi, volume2); } } } private void PlayFluteMidiEvent(Player player, MidiNoteEvent noteEvent, int maxSimultaneousNotes, float volume) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) NoteDefinition noteDefinition = FluteMidiMapper.MapToFluteNote(_profile.ApplyOctaveOffset(noteEvent)); NoteRequest request = new NoteRequest(noteDefinition, ((Component)player).transform.position); if (_flutePlayback.Play(request, maxSimultaneousNotes, volume)) { _noteEmitter.Emit("flute", noteDefinition.Name, ((Component)player).transform.position, LyreNetworkNoteSource.Midi, volume); } } private bool CurrentDrumSongHasMappedPercussion() { MidiSong currentSong = _session.CurrentSong; if (currentSong == null) { return false; } if (currentSong != _drumAnalysisSong) { _drumAnalysisSong = currentSong; _drumAnalysisHasMappedPercussion = DrumMidiMapper.HasMappedPercussion(currentSong.Events); } return _drumAnalysisHasMappedPercussion; } private string GetStatusLine() { string text = _library.SelectedSong?.DisplayName ?? "No song"; string text2 = (_session.IsPlaying ? "Playing" : "Selected"); string text3 = string.Empty; if (_session.CurrentSong != null && _session.CurrentSong.LengthSeconds > 0.0) { text3 = " " + FormatSeconds(_session.ElapsedSongSeconds) + " / " + FormatSeconds(_session.CurrentSong.LengthSeconds); } string text4 = (_session.LoopEnabled ? "On" : "Off"); return $"{text2}: {text} Songs: {_library.Songs.Count} Speed: {_session.SpeedMultiplier:0.00}x Loop: {text4}{text3}"; } private string GetHudTitle() { string activeInstrumentId = _activeInstrumentId; if (1 == 0) { } string result = ((activeInstrumentId == "drums") ? "DRUM SONGS" : ((!(activeInstrumentId == "flute")) ? "LYRE SONGS" : "FLUTE SONGS")); if (1 == 0) { } return result; } private string GetSongLabel() { string activeInstrumentId = _activeInstrumentId; if (1 == 0) { } string result = ((activeInstrumentId == "drums") ? "Drum song" : ((!(activeInstrumentId == "flute")) ? "Lyre song" : "Flute song")); if (1 == 0) { } return result; } private string GetInstrumentName() { string activeInstrumentId = _activeInstrumentId; if (1 == 0) { } string result = ((activeInstrumentId == "drums") ? "Drum" : ((!(activeInstrumentId == "flute")) ? "Lyre" : "Flute")); if (1 == 0) { } return result; } private void EnsureStyles() { //IL_0028: 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_0072: Unknown result type (might be due to invalid IL or missing references) if (!_stylesInitialized) { _mutedStyle.normal.textColor = new Color(0.72f, 0.72f, 0.72f); _selectedStyle.normal.textColor = new Color(1f, 0.88f, 0.48f); _playingStyle.normal.textColor = new Color(0.48f, 1f, 0.62f); _stylesInitialized = true; } } private static string FormatSeconds(double seconds) { int num = Mathf.Max(0, Mathf.FloorToInt((float)seconds)); return $"{num / 60:00}:{num % 60:00}"; } } public sealed class MidiSongLibrary { private readonly string _songsDirectory; private readonly List _songs = new List(); private readonly List _skippedFiles = new List(); public IReadOnlyList Songs => _songs; public IReadOnlyList SkippedFiles => _skippedFiles; public int SelectedIndex { get; private set; } public MidiSong? SelectedSong => (_songs.Count == 0) ? null : _songs[SelectedIndex]; public MidiSongLibrary(string songsDirectory) { _songsDirectory = songsDirectory; } public void Refresh() { Directory.CreateDirectory(_songsDirectory); string selectedName = SelectedSong?.DisplayName; _songs.Clear(); _skippedFiles.Clear(); foreach (string item in Directory.GetFiles(_songsDirectory, "*.mid").OrderBy(Path.GetFileName, StringComparer.OrdinalIgnoreCase)) { try { _songs.Add(MidiFileParser.Parse(Path.GetFileName(item), File.ReadAllBytes(item), item)); } catch { _skippedFiles.Add(item); } } if (_songs.Count == 0) { SelectedIndex = 0; return; } int num = ((selectedName == null) ? (-1) : _songs.FindIndex((MidiSong song) => string.Equals(song.DisplayName, selectedName, StringComparison.OrdinalIgnoreCase))); SelectedIndex = ((num >= 0) ? num : Math.Min(SelectedIndex, _songs.Count - 1)); } public MidiSong? SelectNext() { if (_songs.Count == 0) { return null; } SelectedIndex = (SelectedIndex + 1) % _songs.Count; return SelectedSong; } public MidiSong? SelectPrevious() { if (_songs.Count == 0) { return null; } SelectedIndex = (SelectedIndex + _songs.Count - 1) % _songs.Count; return SelectedSong; } } public sealed class MidiSongProfile { private readonly HashSet _activeChannels; private readonly HashSet _mutedChannels; private readonly Dictionary _channelOctaveOffsets; public static MidiSongProfile Default { get; } = new MidiSongProfile(new HashSet(), new HashSet { 10 }, new Dictionary(), MidiArrangementMode.Full, int.MaxValue); public MidiArrangementMode ArrangementMode { get; } public int MaxSimultaneousMelodyNotes { get; } private MidiSongProfile(HashSet activeChannels, HashSet mutedChannels, Dictionary channelOctaveOffsets, MidiArrangementMode arrangementMode, int maxSimultaneousMelodyNotes) { _activeChannels = activeChannels; _mutedChannels = mutedChannels; _channelOctaveOffsets = channelOctaveOffsets; ArrangementMode = arrangementMode; MaxSimultaneousMelodyNotes = maxSimultaneousMelodyNotes; } public string DescribeChannelSelection() { string text = ((_activeChannels.Count == 0) ? "all" : string.Join(",", _activeChannels.OrderBy((int channel) => channel))); string text2 = ((_mutedChannels.Count == 0) ? "none" : string.Join(",", _mutedChannels.OrderBy((int channel) => channel))); return $"activeChannels={text}; mutedChannels={text2}; arrangementMode={ArrangementMode}; maxSimultaneousMelodyNotes={MaxSimultaneousMelodyNotes}"; } public static MidiSongProfile ForInstrument(string instrumentId) { return Default; } public static MidiSongProfile LoadFor(MidiSong song) { return LoadFor(song, "lyre"); } public static MidiSongProfile LoadFor(MidiSong song, string instrumentId) { if (song.SourcePath == null) { return ForSong(instrumentId, song); } string path = song.SourcePath + "." + instrumentId + "-profile.json"; if (!File.Exists(path)) { return ForSong(instrumentId, song); } string json = File.ReadAllText(path); if (!ProfileMatchesInstrument(json, instrumentId)) { return ForSong(instrumentId, song); } MidiSongProfile midiSongProfile = ForInstrument(instrumentId); return new MidiSongProfile(ParseChannelSet(json, "activeChannels", midiSongProfile._activeChannels), ParseChannelSet(json, "mutedChannels", midiSongProfile._mutedChannels), ParseOctaveOffsets(json), ParseArrangementMode(json, midiSongProfile.ArrangementMode), ParseInt(json, "maxSimultaneousMelodyNotes", midiSongProfile.MaxSimultaneousMelodyNotes)); } private static MidiSongProfile ForSong(string instrumentId, MidiSong song) { return ForInstrument(instrumentId); } public bool Allows(MidiNoteEvent note) { int item = note.Channel + 1; if (_mutedChannels.Contains(item)) { return false; } return _activeChannels.Count == 0 || _activeChannels.Contains(item); } public int ApplyOctaveOffset(MidiNoteEvent note) { int key = note.Channel + 1; int value; return note.MidiNote + (_channelOctaveOffsets.TryGetValue(key, out value) ? (value * 12) : 0); } private static HashSet ParseChannelSet(string json, string propertyName, HashSet fallback) { HashSet hashSet = new HashSet(); Match match = Regex.Match(json, "\"" + propertyName + "\"\\s*:\\s*\\[(?[^\\]]*)\\]"); if (!match.Success) { return new HashSet(fallback); } foreach (Match item in Regex.Matches(match.Groups["values"].Value, "\\d+")) { hashSet.Add(int.Parse(item.Value)); } return hashSet; } private static Dictionary ParseOctaveOffsets(string json) { Dictionary dictionary = new Dictionary(); Match match = Regex.Match(json, "\"channelOctaveOffsets\"\\s*:\\s*\\{(?[^}]*)\\}"); if (!match.Success) { return dictionary; } foreach (Match item in Regex.Matches(match.Groups["values"].Value, "\"(?\\d+)\"\\s*:\\s*(?-?\\d+)")) { dictionary[int.Parse(item.Groups["channel"].Value)] = int.Parse(item.Groups["offset"].Value); } return dictionary; } private static MidiArrangementMode ParseArrangementMode(string json, MidiArrangementMode fallback) { Match match = Regex.Match(json, "\"arrangementMode\"\\s*:\\s*\"(?[^\"]+)\""); if (!match.Success) { return fallback; } return (!(match.Groups["value"].Value == "Full")) ? MidiArrangementMode.Melody : MidiArrangementMode.Full; } private static int ParseInt(string json, string propertyName, int fallback) { Match match = Regex.Match(json, "\"" + propertyName + "\"\\s*:\\s*(?\\d+)"); return match.Success ? int.Parse(match.Groups["value"].Value) : fallback; } private static bool ProfileMatchesInstrument(string json, string instrumentId) { Match match = Regex.Match(json, "\"instrumentId\"\\s*:\\s*\"(?[^\"]+)\""); return !match.Success || match.Groups["value"].Value == instrumentId; } } } namespace Bardheim.PlayMode { public sealed class LyreInputRouter { private const string CycleButtonName = "Bardheim_CycleNoteSet"; private const string HotbarButtonPrefix = "Hotbar"; private static readonly KeyCode[] NoteKeys; private readonly NoteSetSelector _noteSetSelector; private readonly LyrePlayMode _playMode; private readonly LocalNotePlayback _playback; private readonly LocalDrumPlayback _drumPlayback; private readonly LocalFlutePlayback _flutePlayback; private readonly ILyreNetworkNoteEmitter _noteEmitter; private readonly PlayerFeedback _feedback; private readonly ManualLogSource _logger; private bool _registered; public LyreInputRouter(NoteSetSelector noteSetSelector, LyrePlayMode playMode, LocalNotePlayback playback, LocalDrumPlayback drumPlayback, LocalFlutePlayback flutePlayback, ILyreNetworkNoteEmitter noteEmitter, PlayerFeedback feedback, ManualLogSource logger) { _noteSetSelector = noteSetSelector; _playMode = playMode; _playback = playback; _drumPlayback = drumPlayback; _flutePlayback = flutePlayback; _noteEmitter = noteEmitter; _feedback = feedback; _logger = logger; } public void RegisterButtons() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_005b: 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_0070: Expected O, but got Unknown //IL_008e: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown if (!_registered) { for (int i = 0; i < NoteKeys.Length; i++) { int num = i + 1; InputManager.Instance.AddButton("com.valheimmodlab.bardheim", new ButtonConfig { Name = GetButtonName(num), Key = NoteKeys[i], Hint = $"Lyre note {num}", BlockOtherInputs = true, ActiveInGUI = false }); } InputManager.Instance.AddButton("com.valheimmodlab.bardheim", new ButtonConfig { Name = "Bardheim_CycleNoteSet", Key = (KeyCode)57, Hint = "Cycle lyre tuning", BlockOtherInputs = true, ActiveInGUI = false }); _registered = true; } } public void Update(Player player, string? activeInstrumentId, int maxSimultaneousNotes, float volume) { if (!_playMode.IsActive || player == null || (activeInstrumentId == "lyre" && TryCycleNoteSet())) { return; } for (int i = 1; i <= NoteKeys.Length; i++) { bool flag = ZInput.GetButtonDown(GetButtonName(i)) || ZInput.GetButtonDown(GetHotbarButtonName(i)) || ZInput.GetKeyDown(NoteKeys[i - 1], false); ZInput.ResetButtonStatus(GetHotbarButtonName(i)); if (flag) { switch (activeInstrumentId) { case "lyre": PlayLyreSlot(player, i, maxSimultaneousNotes, volume); break; case "drums": PlayDrumSlot(player, i, maxSimultaneousNotes, volume); break; case "flute": PlayFluteSlot(player, i, maxSimultaneousNotes, volume); break; } } } } private void PlayLyreSlot(Player player, int slot, int maxSimultaneousNotes, float volume) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (_noteSetSelector.Current.Map.TryGet(slot, out NoteDefinition note)) { NoteRequest request = new NoteRequest(note, ((Component)player).transform.position); if (_playback.Play(request, maxSimultaneousNotes, volume)) { _noteEmitter.Emit(request, LyreNetworkNoteSource.Manual, volume); _logger.LogInfo((object)$"Played lyre note {note.Name} from slot {slot}."); } } } private void PlayDrumSlot(Player player, int slot, int maxSimultaneousHits, float volume) { //IL_0091: 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) if (1 == 0) { } string text = slot switch { 1 => "kick", 2 => "snare", 3 => "rim", 4 => "clap", 5 => "muted", 6 => "open", 7 => "low_tom", 8 => "high_tom", _ => null, }; if (1 == 0) { } string text2 = text; if (text2 != null && _drumPlayback.Play(text2, ((Component)player).transform.position, maxSimultaneousHits, volume)) { _noteEmitter.Emit("drums", text2, ((Component)player).transform.position, LyreNetworkNoteSource.Manual, volume); _logger.LogInfo((object)$"Played drum hit {text2} from slot {slot}."); } } private void PlayFluteSlot(Player player, int slot, int maxSimultaneousNotes, float volume) { //IL_003b: 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) InstrumentDefinition instrumentDefinition = InstrumentCatalog.CreateDefaultInstruments()[2]; NoteSet noteSet = instrumentDefinition.NoteSets[0]; if (noteSet.Map.TryGet(slot, out NoteDefinition note)) { NoteRequest request = new NoteRequest(note, ((Component)player).transform.position); if (_flutePlayback.Play(request, maxSimultaneousNotes, volume)) { _noteEmitter.Emit("flute", note.Name, ((Component)player).transform.position, LyreNetworkNoteSource.Manual, volume); _logger.LogInfo((object)$"Played flute note {note.Name} from slot {slot}."); } } } private bool TryCycleNoteSet() { bool flag = ZInput.GetButtonDown("Bardheim_CycleNoteSet") || ZInput.GetButtonDown(GetHotbarButtonName(9)) || ZInput.GetKeyDown((KeyCode)57, false); ZInput.ResetButtonStatus(GetHotbarButtonName(9)); if (!flag) { return false; } NoteSet noteSet = _noteSetSelector.CycleNext(); _feedback.Center("Lyre tuning: " + noteSet.Name); return true; } private static string GetButtonName(int slot) { return $"Bardheim_Note{slot}"; } private static string GetHotbarButtonName(int slot) { return string.Format("{0}{1}", "Hotbar", slot); } static LyreInputRouter() { KeyCode[] array = new KeyCode[8]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); NoteKeys = (KeyCode[])(object)array; } } public sealed class LyrePlayMode { public bool IsActive { get; private set; } public bool Toggle(bool canPlay) { if (!canPlay) { return DisableIfActive(); } IsActive = !IsActive; return true; } public bool UpdateEligibility(bool canPlay) { return !canPlay && DisableIfActive(); } public bool DisableIfActive() { if (!IsActive) { return false; } IsActive = false; return true; } } } namespace Bardheim.Notes { public sealed class NoteDefinition { public int Slot { get; } public string Name { get; } public float FrequencyHz { get; } public NoteDefinition(int slot, string name, float frequencyHz) { Slot = slot; Name = name; FrequencyHz = frequencyHz; } } public sealed class NoteMap { private readonly Dictionary _notesBySlot; public IReadOnlyList Notes { get; } public NoteMap(IEnumerable notes) { _notesBySlot = new Dictionary(); List list = new List(); foreach (NoteDefinition note in notes) { if (note.Slot < 1) { throw new ArgumentOutOfRangeException("notes", "Note slots must be positive."); } _notesBySlot.Add(note.Slot, note); list.Add(note); } Notes = new ReadOnlyCollection(list); } public bool TryGet(int slot, out NoteDefinition note) { return _notesBySlot.TryGetValue(slot, out note); } public NoteDefinition GetRequired(int slot) { if (!TryGet(slot, out NoteDefinition note)) { throw new KeyNotFoundException($"No lyre note is mapped to slot {slot}."); } return note; } } public sealed class NoteRequest { public NoteDefinition Note { get; } public Vector3 Position { get; } public NoteRequest(NoteDefinition note, Vector3 position) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) Note = note; Position = position; } } public sealed class NoteSet { public string Name { get; } public NoteMap Map { get; } public NoteSet(string name, NoteMap map) { Name = name; Map = map; } } public static class NoteSetCatalog { public static IReadOnlyList CreateDefaultSets() { return new NoteSet[3] { Create("D minor pentatonic", ("D3", 146.83f), ("F3", 174.61f), ("G3", 196f), ("A3", 220f), ("C4", 261.63f), ("D4", 293.66f), ("F4", 349.23f), ("G4", 392f)), Create("D natural minor", ("D3", 146.83f), ("E3", 164.81f), ("F3", 174.61f), ("G3", 196f), ("A3", 220f), ("Bb3", 233.08f), ("C4", 261.63f), ("D4", 293.66f)), Create("D folk/dorian", ("D3", 146.83f), ("E3", 164.81f), ("F3", 174.61f), ("G3", 196f), ("A3", 220f), ("C4", 261.63f), ("D4", 293.66f), ("E4", 329.63f)) }; } public static NoteSet Create(string name, params (string Name, float FrequencyHz)[] notes) { NoteDefinition[] array = new NoteDefinition[notes.Length]; for (int i = 0; i < notes.Length; i++) { array[i] = new NoteDefinition(i + 1, notes[i].Name, notes[i].FrequencyHz); } return new NoteSet(name, new NoteMap(array)); } } public sealed class NoteSetSelector { private readonly IReadOnlyList _sets; private int _index; public NoteSet Current { get; private set; } public NoteSetSelector(IReadOnlyList sets) { if (sets.Count == 0) { throw new ArgumentException("At least one note set is required.", "sets"); } _sets = sets; Current = _sets[0]; } public NoteSet CycleNext() { _index = (_index + 1) % _sets.Count; Current = _sets[_index]; return Current; } } } namespace Bardheim.Network { public sealed class DisabledLyreNetworkNoteEmitter : ILyreNetworkNoteEmitter { public static readonly DisabledLyreNetworkNoteEmitter Instance = new DisabledLyreNetworkNoteEmitter(); private DisabledLyreNetworkNoteEmitter() { } public void Emit(NoteRequest request, LyreNetworkNoteSource source, float volume) { } public void Emit(string instrumentId, string eventName, Vector3 position, LyreNetworkNoteSource source, float volume) { } } public interface ILyreNetworkNoteEmitter { void Emit(NoteRequest request, LyreNetworkNoteSource source, float volume); void Emit(string instrumentId, string eventName, Vector3 position, LyreNetworkNoteSource source, float volume); } public interface ILyreNetworkNoteTransport { void Send(byte[] payload); } public sealed class LyreNetworkNoteEmitter : ILyreNetworkNoteEmitter { private readonly ILyreNetworkNoteTransport _transport; private long _nextEventId; public LyreNetworkNoteEmitter(ILyreNetworkNoteTransport transport) { _transport = transport; } public void Emit(NoteRequest request, LyreNetworkNoteSource source, float volume) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) Emit("lyre", request.Note.Name, request.Position, source, volume); } public void Emit(string instrumentId, string eventName, Vector3 position, LyreNetworkNoteSource source, float volume) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) LyreNetworkNoteEvent noteEvent = new LyreNetworkNoteEvent(Interlocked.Increment(ref _nextEventId), instrumentId, eventName, new LyreNetworkPosition(position.x, position.y, position.z), volume, source); byte[] payload = LyreNetworkNoteSerializer.Serialize(noteEvent); _transport.Send(payload); } } public sealed class LyreNetworkNoteEvent { public long EventId { get; } public string InstrumentId { get; } public string NoteName { get; } public LyreNetworkPosition Position { get; } public float Volume { get; } public LyreNetworkNoteSource Source { get; } public LyreNetworkNoteEvent(long eventId, string noteName, LyreNetworkPosition position, float volume, LyreNetworkNoteSource source) : this(eventId, "lyre", noteName, position, volume, source) { } public LyreNetworkNoteEvent(long eventId, string instrumentId, string noteName, LyreNetworkPosition position, float volume, LyreNetworkNoteSource source) { EventId = eventId; InstrumentId = instrumentId ?? throw new ArgumentNullException("instrumentId"); NoteName = noteName ?? throw new ArgumentNullException("noteName"); Position = position; Volume = volume; Source = source; } } public enum LyreNetworkNoteRejectReason { None, SelfOriginated, UnknownNote, InvalidPayload, Duplicate, RateLimited } public static class LyreNetworkNoteSerializer { public const int CurrentVersion = 2; public static byte[] Serialize(LyreNetworkNoteEvent noteEvent) { if (noteEvent == null) { throw new ArgumentNullException("noteEvent"); } using MemoryStream memoryStream = new MemoryStream(); using BinaryWriter binaryWriter = new BinaryWriter(memoryStream, Encoding.UTF8); binaryWriter.Write(2); binaryWriter.Write(noteEvent.EventId); binaryWriter.Write(noteEvent.InstrumentId); binaryWriter.Write(noteEvent.NoteName); binaryWriter.Write(noteEvent.Position.X); binaryWriter.Write(noteEvent.Position.Y); binaryWriter.Write(noteEvent.Position.Z); binaryWriter.Write(noteEvent.Volume); binaryWriter.Write((byte)noteEvent.Source); binaryWriter.Flush(); return memoryStream.ToArray(); } public static bool TryDeserialize(byte[]? bytes, out LyreNetworkNoteEvent noteEvent) { noteEvent = new LyreNetworkNoteEvent(0L, "lyre", string.Empty, LyreNetworkPosition.Zero, 0f, LyreNetworkNoteSource.Manual); if (bytes == null || bytes.Length == 0) { return false; } try { using MemoryStream input = new MemoryStream(bytes); using BinaryReader binaryReader = new BinaryReader(input, Encoding.UTF8); switch (binaryReader.ReadInt32()) { case 1: return TryReadVersionOne(binaryReader, out noteEvent); default: return false; case 2: { long eventId = binaryReader.ReadInt64(); string text = binaryReader.ReadString(); string text2 = binaryReader.ReadString(); LyreNetworkPosition position = new LyreNetworkPosition(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); float volume = binaryReader.ReadSingle(); LyreNetworkNoteSource source = (LyreNetworkNoteSource)binaryReader.ReadByte(); if (string.IsNullOrWhiteSpace(text) || string.IsNullOrWhiteSpace(text2)) { return false; } noteEvent = new LyreNetworkNoteEvent(eventId, text, text2, position, volume, source); return true; } } } catch (EndOfStreamException) { return false; } catch (IOException) { return false; } } private static bool TryReadVersionOne(BinaryReader reader, out LyreNetworkNoteEvent noteEvent) { long eventId = reader.ReadInt64(); string text = reader.ReadString(); LyreNetworkPosition position = new LyreNetworkPosition(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); float volume = reader.ReadSingle(); LyreNetworkNoteSource source = (LyreNetworkNoteSource)reader.ReadByte(); if (string.IsNullOrWhiteSpace(text)) { noteEvent = new LyreNetworkNoteEvent(0L, "lyre", string.Empty, LyreNetworkPosition.Zero, 0f, LyreNetworkNoteSource.Manual); return false; } noteEvent = new LyreNetworkNoteEvent(eventId, "lyre", text, position, volume, source); return true; } } public enum LyreNetworkNoteSource : byte { Manual = 1, Midi } public static class LyreNetworkNoteValidator { public static bool TryValidate(LyreNetworkNoteEvent noteEvent, long senderPeerId, long localPeerId, ISet validNoteNames, out LyreNetworkNoteRejectReason reason) { Dictionary> validEventNamesByInstrument = new Dictionary>(StringComparer.Ordinal) { ["lyre"] = validNoteNames }; return TryValidate(noteEvent, senderPeerId, localPeerId, validEventNamesByInstrument, out reason); } public static bool TryValidate(LyreNetworkNoteEvent noteEvent, long senderPeerId, long localPeerId, IReadOnlyDictionary> validEventNamesByInstrument, out LyreNetworkNoteRejectReason reason) { if (senderPeerId == localPeerId) { reason = LyreNetworkNoteRejectReason.SelfOriginated; return false; } if (validEventNamesByInstrument == null || !validEventNamesByInstrument.TryGetValue(noteEvent.InstrumentId, out ISet value) || value == null || !value.Contains(noteEvent.NoteName)) { reason = LyreNetworkNoteRejectReason.UnknownNote; return false; } if (noteEvent.EventId <= 0 || noteEvent.Volume < 0f || float.IsNaN(noteEvent.Volume) || float.IsInfinity(noteEvent.Volume) || !Enum.IsDefined(typeof(LyreNetworkNoteSource), noteEvent.Source)) { reason = LyreNetworkNoteRejectReason.InvalidPayload; return false; } reason = LyreNetworkNoteRejectReason.None; return true; } } public readonly struct LyreNetworkPosition { public static readonly LyreNetworkPosition Zero = new LyreNetworkPosition(0f, 0f, 0f); public float X { get; } public float Y { get; } public float Z { get; } public LyreNetworkPosition(float x, float y, float z) { X = x; Y = y; Z = z; } } public sealed class LyreRemoteNoteIntakeGate { private sealed class SenderState { public HashSet SeenEventIds { get; } = new HashSet(); public Queue RecentEventTimes { get; } = new Queue(); } private const double RateWindowSeconds = 1.0; private readonly Dictionary _statesBySender = new Dictionary(); private readonly int _maxEventsPerSecond; public LyreRemoteNoteIntakeGate(int maxEventsPerSecond) { if (maxEventsPerSecond < 1) { throw new ArgumentOutOfRangeException("maxEventsPerSecond", "Remote rate limit must allow at least one event per second."); } _maxEventsPerSecond = maxEventsPerSecond; } public bool TryAccept(long senderPeerId, LyreNetworkNoteEvent noteEvent, double nowSeconds, out LyreNetworkNoteRejectReason reason) { SenderState senderState = GetSenderState(senderPeerId); if (senderState.SeenEventIds.Contains(noteEvent.EventId)) { reason = LyreNetworkNoteRejectReason.Duplicate; return false; } PruneOldEvents(senderState, nowSeconds); if (senderState.RecentEventTimes.Count >= _maxEventsPerSecond) { reason = LyreNetworkNoteRejectReason.RateLimited; return false; } senderState.SeenEventIds.Add(noteEvent.EventId); senderState.RecentEventTimes.Enqueue(nowSeconds); reason = LyreNetworkNoteRejectReason.None; return true; } private SenderState GetSenderState(long senderPeerId) { if (_statesBySender.TryGetValue(senderPeerId, out SenderState value)) { return value; } value = new SenderState(); _statesBySender.Add(senderPeerId, value); return value; } private static void PruneOldEvents(SenderState state, double nowSeconds) { while (state.RecentEventTimes.Count > 0 && state.RecentEventTimes.Peek() <= nowSeconds - 1.0) { state.RecentEventTimes.Dequeue(); } } } public sealed class ValheimRoutedLyreNetwork : ILyreNetworkNoteEmitter, ILyreNetworkNoteTransport { private const string RpcName = "Bardheim_NoteEvent"; private readonly LyreNetworkNoteEmitter _emitter; private readonly Dictionary> _validEventNamesByInstrument; private readonly LyreRemoteNoteIntakeGate _intakeGate; private readonly RemoteNotePlayback _remotePlayback; private readonly RemoteDrumPlayback _remoteDrumPlayback; private readonly RemoteFlutePlayback _remoteFlutePlayback; private readonly ManualLogSource _logger; private readonly bool _multiplayerEnabled; private readonly float _remoteVolume; private readonly int _remoteMaxSimultaneousNotes; private readonly float _remoteAudibleDistance; private bool _registered; public ValheimRoutedLyreNetwork(RemoteNotePlayback remotePlayback, RemoteDrumPlayback remoteDrumPlayback, RemoteFlutePlayback remoteFlutePlayback, ManualLogSource logger, bool multiplayerEnabled, float remoteVolume, int remoteMaxSimultaneousNotes, int remoteMaxNoteEventsPerSecond, float remoteAudibleDistance) { _emitter = new LyreNetworkNoteEmitter(this); _validEventNamesByInstrument = BuildValidEventNamesByInstrument(); _intakeGate = new LyreRemoteNoteIntakeGate(remoteMaxNoteEventsPerSecond); _remotePlayback = remotePlayback; _remoteDrumPlayback = remoteDrumPlayback; _remoteFlutePlayback = remoteFlutePlayback; _logger = logger; _multiplayerEnabled = multiplayerEnabled; _remoteVolume = remoteVolume; _remoteMaxSimultaneousNotes = remoteMaxSimultaneousNotes; _remoteAudibleDistance = remoteAudibleDistance; } public void RegisterReceiver() { if (!_multiplayerEnabled) { _logger.LogInfo((object)"Lyre multiplayer audio is disabled by config."); } else if (!_registered) { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance == null) { _logger.LogWarning((object)"Lyre multiplayer audio RPC registration skipped because ZRoutedRpc is not ready."); return; } instance.Register("Bardheim_NoteEvent", (Action)OnRoutedNote); _registered = true; _logger.LogInfo((object)"Lyre multiplayer audio RPC receiver registered."); } } public void Emit(NoteRequest request, LyreNetworkNoteSource source, float volume) { _emitter.Emit(request, source, volume); } public void Emit(string instrumentId, string eventName, Vector3 position, LyreNetworkNoteSource source, float volume) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) _emitter.Emit(instrumentId, eventName, position, source, volume); } public void Send(byte[] payload) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown if (_multiplayerEnabled) { ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { ZPackage val = new ZPackage(); val.Write(payload); instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "Bardheim_NoteEvent", new object[1] { val }); } } } private void OnRoutedNote(long senderPeerId, ZPackage package) { if (!_multiplayerEnabled || package == null) { return; } byte[] bytes = package.ReadByteArray(); if (!LyreNetworkNoteSerializer.TryDeserialize(bytes, out LyreNetworkNoteEvent noteEvent)) { _logger.LogDebug((object)"Skipped lyre multiplayer note because the payload was invalid."); return; } long uID = ZNet.GetUID(); if (!LyreNetworkNoteValidator.TryValidate(noteEvent, senderPeerId, uID, _validEventNamesByInstrument, out var reason)) { LogRejected(reason); } else if (!_intakeGate.TryAccept(senderPeerId, noteEvent, Time.timeAsDouble, out reason)) { LogRejected(reason); } else if (noteEvent.InstrumentId == "lyre") { TryPlayRemoteLyreEvent(noteEvent); } else if (noteEvent.InstrumentId == "drums") { TryPlayRemoteDrumEvent(noteEvent); } else if (noteEvent.InstrumentId == "flute") { TryPlayRemoteFluteEvent(noteEvent); } } private void TryPlayRemoteLyreEvent(LyreNetworkNoteEvent noteEvent) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (!TryFindNote(noteEvent.NoteName, out NoteDefinition note)) { LogRejected(LyreNetworkNoteRejectReason.UnknownNote); return; } NoteRequest request = new NoteRequest(note, new Vector3(noteEvent.Position.X, noteEvent.Position.Y, noteEvent.Position.Z)); _remotePlayback.Play(request, _remoteMaxSimultaneousNotes, noteEvent.Volume * _remoteVolume, _remoteAudibleDistance); } private void TryPlayRemoteDrumEvent(LyreNetworkNoteEvent noteEvent) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) _remoteDrumPlayback.Play(noteEvent.NoteName, new Vector3(noteEvent.Position.X, noteEvent.Position.Y, noteEvent.Position.Z), _remoteMaxSimultaneousNotes, noteEvent.Volume * _remoteVolume, _remoteAudibleDistance); } private void TryPlayRemoteFluteEvent(LyreNetworkNoteEvent noteEvent) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) if (!TryFindInstrumentNote("flute", noteEvent.NoteName, out NoteDefinition note)) { LogRejected(LyreNetworkNoteRejectReason.UnknownNote); return; } NoteRequest request = new NoteRequest(note, new Vector3(noteEvent.Position.X, noteEvent.Position.Y, noteEvent.Position.Z)); _remoteFlutePlayback.Play(request, _remoteMaxSimultaneousNotes, noteEvent.Volume * _remoteVolume, _remoteAudibleDistance); } private void LogRejected(LyreNetworkNoteRejectReason reason) { if (reason != LyreNetworkNoteRejectReason.SelfOriginated) { _logger.LogDebug((object)$"Skipped lyre multiplayer note: {reason}."); } } private bool TryFindNote(string noteName, out NoteDefinition note) { return TryFindInstrumentNote("lyre", noteName, out note); } private bool TryFindInstrumentNote(string instrumentId, string noteName, out NoteDefinition note) { foreach (InstrumentDefinition item in InstrumentCatalog.CreateDefaultInstruments()) { if (item.Id != instrumentId) { continue; } foreach (NoteSet noteSet in item.NoteSets) { foreach (NoteDefinition note2 in noteSet.Map.Notes) { if (note2.Name == noteName) { note = note2; return true; } } } } note = new NoteDefinition(0, noteName, 0f); return false; } private static Dictionary> BuildValidEventNamesByInstrument() { HashSet hashSet = new HashSet(StringComparer.Ordinal); foreach (NoteSet item in NoteSetCatalog.CreateDefaultSets()) { foreach (NoteDefinition note in item.Map.Notes) { hashSet.Add(note.Name); } } HashSet hashSet2 = new HashSet(StringComparer.Ordinal); HashSet hashSet3 = new HashSet(StringComparer.Ordinal); foreach (InstrumentDefinition item2 in InstrumentCatalog.CreateDefaultInstruments()) { if (item2.Id == "drums") { foreach (DrumHitDefinition drumHit in item2.DrumHits) { hashSet2.Add(drumHit.Id); } } if (!(item2.Id == "flute")) { continue; } foreach (NoteSet noteSet in item2.NoteSets) { foreach (NoteDefinition note2 in noteSet.Map.Notes) { hashSet3.Add(note2.Name); } } } return new Dictionary>(StringComparer.Ordinal) { ["lyre"] = hashSet, ["drums"] = hashSet2, ["flute"] = hashSet3 }; } } } namespace Bardheim.Items { internal static class DrumInventoryIconFactory { private const int Size = 128; public static Sprite Create() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false) { name = "Bardheim_GeneratedDrumInventoryIcon", filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)1 }; Clear(val, new Color(0f, 0f, 0f, 0f)); DrawDrum(val); val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 128f); } private static void DrawDrum(Texture2D texture) { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0169: 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_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) Color color = default(Color); ((Color)(ref color))..ctor(0.035f, 0.025f, 0.018f, 0.65f); Color color2 = default(Color); ((Color)(ref color2))..ctor(0.18f, 0.08f, 0.035f, 1f); Color color3 = default(Color); ((Color)(ref color3))..ctor(0.42f, 0.22f, 0.09f, 1f); Color color4 = default(Color); ((Color)(ref color4))..ctor(0.68f, 0.39f, 0.16f, 1f); Color color5 = default(Color); ((Color)(ref color5))..ctor(0.72f, 0.58f, 0.36f, 1f); Color color6 = default(Color); ((Color)(ref color6))..ctor(0.88f, 0.75f, 0.48f, 1f); Color val = default(Color); ((Color)(ref val))..ctor(0.43f, 0.31f, 0.15f, 1f); Color color7 = default(Color); ((Color)(ref color7))..ctor(0.68f, 0.52f, 0.25f, 1f); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.23f, 0.11f, 0.045f, 1f); Color color8 = default(Color); ((Color)(ref color8))..ctor(0.45f, 0.09f, 0.04f, 1f); DrawBarrel(texture, 67, 31, 99, 96, color2); DrawEllipse(texture, 70, 68, 36, 36, color); DrawEllipse(texture, 62, 64, 41, 39, color2); DrawEllipse(texture, 62, 64, 35, 33, color3); DrawEllipse(texture, 62, 64, 30, 29, color5); DrawEllipse(texture, 55, 54, 15, 11, color6); DrawSideHandles(texture, val2, val); DrawEdgeTabs(texture, val2); DrawShellBraces(texture, val2, val); DrawEllipseOutline(texture, 62, 64, 40, 38, color2, 6); DrawEllipseOutline(texture, 62, 64, 34, 32, color4, 3); DrawEllipseOutline(texture, 62, 64, 26, 25, val2, 2); DrawWeatheredHide(texture, val2, val); for (int i = 0; i < 14; i++) { float num = (float)i * (float)Math.PI * 2f / 14f; int num2 = 62 + Mathf.RoundToInt(Mathf.Cos(num) * 37f); int num3 = 64 + Mathf.RoundToInt(Mathf.Sin(num) * 35f); int x = 62 + Mathf.RoundToInt(Mathf.Cos(num) * 28f); int y = 64 + Mathf.RoundToInt(Mathf.Sin(num) * 27f); DrawLine(texture, num2, num3, x, y, val2, 2); DrawCircle(texture, num2, num3, 2, color7); } for (int j = 0; j < 6; j++) { float num4 = (float)j * (float)Math.PI * 2f / 6f + 0.25f; DrawLine(texture, 62 + Mathf.RoundToInt(Mathf.Cos(num4) * 9f), 64 + Mathf.RoundToInt(Mathf.Sin(num4) * 8f), 62 + Mathf.RoundToInt(Mathf.Cos(num4) * 22f), 64 + Mathf.RoundToInt(Mathf.Sin(num4) * 20f), color8, 2); } DrawEllipseOutline(texture, 62, 64, 19, 18, color8, 2); DrawLine(texture, 44, 64, 80, 64, color8, 2); DrawLine(texture, 62, 45, 62, 83, color8, 2); DrawLine(texture, 47, 82, 77, 46, color8, 2); DrawLine(texture, 47, 46, 77, 82, color8, 2); DrawLine(texture, 50, 77, 68, 48, val2, 1); DrawLine(texture, 74, 77, 56, 48, val2, 1); DrawLine(texture, 52, 29, 84, 38, color2, 5); DrawLine(texture, 55, 31, 81, 38, val, 2); } private static void DrawSideHandles(Texture2D texture, Color leather, Color bronze) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_008a: 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) DrawLine(texture, 29, 51, 20, 59, leather, 3); DrawLine(texture, 20, 59, 20, 73, leather, 4); DrawLine(texture, 20, 73, 29, 81, leather, 3); DrawLine(texture, 93, 51, 102, 59, leather, 3); DrawLine(texture, 102, 59, 102, 73, leather, 4); DrawLine(texture, 102, 73, 93, 81, leather, 3); DrawRect(texture, 27, 49, 6, 8, bronze); DrawRect(texture, 27, 78, 6, 8, bronze); DrawRect(texture, 90, 49, 6, 8, bronze); DrawRect(texture, 90, 78, 6, 8, bronze); } private static void DrawEdgeTabs(Texture2D texture, Color leather) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 18; i++) { float num = (float)i * (float)Math.PI * 2f / 18f + 0.15f; int x = 62 + Mathf.RoundToInt(Mathf.Cos(num) * 36f); int y = 64 + Mathf.RoundToInt(Mathf.Sin(num) * 34f); int x2 = 62 + Mathf.RoundToInt(Mathf.Cos(num) * 42f); int y2 = 64 + Mathf.RoundToInt(Mathf.Sin(num) * 39f); DrawLine(texture, x, y, x2, y2, leather, 2); } } private static void DrawWeatheredHide(Texture2D texture, Color leather, Color bronze) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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) DrawLine(texture, 42, 48, 56, 53, bronze, 3); DrawLine(texture, 68, 78, 84, 72, leather, 3); DrawLine(texture, 47, 85, 62, 88, bronze, 2); DrawLine(texture, 73, 45, 86, 52, leather, 2); DrawLine(texture, 43, 55, 53, 51, bronze, 1); DrawLine(texture, 43, 75, 57, 80, bronze, 1); DrawLine(texture, 74, 52, 84, 59, leather, 1); DrawLine(texture, 73, 82, 84, 76, bronze, 1); DrawLine(texture, 55, 42, 65, 39, leather, 1); DrawLine(texture, 50, 92, 66, 89, leather, 1); DrawCircle(texture, 52, 58, 1, bronze); DrawCircle(texture, 72, 70, 1, leather); DrawCircle(texture, 59, 80, 1, bronze); } private static void DrawShellBraces(Texture2D texture, Color leather, Color bronze) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) DrawLine(texture, 82, 37, 100, 54, leather, 2); DrawLine(texture, 100, 54, 84, 92, leather, 2); DrawLine(texture, 89, 38, 101, 69, bronze, 1); DrawLine(texture, 101, 69, 90, 93, bronze, 1); DrawLine(texture, 75, 33, 94, 47, leather, 2); DrawLine(texture, 94, 86, 75, 98, leather, 2); } private static void DrawBarrel(Texture2D texture, int left, int top, int right, int bottom, Color color) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) for (int i = top; i <= bottom; i++) { float num = (float)(i - top) / (float)(bottom - top); float num2 = Mathf.Sin(num * (float)Math.PI) * 9f; int num3 = Mathf.RoundToInt(6f - num2); DrawLine(texture, left + num3, i, right - num3, i, color, 1); } } private static void DrawEllipse(Texture2D texture, int centerX, int centerY, int radiusX, int radiusY, Color color) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) for (int i = centerY - radiusY; i <= centerY + radiusY; i++) { for (int j = centerX - radiusX; j <= centerX + radiusX; j++) { float num = (float)(j - centerX) / (float)radiusX; float num2 = (float)(i - centerY) / (float)radiusY; if (num * num + num2 * num2 <= 1f) { SetPixel(texture, j, i, color); } } } } private static void DrawCircle(Texture2D texture, int centerX, int centerY, int radius, Color color) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) DrawEllipse(texture, centerX, centerY, radius, radius, color); } private static void DrawEllipseOutline(Texture2D texture, int centerX, int centerY, int radiusX, int radiusY, Color color, int thickness) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < thickness; i++) { for (int j = 0; j < 360; j += 2) { float num = (float)j * ((float)Math.PI / 180f); SetPixel(texture, centerX + Mathf.RoundToInt(Mathf.Cos(num) * (float)(radiusX - i)), centerY + Mathf.RoundToInt(Mathf.Sin(num) * (float)(radiusY - i)), color); } } } private static void DrawArcBand(Texture2D texture, int centerX, int centerY, int radiusX, int radiusY, Color color, int thickness) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < thickness; i++) { for (int j = 18; j <= 162; j += 2) { float num = (float)j * ((float)Math.PI / 180f); SetPixel(texture, centerX + Mathf.RoundToInt(Mathf.Cos(num) * (float)(radiusX - i)), centerY + Mathf.RoundToInt(Mathf.Sin(num) * (float)(radiusY - i)), color); } } } private static void Clear(Texture2D texture, Color color) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { texture.SetPixel(j, i, color); } } } private static void DrawRect(Texture2D texture, int x, int y, int width, int height, Color color) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) for (int i = y; i < y + height; i++) { for (int j = x; j < x + width; j++) { SetPixel(texture, j, i, color); } } } private static void DrawLine(Texture2D texture, int x0, int y0, int x1, int y1, Color color, int thickness) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Abs(x1 - x0); int num2 = -Mathf.Abs(y1 - y0); int num3 = ((x0 < x1) ? 1 : (-1)); int num4 = ((y0 < y1) ? 1 : (-1)); int num5 = num + num2; while (true) { DrawBrush(texture, x0, y0, thickness, color); if (x0 == x1 && y0 == y1) { break; } int num6 = 2 * num5; if (num6 >= num2) { num5 += num2; x0 += num3; } if (num6 <= num) { num5 += num; y0 += num4; } } } private static void DrawBrush(Texture2D texture, int centerX, int centerY, int thickness, Color color) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) int num = thickness / 2; for (int i = centerY - num; i <= centerY + num; i++) { for (int j = centerX - num; j <= centerX + num; j++) { SetPixel(texture, j, i, color); } } } private static void SetPixel(Texture2D texture, int x, int y, Color color) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (x >= 0 && x < 128 && y >= 0 && y < 128) { texture.SetPixel(x, y, color); } } } public sealed class DrumItemRegistration { public const string PrefabName = "Bardheim_Drum"; public const string BasePrefabName = "Hammer"; private readonly ManualLogSource _logger; private bool _registered; public DrumItemRegistration(ManualLogSource logger) { _logger = logger; } public void Register() { PrefabManager.OnVanillaPrefabsAvailable += RegisterWhenPrefabsAvailable; } private void RegisterWhenPrefabsAvailable() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown if (!_registered) { ItemConfig val = CreateItemConfig(); CustomItem val2 = new CustomItem("Bardheim_Drum", "Hammer", val); ConfigureHeldOnlyDrum(val2.ItemDrop); DrumHandDrumVisualProbe.Apply(val2.ItemPrefab, _logger); ItemManager.Instance.AddItem(val2); _registered = true; PrefabManager.OnVanillaPrefabsAvailable -= RegisterWhenPrefabsAvailable; _logger.LogInfo((object)"Registered drum item Bardheim_Drum cloned from Hammer; generated one-handed frame-drum visual/icon probe applied and custom asset bundle pipeline disabled."); } } private static ItemConfig CreateItemConfig() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown ItemConfig val = new ItemConfig { Name = "Drum", Description = "A simple hand drum for playing rhythm hits.", CraftingStation = CraftingStations.Workbench, Amount = 1, Icon = DrumInventoryIconFactory.Create() }; val.AddRequirement("Wood", 8, 1); val.AddRequirement("LeatherScraps", 4, 1); val.AddRequirement("DeerHide", 2, 1); return val; } private void ConfigureHeldOnlyDrum(ItemDrop itemDrop) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) SharedData shared = itemDrop.m_itemData.m_shared; shared.m_itemType = (ItemType)19; shared.m_attachOverride = (ItemType)0; shared.m_animationState = (AnimationState)1; shared.m_buildPieces = null; shared.m_attack = null; shared.m_secondaryAttack = null; shared.m_toolTier = 0; shared.m_skillType = (SkillType)0; shared.m_useDurability = false; shared.m_canBeReparied = false; shared.m_maxDurability = 0f; shared.m_durabilityDrain = 0f; shared.m_useDurabilityDrain = 0f; _logger.LogInfo((object)"Configured drum as held-only one-handed Hammer carrier: build pieces, attacks, tool tier, and repair/durability actions disabled."); } } internal static class DrumHandDrumVisualProbe { private sealed class RendererTarget { public MeshRenderer Renderer { get; } public MeshFilter? Filter { get; } public RendererTarget(MeshRenderer renderer, MeshFilter? filter) { Renderer = renderer; Filter = filter; } } private sealed class MeshBuilder { private readonly List _vertices = new List(); private readonly List[] _triangles; public MeshBuilder(int materialCount) { _triangles = (from _ in Enumerable.Range(0, materialCount) select new List()).ToArray(); } public void ApplyTo(Mesh mesh) { mesh.SetVertices(_vertices); mesh.subMeshCount = _triangles.Length; for (int i = 0; i < _triangles.Length; i++) { mesh.SetTriangles(_triangles[i].ToArray(), i); } } public void AddCylinderZ(Vector3 center, float radiusX, float radiusY, float depth, int segments, int materialSide, int materialCap) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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) int[] array = new int[segments]; int[] array2 = new int[segments]; for (int i = 0; i < segments; i++) { float num = (float)Math.PI * 2f * (float)i / (float)segments; float num2 = 1f + 0.025f * Mathf.Sin((float)i * 2.1f); float num3 = Mathf.Cos(num) * radiusX * num2; float num4 = Mathf.Sin(num) * radiusY * num2; array[i] = AddVertex(center + new Vector3(num3, num4, depth * 0.5f)); array2[i] = AddVertex(center + new Vector3(num3, num4, (0f - depth) * 0.5f)); } for (int j = 0; j < segments; j++) { AddQuad(array[j], array[(j + 1) % segments], array2[(j + 1) % segments], array2[j], materialSide); } int a = AddVertex(center + new Vector3(0f, 0f, depth * 0.5f)); int a2 = AddVertex(center + new Vector3(0f, 0f, (0f - depth) * 0.5f)); for (int k = 0; k < segments; k++) { AddTriangle(a, array[k], array[(k + 1) % segments], materialCap); AddTriangle(a2, array2[(k + 1) % segments], array2[k], materialCap); } } public void AddCylinderSideZ(Vector3 center, float radiusX, float radiusY, float depth, int segments, int materialSide) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) int[] array = new int[segments]; int[] array2 = new int[segments]; for (int i = 0; i < segments; i++) { float num = (float)Math.PI * 2f * (float)i / (float)segments; float num2 = 1f + 0.018f * Mathf.Sin((float)i * 1.8f); float num3 = Mathf.Cos(num) * radiusX * num2; float num4 = Mathf.Sin(num) * radiusY * num2; array[i] = AddVertex(center + new Vector3(num3, num4, depth * 0.5f)); array2[i] = AddVertex(center + new Vector3(num3, num4, (0f - depth) * 0.5f)); } for (int j = 0; j < segments; j++) { int num5 = (j + 1) % segments; AddQuad(array[j], array[num5], array2[num5], array2[j], materialSide); AddQuad(array2[j], array2[num5], array[num5], array[j], materialSide); } } public void AddOrientedBox(Vector3 center, Vector3 axisX, Vector3 axisY, Vector3 axisZ, Vector3 size, int material) { //IL_0019: 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_0025: 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_004b: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) ((Vector3)(ref axisX)).Normalize(); ((Vector3)(ref axisY)).Normalize(); ((Vector3)(ref axisZ)).Normalize(); Vector3 val = size * 0.5f; int[] array = new int[8]; int num = 0; for (int i = -1; i <= 1; i += 2) { for (int j = -1; j <= 1; j += 2) { for (int k = -1; k <= 1; k += 2) { array[num++] = AddVertex(center + axisX * val.x * (float)i + axisY * val.y * (float)j + axisZ * val.z * (float)k); } } } AddQuad(array[0], array[2], array[3], array[1], material); AddQuad(array[4], array[5], array[7], array[6], material); AddQuad(array[0], array[1], array[5], array[4], material); AddQuad(array[2], array[6], array[7], array[3], material); AddQuad(array[1], array[3], array[7], array[5], material); AddQuad(array[0], array[4], array[6], array[2], material); } public void AddRod(Vector3 start, Vector3 end, float radius, int segments, int material) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0042: 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_0048: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0088: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 val2 = ((Mathf.Abs(normalized.z) < 0.92f) ? Vector3.forward : Vector3.up); Vector3 val3 = Vector3.Cross(normalized, val2); Vector3 normalized2 = ((Vector3)(ref val3)).normalized; val3 = Vector3.Cross(normalized2, normalized); Vector3 normalized3 = ((Vector3)(ref val3)).normalized; int[] array = new int[segments]; int[] array2 = new int[segments]; for (int i = 0; i < segments; i++) { float num = (float)Math.PI * 2f * (float)i / (float)segments; Vector3 val4 = normalized2 * Mathf.Cos(num) * radius + normalized3 * Mathf.Sin(num) * radius; array[i] = AddVertex(start + val4); array2[i] = AddVertex(end + val4); } for (int j = 0; j < segments; j++) { AddQuad(array[j], array[(j + 1) % segments], array2[(j + 1) % segments], array2[j], material); } int a = AddVertex(start); int a2 = AddVertex(end); for (int k = 0; k < segments; k++) { AddTriangle(a, array[(k + 1) % segments], array[k], material); AddTriangle(a2, array2[k], array2[(k + 1) % segments], material); } } private int AddVertex(Vector3 vertex) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) _vertices.Add(vertex); return _vertices.Count - 1; } private void AddQuad(int a, int b, int c, int d, int material) { AddTriangle(a, b, c, material); AddTriangle(a, c, d, material); } private void AddTriangle(int a, int b, int c, int material) { _triangles[material].Add(a); _triangles[material].Add(b); _triangles[material].Add(c); } } private const string VisualName = "Bardheim_OneHandedHangingDrumVisual"; private const int BodySegments = 24; private const int RodSegments = 8; public static void Apply(GameObject itemPrefab, ManualLogSource logger) { //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) if (itemPrefab == null) { logger.LogWarning((object)"Drum one-handed visual probe skipped because the cloned item prefab is null."); return; } Mesh val = BuildDrumMesh(); Material[] array = CreateMaterials(); Renderer[] componentsInChildren = itemPrefab.GetComponentsInChildren(true); RendererTarget rendererTarget = SelectTargetRenderer(itemPrefab); if (rendererTarget != null) { rendererTarget.Filter.sharedMesh = val; ((Renderer)rendererTarget.Renderer).sharedMaterials = array; ((Object)((Component)rendererTarget.Renderer).gameObject).name = "Bardheim_OneHandedHangingDrumVisual"; EnsurePlayModePose(((Component)rendererTarget.Renderer).gameObject); ((Renderer)rendererTarget.Renderer).enabled = true; Renderer[] array2 = componentsInChildren; foreach (Renderer val2 in array2) { if ((Object)(object)val2 != (Object)(object)rendererTarget.Renderer) { val2.enabled = false; } } logger.LogInfo((object)("Applied one-handed hanging drum visual by replacing renderer path=" + GetPath(itemPrefab.transform, ((Component)rendererTarget.Renderer).transform) + " " + $"mesh={((Object)val).name} materials={array.Length} disabledRenderers={Math.Max(0, componentsInChildren.Length - 1)}.")); return; } GameObject val3 = new GameObject("Bardheim_OneHandedHangingDrumVisual"); val3.transform.SetParent(itemPrefab.transform, false); val3.transform.localPosition = Vector3.zero; val3.transform.localRotation = Quaternion.identity; val3.transform.localScale = Vector3.one; MeshFilter val4 = val3.AddComponent(); MeshRenderer val5 = val3.AddComponent(); val4.sharedMesh = val; ((Renderer)val5).sharedMaterials = array; EnsurePlayModePose(val3); Renderer[] array3 = componentsInChildren; foreach (Renderer val6 in array3) { val6.enabled = false; } logger.LogWarning((object)"Applied one-handed hanging drum visual as fallback child path=Bardheim_OneHandedHangingDrumVisual; no MeshRenderer with MeshFilter was found to replace in place."); } private static RendererTarget? SelectTargetRenderer(GameObject itemPrefab) { GameObject itemPrefab2 = itemPrefab; RendererTarget[] array = (from renderer in itemPrefab2.GetComponentsInChildren(true) select new RendererTarget(renderer, ((Component)renderer).GetComponent()) into candidate where candidate.Filter != null orderby ((Renderer)candidate.Renderer).enabled descending select candidate).ThenBy((RendererTarget candidate) => GetPath(itemPrefab2.transform, ((Component)candidate.Renderer).transform), StringComparer.Ordinal).ToArray(); return (array.Length == 0) ? null : array[0]; } private static void EnsurePlayModePose(GameObject visual) { if (visual.GetComponent() == null) { visual.AddComponent(); } } private static Mesh BuildDrumMesh() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Expected O, but got Unknown MeshBuilder meshBuilder = new MeshBuilder(6); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, -0.42f, 0f); meshBuilder.AddCylinderZ(val, 0.56f, 0.52f, 0.42f, 24, 0, 1); meshBuilder.AddCylinderZ(val + new Vector3(0f, 0f, 0.235f), 0.585f, 0.545f, 0.055f, 24, 4, 1); meshBuilder.AddCylinderZ(val + new Vector3(0f, 0f, -0.235f), 0.585f, 0.545f, 0.055f, 24, 4, 1); AddOutsideShellBand(meshBuilder, val); AddRaisedOutsideBands(meshBuilder, val); AddSolidSideShellPanels(meshBuilder, val); AddSideStaves(meshBuilder, val); AddRimBinding(meshBuilder, val); AddLacing(meshBuilder, val); AddSideCrossBraces(meshBuilder, val); AddLaceKnots(meshBuilder, val); AddExtraEdgeTabs(meshBuilder, val); AddBroadHidePanelVariation(meshBuilder, val); AddIrregularHidePatches(meshBuilder, val); AddTopGrip(meshBuilder, val); AddSideHandles(meshBuilder, val); AddRaisedKnotworkPaint(meshBuilder, val); Mesh val2 = new Mesh { name = "Bardheim_GeneratedOneHandedHangingDrum" }; meshBuilder.ApplyTo(val2); val2.RecalculateNormals(); val2.RecalculateBounds(); return val2; } private static void AddSolidSideShellPanels(MeshBuilder builder, Vector3 center) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); Vector3 axisY = default(Vector3); for (int i = 0; i < 18; i++) { float num = (float)Math.PI * 2f * (float)i / 18f; ((Vector3)(ref val))..ctor(Mathf.Cos(num), Mathf.Sin(num), 0f); ((Vector3)(ref axisY))..ctor(0f - Mathf.Sin(num), Mathf.Cos(num), 0f); float num2 = 1f + 0.025f * Mathf.Sin((float)i * 1.7f); Vector3 center2 = center + new Vector3(val.x * 0.535f * num2, val.y * 0.5f * num2, 0f); int material = ((i % 3 == 0) ? 3 : 0); builder.AddOrientedBox(center2, val, axisY, Vector3.forward, new Vector3(0.07f, 0.125f, 0.43f), material); } } private static void AddOutsideShellBand(MeshBuilder builder, Vector3 center) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) builder.AddCylinderSideZ(center, 0.625f, 0.585f, 0.46f, 24, 3); builder.AddCylinderSideZ(center, 0.585f, 0.545f, 0.42f, 24, 0); } private static void AddRaisedOutsideBands(MeshBuilder builder, Vector3 center) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0031: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) builder.AddCylinderSideZ(center, 0.655f, 0.615f, 0.14f, 24, 4); builder.AddCylinderSideZ(center + new Vector3(0f, 0f, 0.185f), 0.645f, 0.605f, 0.06f, 24, 4); builder.AddCylinderSideZ(center + new Vector3(0f, 0f, -0.185f), 0.645f, 0.605f, 0.06f, 24, 4); Vector3 val = default(Vector3); Vector3 axisY = default(Vector3); for (int i = 0; i < 12; i++) { float num = (float)Math.PI * 2f * (float)i / 12f; ((Vector3)(ref val))..ctor(Mathf.Cos(num), Mathf.Sin(num), 0f); ((Vector3)(ref axisY))..ctor(0f - Mathf.Sin(num), Mathf.Cos(num), 0f); Vector3 center2 = center + new Vector3(val.x * 0.665f, val.y * 0.625f, 0f); builder.AddOrientedBox(center2, val, axisY, Vector3.forward, new Vector3(0.026f, 0.07f, 0.04f), (i % 2 == 0) ? 2 : 4); } } private static void AddSideStaves(MeshBuilder builder, Vector3 center) { //IL_0049: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00c9: 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_00d9: 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) Vector3 val = default(Vector3); Vector3 val2 = default(Vector3); for (int i = 0; i < 12; i++) { float num = (float)Math.PI * 2f * (float)i / 12f; ((Vector3)(ref val))..ctor(Mathf.Cos(num), Mathf.Sin(num), 0f); ((Vector3)(ref val2))..ctor(0f - Mathf.Sin(num), Mathf.Cos(num), 0f); Vector3 val3 = center + new Vector3(val.x * 0.595f, val.y * 0.555f, 0f); builder.AddOrientedBox(val3, val, val2, Vector3.forward, new Vector3(0.04f, 0.09f, 0.43f), (i % 2 == 0) ? 3 : 0); builder.AddRod(val3 + val2 * -0.035f + Vector3.forward * 0.205f, val3 + val2 * -0.035f + Vector3.forward * -0.205f, 0.005f, 4, 4); } } private static void AddRimBinding(MeshBuilder builder, Vector3 center) { //IL_0002: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_0100: Unknown result type (might be due to invalid IL or missing references) AddEllipseRing(builder, center, 0.61f, 0.57f, 0.27f, 0.022f, 4); AddEllipseRing(builder, center, 0.61f, 0.57f, -0.27f, 0.022f, 4); AddEllipseRing(builder, center, 0.5f, 0.47f, 0.285f, 0.011f, 2); AddEllipseRing(builder, center, 0.5f, 0.47f, -0.285f, 0.011f, 2); Vector3 val = default(Vector3); Vector3 axisY = default(Vector3); for (int i = 0; i < 16; i++) { float num = (float)Math.PI * 2f * (float)i / 16f; ((Vector3)(ref val))..ctor(Mathf.Cos(num), Mathf.Sin(num), 0f); ((Vector3)(ref axisY))..ctor(0f - Mathf.Sin(num), Mathf.Cos(num), 0f); Vector3 center2 = center + new Vector3(val.x * 0.5f, val.y * 0.47f, 0.3f); builder.AddOrientedBox(center2, val, axisY, Vector3.forward, new Vector3(0.026f, 0.038f, 0.014f), 2); } } private static void AddLacing(MeshBuilder builder, Vector3 center) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) Vector3 axisX = default(Vector3); Vector3 axisY = default(Vector3); for (int i = 0; i < 14; i++) { float num = (float)Math.PI * 2f * (float)i / 14f; float num2 = (float)Math.PI * 2f * ((float)i + 0.42f) / 14f; Vector3 start = center + new Vector3(Mathf.Cos(num) * 0.575f, Mathf.Sin(num) * 0.535f, 0.285f); Vector3 end = center + new Vector3(Mathf.Cos(num2) * 0.575f, Mathf.Sin(num2) * 0.535f, -0.285f); builder.AddRod(start, end, 0.012f, 5, 4); Vector3 center2 = center + new Vector3(Mathf.Cos(num) * 0.595f, Mathf.Sin(num) * 0.555f, 0.285f); ((Vector3)(ref axisX))..ctor(Mathf.Cos(num), Mathf.Sin(num), 0f); ((Vector3)(ref axisY))..ctor(0f - Mathf.Sin(num), Mathf.Cos(num), 0f); builder.AddOrientedBox(center2, axisX, axisY, Vector3.forward, new Vector3(0.042f, 0.09f, 0.036f), 4); } } private static void AddSideCrossBraces(MeshBuilder builder, Vector3 center) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 12; i++) { float num = (float)Math.PI * 2f * (float)i / 12f; float num2 = (float)Math.PI * 2f * ((float)i + 0.55f) / 12f; float num3 = (float)Math.PI * 2f * ((float)i - 0.55f) / 12f; Vector3 start = center + new Vector3(Mathf.Cos(num) * 0.6f, Mathf.Sin(num) * 0.56f, 0.225f); Vector3 end = center + new Vector3(Mathf.Cos(num2) * 0.6f, Mathf.Sin(num2) * 0.56f, -0.225f); Vector3 end2 = center + new Vector3(Mathf.Cos(num3) * 0.6f, Mathf.Sin(num3) * 0.56f, -0.225f); builder.AddRod(start, end, 0.01f, 5, 4); builder.AddRod(start, end2, 0.01f, 5, 4); } } private static void AddLaceKnots(MeshBuilder builder, Vector3 center) { //IL_0049: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0074: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00db: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); Vector3 axisY = default(Vector3); for (int i = 0; i < 14; i++) { float num = (float)Math.PI * 2f * (float)i / 14f; ((Vector3)(ref val))..ctor(Mathf.Cos(num), Mathf.Sin(num), 0f); ((Vector3)(ref axisY))..ctor(0f - Mathf.Sin(num), Mathf.Cos(num), 0f); Vector3 center2 = center + new Vector3(val.x * 0.6f, val.y * 0.56f, 0.305f); Vector3 center3 = center + new Vector3(val.x * 0.6f, val.y * 0.56f, -0.305f); builder.AddOrientedBox(center2, val, axisY, Vector3.forward, new Vector3(0.04f, 0.045f, 0.026f), 4); builder.AddOrientedBox(center3, val, axisY, Vector3.forward, new Vector3(0.036f, 0.04f, 0.024f), 4); } } private static void AddExtraEdgeTabs(MeshBuilder builder, Vector3 center) { //IL_0062: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); Vector3 axisY = default(Vector3); for (int i = 0; i < 24; i++) { float num = (float)Math.PI * 2f * ((float)i + 0.25f) / 24f; ((Vector3)(ref val))..ctor(Mathf.Cos(num), Mathf.Sin(num), 0f); ((Vector3)(ref axisY))..ctor(0f - Mathf.Sin(num), Mathf.Cos(num), 0f); float num2 = ((i % 2 == 0) ? 0.307f : (-0.307f)); Vector3 center2 = center + new Vector3(val.x * 0.525f, val.y * 0.495f, num2); float num3 = ((i % 3 == 0) ? 0.07f : 0.05f); builder.AddOrientedBox(center2, val, axisY, Vector3.forward, new Vector3(0.026f, num3, 0.02f), 4); } } private static void AddIrregularHidePatches(MeshBuilder builder, Vector3 center) { //IL_0001: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) float num = center.z + 0.313f; Vector3[] array = (Vector3[])(object)new Vector3[6] { new Vector3(-0.28f, -0.1f, num), new Vector3(-0.16f, 0.28f, num), new Vector3(0.23f, -0.23f, num), new Vector3(0.3f, 0.14f, num), new Vector3(-0.38f, 0.12f, num), new Vector3(0.03f, -0.35f, num) }; Vector3 axisX = default(Vector3); Vector3 axisY = default(Vector3); for (int i = 0; i < array.Length; i++) { Vector3 val = center + array[i]; float num2 = 0.65f + (float)i * 0.9f; ((Vector3)(ref axisX))..ctor(Mathf.Cos(num2), Mathf.Sin(num2), 0f); ((Vector3)(ref axisY))..ctor(0f - Mathf.Sin(num2), Mathf.Cos(num2), 0f); builder.AddOrientedBox(val, axisX, axisY, Vector3.forward, new Vector3(0.09f, 0.03f, 0.01f), (i % 2 == 0) ? 3 : 2); Vector3 end = val + new Vector3(Mathf.Cos(num2) * 0.075f, Mathf.Sin(num2) * 0.05f, 0f); builder.AddRod(val, end, 0.008f, 4, (i % 2 == 0) ? 3 : 2); } } private static void AddBroadHidePanelVariation(MeshBuilder builder, Vector3 center) { //IL_0001: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) float num = center.z + 0.308f; (Vector3, float, Vector3, int)[] array = new(Vector3, float, Vector3, int)[4] { (new Vector3(-0.17f, 0.16f, num), 0.35f, new Vector3(0.18f, 0.055f, 0.009f), 3), (new Vector3(0.19f, -0.12f, num), -0.55f, new Vector3(0.2f, 0.05f, 0.009f), 2), (new Vector3(-0.23f, -0.2f, num), -0.15f, new Vector3(0.13f, 0.045f, 0.009f), 3), (new Vector3(0.25f, 0.21f, num), 0.7f, new Vector3(0.14f, 0.04f, 0.009f), 2) }; (Vector3, float, Vector3, int)[] array2 = array; Vector3 axisX = default(Vector3); Vector3 axisY = default(Vector3); for (int i = 0; i < array2.Length; i++) { (Vector3, float, Vector3, int) tuple = array2[i]; ((Vector3)(ref axisX))..ctor(Mathf.Cos(tuple.Item2), Mathf.Sin(tuple.Item2), 0f); ((Vector3)(ref axisY))..ctor(0f - Mathf.Sin(tuple.Item2), Mathf.Cos(tuple.Item2), 0f); builder.AddOrientedBox(center + tuple.Item1, axisX, axisY, Vector3.forward, tuple.Item3, tuple.Item4); } } private static void AddTopGrip(MeshBuilder builder, Vector3 center) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0031: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_00b7: Unknown result type (might be due to invalid IL or missing references) Vector3 start = center + new Vector3(-0.22f, 0.34f, -0.04f); Vector3 start2 = center + new Vector3(0.22f, 0.34f, -0.04f); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(-0.12f, -0.08f, -0.05f); Vector3 end = default(Vector3); ((Vector3)(ref end))..ctor(0.12f, -0.08f, -0.05f); builder.AddRod(start, val, 0.026f, 8, 4); builder.AddRod(start2, end, 0.026f, 8, 4); builder.AddRod(val, end, 0.04f, 8, 4); builder.AddRod(new Vector3(-0.1f, -0.08f, -0.04f), new Vector3(0.1f, -0.08f, -0.04f), 0.055f, 8, 3); } private static void AddSideHandles(MeshBuilder builder, Vector3 center) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) AddSideHandle(builder, center, -1f); AddSideHandle(builder, center, 1f); } private static void AddSideHandle(MeshBuilder builder, Vector3 center, float side) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0048: 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_0052: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_008d: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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) //IL_010d: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) Vector3 axisX = default(Vector3); ((Vector3)(ref axisX))..ctor(side, 0f, 0f); Vector3 up = Vector3.up; Vector3 val = center + new Vector3(side * 0.59f, 0.16f, -0.02f); Vector3 val2 = center + new Vector3(side * 0.59f, -0.16f, -0.02f); Vector3 val3 = center + new Vector3(side * 0.69f, 0.09f, -0.04f); Vector3 val4 = center + new Vector3(side * 0.69f, -0.09f, -0.04f); Vector3 val5 = center + new Vector3(side * 0.71f, 0f, -0.045f); builder.AddOrientedBox(val, axisX, up, Vector3.forward, new Vector3(0.055f, 0.085f, 0.045f), 4); builder.AddOrientedBox(val2, axisX, up, Vector3.forward, new Vector3(0.055f, 0.085f, 0.045f), 4); builder.AddRod(val + new Vector3(side * 0.02f, -0.02f, -0.005f), val3, 0.02f, 8, 4); builder.AddRod(val3, val4, 0.026f, 8, 4); builder.AddRod(val4, val2 + new Vector3(side * 0.02f, 0.02f, -0.005f), 0.02f, 8, 4); builder.AddRod(val5 + new Vector3(0f, -0.07f, 0.006f), val5 + new Vector3(0f, 0.07f, 0.006f), 0.034f, 8, 3); } private static void AddRaisedKnotworkPaint(MeshBuilder builder, Vector3 center) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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) //IL_007a: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00b9: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) float num = center.z + 0.32f; AddEllipseRing(builder, center, 0.32f, 0.3f, num - center.z, 0.009f, 5); builder.AddRod(center + new Vector3(-0.25f, 0f, num), center + new Vector3(0.25f, 0f, num), 0.012f, 4, 5); builder.AddRod(center + new Vector3(0f, -0.25f, num), center + new Vector3(0f, 0.27f, num), 0.012f, 4, 5); builder.AddRod(center + new Vector3(-0.3f, 0.22f, num), center + new Vector3(0.3f, 0.22f, num), 0.01f, 4, 5); builder.AddRod(center + new Vector3(-0.22f, -0.26f, num), center + new Vector3(0.22f, 0.24f, num), 0.01f, 4, 5); builder.AddRod(center + new Vector3(0.22f, -0.26f, num), center + new Vector3(-0.22f, 0.24f, num), 0.01f, 4, 5); AddKnotLoop(builder, center, num, 0f); AddKnotLoop(builder, center, num, (float)Math.PI * 2f / 3f); AddKnotLoop(builder, center, num, 4.1887903f); for (int i = 0; i < 6; i++) { float num2 = (float)Math.PI * 2f * (float)i / 6f + 0.35f; builder.AddRod(center + new Vector3(Mathf.Cos(num2) * 0.15f, Mathf.Sin(num2) * 0.14f, num), center + new Vector3(Mathf.Cos(num2) * 0.31f, Mathf.Sin(num2) * 0.29f, num), 0.006f, 4, 5); } } private static void AddKnotLoop(MeshBuilder builder, Vector3 center, float z, float rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_007a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = center + RotateFace(new Vector3(0f, 0.075f, z), rotation); Vector3 val2 = center + RotateFace(new Vector3(0.115f, -0.055f, z), rotation); Vector3 val3 = center + RotateFace(new Vector3(-0.115f, -0.055f, z), rotation); builder.AddRod(val, val2, 0.009f, 4, 5); builder.AddRod(val2, val3, 0.009f, 4, 5); builder.AddRod(val3, val, 0.009f, 4, 5); } private static Vector3 RotateFace(Vector3 point, float rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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) return new Vector3(point.x * Mathf.Cos(rotation) - point.y * Mathf.Sin(rotation), point.x * Mathf.Sin(rotation) + point.y * Mathf.Cos(rotation), point.z); } private static void AddEllipseRing(MeshBuilder builder, Vector3 center, float radiusX, float radiusY, float zOffset, float radius, int material) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 24; i++) { float num = (float)Math.PI * 2f * (float)i / 24f; float num2 = (float)Math.PI * 2f * (float)(i + 1) / 24f; builder.AddRod(center + new Vector3(Mathf.Cos(num) * radiusX, Mathf.Sin(num) * radiusY, zOffset), center + new Vector3(Mathf.Cos(num2) * radiusX, Mathf.Sin(num2) * radiusY, zOffset), radius, 4, material); } } private static Material[] CreateMaterials() { //IL_003c: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) Shader shader = Shader.Find("Standard") ?? Shader.Find("Diffuse"); return (Material[])(object)new Material[6] { CreateMaterial(shader, "Bardheim_HangingDrumDarkOak", new Color(0.18f, 0.085f, 0.035f, 1f)), CreateMaterial(shader, "Bardheim_HangingDrumRawhide", new Color(0.58f, 0.46f, 0.29f, 1f)), CreateMaterial(shader, "Bardheim_HangingDrumWornBronze", new Color(0.4f, 0.29f, 0.13f, 1f)), CreateMaterial(shader, "Bardheim_HangingDrumOakHighlight", new Color(0.56f, 0.34f, 0.13f, 1f)), CreateMaterial(shader, "Bardheim_HangingDrumLeather", new Color(0.12f, 0.055f, 0.025f, 1f)), CreateMaterial(shader, "Bardheim_HangingDrumRedPaint", new Color(0.32f, 0.045f, 0.025f, 1f)) }; } private static Material CreateMaterial(Shader shader, string name, Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return new Material(shader) { name = name, color = color }; } private static string GetPath(Transform root, Transform current) { Stack stack = new Stack(); for (Transform val = current; val != null; val = val.parent) { stack.Push(((Object)val).name); if ((Object)(object)val == (Object)(object)root) { break; } } return string.Join("/", stack.ToArray()); } } internal static class FluteHandVisualProbe { private sealed class RendererTarget { public MeshRenderer Renderer { get; } public MeshFilter? Filter { get; } public RendererTarget(MeshRenderer renderer, MeshFilter? filter) { Renderer = renderer; Filter = filter; } } private sealed class MeshBuilder { private readonly List _vertices = new List(); private readonly List[] _triangles; public MeshBuilder(int materialCount) { _triangles = (from _ in Enumerable.Range(0, materialCount) select new List()).ToArray(); } public void ApplyTo(Mesh mesh) { mesh.SetVertices(_vertices); mesh.subMeshCount = _triangles.Length; for (int i = 0; i < _triangles.Length; i++) { mesh.SetTriangles(_triangles[i].ToArray(), i); } } public void AddOrientedBox(Vector3 center, Vector3 axisX, Vector3 axisY, Vector3 axisZ, Vector3 size, int material) { //IL_0019: 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_0025: 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_004b: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) ((Vector3)(ref axisX)).Normalize(); ((Vector3)(ref axisY)).Normalize(); ((Vector3)(ref axisZ)).Normalize(); Vector3 val = size * 0.5f; int[] array = new int[8]; int num = 0; for (int i = -1; i <= 1; i += 2) { for (int j = -1; j <= 1; j += 2) { for (int k = -1; k <= 1; k += 2) { array[num++] = AddVertex(center + axisX * val.x * (float)i + axisY * val.y * (float)j + axisZ * val.z * (float)k); } } } AddQuad(array[0], array[2], array[3], array[1], material); AddQuad(array[4], array[5], array[7], array[6], material); AddQuad(array[0], array[1], array[5], array[4], material); AddQuad(array[2], array[6], array[7], array[3], material); AddQuad(array[1], array[3], array[7], array[5], material); AddQuad(array[0], array[4], array[6], array[2], material); } public void AddRod(Vector3 start, Vector3 end, float radius, int segments, int material) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) AddTaperedRod(start, end, radius, radius, segments, material); } public void AddTaperedRod(Vector3 start, Vector3 end, float startRadius, float endRadius, int segments, int material) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0042: 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_0048: 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_0051: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) Vector3 val = end - start; Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 val2 = ((Mathf.Abs(normalized.z) < 0.92f) ? Vector3.forward : Vector3.up); Vector3 val3 = Vector3.Cross(normalized, val2); Vector3 normalized2 = ((Vector3)(ref val3)).normalized; val3 = Vector3.Cross(normalized2, normalized); Vector3 normalized3 = ((Vector3)(ref val3)).normalized; int[] array = new int[segments]; int[] array2 = new int[segments]; for (int i = 0; i < segments; i++) { float num = (float)Math.PI * 2f * (float)i / (float)segments; array[i] = AddVertex(start + normalized2 * Mathf.Cos(num) * startRadius + normalized3 * Mathf.Sin(num) * startRadius); array2[i] = AddVertex(end + normalized2 * Mathf.Cos(num) * endRadius + normalized3 * Mathf.Sin(num) * endRadius); } for (int j = 0; j < segments; j++) { AddQuad(array[j], array[(j + 1) % segments], array2[(j + 1) % segments], array2[j], material); } int a = AddVertex(start); int a2 = AddVertex(end); for (int k = 0; k < segments; k++) { AddTriangle(a, array[(k + 1) % segments], array[k], material); AddTriangle(a2, array2[k], array2[(k + 1) % segments], material); } } private int AddVertex(Vector3 vertex) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) _vertices.Add(vertex); return _vertices.Count - 1; } private void AddQuad(int a, int b, int c, int d, int material) { AddTriangle(a, b, c, material); AddTriangle(a, c, d, material); } private void AddTriangle(int a, int b, int c, int material) { _triangles[material].Add(a); _triangles[material].Add(b); _triangles[material].Add(c); } } private const string VisualName = "Bardheim_OneHandedFluteVisual"; private const int BodySegments = 16; private const int RingSegments = 12; public static void Apply(GameObject itemPrefab, ManualLogSource logger) { //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) if (itemPrefab == null) { logger.LogWarning((object)"Flute one-handed visual probe skipped because the cloned item prefab is null."); return; } Mesh val = BuildFluteMesh(); Material[] array = CreateMaterials(); Renderer[] componentsInChildren = itemPrefab.GetComponentsInChildren(true); RendererTarget rendererTarget = SelectTargetRenderer(itemPrefab); if (rendererTarget != null) { rendererTarget.Filter.sharedMesh = val; ((Renderer)rendererTarget.Renderer).sharedMaterials = array; ((Object)((Component)rendererTarget.Renderer).gameObject).name = "Bardheim_OneHandedFluteVisual"; EnsurePlayModePose(((Component)rendererTarget.Renderer).gameObject); ((Renderer)rendererTarget.Renderer).enabled = true; Renderer[] array2 = componentsInChildren; foreach (Renderer val2 in array2) { if ((Object)(object)val2 != (Object)(object)rendererTarget.Renderer) { val2.enabled = false; } } logger.LogInfo((object)("Applied one-handed flute visual by replacing renderer path=" + GetPath(itemPrefab.transform, ((Component)rendererTarget.Renderer).transform) + " " + $"mesh={((Object)val).name} materials={array.Length} disabledRenderers={Math.Max(0, componentsInChildren.Length - 1)}.")); return; } GameObject val3 = new GameObject("Bardheim_OneHandedFluteVisual"); val3.transform.SetParent(itemPrefab.transform, false); val3.transform.localPosition = Vector3.zero; val3.transform.localRotation = Quaternion.identity; val3.transform.localScale = Vector3.one; MeshFilter val4 = val3.AddComponent(); MeshRenderer val5 = val3.AddComponent(); val4.sharedMesh = val; ((Renderer)val5).sharedMaterials = array; EnsurePlayModePose(val3); Renderer[] array3 = componentsInChildren; foreach (Renderer val6 in array3) { val6.enabled = false; } logger.LogWarning((object)"Applied one-handed flute visual as fallback child path=Bardheim_OneHandedFluteVisual; no MeshRenderer with MeshFilter was found to replace in place."); } private static RendererTarget? SelectTargetRenderer(GameObject itemPrefab) { GameObject itemPrefab2 = itemPrefab; RendererTarget[] array = (from renderer in itemPrefab2.GetComponentsInChildren(true) select new RendererTarget(renderer, ((Component)renderer).GetComponent()) into candidate where candidate.Filter != null orderby ((Renderer)candidate.Renderer).enabled descending select candidate).ThenBy((RendererTarget candidate) => GetPath(itemPrefab2.transform, ((Component)candidate.Renderer).transform), StringComparer.Ordinal).ToArray(); return (array.Length == 0) ? null : array[0]; } private static void EnsurePlayModePose(GameObject visual) { if (visual.GetComponent() == null) { visual.AddComponent(); } } private static Mesh BuildFluteMesh() { //IL_0035: 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_003e: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown MeshBuilder meshBuilder = new MeshBuilder(7); Vector3 start = default(Vector3); ((Vector3)(ref start))..ctor(-0.56f, -0.18f, 0f); Vector3 end = default(Vector3); ((Vector3)(ref end))..ctor(0.6f, -0.18f, 0f); AddTaperedBody(meshBuilder, start, end); AddEndCaps(meshBuilder, start, end); AddCarvedBands(meshBuilder); AddMetalInlayBands(meshBuilder); AddRaisedMouthpiece(meshBuilder); AddFingerHoles(meshBuilder); AddInsetToneHoleRims(meshBuilder); AddMouthNotch(meshBuilder); AddRuneCuts(meshBuilder); AddLeatherWrap(meshBuilder); Mesh val = new Mesh { name = "Bardheim_GeneratedOneHandedFlute" }; meshBuilder.ApplyTo(val); val.RecalculateNormals(); val.RecalculateBounds(); return val; } private static void AddTaperedBody(MeshBuilder builder, Vector3 start, Vector3 end) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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) builder.AddTaperedRod(start, end, 0.07f, 0.048f, 16, 0); builder.AddOrientedBox(new Vector3(0.02f, -0.126f, -0.05f), Vector3.right, Vector3.up, Vector3.forward, new Vector3(0.86f, 0.015f, 0.014f), 5); builder.AddOrientedBox(new Vector3(0.02f, -0.236f, 0.046f), Vector3.right, Vector3.up, Vector3.forward, new Vector3(0.78f, 0.012f, 0.012f), 3); } private static void AddEndCaps(MeshBuilder builder, Vector3 start, Vector3 end) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0074: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) builder.AddRod(start + new Vector3(-0.032f, 0f, 0f), start + new Vector3(0.03f, 0f, 0f), 0.079f, 12, 2); builder.AddRod(end + new Vector3(-0.032f, 0f, 0f), end + new Vector3(0.022f, 0f, 0f), 0.059f, 12, 2); builder.AddRod(start + new Vector3(-0.052f, 0f, 0f), start + new Vector3(-0.034f, 0f, 0f), 0.056f, 12, 6); builder.AddRod(end + new Vector3(0.023f, 0f, 0f), end + new Vector3(0.052f, 0f, 0f), 0.043f, 12, 6); } private static void AddFingerHoles(MeshBuilder builder) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 6; i++) { float num = -0.18f + (float)i * 0.115f; builder.AddOrientedBox(new Vector3(num, -0.125f, -0.02f), Vector3.right, Vector3.forward, Vector3.up, new Vector3(0.034f, 0.026f, 0.014f), 1); } } private static void AddInsetToneHoleRims(MeshBuilder builder) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_008a: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 6; i++) { float num = -0.18f + (float)i * 0.115f; builder.AddOrientedBox(new Vector3(num, -0.121f, -0.025f), Vector3.right, Vector3.forward, Vector3.up, new Vector3(0.048f, 0.01f, 0.012f), (i % 2 == 0) ? 2 : 5); builder.AddOrientedBox(new Vector3(num, -0.121f, -0.001f), Vector3.right, Vector3.forward, Vector3.up, new Vector3(0.048f, 0.01f, 0.012f), 3); } } private static void AddRaisedMouthpiece(MeshBuilder builder) { //IL_0018: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(-0.505f, -0.18f, -0.02f); builder.AddRod(val + new Vector3(-0.05f, 0f, 0f), val + new Vector3(0.07f, 0f, 0f), 0.083f, 12, 5); builder.AddRod(val + new Vector3(-0.028f, 0f, -0.01f), val + new Vector3(0.045f, 0f, -0.01f), 0.058f, 12, 0); builder.AddOrientedBox(new Vector3(-0.505f, -0.116f, -0.026f), Vector3.right, Vector3.forward, Vector3.up, new Vector3(0.11f, 0.042f, 0.018f), 6); } private static void AddMouthNotch(MeshBuilder builder) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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) builder.AddOrientedBox(new Vector3(-0.505f, -0.124f, -0.012f), Vector3.right, Vector3.forward, Vector3.up, new Vector3(0.07f, 0.03f, 0.018f), 1); builder.AddOrientedBox(new Vector3(-0.56f, -0.18f, -0.058f), Vector3.right, Vector3.up, Vector3.forward, new Vector3(0.055f, 0.018f, 0.018f), 3); } private static void AddCarvedBands(MeshBuilder builder) { //IL_0031: 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) float[] array = new float[4] { -0.42f, -0.31f, 0.32f, 0.45f }; float[] array2 = array; foreach (float num in array2) { builder.AddRod(new Vector3(num - 0.01f, -0.18f, 0f), new Vector3(num + 0.01f, -0.18f, 0f), 0.071f, 12, 3); } } private static void AddMetalInlayBands(MeshBuilder builder) { //IL_0031: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0084: 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_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) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) float[] array = new float[4] { -0.38f, -0.27f, 0.27f, 0.4f }; float[] array2 = array; foreach (float num in array2) { builder.AddRod(new Vector3(num - 0.006f, -0.18f, 0f), new Vector3(num + 0.006f, -0.18f, 0f), 0.074f, 12, 2); } builder.AddOrientedBox(new Vector3(-0.055f, -0.118f, -0.033f), Vector3.right, Vector3.forward, Vector3.up, new Vector3(0.07f, 0.012f, 0.012f), 2); builder.AddOrientedBox(new Vector3(0.135f, -0.118f, -0.033f), Vector3.right, Vector3.forward, Vector3.up, new Vector3(0.07f, 0.012f, 0.012f), 2); } private static void AddRuneCuts(MeshBuilder builder) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) builder.AddOrientedBox(new Vector3(-0.285f, -0.118f, -0.016f), Vector3.right, Vector3.forward, Vector3.up, new Vector3(0.013f, 0.08f, 0.011f), 3); builder.AddOrientedBox(new Vector3(-0.268f, -0.116f, -0.016f), Vector3.right, Vector3.forward, Vector3.up, new Vector3(0.013f, 0.05f, 0.011f), 3); builder.AddOrientedBox(new Vector3(0.215f, -0.118f, -0.016f), Vector3.right, Vector3.forward, Vector3.up, new Vector3(0.013f, 0.075f, 0.011f), 3); builder.AddOrientedBox(new Vector3(0.238f, -0.115f, -0.016f), Vector3.right, Vector3.forward, Vector3.up, new Vector3(0.013f, 0.048f, 0.011f), 3); } private static void AddLeatherWrap(MeshBuilder builder) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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) builder.AddOrientedBox(new Vector3(-0.395f, -0.18f, -0.068f), Vector3.right, Vector3.up, Vector3.forward, new Vector3(0.045f, 0.11f, 0.02f), 4); builder.AddOrientedBox(new Vector3(0.455f, -0.18f, -0.068f), Vector3.right, Vector3.up, Vector3.forward, new Vector3(0.045f, 0.11f, 0.02f), 4); } private static Material[] CreateMaterials() { //IL_003c: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) Shader shader = Shader.Find("Standard") ?? Shader.Find("Diffuse"); return (Material[])(object)new Material[7] { CreateMaterial(shader, "Bardheim_FlutePolishedBirch", new Color(0.62f, 0.36f, 0.16f, 1f)), CreateMaterial(shader, "Bardheim_FluteDarkHoles", new Color(0.025f, 0.018f, 0.012f, 1f)), CreateMaterial(shader, "Bardheim_FluteWornBronzeInlay", new Color(0.54f, 0.39f, 0.16f, 1f)), CreateMaterial(shader, "Bardheim_FluteCarvedDark", new Color(0.16f, 0.07f, 0.03f, 1f)), CreateMaterial(shader, "Bardheim_FluteLeatherWrap", new Color(0.13f, 0.055f, 0.025f, 1f)), CreateMaterial(shader, "Bardheim_FluteHoneyWoodHighlight", new Color(0.86f, 0.58f, 0.25f, 1f)), CreateMaterial(shader, "Bardheim_FluteBoneMouthpiece", new Color(0.72f, 0.58f, 0.38f, 1f)) }; } private static Material CreateMaterial(Shader shader, string name, Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown return new Material(shader) { name = name, color = color }; } private static string GetPath(Transform root, Transform current) { Stack stack = new Stack(); for (Transform val = current; val != null; val = val.parent) { stack.Push(((Object)val).name); if ((Object)(object)val == (Object)(object)root) { break; } } return string.Join("/", stack.ToArray()); } } internal static class FluteInventoryIconFactory { private const int Size = 128; public static Sprite Create() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false) { name = "Bardheim_GeneratedFluteInventoryIcon", filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)1 }; Clear(val, new Color(0f, 0f, 0f, 0f)); DrawFlute(val); val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 128f); } private static void DrawFlute(Texture2D texture) { //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_00ee: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_010c: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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) Color shadow = default(Color); ((Color)(ref shadow))..ctor(0.025f, 0.02f, 0.014f, 0.6f); Color val = default(Color); ((Color)(ref val))..ctor(0.13f, 0.06f, 0.025f, 1f); Color midWood = default(Color); ((Color)(ref midWood))..ctor(0.66f, 0.4f, 0.16f, 1f); Color lightWood = default(Color); ((Color)(ref lightWood))..ctor(0.9f, 0.63f, 0.28f, 1f); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.025f, 0.018f, 0.012f, 1f); Color bronze = default(Color); ((Color)(ref bronze))..ctor(0.58f, 0.43f, 0.18f, 1f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.82f, 0.64f, 0.3f, 1f); Color bone = default(Color); ((Color)(ref bone))..ctor(0.78f, 0.65f, 0.42f, 1f); DrawCleanSilhouette(texture, shadow, val); DrawTaperedBody(texture, midWood, lightWood); DrawSimpleEndCaps(texture, bronze, val3); DrawCarvedBands(texture, bronze, val); DrawSubtleInlays(texture, val3); DrawRaisedMouthpiece(texture, bone, val2); DrawReadableToneHoles(texture, val2, val3); DrawFingerHoles(texture, val2, val3); DrawMouthNotch(texture, val2); DrawRuneMarks(texture, val); } private static void DrawCleanSilhouette(Texture2D texture, Color shadow, Color outline) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) DrawLine(texture, 18, 84, 106, 34, shadow, 17); DrawLine(texture, 16, 80, 104, 32, outline, 15); } private static void DrawTaperedBody(Texture2D texture, Color midWood, Color lightWood) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) DrawLine(texture, 20, 78, 101, 33, midWood, 11); DrawLine(texture, 30, 73, 90, 39, lightWood, 4); DrawLine(texture, 39, 76, 93, 46, midWood, 2); } private static void DrawSimpleEndCaps(Texture2D texture, Color bronze, Color bronzeLight) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) DrawLine(texture, 18, 80, 28, 74, bronze, 6); DrawLine(texture, 23, 81, 31, 76, bronzeLight, 2); DrawLine(texture, 97, 36, 107, 30, bronze, 6); DrawLine(texture, 101, 38, 109, 33, bronzeLight, 2); } private static void DrawFingerHoles(Texture2D texture, Color hole, Color rim) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) Vector2Int[] array = (Vector2Int[])(object)new Vector2Int[6] { new Vector2Int(43, 66), new Vector2Int(53, 60), new Vector2Int(63, 55), new Vector2Int(73, 49), new Vector2Int(83, 43), new Vector2Int(91, 39) }; Vector2Int[] array2 = array; for (int i = 0; i < array2.Length; i++) { Vector2Int val = array2[i]; DrawCircle(texture, ((Vector2Int)(ref val)).x, ((Vector2Int)(ref val)).y, 3, rim); DrawCircle(texture, ((Vector2Int)(ref val)).x, ((Vector2Int)(ref val)).y, 2, hole); } } private static void DrawReadableToneHoles(Texture2D texture, Color hole, Color rim) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) Vector2Int[] array = (Vector2Int[])(object)new Vector2Int[6] { new Vector2Int(43, 66), new Vector2Int(53, 60), new Vector2Int(63, 55), new Vector2Int(73, 49), new Vector2Int(83, 43), new Vector2Int(91, 39) }; Vector2Int[] array2 = array; for (int i = 0; i < array2.Length; i++) { Vector2Int val = array2[i]; DrawCircle(texture, ((Vector2Int)(ref val)).x, ((Vector2Int)(ref val)).y, 5, rim); DrawCircle(texture, ((Vector2Int)(ref val)).x, ((Vector2Int)(ref val)).y, 3, hole); } } private static void DrawCarvedBands(Texture2D texture, Color bronze, Color leather) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) DrawLine(texture, 24, 78, 18, 68, bronze, 3); DrawLine(texture, 30, 74, 24, 64, leather, 2); DrawLine(texture, 97, 34, 91, 24, bronze, 3); DrawLine(texture, 90, 39, 84, 29, leather, 2); DrawLine(texture, 37, 69, 31, 59, leather, 2); } private static void DrawSubtleInlays(Texture2D texture, Color bronze) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) DrawLine(texture, 35, 72, 29, 62, bronze, 1); DrawLine(texture, 48, 65, 42, 55, bronze, 1); DrawLine(texture, 86, 44, 80, 34, bronze, 1); DrawLine(texture, 96, 38, 90, 28, bronze, 1); DrawLine(texture, 57, 61, 66, 56, bronze, 1); DrawLine(texture, 70, 53, 78, 48, bronze, 1); } private static void DrawRaisedMouthpiece(Texture2D texture, Color bone, Color hole) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) DrawLine(texture, 17, 82, 35, 72, bone, 9); DrawLine(texture, 20, 78, 34, 70, hole, 3); DrawLine(texture, 27, 71, 37, 66, bone, 3); } private static void DrawMouthNotch(Texture2D texture, Color color) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) DrawLine(texture, 18, 80, 26, 72, color, 3); DrawCircle(texture, 28, 72, 2, color); } private static void DrawRuneMarks(Texture2D texture, Color color) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) DrawLine(texture, 34, 77, 36, 70, color, 1); DrawLine(texture, 36, 70, 41, 73, color, 1); DrawLine(texture, 69, 50, 70, 43, color, 1); DrawLine(texture, 70, 43, 75, 46, color, 1); DrawLine(texture, 78, 51, 81, 45, color, 1); DrawLine(texture, 81, 45, 85, 48, color, 1); } private static void Clear(Texture2D texture, Color color) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { texture.SetPixel(j, i, color); } } } private static void DrawCircle(Texture2D texture, int centerX, int centerY, int radius, Color color) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) for (int i = centerY - radius; i <= centerY + radius; i++) { for (int j = centerX - radius; j <= centerX + radius; j++) { int num = j - centerX; int num2 = i - centerY; if (num * num + num2 * num2 <= radius * radius) { SetPixel(texture, j, i, color); } } } } private static void DrawLine(Texture2D texture, int x0, int y0, int x1, int y1, Color color, int thickness) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Abs(x1 - x0); int num2 = -Mathf.Abs(y1 - y0); int num3 = ((x0 < x1) ? 1 : (-1)); int num4 = ((y0 < y1) ? 1 : (-1)); int num5 = num + num2; while (true) { DrawBrush(texture, x0, y0, thickness, color); if (x0 == x1 && y0 == y1) { break; } int num6 = 2 * num5; if (num6 >= num2) { num5 += num2; x0 += num3; } if (num6 <= num) { num5 += num; y0 += num4; } } } private static void DrawBrush(Texture2D texture, int centerX, int centerY, int thickness, Color color) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) int num = thickness / 2; for (int i = centerY - num; i <= centerY + num; i++) { for (int j = centerX - num; j <= centerX + num; j++) { SetPixel(texture, j, i, color); } } } private static void SetPixel(Texture2D texture, int x, int y, Color color) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (x >= 0 && x < 128 && y >= 0 && y < 128) { texture.SetPixel(x, y, color); } } } public sealed class FluteItemRegistration { public const string PrefabName = "Bardheim_Flute"; public const string BasePrefabName = "Hammer"; private readonly ManualLogSource _logger; private bool _registered; public FluteItemRegistration(ManualLogSource logger) { _logger = logger; } public void Register() { PrefabManager.OnVanillaPrefabsAvailable += RegisterWhenPrefabsAvailable; } private void RegisterWhenPrefabsAvailable() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown if (!_registered) { ItemConfig val = CreateItemConfig(); CustomItem val2 = new CustomItem("Bardheim_Flute", "Hammer", val); ConfigureHeldOnlyFlute(val2.ItemDrop); FluteHandVisualProbe.Apply(val2.ItemPrefab, _logger); ItemManager.Instance.AddItem(val2); _registered = true; PrefabManager.OnVanillaPrefabsAvailable -= RegisterWhenPrefabsAvailable; _logger.LogInfo((object)"Registered flute item Bardheim_Flute cloned from Hammer; generated one-handed flute visual/icon probe applied and custom asset bundle pipeline disabled."); } } private static ItemConfig CreateItemConfig() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown ItemConfig val = new ItemConfig { Name = "Flute", Description = "A simple flute for playing melodic notes.", CraftingStation = CraftingStations.Workbench, Amount = 1, Icon = FluteInventoryIconFactory.Create() }; val.AddRequirement("Wood", 6, 1); val.AddRequirement("DeerHide", 1, 1); return val; } private void ConfigureHeldOnlyFlute(ItemDrop itemDrop) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) SharedData shared = itemDrop.m_itemData.m_shared; shared.m_itemType = (ItemType)19; shared.m_attachOverride = (ItemType)0; shared.m_animationState = (AnimationState)1; shared.m_buildPieces = null; shared.m_attack = null; shared.m_secondaryAttack = null; shared.m_toolTier = 0; shared.m_skillType = (SkillType)0; shared.m_useDurability = false; shared.m_canBeReparied = false; shared.m_maxDurability = 0f; shared.m_durabilityDrain = 0f; shared.m_useDurabilityDrain = 0f; _logger.LogInfo((object)"Configured flute as held-only one-handed Hammer carrier: build pieces, attacks, tool tier, and repair/durability actions disabled."); } } internal static class LyreHammerVisualProbe { private sealed class RendererTarget { public MeshRenderer Renderer { get; } public MeshFilter? Filter { get; } public RendererTarget(MeshRenderer renderer, MeshFilter? filter) { Renderer = renderer; Filter = filter; } } private const string VisualName = "Bardheim_HammerCarrierLyreVisual"; private const float VisualScale = 2.4f; private const int FrameSegmentCount = 14; private const int StringCount = 6; private const float StringBottomY = -0.29f; private const float StringTopY = 0.34f; private static readonly Vector3 GripOffset = new Vector3(0.5f, 0f, 0f); private static readonly Vector3 StringThickness = new Vector3(0.012f, 0.012f, 0.009f); public static void Apply(GameObject itemPrefab, ManualLogSource logger) { //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) if (itemPrefab == null) { logger.LogWarning((object)"Lyre Hammer-carrier visual probe skipped because the cloned item prefab is null."); return; } LogHierarchy(itemPrefab, logger); Mesh val = BuildLyreMesh(); Material[] array = CreateMaterials(); Renderer[] componentsInChildren = itemPrefab.GetComponentsInChildren(true); RendererTarget rendererTarget = SelectTargetRenderer(itemPrefab); if (rendererTarget != null) { rendererTarget.Filter.sharedMesh = val; ((Renderer)rendererTarget.Renderer).sharedMaterials = array; ((Object)((Component)rendererTarget.Renderer).gameObject).name = "Bardheim_HammerCarrierLyreVisual"; EnsurePlayModePose(((Component)rendererTarget.Renderer).gameObject); ((Renderer)rendererTarget.Renderer).enabled = true; Renderer[] array2 = componentsInChildren; foreach (Renderer val2 in array2) { if ((Object)(object)val2 != (Object)(object)rendererTarget.Renderer) { val2.enabled = false; } } logger.LogInfo((object)("Applied Hammer-carrier lyre visual by replacing renderer path=" + GetPath(itemPrefab.transform, ((Component)rendererTarget.Renderer).transform) + " " + $"mesh={((Object)val).name} materials={array.Length} disabledRenderers={Math.Max(0, componentsInChildren.Length - 1)}.")); return; } GameObject val3 = new GameObject("Bardheim_HammerCarrierLyreVisual"); val3.transform.SetParent(itemPrefab.transform, false); val3.transform.localPosition = Vector3.zero; val3.transform.localRotation = Quaternion.identity; val3.transform.localScale = Vector3.one; MeshFilter val4 = val3.AddComponent(); MeshRenderer val5 = val3.AddComponent(); val4.sharedMesh = val; ((Renderer)val5).sharedMaterials = array; EnsurePlayModePose(val3); Renderer[] array3 = componentsInChildren; foreach (Renderer val6 in array3) { val6.enabled = false; } logger.LogWarning((object)"Applied Hammer-carrier lyre visual as fallback child path=Bardheim_HammerCarrierLyreVisual; no MeshRenderer with MeshFilter was found to replace in place."); } private static RendererTarget? SelectTargetRenderer(GameObject itemPrefab) { GameObject itemPrefab2 = itemPrefab; RendererTarget[] array = (from renderer in itemPrefab2.GetComponentsInChildren(true) select new RendererTarget(renderer, ((Component)renderer).GetComponent()) into candidate where candidate.Filter != null orderby ((Renderer)candidate.Renderer).enabled descending select candidate).ThenBy((RendererTarget candidate) => GetPath(itemPrefab2.transform, ((Component)candidate.Renderer).transform), StringComparer.Ordinal).ToArray(); return (array.Length == 0) ? null : array[0]; } private static void EnsurePlayModePose(GameObject visual) { if (visual.GetComponent() == null) { visual.AddComponent(); } } private static void LogHierarchy(GameObject itemPrefab, ManualLogSource logger) { Renderer[] componentsInChildren = itemPrefab.GetComponentsInChildren(true); logger.LogInfo((object)$"Hammer-carrier visual probe for {((Object)itemPrefab).name}: rendererCount={componentsInChildren.Length}."); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { string meshName = GetMeshName(val); string arg = string.Join(",", val.sharedMaterials.Select((Material material) => (material == null) ? "" : ((Object)material).name)); logger.LogInfo((object)("Hammer renderer path=" + GetPath(itemPrefab.transform, ((Component)val).transform) + " type=" + ((object)val).GetType().Name + " " + $"enabled={val.enabled} mesh={meshName} materials=[{arg}].")); } Component[] componentsInChildren2 = itemPrefab.GetComponentsInChildren(true); foreach (Component val2 in componentsInChildren2) { if (val2 != null) { string name = ((object)val2).GetType().Name; if (name.Contains("Collider") || name == "Rigidbody") { logger.LogInfo((object)("Hammer carrier component path=" + GetPath(itemPrefab.transform, val2.transform) + " type=" + name + ".")); } if (((Object)val2.transform).name.Equals("attach", StringComparison.OrdinalIgnoreCase) || ((Object)val2.transform).name.Equals("equipoffset", StringComparison.OrdinalIgnoreCase)) { logger.LogInfo((object)("Hammer held-offset child path=" + GetPath(itemPrefab.transform, val2.transform) + ".")); } } } } private static Mesh BuildLyreMesh() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown List vertices = new List(); List list = new List(); List list2 = new List(); AddRoundedFrame(vertices, list); AddSoundboardPanel(vertices, list); AddBridge(vertices, list); AddDecorativeWoodwork(vertices, list); for (int i = 0; i < 6; i++) { float num = (float)i / 5f; float num2 = Mathf.Lerp(-0.16f, 0.16f, num); AddSlenderBoxBetween(vertices, list2, Scale(new Vector3(num2, -0.29f, -0.055f)), Scale(new Vector3(num2, 0.34f, -0.055f)), Scale(StringThickness)); } Mesh val = new Mesh { name = "Bardheim_GeneratedHammerCarrierLyre" }; val.SetVertices(vertices); val.subMeshCount = 2; val.SetTriangles(list.ToArray(), 0); val.SetTriangles(list2.ToArray(), 1); val.RecalculateNormals(); val.RecalculateBounds(); return val; } private static void AddRoundedFrame(ICollection vertices, ICollection triangles) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) Vector3 value = default(Vector3); ((Vector3)(ref value))..ctor(-0.27f, -0.31f, 0f); Vector3 value2 = default(Vector3); ((Vector3)(ref value2))..ctor(0.27f, -0.31f, 0f); Vector3 val = default(Vector3); Vector3 val2 = default(Vector3); for (int i = 1; i <= 14; i++) { float num = (float)i / 14f; float num2 = Mathf.Lerp(-0.31f, 0.36f, num); float num3 = Mathf.Sin(num * (float)Math.PI) * 0.078f; float num4 = Mathf.Lerp(0.27f, 0.215f, num); ((Vector3)(ref val))..ctor(0f - num4 - num3, num2, 0f); ((Vector3)(ref val2))..ctor(num4 + num3, num2, 0f); AddSlenderBoxBetween(vertices, triangles, Scale(value), Scale(val), Scale(new Vector3(0.078f, 0.078f, 0.075f))); AddSlenderBoxBetween(vertices, triangles, Scale(value2), Scale(val2), Scale(new Vector3(0.078f, 0.078f, 0.075f))); value = val; value2 = val2; } AddSlenderBoxBetween(vertices, triangles, Scale(value), Scale(value2), Scale(new Vector3(0.09f, 0.09f, 0.075f))); AddBox(vertices, triangles, Scale(new Vector3(0f, -0.37f, 0f)), Scale(new Vector3(0.56f, 0.13f, 0.09f))); AddRoundedCornerCaps(vertices, triangles); for (int j = 0; j < 6; j++) { float num5 = -0.2f + (float)j * 0.08f; AddTuningPeg(vertices, triangles, new Vector3(num5, 0.43f, 0f)); } } private static void AddSoundboardPanel(ICollection vertices, ICollection triangles) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) AddBox(vertices, triangles, Scale(new Vector3(0f, -0.29f, 0.018f)), Scale(new Vector3(0.4f, 0.16f, 0.035f))); AddBox(vertices, triangles, Scale(new Vector3(0f, -0.3f, -0.006f)), Scale(new Vector3(0.25f, 0.09f, 0.035f))); } private static void AddBridge(ICollection vertices, ICollection triangles) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) AddBox(vertices, triangles, Scale(new Vector3(0f, -0.18f, -0.06f)), Scale(new Vector3(0.38f, 0.035f, 0.04f))); AddBox(vertices, triangles, Scale(new Vector3(0f, 0.31f, -0.06f)), Scale(new Vector3(0.46f, 0.028f, 0.035f))); } private static void AddDecorativeWoodwork(ICollection vertices, ICollection triangles) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) AddCarvedBands(vertices, triangles); AddVikingKnotwork(vertices, triangles); AddBox(vertices, triangles, Scale(new Vector3(-0.315f, -0.05f, -0.072f)), Scale(new Vector3(0.026f, 0.3f, 0.018f))); AddBox(vertices, triangles, Scale(new Vector3(0.315f, -0.05f, -0.072f)), Scale(new Vector3(0.026f, 0.3f, 0.018f))); AddBox(vertices, triangles, Scale(new Vector3(-0.235f, -0.39f, -0.07f)), Scale(new Vector3(0.055f, 0.045f, 0.02f))); AddBox(vertices, triangles, Scale(new Vector3(0.235f, -0.39f, -0.07f)), Scale(new Vector3(0.055f, 0.045f, 0.02f))); } private static void AddRoundedCornerCaps(ICollection vertices, ICollection triangles) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) AddBox(vertices, triangles, Scale(new Vector3(-0.275f, -0.37f, 0f)), Scale(new Vector3(0.11f, 0.12f, 0.09f))); AddBox(vertices, triangles, Scale(new Vector3(0.275f, -0.37f, 0f)), Scale(new Vector3(0.11f, 0.12f, 0.09f))); AddBox(vertices, triangles, Scale(new Vector3(-0.225f, 0.365f, 0f)), Scale(new Vector3(0.1f, 0.1f, 0.08f))); AddBox(vertices, triangles, Scale(new Vector3(0.225f, 0.365f, 0f)), Scale(new Vector3(0.1f, 0.1f, 0.08f))); } private static void AddCarvedBands(ICollection vertices, ICollection triangles) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) AddBox(vertices, triangles, Scale(new Vector3(0f, -0.405f, -0.08f)), Scale(new Vector3(0.55f, 0.025f, 0.02f))); AddBox(vertices, triangles, Scale(new Vector3(0f, -0.335f, -0.08f)), Scale(new Vector3(0.48f, 0.018f, 0.018f))); AddBox(vertices, triangles, Scale(new Vector3(0f, 0.385f, -0.08f)), Scale(new Vector3(0.46f, 0.02f, 0.018f))); } private static void AddVikingKnotwork(ICollection vertices, ICollection triangles) { //IL_0022: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 4; i++) { float num = -0.23f + (float)i * 0.13f; AddOrnamentalCross(vertices, triangles, new Vector3(-0.315f, num, -0.086f), 34f); AddOrnamentalCross(vertices, triangles, new Vector3(0.315f, num, -0.086f), -34f); } AddOrientedBox(vertices, triangles, new Vector3(-0.1f, -0.405f, -0.092f), new Vector3(0.018f, 0.12f, 0.018f), 55f); AddOrientedBox(vertices, triangles, new Vector3(-0.1f, -0.405f, -0.091f), new Vector3(0.018f, 0.12f, 0.018f), -55f); AddOrientedBox(vertices, triangles, new Vector3(0.1f, -0.405f, -0.092f), new Vector3(0.018f, 0.12f, 0.018f), 55f); AddOrientedBox(vertices, triangles, new Vector3(0.1f, -0.405f, -0.091f), new Vector3(0.018f, 0.12f, 0.018f), -55f); AddOrientedBox(vertices, triangles, new Vector3(0f, 0.385f, -0.092f), new Vector3(0.016f, 0.16f, 0.018f), 62f); AddOrientedBox(vertices, triangles, new Vector3(0f, 0.385f, -0.091f), new Vector3(0.016f, 0.16f, 0.018f), -62f); } private static void AddOrnamentalCross(ICollection vertices, ICollection triangles, Vector3 localCenter, float rotationDegrees) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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) AddOrientedBox(vertices, triangles, localCenter, new Vector3(0.014f, 0.085f, 0.016f), rotationDegrees); AddOrientedBox(vertices, triangles, localCenter + new Vector3(0f, 0f, 0.001f), new Vector3(0.014f, 0.085f, 0.016f), 0f - rotationDegrees); } private static void AddTuningPeg(ICollection vertices, ICollection triangles, Vector3 localCenter) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) AddBox(vertices, triangles, Scale(localCenter), Scale(new Vector3(0.035f, 0.09f, 0.05f))); AddBox(vertices, triangles, Scale(localCenter + new Vector3(0f, 0.045f, -0.025f)), Scale(new Vector3(0.055f, 0.025f, 0.035f))); } private static void AddSlenderBoxBetween(ICollection vertices, ICollection triangles, Vector3 start, Vector3 end, Vector3 thickness) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_004e: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) Vector3 center = (start + end) * 0.5f; Vector3 val = end - start; Vector3 size = default(Vector3); ((Vector3)(ref size))..ctor(Mathf.Max(thickness.x, Mathf.Abs(val.x) + thickness.x), Mathf.Max(thickness.y, Mathf.Abs(val.y) + thickness.y), thickness.z); AddBox(vertices, triangles, center, size); } private static Vector3 Scale(Vector3 value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) return value * 2.4f; } private static Vector3 ApplyGripOffset(Vector3 value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) return value + GripOffset; } private static Material[] CreateMaterials() { //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_002c: 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_004d: Expected O, but got Unknown //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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown Shader val = Shader.Find("Standard") ?? Shader.Find("Diffuse"); Material val2 = new Material(val) { name = "Bardheim_WarmWood", color = new Color(0.48f, 0.27f, 0.12f, 1f) }; Material val3 = new Material(val) { name = "Bardheim_PaleStrings", color = new Color(0.82f, 0.72f, 0.52f, 1f) }; return (Material[])(object)new Material[2] { val2, val3 }; } private static void AddBox(ICollection vertices, ICollection triangles, Vector3 center, Vector3 size) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_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_006c: 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_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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_0096: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_0116: 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_011d: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) int count = vertices.Count; Vector3 val = size * 0.5f; vertices.Add(ApplyGripOffset(center + new Vector3(0f - val.x, 0f - val.y, 0f - val.z))); vertices.Add(ApplyGripOffset(center + new Vector3(val.x, 0f - val.y, 0f - val.z))); vertices.Add(ApplyGripOffset(center + new Vector3(val.x, val.y, 0f - val.z))); vertices.Add(ApplyGripOffset(center + new Vector3(0f - val.x, val.y, 0f - val.z))); vertices.Add(ApplyGripOffset(center + new Vector3(0f - val.x, 0f - val.y, val.z))); vertices.Add(ApplyGripOffset(center + new Vector3(val.x, 0f - val.y, val.z))); vertices.Add(ApplyGripOffset(center + new Vector3(val.x, val.y, val.z))); vertices.Add(ApplyGripOffset(center + new Vector3(0f - val.x, val.y, val.z))); AddFace(triangles, count, 0, 2, 1, 0, 3, 2); AddFace(triangles, count, 4, 5, 6, 4, 6, 7); AddFace(triangles, count, 0, 1, 5, 0, 5, 4); AddFace(triangles, count, 2, 3, 7, 2, 7, 6); AddFace(triangles, count, 1, 2, 6, 1, 6, 5); AddFace(triangles, count, 3, 0, 4, 3, 4, 7); } private static void AddOrientedBox(ICollection vertices, ICollection triangles, Vector3 localCenter, Vector3 localSize, float rotationDegrees) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0059: 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_0067: 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) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00e2: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012e: 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_013a: Unknown result type (might be due to invalid IL or missing references) int count = vertices.Count; Vector3 val = localSize * 0.5f; float num = rotationDegrees * ((float)Math.PI / 180f); float sin = Mathf.Sin(num); float cos = Mathf.Cos(num); AddRotatedVertex(vertices, localCenter, new Vector3(0f - val.x, 0f - val.y, 0f - val.z), sin, cos); AddRotatedVertex(vertices, localCenter, new Vector3(val.x, 0f - val.y, 0f - val.z), sin, cos); AddRotatedVertex(vertices, localCenter, new Vector3(val.x, val.y, 0f - val.z), sin, cos); AddRotatedVertex(vertices, localCenter, new Vector3(0f - val.x, val.y, 0f - val.z), sin, cos); AddRotatedVertex(vertices, localCenter, new Vector3(0f - val.x, 0f - val.y, val.z), sin, cos); AddRotatedVertex(vertices, localCenter, new Vector3(val.x, 0f - val.y, val.z), sin, cos); AddRotatedVertex(vertices, localCenter, new Vector3(val.x, val.y, val.z), sin, cos); AddRotatedVertex(vertices, localCenter, new Vector3(0f - val.x, val.y, val.z), sin, cos); AddFace(triangles, count, 0, 2, 1, 0, 3, 2); AddFace(triangles, count, 4, 5, 6, 4, 6, 7); AddFace(triangles, count, 0, 1, 5, 0, 5, 4); AddFace(triangles, count, 2, 3, 7, 2, 7, 6); AddFace(triangles, count, 1, 2, 6, 1, 6, 5); AddFace(triangles, count, 3, 0, 4, 3, 4, 7); } private static void AddRotatedVertex(ICollection vertices, Vector3 localCenter, Vector3 localOffset, float sin, float cos) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(localOffset.x * cos - localOffset.y * sin, localOffset.x * sin + localOffset.y * cos, localOffset.z); vertices.Add(ApplyGripOffset(Scale(localCenter + val))); } private static void AddFace(ICollection triangles, int start, params int[] indices) { foreach (int num in indices) { triangles.Add(start + num); } } private static string GetMeshName(Renderer renderer) { SkinnedMeshRenderer val = (SkinnedMeshRenderer)(object)((renderer is SkinnedMeshRenderer) ? renderer : null); if (val != null) { return (val.sharedMesh == null) ? "" : ((Object)val.sharedMesh).name; } MeshFilter component = ((Component)renderer).GetComponent(); return (((component != null) ? component.sharedMesh : null) == null) ? "" : ((Object)component.sharedMesh).name; } private static string GetPath(Transform root, Transform current) { Stack stack = new Stack(); for (Transform val = current; val != null; val = val.parent) { stack.Push(((Object)val).name); if ((Object)(object)val == (Object)(object)root) { break; } } return string.Join("/", stack.ToArray()); } } internal static class LyreInventoryIconFactory { private const int Size = 128; private const int IconStringCount = 6; public static Sprite Create() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false) { name = "Bardheim_GeneratedInventoryIcon", filterMode = (FilterMode)0, wrapMode = (TextureWrapMode)1 }; Clear(val, new Color(0f, 0f, 0f, 0f)); DrawLyre(val); val.Apply(false, true); return Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 128f); } private static void DrawLyre(Texture2D texture) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) Color color = default(Color); ((Color)(ref color))..ctor(0.06f, 0.035f, 0.02f, 0.55f); Color val = default(Color); ((Color)(ref val))..ctor(0.3f, 0.14f, 0.055f, 1f); Color color2 = default(Color); ((Color)(ref color2))..ctor(0.58f, 0.29f, 0.11f, 1f); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.85f, 0.48f, 0.2f, 1f); Color color3 = default(Color); ((Color)(ref color3))..ctor(0.96f, 0.86f, 0.62f, 1f); DrawLine(texture, 37, 103, 29, 32, color, 8); DrawLine(texture, 91, 103, 99, 32, color, 8); DrawLine(texture, 32, 32, 96, 32, color, 8); DrawLine(texture, 38, 98, 90, 98, color, 13); DrawLine(texture, 36, 101, 28, 31, val, 7); DrawLine(texture, 92, 101, 100, 31, val, 7); DrawLine(texture, 30, 31, 98, 31, val, 7); DrawLine(texture, 38, 97, 90, 97, val, 13); DrawLine(texture, 39, 98, 31, 35, color2, 4); DrawLine(texture, 89, 98, 97, 35, color2, 4); DrawLine(texture, 35, 35, 93, 35, color2, 4); DrawLine(texture, 42, 93, 86, 93, color2, 8); DrawLine(texture, 43, 91, 85, 91, val2, 2); DrawLine(texture, 39, 42, 89, 42, val2, 2); DrawDecorativeWoodwork(texture, val, val2); for (int i = 0; i < 6; i++) { int num = 44 + i * 8; DrawLine(texture, num, 88, num, 42, color3, 2); } for (int j = 0; j < 6; j++) { int num2 = 46 + j * 7; DrawRect(texture, num2, 25, 4, 8, val2); DrawRect(texture, num2 + 1, 24, 2, 2, color3); } } private static void DrawDecorativeWoodwork(Texture2D texture, Color darkWood, Color lightWood) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0034: 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) DrawVikingKnotwork(texture, lightWood); DrawLine(texture, 40, 101, 88, 101, darkWood, 3); DrawLine(texture, 42, 84, 86, 84, lightWood, 2); DrawLine(texture, 52, 96, 50, 103, lightWood, 2); DrawLine(texture, 76, 96, 78, 103, lightWood, 2); } private static void DrawVikingKnotwork(Texture2D texture, Color lightWood) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) DrawKnot(texture, 36, 58, lightWood); DrawKnot(texture, 92, 58, lightWood); DrawKnot(texture, 37, 72, lightWood); DrawKnot(texture, 91, 72, lightWood); DrawLine(texture, 55, 101, 60, 96, lightWood, 2); DrawLine(texture, 55, 96, 60, 101, lightWood, 2); DrawLine(texture, 68, 101, 73, 96, lightWood, 2); DrawLine(texture, 68, 96, 73, 101, lightWood, 2); } private static void DrawKnot(Texture2D texture, int centerX, int centerY, Color color) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) DrawLine(texture, centerX - 4, centerY, centerX, centerY - 4, color, 2); DrawLine(texture, centerX, centerY - 4, centerX + 4, centerY, color, 2); DrawLine(texture, centerX + 4, centerY, centerX, centerY + 4, color, 2); DrawLine(texture, centerX, centerY + 4, centerX - 4, centerY, color, 2); } private static void Clear(Texture2D texture, Color color) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { texture.SetPixel(j, i, color); } } } private static void DrawRect(Texture2D texture, int x, int y, int width, int height, Color color) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) for (int i = y; i < y + height; i++) { for (int j = x; j < x + width; j++) { SetPixel(texture, j, i, color); } } } private static void DrawLine(Texture2D texture, int x0, int y0, int x1, int y1, Color color, int thickness) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Abs(x1 - x0); int num2 = -Mathf.Abs(y1 - y0); int num3 = ((x0 < x1) ? 1 : (-1)); int num4 = ((y0 < y1) ? 1 : (-1)); int num5 = num + num2; while (true) { DrawBrush(texture, x0, y0, thickness, color); if (x0 == x1 && y0 == y1) { break; } int num6 = 2 * num5; if (num6 >= num2) { num5 += num2; x0 += num3; } if (num6 <= num) { num5 += num; y0 += num4; } } } private static void DrawBrush(Texture2D texture, int centerX, int centerY, int thickness, Color color) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) int num = thickness / 2; for (int i = centerY - num; i <= centerY + num; i++) { for (int j = centerX - num; j <= centerX + num; j++) { SetPixel(texture, j, i, color); } } } private static void SetPixel(Texture2D texture, int x, int y, Color color) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (x >= 0 && x < 128 && y >= 0 && y < 128) { texture.SetPixel(x, y, color); } } } public sealed class LyreItemRegistration { public const string PrefabName = "Bardheim_Lyre"; public const string BasePrefabName = "Hammer"; private readonly ManualLogSource _logger; private bool _registered; public LyreItemRegistration(ManualLogSource logger) { _logger = logger; } public void Register() { PrefabManager.OnVanillaPrefabsAvailable += RegisterWhenPrefabsAvailable; } private void RegisterWhenPrefabsAvailable() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if (!_registered) { ItemConfig val = CreateItemConfig(); CustomItem val2 = new CustomItem("Bardheim_Lyre", "Hammer", val); ConfigureHeldOnlyLyre(val2.ItemDrop); LyreHammerVisualProbe.Apply(val2.ItemPrefab, _logger); ItemManager.Instance.AddItem(val2); _registered = true; PrefabManager.OnVanillaPrefabsAvailable -= RegisterWhenPrefabsAvailable; _logger.LogInfo((object)"Registered lyre item Bardheim_Lyre cloned from Hammer; custom visual asset pipeline disabled."); } } private ItemConfig CreateItemConfig() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown ItemConfig val = new ItemConfig { Name = "Lyre", Description = "A simple lyre for playing local placeholder notes.", CraftingStation = CraftingStations.Workbench, Amount = 1 }; val.Icon = LyreInventoryIconFactory.Create(); val.AddRequirement("Wood", 10, 1); val.AddRequirement("LeatherScraps", 2, 1); return val; } private void ConfigureHeldOnlyLyre(ItemDrop itemDrop) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) SharedData shared = itemDrop.m_itemData.m_shared; shared.m_itemType = (ItemType)19; shared.m_attachOverride = (ItemType)0; shared.m_animationState = (AnimationState)1; shared.m_buildPieces = null; shared.m_attack = null; shared.m_secondaryAttack = null; shared.m_toolTier = 0; shared.m_skillType = (SkillType)0; shared.m_useDurability = false; shared.m_canBeReparied = false; shared.m_maxDurability = 0f; shared.m_durabilityDrain = 0f; shared.m_useDurabilityDrain = 0f; _logger.LogInfo((object)"Configured lyre as held-only Hammer carrier: build pieces, attacks, tool tier, and repair/durability actions disabled."); } } } namespace Bardheim.Instruments { public sealed class DrumHitDefinition { public int Slot { get; } public string Id { get; } public DrumHitDefinition(int slot, string id) { Slot = slot; Id = id; } } public static class InstrumentCatalog { public const string LyreId = "lyre"; public const string DrumsId = "drums"; public const string FluteId = "flute"; public static IReadOnlyList CreateDefaultInstruments() { return new InstrumentDefinition[3] { new InstrumentDefinition("lyre", NoteSetCatalog.CreateDefaultSets(), new DrumHitDefinition[0]), new InstrumentDefinition("drums", new NoteSet[0], new DrumHitDefinition[16] { new DrumHitDefinition(1, "kick"), new DrumHitDefinition(2, "snare"), new DrumHitDefinition(3, "rim"), new DrumHitDefinition(4, "clap"), new DrumHitDefinition(5, "muted"), new DrumHitDefinition(6, "open"), new DrumHitDefinition(7, "low_tom"), new DrumHitDefinition(8, "high_tom"), new DrumHitDefinition(9, "low_kick"), new DrumHitDefinition(10, "electric_snare"), new DrumHitDefinition(11, "pedal_hat"), new DrumHitDefinition(12, "crash"), new DrumHitDefinition(13, "ride"), new DrumHitDefinition(14, "mid_tom"), new DrumHitDefinition(15, "cowbell"), new DrumHitDefinition(16, "tambourine") }), new InstrumentDefinition("flute", new NoteSet[1] { NoteSetCatalog.Create("D natural minor flute", ("D4", 293.66f), ("E4", 329.63f), ("F4", 349.23f), ("G4", 392f), ("A4", 440f), ("Bb4", 466.16f), ("C5", 523.25f), ("D5", 587.33f)) }, new DrumHitDefinition[0]) }; } } public sealed class InstrumentDefinition { public string Id { get; } public IReadOnlyList NoteSets { get; } public IReadOnlyList DrumHits { get; } public InstrumentDefinition(string id, IReadOnlyList noteSets, IReadOnlyList drumHits) { Id = id; NoteSets = noteSets; DrumHits = drumHits; } } } namespace Bardheim.Config { public sealed class LyreConfig { public ConfigEntry PlayModeToggle { get; } public ConfigEntry NoteVolume { get; } public ConfigEntry MaxSimultaneousNotes { get; } public ConfigEntry MaxSimultaneousMidiNotes { get; } public ConfigEntry MaxFluteMidiNotesPerSecond { get; } public ConfigEntry EnableMultiplayerAudio { get; } public ConfigEntry RemoteNoteVolume { get; } public ConfigEntry RemoteMaxSimultaneousNotes { get; } public ConfigEntry RemoteMaxNoteEventsPerSecond { get; } public ConfigEntry RemoteAudibleDistance { get; } public ConfigEntry EnablePlayPoseCalibration { get; } private LyreConfig(ConfigEntry playModeToggle, ConfigEntry noteVolume, ConfigEntry maxSimultaneousNotes, ConfigEntry maxSimultaneousMidiNotes, ConfigEntry maxFluteMidiNotesPerSecond, ConfigEntry enableMultiplayerAudio, ConfigEntry remoteNoteVolume, ConfigEntry remoteMaxSimultaneousNotes, ConfigEntry remoteMaxNoteEventsPerSecond, ConfigEntry remoteAudibleDistance, ConfigEntry enablePlayPoseCalibration) { PlayModeToggle = playModeToggle; NoteVolume = noteVolume; MaxSimultaneousNotes = maxSimultaneousNotes; MaxSimultaneousMidiNotes = maxSimultaneousMidiNotes; MaxFluteMidiNotesPerSecond = maxFluteMidiNotesPerSecond; EnableMultiplayerAudio = enableMultiplayerAudio; RemoteNoteVolume = remoteNoteVolume; RemoteMaxSimultaneousNotes = remoteMaxSimultaneousNotes; RemoteMaxNoteEventsPerSecond = remoteMaxNoteEventsPerSecond; RemoteAudibleDistance = remoteAudibleDistance; EnablePlayPoseCalibration = enablePlayPoseCalibration; } public static LyreConfig Bind(ConfigFile config) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown return new LyreConfig(config.Bind("Input", "PlayModeToggle", new KeyboardShortcut((KeyCode)112, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "Toggles lyre play mode while the lyre is equipped."), config.Bind("Audio", "NoteVolume", 0.45f, new ConfigDescription("Local placeholder note volume.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 1f), Array.Empty())), config.Bind("Audio", "MaxSimultaneousNotes", 6, new ConfigDescription("Maximum overlapping local placeholder notes.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 12), Array.Empty())), config.Bind("Audio", "MaxSimultaneousMidiNotes", 24, new ConfigDescription("Maximum overlapping local MIDI notes. Raise this for dense multi-channel songs; lower it if playback is too busy.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 48), Array.Empty())), config.Bind("Audio", "MaxFluteMidiNotesPerSecond", 14, new ConfigDescription("Maximum flute MIDI note starts per second. Lower this if dense songs drown out the flute melody; raise it for busier flute playback.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 48), Array.Empty())), config.Bind("Multiplayer", "EnableMultiplayerAudio", false, "Enables experimental sending and receiving of nearby-player instrument audio through Valheim routed RPC."), config.Bind("Multiplayer", "RemoteNoteVolume", 1f, new ConfigDescription("Volume multiplier applied to lyre notes heard from other players.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 2f), Array.Empty())), config.Bind("Multiplayer", "RemoteMaxSimultaneousNotes", 24, new ConfigDescription("Maximum overlapping lyre notes heard from other players.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 48), Array.Empty())), config.Bind("Multiplayer", "RemoteMaxNoteEventsPerSecond", 48, new ConfigDescription("Maximum remote lyre note events accepted per sender per second.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 120), Array.Empty())), config.Bind("Multiplayer", "RemoteAudibleDistance", 32f, new ConfigDescription("Maximum distance for spatial lyre notes heard from other players.", (AcceptableValueBase)(object)new AcceptableValueRange(4f, 96f), Array.Empty())), config.Bind("VisualDebug", "EnablePlayPoseCalibration", false, "Enables in-game play-mode visual pose nudge keys for calibration. Keep disabled during normal play.")); } } } namespace Bardheim.Audio { public sealed class DrumHitClipCache { private readonly Dictionary _clipsByHitId = new Dictionary(); private readonly ManualLogSource _logger; public DrumHitClipCache(ManualLogSource logger) { _logger = logger; } public AudioClip? GetOrCreate(string hitId) { if (_clipsByHitId.TryGetValue(hitId, out AudioClip value)) { return value; } value = EmbeddedDrumSampleFactory.TryCreate(hitId, _logger); if (value != null) { _clipsByHitId.Add(hitId, value); } return value; } } public static class EmbeddedDrumSampleFactory { private const string ResourcePrefix = "Bardheim.Assets.Audio.Drums."; public static AudioClip? TryCreate(string hitId, ManualLogSource logger) { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown string text = "Bardheim.Assets.Audio.Drums." + hitId + ".wav"; byte[] array = EmbeddedAssetLoader.ReadResource(text); if (array == null) { logger.LogWarning((object)("Drum hit sample resource not found: " + text)); return null; } if (!TryReadPcm16Wav(array, out float[] samples, out int channels, out int sampleRate, out string error)) { logger.LogWarning((object)("Could not load drum hit sample " + hitId + ": " + error)); return null; } int num = samples.Length / channels; int samplePosition = 0; AudioClip result = AudioClip.Create("Drum_" + hitId + "_Sample", num, channels, sampleRate, false, (PCMReaderCallback)delegate(float[] target) { Fill(target, samples, ref samplePosition); }); logger.LogInfo((object)("Loaded drum hit sample " + hitId + ".")); return result; } private static bool TryReadPcm16Wav(byte[] data, out float[] samples, out int channels, out int sampleRate, out string error) { samples = Array.Empty(); channels = 0; sampleRate = 0; error = string.Empty; using MemoryStream memoryStream = new MemoryStream(data); using BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.ASCII); if (ReadFourCc(binaryReader) != "RIFF") { error = "Missing RIFF header."; return false; } binaryReader.ReadInt32(); if (ReadFourCc(binaryReader) != "WAVE") { error = "Missing WAVE header."; return false; } ushort num = 0; ushort num2 = 0; byte[] array = null; while (memoryStream.Position + 8 <= memoryStream.Length) { string text = ReadFourCc(binaryReader); int num3 = binaryReader.ReadInt32(); long position = memoryStream.Position; if (text == "fmt ") { num = binaryReader.ReadUInt16(); channels = binaryReader.ReadUInt16(); sampleRate = binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadUInt16(); num2 = binaryReader.ReadUInt16(); } else if (text == "data") { array = binaryReader.ReadBytes(num3); } memoryStream.Position = position + num3 + num3 % 2; } if (num != 1) { error = $"Unsupported WAV format {num}; expected PCM."; return false; } if (channels < 1) { error = "Invalid channel count."; return false; } if (sampleRate <= 0) { error = "Invalid sample rate."; return false; } if (num2 != 16) { error = $"Unsupported bit depth {num2}; expected 16-bit."; return false; } if (array == null || array.Length == 0) { error = "Missing sample data."; return false; } samples = new float[array.Length / 2]; for (int i = 0; i < samples.Length; i++) { short num4 = BitConverter.ToInt16(array, i * 2); samples[i] = (float)num4 / 32768f; } return true; } private static string ReadFourCc(BinaryReader reader) { return Encoding.ASCII.GetString(reader.ReadBytes(4)); } private static void Fill(float[] target, float[] source, ref int samplePosition) { for (int i = 0; i < target.Length; i++) { target[i] = ((samplePosition < source.Length) ? source[samplePosition] : 0f); samplePosition++; } } } public static class EmbeddedFluteSampleFactory { private const string ResourcePrefix = "Bardheim.Assets.Audio.Flute."; public static AudioClip? TryCreate(NoteDefinition note, ManualLogSource logger) { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown string text = "Bardheim.Assets.Audio.Flute." + note.Name + ".wav"; byte[] array = EmbeddedAssetLoader.ReadResource(text); if (array == null) { logger.LogWarning((object)("Flute note sample resource not found: " + text)); return null; } if (!TryReadPcm16Wav(array, out float[] samples, out int channels, out int sampleRate, out string error)) { logger.LogWarning((object)("Could not load flute note sample " + note.Name + ": " + error)); return null; } int num = samples.Length / channels; int samplePosition = 0; AudioClip result = AudioClip.Create("Flute_" + note.Name + "_Sample", num, channels, sampleRate, false, (PCMReaderCallback)delegate(float[] target) { Fill(target, samples, ref samplePosition); }); logger.LogInfo((object)("Loaded flute note sample " + note.Name + ".")); return result; } private static bool TryReadPcm16Wav(byte[] data, out float[] samples, out int channels, out int sampleRate, out string error) { samples = Array.Empty(); channels = 0; sampleRate = 0; error = string.Empty; using MemoryStream memoryStream = new MemoryStream(data); using BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.ASCII); if (ReadFourCc(binaryReader) != "RIFF") { error = "Missing RIFF header."; return false; } binaryReader.ReadInt32(); if (ReadFourCc(binaryReader) != "WAVE") { error = "Missing WAVE header."; return false; } ushort num = 0; ushort num2 = 0; byte[] array = null; while (memoryStream.Position + 8 <= memoryStream.Length) { string text = ReadFourCc(binaryReader); int num3 = binaryReader.ReadInt32(); long position = memoryStream.Position; if (text == "fmt ") { num = binaryReader.ReadUInt16(); channels = binaryReader.ReadUInt16(); sampleRate = binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadUInt16(); num2 = binaryReader.ReadUInt16(); } else if (text == "data") { array = binaryReader.ReadBytes(num3); } memoryStream.Position = position + num3 + num3 % 2; } if (num != 1) { error = $"Unsupported WAV format {num}; expected PCM."; return false; } if (channels < 1) { error = "Invalid channel count."; return false; } if (sampleRate <= 0) { error = "Invalid sample rate."; return false; } if (num2 != 16) { error = $"Unsupported bit depth {num2}; expected 16-bit."; return false; } if (array == null || array.Length == 0) { error = "Missing sample data."; return false; } samples = new float[array.Length / 2]; for (int i = 0; i < samples.Length; i++) { short num4 = BitConverter.ToInt16(array, i * 2); samples[i] = (float)num4 / 32768f; } return true; } private static string ReadFourCc(BinaryReader reader) { return Encoding.ASCII.GetString(reader.ReadBytes(4)); } private static void Fill(float[] target, float[] source, ref int samplePosition) { for (int i = 0; i < target.Length; i++) { target[i] = ((samplePosition < source.Length) ? source[samplePosition] : 0f); samplePosition++; } } } public static class EmbeddedNoteSampleFactory { private const string ResourcePrefix = "Bardheim.Assets.Audio."; public static AudioClip? TryCreate(NoteDefinition note, ManualLogSource logger) { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown string text = "Bardheim.Assets.Audio." + note.Name + ".wav"; byte[] array = EmbeddedAssetLoader.ReadResource(text); if (array == null) { logger.LogWarning((object)("Lyre note sample resource not found: " + text)); return null; } if (!TryReadPcm16Wav(array, out float[] samples, out int channels, out int sampleRate, out string error)) { logger.LogWarning((object)("Could not load lyre note sample " + note.Name + ": " + error)); return null; } int num = samples.Length / channels; int samplePosition = 0; AudioClip result = AudioClip.Create("Lyre_" + note.Name + "_Sample", num, channels, sampleRate, false, (PCMReaderCallback)delegate(float[] target) { Fill(target, samples, ref samplePosition); }); logger.LogInfo((object)("Loaded lyre note sample " + note.Name + ".")); return result; } private static bool TryReadPcm16Wav(byte[] data, out float[] samples, out int channels, out int sampleRate, out string error) { samples = Array.Empty(); channels = 0; sampleRate = 0; error = string.Empty; using MemoryStream memoryStream = new MemoryStream(data); using BinaryReader binaryReader = new BinaryReader(memoryStream, Encoding.ASCII); if (ReadFourCc(binaryReader) != "RIFF") { error = "Missing RIFF header."; return false; } binaryReader.ReadInt32(); if (ReadFourCc(binaryReader) != "WAVE") { error = "Missing WAVE header."; return false; } ushort num = 0; ushort num2 = 0; byte[] array = null; while (memoryStream.Position + 8 <= memoryStream.Length) { string text = ReadFourCc(binaryReader); int num3 = binaryReader.ReadInt32(); long position = memoryStream.Position; if (text == "fmt ") { num = binaryReader.ReadUInt16(); channels = binaryReader.ReadUInt16(); sampleRate = binaryReader.ReadInt32(); binaryReader.ReadInt32(); binaryReader.ReadUInt16(); num2 = binaryReader.ReadUInt16(); } else if (text == "data") { array = binaryReader.ReadBytes(num3); } memoryStream.Position = position + num3 + num3 % 2; } if (num != 1) { error = $"Unsupported WAV format {num}; expected PCM."; return false; } if (channels < 1) { error = "Invalid channel count."; return false; } if (sampleRate <= 0) { error = "Invalid sample rate."; return false; } if (num2 != 16) { error = $"Unsupported bit depth {num2}; expected 16-bit."; return false; } if (array == null || array.Length == 0) { error = "Missing sample data."; return false; } samples = new float[array.Length / 2]; for (int i = 0; i < samples.Length; i++) { short num4 = BitConverter.ToInt16(array, i * 2); samples[i] = (float)num4 / 32768f; } return true; } private static string ReadFourCc(BinaryReader reader) { return Encoding.ASCII.GetString(reader.ReadBytes(4)); } private static void Fill(float[] target, float[] source, ref int samplePosition) { for (int i = 0; i < target.Length; i++) { target[i] = ((samplePosition < source.Length) ? source[samplePosition] : 0f); samplePosition++; } } } public sealed class FluteNoteClipCache { private readonly Dictionary _clipsByNoteName = new Dictionary(); private readonly ManualLogSource _logger; public FluteNoteClipCache(ManualLogSource logger) { _logger = logger; } public AudioClip? GetOrCreate(NoteDefinition note) { if (_clipsByNoteName.TryGetValue(note.Name, out AudioClip value)) { return value; } value = EmbeddedFluteSampleFactory.TryCreate(note, _logger); if (value != null) { _clipsByNoteName.Add(note.Name, value); } return value; } } public sealed class LocalDrumPlayback { private readonly List _activeUntil = new List(); private readonly DrumHitClipCache _clipCache; private readonly ManualLogSource _logger; private AudioSource? _source; public LocalDrumPlayback(ManualLogSource logger) : this(logger, new DrumHitClipCache(logger)) { } public LocalDrumPlayback(ManualLogSource logger, DrumHitClipCache clipCache) { _logger = logger; _clipCache = clipCache; } public bool Play(string hitId, Vector3 position, int maxSimultaneousHits, float volume) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) float now = Time.time; _activeUntil.RemoveAll((float until) => until <= now); if (_activeUntil.Count >= maxSimultaneousHits) { _logger.LogDebug((object)"Skipped drum hit because the local overlap limit is active."); return false; } AudioClip orCreate = _clipCache.GetOrCreate(hitId); if (orCreate == null) { return false; } AudioSource val = EnsureSource(); ((Component)val).transform.position = position; val.PlayOneShot(orCreate, volume); _activeUntil.Add(now + orCreate.length); return true; } private AudioSource EnsureSource() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if (_source != null) { return _source; } GameObject val = new GameObject("Bardheim_LocalDrumAudio"); Object.DontDestroyOnLoad((Object)(object)val); _source = val.AddComponent(); _source.playOnAwake = false; _source.spatialBlend = 0f; _source.rolloffMode = (AudioRolloffMode)1; _source.minDistance = 1f; _source.maxDistance = 24f; return _source; } } public sealed class LocalFlutePlayback { private readonly List _activeUntil = new List(); private readonly FluteNoteClipCache _clipCache; private readonly ManualLogSource _logger; private AudioSource? _source; public LocalFlutePlayback(ManualLogSource logger) : this(logger, new FluteNoteClipCache(logger)) { } public LocalFlutePlayback(ManualLogSource logger, FluteNoteClipCache clipCache) { _logger = logger; _clipCache = clipCache; } public bool Play(NoteRequest request, int maxSimultaneousNotes, float volume) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) float now = Time.time; _activeUntil.RemoveAll((float until) => until <= now); if (_activeUntil.Count >= maxSimultaneousNotes) { _logger.LogDebug((object)"Skipped flute note because the local overlap limit is active."); return false; } AudioClip orCreate = _clipCache.GetOrCreate(request.Note); if (orCreate == null) { return false; } AudioSource val = EnsureSource(); ((Component)val).transform.position = request.Position; val.PlayOneShot(orCreate, volume); _activeUntil.Add(now + orCreate.length); return true; } private AudioSource EnsureSource() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if (_source != null) { return _source; } GameObject val = new GameObject("Bardheim_LocalFluteAudio"); Object.DontDestroyOnLoad((Object)(object)val); _source = val.AddComponent(); _source.playOnAwake = false; _source.spatialBlend = 0f; _source.rolloffMode = (AudioRolloffMode)1; _source.minDistance = 1f; _source.maxDistance = 24f; return _source; } } public sealed class LocalNotePlayback { private readonly List _activeUntil = new List(); private readonly LyreNoteClipCache _clipCache; private readonly ManualLogSource _logger; private AudioSource? _source; public LocalNotePlayback(ManualLogSource logger) : this(logger, new LyreNoteClipCache(logger)) { } public LocalNotePlayback(ManualLogSource logger, LyreNoteClipCache clipCache) { _logger = logger; _clipCache = clipCache; } public bool Play(NoteRequest request, int maxSimultaneousNotes, float volume) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) float now = Time.time; _activeUntil.RemoveAll((float until) => until <= now); if (_activeUntil.Count >= maxSimultaneousNotes) { _logger.LogDebug((object)"Skipped lyre note because the local overlap limit is active."); return false; } AudioSource val = EnsureSource(); ((Component)val).transform.position = request.Position; AudioClip orCreate = _clipCache.GetOrCreate(request.Note); val.PlayOneShot(orCreate, volume); _activeUntil.Add(now + orCreate.length); return true; } private AudioSource EnsureSource() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if (_source != null) { return _source; } GameObject val = new GameObject("Bardheim_LocalAudio"); Object.DontDestroyOnLoad((Object)(object)val); _source = val.AddComponent(); _source.playOnAwake = false; _source.spatialBlend = 0f; _source.rolloffMode = (AudioRolloffMode)1; _source.minDistance = 1f; _source.maxDistance = 24f; return _source; } } public sealed class LyreNoteClipCache { private readonly Dictionary _clipsByNoteName = new Dictionary(); private readonly ManualLogSource _logger; public LyreNoteClipCache(ManualLogSource logger) { _logger = logger; } public AudioClip GetOrCreate(NoteDefinition note) { if (_clipsByNoteName.TryGetValue(note.Name, out AudioClip value)) { return value; } value = EmbeddedNoteSampleFactory.TryCreate(note, _logger) ?? PlaceholderToneFactory.Create(note); _clipsByNoteName.Add(note.Name, value); return value; } } public static class PlaceholderToneFactory { private const int SampleRate = 44100; private const float DurationSeconds = 0.32f; public static AudioClip Create(NoteDefinition note) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown NoteDefinition note2 = note; int sampleCount = Mathf.CeilToInt(14112f); int sampleIndex = 0; return AudioClip.Create("Lyre_" + note2.Name, sampleCount, 1, 44100, false, (PCMReaderCallback)delegate(float[] data) { Fill(data, note2.FrequencyHz, sampleCount, ref sampleIndex); }); } private static void Fill(float[] data, float frequencyHz, int sampleCount, ref int sampleIndex) { for (int i = 0; i < data.Length; i++) { if (sampleIndex >= sampleCount) { data[i] = 0f; continue; } float num = (float)sampleIndex / 44100f; float num2 = CreateEnvelope(sampleIndex, sampleCount); data[i] = Mathf.Sin((float)Math.PI * 2f * frequencyHz * num) * num2; sampleIndex++; } } private static float CreateEnvelope(int sampleIndex, int sampleCount) { float num = (float)sampleIndex / (float)sampleCount; if (num < 0.04f) { return num / 0.04f; } if (num > 0.82f) { return Mathf.Clamp01((1f - num) / 0.18f); } return 1f; } } public sealed class RemoteDrumPlayback { private readonly List _activeUntil = new List(); private readonly DrumHitClipCache _clipCache; private readonly ManualLogSource _logger; private AudioSource? _source; public RemoteDrumPlayback(ManualLogSource logger) : this(logger, new DrumHitClipCache(logger)) { } public RemoteDrumPlayback(ManualLogSource logger, DrumHitClipCache clipCache) { _logger = logger; _clipCache = clipCache; } public bool Play(string hitId, Vector3 position, int maxSimultaneousHits, float volume, float maxDistance) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) float now = Time.time; _activeUntil.RemoveAll((float until) => until <= now); if (_activeUntil.Count >= maxSimultaneousHits) { _logger.LogDebug((object)"Skipped drum hit because the remote overlap limit is active."); return false; } AudioClip orCreate = _clipCache.GetOrCreate(hitId); if (orCreate == null) { return false; } AudioSource val = EnsureSource(maxDistance); ((Component)val).transform.position = position; val.maxDistance = maxDistance; val.PlayOneShot(orCreate, volume); _activeUntil.Add(now + orCreate.length); return true; } private AudioSource EnsureSource(float maxDistance) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if (_source != null) { return _source; } GameObject val = new GameObject("Bardheim_RemoteDrumAudio"); Object.DontDestroyOnLoad((Object)(object)val); _source = val.AddComponent(); _source.playOnAwake = false; _source.spatialBlend = 1f; _source.rolloffMode = (AudioRolloffMode)1; _source.minDistance = 1f; _source.maxDistance = maxDistance; return _source; } } public sealed class RemoteFlutePlayback { private readonly List _activeUntil = new List(); private readonly FluteNoteClipCache _clipCache; private readonly ManualLogSource _logger; private AudioSource? _source; public RemoteFlutePlayback(ManualLogSource logger) : this(logger, new FluteNoteClipCache(logger)) { } public RemoteFlutePlayback(ManualLogSource logger, FluteNoteClipCache clipCache) { _logger = logger; _clipCache = clipCache; } public bool Play(NoteRequest request, int maxSimultaneousNotes, float volume, float maxDistance) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) float now = Time.time; _activeUntil.RemoveAll((float until) => until <= now); if (_activeUntil.Count >= maxSimultaneousNotes) { _logger.LogDebug((object)"Skipped flute note because the remote overlap limit is active."); return false; } AudioClip orCreate = _clipCache.GetOrCreate(request.Note); if (orCreate == null) { return false; } AudioSource val = EnsureSource(maxDistance); ((Component)val).transform.position = request.Position; val.maxDistance = maxDistance; val.PlayOneShot(orCreate, volume); _activeUntil.Add(now + orCreate.length); return true; } private AudioSource EnsureSource(float maxDistance) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if (_source != null) { return _source; } GameObject val = new GameObject("Bardheim_RemoteFluteAudio"); Object.DontDestroyOnLoad((Object)(object)val); _source = val.AddComponent(); _source.playOnAwake = false; _source.spatialBlend = 1f; _source.rolloffMode = (AudioRolloffMode)1; _source.minDistance = 1f; _source.maxDistance = maxDistance; return _source; } } public sealed class RemoteNotePlayback { private readonly List _activeUntil = new List(); private readonly LyreNoteClipCache _clipCache; private readonly ManualLogSource _logger; private AudioSource? _source; public RemoteNotePlayback(ManualLogSource logger) : this(logger, new LyreNoteClipCache(logger)) { } public RemoteNotePlayback(ManualLogSource logger, LyreNoteClipCache clipCache) { _logger = logger; _clipCache = clipCache; } public bool Play(NoteRequest request, int maxSimultaneousNotes, float volume, float maxDistance) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) float now = Time.time; _activeUntil.RemoveAll((float until) => until <= now); if (_activeUntil.Count >= maxSimultaneousNotes) { _logger.LogDebug((object)"Skipped lyre note because the remote overlap limit is active."); return false; } AudioSource val = EnsureSource(maxDistance); ((Component)val).transform.position = request.Position; val.maxDistance = maxDistance; AudioClip orCreate = _clipCache.GetOrCreate(request.Note); val.PlayOneShot(orCreate, volume); _activeUntil.Add(now + orCreate.length); return true; } private AudioSource EnsureSource(float maxDistance) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if (_source != null) { return _source; } GameObject val = new GameObject("Bardheim_RemoteAudio"); Object.DontDestroyOnLoad((Object)(object)val); _source = val.AddComponent(); _source.playOnAwake = false; _source.spatialBlend = 1f; _source.rolloffMode = (AudioRolloffMode)1; _source.minDistance = 1f; _source.maxDistance = maxDistance; return _source; } } } namespace Bardheim.Assets { public static class EmbeddedAssetLoader { public static byte[]? ReadResource(string resourceName) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); using Stream stream = executingAssembly.GetManifestResourceStream(resourceName); if (stream == null) { return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); } } }