Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Mita Valuables v1.0.0
MitaValuables.dll
Decompiled 2 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using REPOLib.Modules; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Empress")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5f1b735e473ca4ccf3b383128fbebd889cb564da")] [assembly: AssemblyProduct("MitaValuables")] [assembly: AssemblyTitle("MitaValuables")] [assembly: AssemblyVersion("1.0.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 Empress.REPO.MitaValuables { internal static class MitaValuableBundleVisuals { private const string BundleFileName = "mitavaluablesassets"; private static readonly Dictionary<string, GameObject?> VisualPrefabs = new Dictionary<string, GameObject>(); private static readonly Dictionary<string, AudioClip> VoiceClips = new Dictionary<string, AudioClip>(StringComparer.OrdinalIgnoreCase); private static ManualLogSource? _log; private static AssetBundle? _bundle; private static bool _loadAttempted; private static bool _voiceClipsLoaded; public static void Initialize(string pluginDirectory, ManualLogSource log) { _log = log; if (_loadAttempted) { return; } _loadAttempted = true; string text = Path.Combine(pluginDirectory, "mitavaluablesassets"); if (!File.Exists(text)) { log.LogWarning((object)("MiSide valuable asset bundle was not found at " + text + ". Falling back to procedural visuals.")); return; } try { foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles()) { if (string.Equals(((Object)allLoadedAssetBundle).name, "mitavaluablesassets", StringComparison.OrdinalIgnoreCase)) { _bundle = allLoadedAssetBundle; log.LogInfo((object)"Using already-loaded MiSide valuable asset bundle: mitavaluablesassets"); return; } } _bundle = AssetBundle.LoadFromFile(text); if ((Object)(object)_bundle == (Object)null) { log.LogWarning((object)("Unity returned null when loading " + text + ". Falling back to procedural visuals.")); } else { log.LogInfo((object)("Loaded MiSide valuable asset bundle: " + text)); } } catch (Exception arg) { log.LogWarning((object)$"Failed to load MiSide valuable asset bundle {text}: {arg}"); _bundle = null; } } public static bool TryAttach(Transform parent, MitaValuableDefinition definition) { //IL_0031: 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_0051: Unknown result type (might be due to invalid IL or missing references) GameObject val = LoadVisualPrefab(definition.PrefabName); if ((Object)(object)val == (Object)null) { return false; } GameObject val2 = Object.Instantiate<GameObject>(val, parent, false); ((Object)val2).name = "MitaValuableVisual"; val2.transform.localPosition = Vector3.zero; val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; ((Object)val2).hideFlags = (HideFlags)52; SetLayerRecursively(val2.transform, ((Component)parent).gameObject.layer); Collider[] componentsInChildren = val2.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } StripBoxedParticleEffects(val2); return true; } public static AudioClip[] LoadVoiceClips(MitaValuableDefinition definition) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) EnsureVoiceClipsLoaded(); if (VoiceClips.Count == 0 || definition.VoiceClipNames.Length == 0) { return Array.Empty<AudioClip>(); } List<AudioClip> list = new List<AudioClip>(definition.VoiceClipNames.Length); string[] voiceClipNames = definition.VoiceClipNames; foreach (string text in voiceClipNames) { if (VoiceClips.TryGetValue(text, out AudioClip value) && (Object)(object)value != (Object)null) { if ((int)value.loadState == 0) { value.LoadAudioData(); } list.Add(value); continue; } ManualLogSource? log = _log; if (log != null) { log.LogWarning((object)("MiSide bundle is missing voice clip '" + text + "' for " + definition.DisplayName + ".")); } } return list.ToArray(); } private static GameObject? LoadVisualPrefab(string prefabName) { if (VisualPrefabs.TryGetValue(prefabName, out GameObject value)) { return value; } if ((Object)(object)_bundle == (Object)null) { VisualPrefabs[prefabName] = null; return null; } try { GameObject val = _bundle.LoadAsset<GameObject>(prefabName); if ((Object)(object)val == (Object)null) { val = _bundle.LoadAsset<GameObject>("Assets/MitaValuables/Prefabs/" + prefabName + ".prefab"); } if ((Object)(object)val == (Object)null) { ManualLogSource? log = _log; if (log != null) { log.LogWarning((object)("MiSide bundle is missing valuable visual prefab '" + prefabName + "'.")); } } VisualPrefabs[prefabName] = val; return val; } catch (Exception arg) { ManualLogSource? log2 = _log; if (log2 != null) { log2.LogWarning((object)$"Failed to load visual prefab '{prefabName}' from MiSide bundle: {arg}"); } VisualPrefabs[prefabName] = null; return null; } } private static void EnsureVoiceClipsLoaded() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (_voiceClipsLoaded) { return; } _voiceClipsLoaded = true; if ((Object)(object)_bundle == (Object)null) { return; } try { AudioClip[] array = _bundle.LoadAllAssets<AudioClip>(); foreach (AudioClip val in array) { if ((Object)(object)val != (Object)null && !VoiceClips.ContainsKey(((Object)val).name)) { if ((int)val.loadState == 0) { val.LoadAudioData(); } VoiceClips.Add(((Object)val).name, val); } } ManualLogSource? log = _log; if (log != null) { log.LogInfo((object)$"Loaded {VoiceClips.Count} MiSide voice clips from the valuable bundle."); } } catch (Exception arg) { ManualLogSource? log2 = _log; if (log2 != null) { log2.LogWarning((object)$"Failed to load MiSide voice clips from asset bundle: {arg}"); } } } private static void SetLayerRecursively(Transform root, int layer) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown ((Component)root).gameObject.layer = layer; foreach (Transform item in root) { SetLayerRecursively(item, layer); } } private static void StripBoxedParticleEffects(GameObject root) { ParticleSystem[] componentsInChildren = root.GetComponentsInChildren<ParticleSystem>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.Destroy((Object)(object)componentsInChildren[i]); } ParticleSystemRenderer[] componentsInChildren2 = root.GetComponentsInChildren<ParticleSystemRenderer>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.Destroy((Object)(object)componentsInChildren2[i]); } TrailRenderer[] componentsInChildren3 = root.GetComponentsInChildren<TrailRenderer>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.Destroy((Object)(object)componentsInChildren3[i]); } LineRenderer[] componentsInChildren4 = root.GetComponentsInChildren<LineRenderer>(true); for (int i = 0; i < componentsInChildren4.Length; i++) { Object.Destroy((Object)(object)componentsInChildren4[i]); } } } internal sealed class MitaValuableDefinition { public string PrefabName { get; } public string DisplayName { get; } public string SourceReference { get; } public Type VolumeType { get; } public int ValueMin { get; } public int ValueMax { get; } public float Fragility { get; } public float Durability { get; } public float Mass { get; } public Color Primary { get; } public Color Secondary { get; } public Color Accent { get; } public bool GrabGlow { get; } public bool Chibi { get; } public Vector3 GrabBoundsCenter { get; } public Vector3 GrabBoundsSize { get; } public string[] VoiceClipNames { get; } public float VoiceVolume { get; } public MitaValuableDefinition(string prefabName, string displayName, string sourceReference, Type volumeType, int valueMin, int valueMax, float fragility, float durability, float mass, Color primary, Color secondary, Color accent, bool grabGlow, bool chibi, Vector3 grabBoundsCenter, Vector3 grabBoundsSize, string[] voiceClipNames, float voiceVolume = 1f) { //IL_001c: 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_004c: 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_0054: 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_005c: 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_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_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) PrefabName = prefabName; DisplayName = displayName; SourceReference = sourceReference; VolumeType = volumeType; ValueMin = valueMin; ValueMax = valueMax; Fragility = fragility; Durability = durability; Mass = mass; Primary = primary; Secondary = secondary; Accent = accent; GrabGlow = grabGlow; Chibi = chibi; GrabBoundsCenter = grabBoundsCenter; GrabBoundsSize = grabBoundsSize; VoiceClipNames = voiceClipNames ?? Array.Empty<string>(); VoiceVolume = voiceVolume; } } internal static class MitaValuableDefinitions { public static readonly MitaValuableDefinition[] All = new MitaValuableDefinition[13] { Full("MitaValuable_MitaClassic", "Mita Figurine", "MiSide prefab: Assets/Resources/personages/MitaUsual", 4400, 8400, new Color(0.98f, 0.78f, 0.66f), new Color(0.9f, 0.5f, 0.64f), new Color(1f, 0.33f, 0.56f), new string[5] { "Mita Speak", "Mita Cheerful", "Mita Hmm 1", "Mita Hmm 2", "Mita OiStart" }, (Type)5), Full("MitaValuable_KindMita", "Kind Mita Figurine", "MiSide prefab: Assets/Resources/personages/MitaKind", 4700, 9000, new Color(0.98f, 0.8f, 0.68f), new Color(0.95f, 0.52f, 0.66f), new Color(0.35f, 0.95f, 1f), new string[4] { "MitaKind Speak", "MitaKind Pointer", "MitaKind Sit Sofa", "Mita Speak Quest" }, (Type)5), Full("MitaValuable_CappieMita", "Cappie Mita Figurine", "MiSide prefab: Assets/Resources/personages/MitaCap", 4600, 8800, new Color(0.98f, 0.77f, 0.65f), new Color(0.13f, 0.18f, 0.32f), new Color(0.95f, 0.12f, 0.22f), new string[4] { "MitaCap Speak", "MitaCap Angry", "MitaCap ByeBye", "ChibiPlayer Voice 1" }, (Type)5), Full("MitaValuable_CreepyMita", "Creepy Mita Figurine", "MiSide prefab: Assets/Resources/personages/MitaCreepy", 6500, 11200, new Color(0.72f, 0.64f, 0.62f), new Color(0.18f, 0.05f, 0.07f), new Color(1f, 0.04f, 0.04f), new string[5] { "Mita Creepy", "CreepyMita Ape 1", "CreepyMita Ape 2", "CreepyMita Ape 3", "CreepyMita Teeth" }, (Type)5, null, null, 34f, 82f, 2.4f), Full("MitaValuable_ShortHairMita", "Short-Hair Mita Figurine", "MiSide prefab: Assets/Resources/personages/MitaShortHairs", 3900, 7800, new Color(0.96f, 0.75f, 0.64f), new Color(0.2f, 0.28f, 0.46f), new Color(0.96f, 0.86f, 0.34f), new string[4] { "Mita Sit Talk 1", "Mita Sit Talk 2", "Mita Sit Talk 3", "Mita Speak Whisper" }, (Type)5), Full("MitaValuable_TinyMita", "Tiny Mita Figurine", "MiSide prefab: Assets/Resources/personages/MitaLittle", 3200, 6600, new Color(0.96f, 0.76f, 0.64f), new Color(0.8f, 0.18f, 0.34f), new Color(0.55f, 1f, 0.72f), new string[4] { "LittleMita Speak", "Mita Chibi", "Mita Yawns", "ChibiMita Jump" }, (Type)1, (Vector3?)new Vector3(0f, 0.52f, 0f), (Vector3?)new Vector3(0.78f, 1.08f, 0.64f), 42f, 68f, 1.3f), Full("MitaValuable_CoreMita", "Core Mita Figurine", "MiSide prefab: Assets/Resources/personages/MitaCore", 6200, 10800, new Color(0.95f, 0.76f, 0.65f), new Color(0.08f, 0.18f, 0.26f), new Color(0.1f, 0.95f, 1f), new string[5] { "MitaCore Heart", "MitaCore Down", "MitaCore Throw", "Core Heart", "Core" }, (Type)5, null, null, 38f, 78f), Full("MitaValuable_BlackMita", "Black Mita Figurine", "MiSide prefab: Assets/Resources/personages/MitaBlack", 5400, 10200, new Color(0.62f, 0.62f, 0.68f), new Color(0.09f, 0.08f, 0.12f), new Color(0.75f, 0.08f, 0.72f), new string[3] { "MitaDark Whisper", "Ambient BlackMita", "MitaGhost Speak" }, (Type)5, null, null, 44f, 66f), Full("MitaValuable_DreamerMita", "Dreamer Mita Figurine", "MiSide prefab: Assets/Resources/personages/MitaDreamer", 4800, 9000, new Color(0.96f, 0.75f, 0.64f), new Color(0.45f, 0.22f, 0.72f), new Color(0.88f, 0.62f, 1f), new string[4] { "MitaDream Speak", "Mita Hmm 3", "Mita Hmm 4", "Mita Hmm 5" }, (Type)5), Full("MitaValuable_MilaMita", "Mila Figurine", "MiSide prefab: Assets/Resources/personages/Mila", 4300, 8500, new Color(0.96f, 0.73f, 0.61f), new Color(0.68f, 0.12f, 0.16f), new Color(1f, 0.75f, 0.28f), new string[5] { "Mila Book Hello", "Mila Book Stay", "Mila Relax", "Mila Scared", "Mila Cry No" }, (Type)5), Full("MitaValuable_ManekenMita", "Maneken Mita Figurine", "MiSide prefab: Assets/Resources/personages/MitaManeken", 5400, 9900, new Color(0.72f, 0.66f, 0.58f), new Color(0.22f, 0.2f, 0.19f), new Color(0.9f, 0.05f, 0.08f), new string[3] { "Mitafon Speak", "MitaDark Whisper", "Ambient BlackMita" }, (Type)5, null, null, 28f, 86f, 2.8f), Full("MitaValuable_TrueMita", "True Mita Figurine", "MiSide prefab: Assets/Resources/personages/MitaTrue", 7000, 12000, new Color(0.96f, 0.72f, 0.65f), new Color(0.16f, 0.08f, 0.12f), new Color(1f, 0.06f, 0.09f), new string[4] { "Mita Agh", "Mita Speak Whisper", "Mita Creepy", "Mita Speak Quest" }, (Type)5, null, null, 32f, 84f, 2.55f), Chibi("MitaValuable_ChibiMita", "Chibi Mita", "MiSide prefab: Assets/Resources/personages/MitaChibi", 2400, 5200, new Color(0.98f, 0.78f, 0.66f), new Color(0.7f, 0.14f, 0.28f), new Color(1f, 0.35f, 0.58f), new string[6] { "Mita Chibi", "ChibiMita Clap", "ChibiMita Jump", "Heart ChibiMita", "ChibiPlayer Voice 1", "ChibiPlayer Voice 2" }) }; private static MitaValuableDefinition Full(string prefabName, string displayName, string sourceReference, int valueMin, int valueMax, Color primary, Color secondary, Color accent, string[] voiceClipNames, Type volumeType = 5, Vector3? center = null, Vector3? size = null, float fragility = 42f, float durability = 68f, float mass = 2.15f) { //IL_0003: 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_0010: 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_003a: 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_0063: 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) return new MitaValuableDefinition(prefabName, displayName, sourceReference, volumeType, valueMin, valueMax, fragility, durability, mass, primary, secondary, accent, grabGlow: true, chibi: false, (Vector3)(((??)center) ?? new Vector3(0f, 0.74f, 0f)), (Vector3)(((??)size) ?? new Vector3(0.9f, 1.55f, 0.7f)), voiceClipNames); } private static MitaValuableDefinition Chibi(string prefabName, string displayName, string sourceReference, int valueMin, int valueMax, Color primary, Color secondary, Color accent, string[] voiceClipNames, float fragility = 54f, float durability = 54f, float mass = 0.85f) { //IL_000d: 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_0011: 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_0038: Unknown result type (might be due to invalid IL or missing references) return new MitaValuableDefinition(prefabName, displayName, sourceReference, (Type)1, valueMin, valueMax, fragility, durability, mass, primary, secondary, accent, grabGlow: true, chibi: true, new Vector3(0f, 0.36f, 0f), new Vector3(0.78f, 0.82f, 0.68f), voiceClipNames); } } internal static class MitaValuableGrabBounds { private const int MaxColliderTriangles = 40; private const float MinColliderExtent = 0.015f; public static void Add(Transform root, MitaValuableDefinition definition) { RemoveTemplateColliders(root); if (AddMeshColliders(root) == 0) { AddFallbackBox(root, definition); MitaValuablesPlugin.Log.LogWarning((object)(definition.DisplayName + " had no usable renderer meshes for grab colliders; using fitted fallback bounds.")); } } private static int AddMeshColliders(Transform root) { int num = 0; Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (val.enabled && !(val is ParticleSystemRenderer)) { Mesh val2 = CreateCollisionMesh(val); if ((Object)(object)val2 == (Object)null || !HasValidCollisionShape(val2)) { DestroyMesh(val2); continue; } MeshCollider obj = ((Component)val).gameObject.AddComponent<MeshCollider>(); obj.cookingOptions = (MeshColliderCookingOptions)14; obj.convex = true; ((Collider)obj).isTrigger = false; obj.sharedMesh = val2; ConfigureColliderObject(((Component)val).gameObject); ((Component)val).gameObject.AddComponent<PhysGrabObjectCollider>(); ((Component)val).gameObject.AddComponent<PhysGrabObjectMeshCollider>().showGizmo = false; num++; } } return num; } private static Mesh? CreateCollisionMesh(Renderer renderer) { //IL_001c: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) Mesh val = null; Mesh val2 = null; SkinnedMeshRenderer val3 = (SkinnedMeshRenderer)(object)((renderer is SkinnedMeshRenderer) ? renderer : null); if (val3 != null && (Object)(object)val3.sharedMesh != (Object)null) { val2 = new Mesh { name = ((Object)renderer).name + "_MitaGrabCollider", hideFlags = (HideFlags)61 }; try { val3.BakeMesh(val2); val = val2; } catch { val = val3.sharedMesh; } } else { MeshFilter component = ((Component)renderer).GetComponent<MeshFilter>(); if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null) { val = component.sharedMesh; } } Mesh val4 = CreateReducedMesh(val, ((Object)renderer).name + "_MitaGrabCollider"); if ((Object)(object)val4 == (Object)null && (Object)(object)val != (Object)null) { val4 = CreateBoxMesh(val.bounds, ((Object)renderer).name + "_MitaGrabCollider"); } DestroyMesh(val2); return val4; } private static Mesh? CreateReducedMesh(Mesh? sourceMesh, string name) { //IL_0025: 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_0100: 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) //IL_0111: Expected O, but got Unknown //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_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_00c6: 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) if ((Object)(object)sourceMesh == (Object)null) { return null; } if (!sourceMesh.isReadable) { return null; } Vector3[] vertices = sourceMesh.vertices; int[] triangles = sourceMesh.triangles; if (!HasValidVertexSet(vertices, sourceMesh.bounds) || triangles.Length < 3) { return null; } int num = triangles.Length / 3; int num2 = Mathf.Min(num, 40); Vector3[] array = (Vector3[])(object)new Vector3[num2 * 3]; int[] array2 = new int[num2 * 3]; for (int i = 0; i < num2; i++) { int num3 = ((num2 > 1) ? Mathf.RoundToInt((float)i * ((float)num - 1f) / ((float)num2 - 1f)) : 0) * 3; int num4 = i * 3; array[num4] = vertices[triangles[num3]]; array[num4 + 1] = vertices[triangles[num3 + 1]]; array[num4 + 2] = vertices[triangles[num3 + 2]]; array2[num4] = num4; array2[num4 + 1] = num4 + 1; array2[num4 + 2] = num4 + 2; } Mesh val = new Mesh { name = name, hideFlags = (HideFlags)61 }; val.vertices = array; val.triangles = array2; val.RecalculateBounds(); if (!HasValidCollisionShape(val)) { DestroyMesh(val); return null; } return val; } private static Mesh? CreateBoxMesh(Bounds bounds, string name) { //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_0010: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0046: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_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_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_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_0097: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_00c7: 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_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_00e5: 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_00f1: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_0133: 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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0166: 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_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown Vector3 size = ((Bounds)(ref bounds)).size; if (Mathf.Max(new float[3] { size.x, size.y, size.z }) < 0.015f) { return null; } Vector3 min = ((Bounds)(ref bounds)).min; Vector3 max = ((Bounds)(ref bounds)).max; Vector3[] vertices = (Vector3[])(object)new Vector3[8] { new Vector3(min.x, min.y, min.z), new Vector3(max.x, min.y, min.z), new Vector3(max.x, max.y, min.z), new Vector3(min.x, max.y, min.z), new Vector3(min.x, min.y, max.z), new Vector3(max.x, min.y, max.z), new Vector3(max.x, max.y, max.z), new Vector3(min.x, max.y, max.z) }; int[] triangles = new int[36] { 0, 2, 1, 0, 3, 2, 4, 5, 6, 4, 6, 7, 0, 1, 5, 0, 5, 4, 2, 3, 7, 2, 7, 6, 1, 2, 6, 1, 6, 5, 3, 0, 4, 3, 4, 7 }; Mesh val = new Mesh { name = name, hideFlags = (HideFlags)61, vertices = vertices, triangles = triangles }; val.RecalculateBounds(); return val; } private static bool HasValidCollisionShape(Mesh mesh) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (mesh.isReadable && mesh.vertexCount >= 3) { return HasValidVertexSet(mesh.vertices, mesh.bounds); } return false; } private static bool HasValidVertexSet(IReadOnlyList<Vector3> vertices, Bounds bounds) { //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_0010: 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_0022: 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_004a: 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_006c: 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) Vector3 size = ((Bounds)(ref bounds)).size; if (Mathf.Max(new float[3] { size.x, size.y, size.z }) < 0.015f) { return false; } HashSet<Vector3Int> hashSet = new HashSet<Vector3Int>(); for (int i = 0; i < vertices.Count; i++) { Vector3 val = vertices[i]; hashSet.Add(new Vector3Int(Mathf.RoundToInt(val.x * 10000f), Mathf.RoundToInt(val.y * 10000f), Mathf.RoundToInt(val.z * 10000f))); if (hashSet.Count >= 3) { return true; } } return false; } private static void AddFallbackBox(Transform root, MitaValuableDefinition definition) { //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_000c: 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_001e: 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_0036: 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_0046: 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_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) //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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_009a: 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_00a7: 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_00cd: 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_00da: 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_00fe: 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_0110: 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_011b: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) Bounds val = CalculateVisualBounds(root); GameObject val2 = new GameObject("MitaValuableFallbackGrabBounds"); val2.transform.SetParent(root, false); val2.transform.localPosition = root.InverseTransformPoint(((Bounds)(ref val)).center); val2.transform.localRotation = Quaternion.identity; val2.transform.localScale = Vector3.one; Vector3 size = ((Bounds)(ref val)).size; Vector3 lossyScale = root.lossyScale; size.x = ((lossyScale.x == 0f) ? definition.GrabBoundsSize.x : (size.x / Mathf.Abs(lossyScale.x))); size.y = ((lossyScale.y == 0f) ? definition.GrabBoundsSize.y : (size.y / Mathf.Abs(lossyScale.y))); size.z = ((lossyScale.z == 0f) ? definition.GrabBoundsSize.z : (size.z / Mathf.Abs(lossyScale.z))); BoxCollider obj = val2.AddComponent<BoxCollider>(); obj.center = Vector3.zero; obj.size = Vector3.Max(size, Vector3.one * 0.12f); ((Collider)obj).isTrigger = false; ConfigureColliderObject(val2); val2.AddComponent<PhysGrabObjectCollider>(); val2.AddComponent<PhysGrabObjectBoxCollider>().drawGizmos = false; } private static void ConfigureColliderObject(GameObject gameObject) { gameObject.tag = "Phys Grab Object"; int num = LayerMask.NameToLayer("PhysGrabObject"); if (num >= 0) { gameObject.layer = num; } } private static Bounds CalculateVisualBounds(Transform root) { //IL_000a: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_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_0048: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>(true); Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(root.position, Vector3.one * 0.3f); bool flag = false; Renderer[] array = componentsInChildren; foreach (Renderer val in array) { if (val.enabled && !(val is ParticleSystemRenderer)) { if (flag) { ((Bounds)(ref bounds)).Encapsulate(val.bounds); continue; } bounds = val.bounds; flag = true; } } return bounds; } private static void RemoveTemplateColliders(Transform root) { PhysGrabObjectCollider[] componentsInChildren = ((Component)root).GetComponentsInChildren<PhysGrabObjectCollider>(true); for (int i = 0; i < componentsInChildren.Length; i++) { DestroyComponent((Component)(object)componentsInChildren[i]); } PhysGrabObjectBoxCollider[] componentsInChildren2 = ((Component)root).GetComponentsInChildren<PhysGrabObjectBoxCollider>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { DestroyComponent((Component)(object)componentsInChildren2[i]); } PhysGrabObjectMeshCollider[] componentsInChildren3 = ((Component)root).GetComponentsInChildren<PhysGrabObjectMeshCollider>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { DestroyComponent((Component)(object)componentsInChildren3[i]); } Collider[] componentsInChildren4 = ((Component)root).GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren4.Length; i++) { DestroyComponent((Component)(object)componentsInChildren4[i]); } } private static void DestroyComponent(Component component) { if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } } private static void DestroyMesh(Mesh? mesh) { //IL_000a: 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) if ((Object)(object)mesh != (Object)null && (((Object)mesh).hideFlags & 0x3D) != 0) { Object.DestroyImmediate((Object)(object)mesh); } } } internal sealed class MitaValuableGrabGlow : MonoBehaviour { private readonly List<Material> _materials = new List<Material>(); private PhysGrabObject? _physGrabObject; [SerializeField] private Color _glowColor = Color.cyan; private bool _wasGrabbed; public void Configure(Color glowColor) { //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) _glowColor = glowColor; } private void Start() { _physGrabObject = ((Component)this).GetComponent<PhysGrabObject>(); Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!val.enabled) { continue; } Material[] materials = val.materials; foreach (Material val2 in materials) { if ((Object)(object)val2 != (Object)null && val2.HasProperty("_EmissionColor")) { val2.EnableKeyword("_EMISSION"); _materials.Add(val2); } } } } private void Update() { //IL_0037: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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) if ((Object)(object)_physGrabObject == (Object)null) { return; } bool flag = RepoValuableAccess.IsGrabbed(_physGrabObject); if (flag == _wasGrabbed) { return; } _wasGrabbed = flag; Color val = (flag ? (_glowColor * 1.35f) : Color.black); foreach (Material material in _materials) { if ((Object)(object)material != (Object)null) { material.SetColor("_EmissionColor", val); } } } } internal static class MitaValuableGrabVoicePatches { [HarmonyPatch(typeof(PhysGrabObject), "GrabStarted")] [HarmonyPostfix] private static void PhysGrabObjectGrabStartedPostfix(PhysGrabObject __instance) { TryPlay(__instance); } [HarmonyPatch(typeof(PhysGrabObject), "GrabLinkRPC")] [HarmonyPostfix] private static void PhysGrabObjectGrabLinkRpcPostfix(PhysGrabObject __instance) { TryPlay(__instance); } [HarmonyPatch(typeof(PhysGrabObject), "GrabPlayerAddRPC")] [HarmonyPostfix] private static void PhysGrabObjectGrabPlayerAddRpcPostfix(PhysGrabObject __instance) { TryPlay(__instance); } private static void TryPlay(PhysGrabObject physGrabObject) { ((Component)physGrabObject).GetComponent<MitaValuableVoiceOnGrab>()?.TryPlayFromGrab(); } } internal sealed class MitaValuablePrefabFactory { private static readonly List<string> GenericPreset = new List<string> { "Valuables - Generic" }; private readonly ManualLogSource _log; private readonly Dictionary<Type, GameObject> _templates = new Dictionary<Type, GameObject>(); private GameObject? _prefabBank; public MitaValuablePrefabFactory(ManualLogSource log) { _log = log; } public bool TryRegisterAll() { //IL_002a: 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) ResolveTemplates(); if (_templates.Count == 0) { return false; } int num = 0; MitaValuableDefinition[] all = MitaValuableDefinitions.All; foreach (MitaValuableDefinition mitaValuableDefinition in all) { GameObject template = GetTemplate(mitaValuableDefinition.VolumeType); if ((Object)(object)template == (Object)null) { _log.LogWarning((object)$"Skipping {mitaValuableDefinition.DisplayName}: no template valuable exists for {mitaValuableDefinition.VolumeType}."); continue; } if (Valuables.RegisterValuable(CreatePrefab(mitaValuableDefinition, template), GenericPreset) == null) { _log.LogWarning((object)("REPOLib rejected " + mitaValuableDefinition.DisplayName + ".")); continue; } num++; _log.LogInfo((object)("Registered " + mitaValuableDefinition.DisplayName + " from " + mitaValuableDefinition.SourceReference + ".")); } return num > 0; } private void ResolveTemplates() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) _templates.Clear(); foreach (LevelValuables value in ValuablePresets.AllValuablePresets.Values) { Type[] volumeTypes = MitaValuableVisuals.VolumeTypes; foreach (Type val in volumeTypes) { if (!_templates.ContainsKey(val)) { GameObject val2 = FindTemplateInList(RepoValuableAccess.GetList(value, val)); if ((Object)(object)val2 != (Object)null) { _templates.Add(val, val2); } } } } } private static GameObject? FindTemplateInList(List<PrefabRef>? prefabRefs) { if (prefabRefs == null) { return null; } foreach (PrefabRef prefabRef in prefabRefs) { if (prefabRef != null && prefabRef.IsValid()) { GameObject prefab = prefabRef.Prefab; if ((Object)(object)prefab != (Object)null && (Object)(object)prefab.GetComponent<ValuableObject>() != (Object)null) { return prefab; } } } return null; } private GameObject? GetTemplate(Type type) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (_templates.TryGetValue(type, out GameObject value) && (Object)(object)value != (Object)null) { return value; } if (_templates.TryGetValue((Type)2, out value) && (Object)(object)value != (Object)null) { return value; } foreach (GameObject value2 in _templates.Values) { if ((Object)(object)value2 != (Object)null) { return value2; } } return null; } private GameObject CreatePrefab(MitaValuableDefinition definition, GameObject template) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) GameObject val = EnsurePrefabBank(); GameObject val2 = Object.Instantiate<GameObject>(template, val.transform, false); ((Object)val2).name = definition.PrefabName; ((Object)val2).hideFlags = (HideFlags)61; val2.SetActive(true); RepoValuableAccess.ConfigureValuable(val2.GetComponent<ValuableObject>(), definition); DisableTemplateRenderers(val2); if (!MitaValuableBundleVisuals.TryAttach(val2.transform, definition)) { MitaValuableVisuals.Build(val2.transform, definition); } MitaValuableGrabBounds.Add(val2.transform, definition); if (definition.GrabGlow) { (val2.GetComponent<MitaValuableGrabGlow>() ?? val2.AddComponent<MitaValuableGrabGlow>()).Configure(definition.Accent); } AudioClip[] array = MitaValuableBundleVisuals.LoadVoiceClips(definition); if (array.Length != 0) { (val2.GetComponent<MitaValuableVoiceOnGrab>() ?? val2.AddComponent<MitaValuableVoiceOnGrab>()).Configure(array, definition.VoiceVolume); } else { _log.LogWarning((object)("No MiSide grab voice clips were loaded for " + definition.DisplayName + ".")); } return val2; } private GameObject EnsurePrefabBank() { //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_002d: Expected O, but got Unknown if ((Object)(object)_prefabBank != (Object)null) { return _prefabBank; } _prefabBank = new GameObject("MitaValuables Prefab Bank") { hideFlags = (HideFlags)61 }; _prefabBank.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_prefabBank); return _prefabBank; } private static void DisableTemplateRenderers(GameObject prefab) { Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } } } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("Empress.REPO.MitaValuables", "Mita Valuables", "1.0.0")] public sealed class MitaValuablesPlugin : BaseUnityPlugin { internal const string PluginGuid = "Empress.REPO.MitaValuables"; internal const string PluginName = "Mita Valuables"; internal const string PluginVersion = "1.0.0"; private static readonly Harmony Harmony = new Harmony("Empress.REPO.MitaValuables"); private bool _registrationStarted; private bool _registered; internal static ManualLogSource Log { get; private set; } = null; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); Harmony.PatchAll(typeof(MitaValuablesPlugin).Assembly); ((MonoBehaviour)this).StartCoroutine(RegisterWhenREPOLibIsReady()); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Mita Valuables v1.0.0 loaded."); } private IEnumerator RegisterWhenREPOLibIsReady() { if (!_registrationStarted) { _registrationStarted = true; while ((Object)(object)RunManager.instance == (Object)null || ValuablePresets.AllValuablePresets.Count == 0) { yield return null; } yield return null; MitaValuableBundleVisuals.Initialize(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? string.Empty, ((BaseUnityPlugin)this).Logger); MitaValuablePrefabFactory mitaValuablePrefabFactory = new MitaValuablePrefabFactory(((BaseUnityPlugin)this).Logger); _registered = mitaValuablePrefabFactory.TryRegisterAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)(_registered ? $"Registered {MitaValuableDefinitions.All.Length} MiSide valuables with REPOLib." : "Mita valuables could not be registered because no vanilla valuable templates were available.")); } } } internal static class MitaValuableVisuals { public static readonly Type[] VolumeTypes; public static void Build(Transform root, MitaValuableDefinition definition) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_001e: 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_003e: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("MitaValuableProceduralVisual"); val.transform.SetParent(root, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; if (definition.Chibi) { BuildChibi(val.transform, definition); } else { BuildFull(val.transform, definition); } } private static void BuildFull(Transform root, MitaValuableDefinition definition) { //IL_0011: 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_004b: 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_0080: 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_00b5: 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_00ea: 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_0110: 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_0145: 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) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) Material material = MaterialFor(definition.PrefabName + " Skin", definition.Primary); Material material2 = MaterialFor(definition.PrefabName + " Outfit", definition.Secondary); Material material3 = MaterialFor(definition.PrefabName + " Accent", definition.Accent, emission: true); AddSphere(root, "Head", new Vector3(0f, 1.2f, 0f), new Vector3(0.26f, 0.3f, 0.26f), material); AddSphere(root, "Hair", new Vector3(0f, 1.29f, -0.02f), new Vector3(0.29f, 0.22f, 0.28f), material2); AddCube(root, "Face", new Vector3(0f, 1.2f, -0.255f), new Vector3(0.3f, 0.19f, 0.018f), material3); AddCapsule(root, "Body", new Vector3(0f, 0.71f, 0f), Quaternion.identity, new Vector3(0.28f, 0.48f, 0.28f), material2); AddCapsule(root, "Left Arm", new Vector3(-0.31f, 0.75f, -0.02f), Quaternion.Euler(0f, 0f, 20f), new Vector3(0.08f, 0.35f, 0.08f), material); AddCapsule(root, "Right Arm", new Vector3(0.31f, 0.75f, -0.02f), Quaternion.Euler(0f, 0f, -20f), new Vector3(0.08f, 0.35f, 0.08f), material); AddCylinder(root, "Display Stand", new Vector3(0f, 0.035f, 0f), Quaternion.identity, new Vector3(0.6f, 0.035f, 0.6f), MaterialFor(definition.PrefabName + " Stand", Color.Lerp(Color.black, definition.Secondary, 0.35f))); } private static void BuildChibi(Transform root, MitaValuableDefinition definition) { //IL_0011: 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_004b: 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_0080: 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_00b5: 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_00ea: 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_0110: 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_0145: 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) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_018e: 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_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) Material material = MaterialFor(definition.PrefabName + " Chibi Skin", definition.Primary); Material material2 = MaterialFor(definition.PrefabName + " Chibi Outfit", definition.Secondary); Material material3 = MaterialFor(definition.PrefabName + " Chibi Accent", definition.Accent, emission: true); AddSphere(root, "Chibi Head", new Vector3(0f, 0.68f, -0.03f), new Vector3(0.28f, 0.3f, 0.27f), material); AddSphere(root, "Chibi Hair", new Vector3(0f, 0.77f, -0.04f), new Vector3(0.31f, 0.22f, 0.29f), material2); AddCube(root, "Chibi Face", new Vector3(0f, 0.67f, -0.285f), new Vector3(0.28f, 0.17f, 0.018f), material3); AddCapsule(root, "Chibi Body", new Vector3(0f, 0.31f, 0f), Quaternion.identity, new Vector3(0.2f, 0.28f, 0.2f), material2); AddSphere(root, "Left Twin Tail", new Vector3(-0.27f, 0.67f, 0.02f), new Vector3(0.11f, 0.19f, 0.11f), material2); AddSphere(root, "Right Twin Tail", new Vector3(0.27f, 0.67f, 0.02f), new Vector3(0.11f, 0.19f, 0.11f), material2); AddCylinder(root, "Display Stand", new Vector3(0f, 0.035f, 0f), Quaternion.identity, new Vector3(0.48f, 0.035f, 0.48f), MaterialFor(definition.PrefabName + " Stand", Color.Lerp(Color.black, definition.Secondary, 0.35f))); } private static GameObject AddCube(Transform parent, string name, Vector3 localPosition, Vector3 localScale, Material material) { //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_0009: Unknown result type (might be due to invalid IL or missing references) return AddPrimitive(parent, name, (PrimitiveType)3, localPosition, Quaternion.identity, localScale, material); } private static GameObject AddSphere(Transform parent, string name, Vector3 localPosition, Vector3 localScale, Material material) { //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_0009: Unknown result type (might be due to invalid IL or missing references) return AddPrimitive(parent, name, (PrimitiveType)0, localPosition, Quaternion.identity, localScale, material); } private static GameObject AddCapsule(Transform parent, string name, Vector3 localPosition, Quaternion localRotation, Vector3 localScale, Material material) { //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_0005: Unknown result type (might be due to invalid IL or missing references) return AddPrimitive(parent, name, (PrimitiveType)1, localPosition, localRotation, localScale, material); } private static GameObject AddCylinder(Transform parent, string name, Vector3 localPosition, Quaternion localRotation, Vector3 localScale, Material material) { //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_0005: Unknown result type (might be due to invalid IL or missing references) return AddPrimitive(parent, name, (PrimitiveType)2, localPosition, localRotation, localScale, material); } private static GameObject AddPrimitive(Transform parent, string name, PrimitiveType primitiveType, Vector3 localPosition, Quaternion localRotation, Vector3 localScale, Material material) { //IL_0000: 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_0039: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive(primitiveType); ((Object)obj).name = name; obj.transform.SetParent(parent, false); obj.transform.localPosition = localPosition; obj.transform.localRotation = localRotation; obj.transform.localScale = localScale; Collider component = obj.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } obj.GetComponent<Renderer>().sharedMaterial = material; return obj; } private static Material MaterialFor(string name, Color color, bool emission = false) { //IL_000a: 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_0016: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_003a: 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) Material val = new Material(Shader.Find("Standard")) { name = name, color = color, hideFlags = (HideFlags)61 }; if (emission) { val.EnableKeyword("_EMISSION"); val.SetColor("_EmissionColor", color * 0.9f); } return val; } static MitaValuableVisuals() { Type[] array = new Type[7]; RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/); VolumeTypes = (Type[])(object)array; } } internal sealed class MitaValuableVoiceOnGrab : MonoBehaviour { [SerializeField] private AudioClip[] _clips = Array.Empty<AudioClip>(); [SerializeField] private float _volume = 0.82f; private AudioSource? _audioSource; private PhysGrabObject? _physGrabObject; private bool _wasGrabbed; private bool _warnedNoClips; private float _nextAllowedTime; public void Configure(AudioClip[] clips, float volume) { _clips = clips ?? Array.Empty<AudioClip>(); _volume = Mathf.Clamp(volume, 0f, 1.5f); PreloadClips(); } internal void TryPlayFromGrab() { EnsureComponents(); PreloadClips(); if ((Object)(object)_audioSource == (Object)null || _clips.Length == 0) { if (!_warnedNoClips) { _warnedNoClips = true; MitaValuablesPlugin.Log.LogWarning((object)(((Object)this).name + " has no serialized MiSide voice clips to play.")); } } else if (Time.time >= _nextAllowedTime) { PlayRandomClip(); } } private void Awake() { EnsureComponents(); } private void OnEnable() { EnsureComponents(); PreloadClips(); _wasGrabbed = false; } private void EnsureComponents() { if ((Object)(object)_physGrabObject == (Object)null) { _physGrabObject = ((Component)this).GetComponent<PhysGrabObject>(); } if ((Object)(object)_audioSource == (Object)null) { _audioSource = ((Component)this).GetComponent<AudioSource>() ?? ((Component)this).gameObject.AddComponent<AudioSource>(); } _audioSource.playOnAwake = false; _audioSource.loop = false; ((Behaviour)_audioSource).enabled = true; _audioSource.mute = false; _audioSource.spatialBlend = 0.82f; _audioSource.rolloffMode = (AudioRolloffMode)1; _audioSource.minDistance = 3.5f; _audioSource.maxDistance = 34f; _audioSource.dopplerLevel = 0f; _audioSource.priority = 32; _audioSource.ignoreListenerPause = true; _audioSource.volume = _volume; } private void Update() { if (!((Object)(object)_physGrabObject == (Object)null) && !((Object)(object)_audioSource == (Object)null) && _clips.Length != 0) { bool flag = RepoValuableAccess.IsGrabbedForVoice(_physGrabObject); if (flag && !_wasGrabbed && Time.time >= _nextAllowedTime) { TryPlayFromGrab(); } _wasGrabbed = flag; } } private void PlayRandomClip() { AudioClip val = _clips[Random.Range(0, _clips.Length)]; if (!((Object)(object)val == (Object)null) && !((Object)(object)_audioSource == (Object)null)) { _audioSource.pitch = Random.Range(0.94f, 1.06f); _audioSource.volume = _volume; _audioSource.clip = val; _audioSource.Stop(); _audioSource.Play(); _nextAllowedTime = Time.time + Mathf.Clamp(val.length * 0.35f, 0.75f, 2.4f); } } private void PreloadClips() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) AudioClip[] clips = _clips; foreach (AudioClip val in clips) { if ((Object)(object)val != (Object)null && (int)val.loadState == 0) { val.LoadAudioData(); } } } } internal static class RepoValuableAccess { private static readonly FieldRef<LevelValuables, List<PrefabRef>> TinyRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("tiny"); private static readonly FieldRef<LevelValuables, List<PrefabRef>> SmallRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("small"); private static readonly FieldRef<LevelValuables, List<PrefabRef>> MediumRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("medium"); private static readonly FieldRef<LevelValuables, List<PrefabRef>> BigRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("big"); private static readonly FieldRef<LevelValuables, List<PrefabRef>> WideRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("wide"); private static readonly FieldRef<LevelValuables, List<PrefabRef>> TallRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("tall"); private static readonly FieldRef<LevelValuables, List<PrefabRef>> VeryTallRef = AccessTools.FieldRefAccess<LevelValuables, List<PrefabRef>>("veryTall"); private static readonly FieldRef<ValuableObject, Value> ValuePresetRef = AccessTools.FieldRefAccess<ValuableObject, Value>("valuePreset"); private static readonly FieldRef<ValuableObject, Durability> DurabilityPresetRef = AccessTools.FieldRefAccess<ValuableObject, Durability>("durabilityPreset"); private static readonly FieldRef<ValuableObject, PhysAttribute> PhysAttributePresetRef = AccessTools.FieldRefAccess<ValuableObject, PhysAttribute>("physAttributePreset"); private static readonly FieldRef<ValuableObject, Type> VolumeTypeRef = AccessTools.FieldRefAccess<ValuableObject, Type>("volumeType"); private static readonly FieldRef<ValuableObject, int> DollarValueOverrideRef = AccessTools.FieldRefAccess<ValuableObject, int>("dollarValueOverride"); private static readonly FieldRef<ValuableObject, bool> DebugVolumeRef = AccessTools.FieldRefAccess<ValuableObject, bool>("debugVolume"); private static readonly FieldRef<ValuableObject, Gradient> ParticleColorsRef = AccessTools.FieldRefAccess<ValuableObject, Gradient>("particleColors"); private static readonly FieldRef<Value, float> ValueMinRef = AccessTools.FieldRefAccess<Value, float>("valueMin"); private static readonly FieldRef<Value, float> ValueMaxRef = AccessTools.FieldRefAccess<Value, float>("valueMax"); private static readonly FieldRef<Durability, float> FragilityRef = AccessTools.FieldRefAccess<Durability, float>("fragility"); private static readonly FieldRef<Durability, float> DurabilityRef = AccessTools.FieldRefAccess<Durability, float>("durability"); private static readonly FieldRef<PhysAttribute, float> MassRef = AccessTools.FieldRefAccess<PhysAttribute, float>("mass"); private static readonly FieldRef<PhysGrabObject, bool> GrabbedRef = AccessTools.FieldRefAccess<PhysGrabObject, bool>("grabbed"); private static readonly FieldRef<PhysGrabObject, bool> GrabbedLocalRef = AccessTools.FieldRefAccess<PhysGrabObject, bool>("grabbedLocal"); private static readonly FieldRef<PhysGrabObject, bool> HeldByLocalPlayerRef = AccessTools.FieldRefAccess<PhysGrabObject, bool>("heldByLocalPlayer"); private static readonly FieldRef<PhysGrabObject, List<PhysGrabber>> PlayerGrabbingRef = AccessTools.FieldRefAccess<PhysGrabObject, List<PhysGrabber>>("playerGrabbing"); public static List<PrefabRef> GetList(LevelValuables preset, Type type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected I4, but got Unknown return (int)type switch { 0 => TinyRef.Invoke(preset), 1 => SmallRef.Invoke(preset), 2 => MediumRef.Invoke(preset), 3 => BigRef.Invoke(preset), 4 => WideRef.Invoke(preset), 5 => TallRef.Invoke(preset), 6 => VeryTallRef.Invoke(preset), _ => MediumRef.Invoke(preset), }; } public static void ConfigureValuable(ValuableObject valuable, MitaValuableDefinition definition) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected I4, but got Unknown ValuePresetRef.Invoke(valuable) = CreateValuePreset(definition); DurabilityPresetRef.Invoke(valuable) = CreateDurabilityPreset(definition); PhysAttributePresetRef.Invoke(valuable) = CreatePhysAttributePreset(definition); VolumeTypeRef.Invoke(valuable) = (Type)(int)definition.VolumeType; DollarValueOverrideRef.Invoke(valuable) = 0; DebugVolumeRef.Invoke(valuable) = false; ParticleColorsRef.Invoke(valuable) = CreateParticleGradient(definition); } public static bool IsGrabbed(PhysGrabObject physGrabObject) { return GrabbedRef.Invoke(physGrabObject); } public static bool IsGrabbedForVoice(PhysGrabObject physGrabObject) { List<PhysGrabber> list = PlayerGrabbingRef.Invoke(physGrabObject); if (!GrabbedRef.Invoke(physGrabObject) && !GrabbedLocalRef.Invoke(physGrabObject) && !HeldByLocalPlayerRef.Invoke(physGrabObject)) { if (list != null) { return list.Count > 0; } return false; } return true; } private static Value CreateValuePreset(MitaValuableDefinition definition) { Value val = ScriptableObject.CreateInstance<Value>(); ((Object)val).hideFlags = (HideFlags)61; ((Object)val).name = "Value - " + definition.DisplayName; ValueMinRef.Invoke(val) = definition.ValueMin; ValueMaxRef.Invoke(val) = definition.ValueMax; return val; } private static Durability CreateDurabilityPreset(MitaValuableDefinition definition) { Durability val = ScriptableObject.CreateInstance<Durability>(); ((Object)val).hideFlags = (HideFlags)61; ((Object)val).name = "Durability - " + definition.DisplayName; FragilityRef.Invoke(val) = Mathf.Clamp(definition.Fragility + StableJitter(definition.PrefabName, "fragility", 5.5f), 5f, 95f); DurabilityRef.Invoke(val) = Mathf.Clamp(definition.Durability + StableJitter(definition.PrefabName, "durability", 5.5f), 5f, 100f); return val; } private static PhysAttribute CreatePhysAttributePreset(MitaValuableDefinition definition) { PhysAttribute val = ScriptableObject.CreateInstance<PhysAttribute>(); ((Object)val).hideFlags = (HideFlags)61; ((Object)val).name = "PhysAttribute - " + definition.DisplayName; MassRef.Invoke(val) = definition.Mass; return val; } private static float StableJitter(string name, string salt, float radius) { uint num = 2166136261u; string text = name + ":" + salt; for (int i = 0; i < text.Length; i++) { num ^= text[i]; num *= 16777619; } return ((float)(num & 0xFFFFu) / 65535f * 2f - 1f) * radius; } private static Gradient CreateParticleGradient(MitaValuableDefinition definition) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0010: 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_001f: 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_002d: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_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) //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_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_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) Gradient val = new Gradient(); val.SetKeys((GradientColorKey[])(object)new GradientColorKey[3] { new GradientColorKey(definition.Accent, 0f), new GradientColorKey(Color.Lerp(definition.Primary, definition.Secondary, 0.6f), 0.55f), new GradientColorKey(definition.Secondary, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[3] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(0.8f, 0.75f), new GradientAlphaKey(0f, 1f) }); return val; } } }