using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BombRushMP.Common; using BombRushMP.PluginCommon; using CommonAPI; using Microsoft.CodeAnalysis; using Reptile; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BombRushMP.CrewBoom { internal static class AudioLibraryUtils { public static AudioLibrary CreateFromCrewBoomCharacterDefinition(object definition) { //IL_0000: 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) //IL_000b: Expected O, but got Unknown //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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_0141: 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_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) //IL_0189: Expected O, but got Unknown AudioLibrary val = new AudioLibrary(); AudioCollection val2 = new AudioCollection(); AudioCollection val3 = new AudioCollection(); AudioCollection val4 = new AudioCollection(); AudioCollection val5 = new AudioCollection(); AudioCollection val6 = new AudioCollection(); AudioCollection val7 = new AudioCollection(); AudioCollection val8 = new AudioCollection(); AudioClip[] collection = CrewBoomTypes.CharacterDefinitionVoiceJumpField.GetValue(definition) as AudioClip[]; AudioClip[] collection2 = CrewBoomTypes.CharacterDefinitionVoiceGetHitField.GetValue(definition) as AudioClip[]; AudioClip[] collection3 = CrewBoomTypes.CharacterDefinitionVoiceDieField.GetValue(definition) as AudioClip[]; AudioClip[] collection4 = CrewBoomTypes.CharacterDefinitionVoiceDieFallField.GetValue(definition) as AudioClip[]; AudioClip[] collection5 = CrewBoomTypes.CharacterDefinitionVoiceComboField.GetValue(definition) as AudioClip[]; AudioClip[] collection6 = CrewBoomTypes.CharacterDefinitionVoiceBoostTrickField.GetValue(definition) as AudioClip[]; AudioClip[] collection7 = CrewBoomTypes.CharacterDefinitionVoiceTalkField.GetValue(definition) as AudioClip[]; val2.Clips.AddRange(collection); val3.Clips.AddRange(collection2); val4.Clips.AddRange(collection3); val5.Clips.AddRange(collection4); val6.Clips.AddRange(collection5); val7.Clips.AddRange(collection6); val8.Clips.AddRange(collection7); val.Collections[(AudioClipID)489] = val2; val.Collections[(AudioClipID)488] = val3; val.Collections[(AudioClipID)484] = val4; val.Collections[(AudioClipID)485] = val5; val.Collections[(AudioClipID)487] = val6; val.Collections[(AudioClipID)498] = val7; val.Collections[(AudioClipID)486] = val8; return val; } } public class CharacterHandle : IDisposable { public bool Finished; public bool Failed; public Action OnLoadFinished; private AssetBundleCreateRequest _request; private AssetBundle _bundle; public Guid GUID = Guid.Empty; private AssetBundleRequest _assetRequest; public GameObject CharacterPrefab { get; private set; } public int References { get; private set; } public AudioLibrary AudioLibrary { get; private set; } public CharacterHandle(Guid guid) { GUID = guid; } public void LoadAsync(string bundle) { _request = AssetBundle.LoadFromFileAsync(bundle); ((AsyncOperation)_request).completed += OnAssetBundleLoadCompletion; } private void OnAssetBundleLoadCompletion(AsyncOperation operation) { _bundle = _request.assetBundle; Failed = (Object)(object)_bundle == (Object)null; if (!Failed) { _assetRequest = _bundle.LoadAllAssetsAsync(); ((AsyncOperation)_assetRequest).completed += OnGameObjectsLoadCompletion; } else { Finished = true; OnLoadFinished?.Invoke(); } } private void OnGameObjectsLoadCompletion(AsyncOperation operation) { Object[] allAssets = _assetRequest.allAssets; foreach (Object obj in allAssets) { GameObject val = (GameObject)(object)((obj is GameObject) ? obj : null); if (!((Object)(object)val == (Object)null)) { Component component = val.GetComponent(CrewBoomTypes.CharacterDefinitionType); if ((Object)(object)component != (Object)null) { CharacterPrefab = val; AudioLibrary = AudioLibraryUtils.CreateFromCrewBoomCharacterDefinition(component); break; } } } Failed = (Object)(object)CharacterPrefab == (Object)null || !((AsyncOperation)_assetRequest).isDone; Finished = true; OnLoadFinished?.Invoke(); } public void Load(string bundle) { try { _bundle = AssetBundle.LoadFromFile(bundle); GameObject[] array = _bundle.LoadAllAssets(); foreach (GameObject val in array) { Component component = val.GetComponent(CrewBoomTypes.CharacterDefinitionType); if ((Object)(object)component != (Object)null) { CharacterPrefab = val; AudioLibrary = AudioLibraryUtils.CreateFromCrewBoomCharacterDefinition(component); break; } } } finally { Failed = (Object)(object)_bundle == (Object)null; Finished = true; OnLoadFinished?.Invoke(); } } public void AddReference() { References++; } public void Release() { References--; } public void Dispose() { if ((Object)(object)_bundle != (Object)null) { _bundle.Unload(true); _bundle = null; } } public CharacterVisual ConstructVisual() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //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) GameObject obj = Object.Instantiate(CharacterPrefab); GameObject val = new GameObject(((Object)CharacterPrefab).name + " Visual"); obj.transform.SetParent(val.transform, false); obj.transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity); return val.AddComponent(); } } public static class CrewBoomStreamer { public static bool AlreadyLoadedThisSession = false; internal static FieldInfo CharacterDefinitionIdField; internal static Dictionary CharacterHandleByGUID = new Dictionary(); private static Dictionary BundlePathByGUID = new Dictionary(); private static List Directories = new List(); private static HashSet CrewBoomFilenames = new HashSet(); public static int LoadedCharacters => CharacterHandleByGUID.Count; public static Shader CharacterShader { get; private set; } public static void Initialize() { CharacterDefinitionIdField = CrewBoomTypes.CharacterDefinitionType.GetField("Id"); } public static void LoadCrewBoomConfigFolder(string configFolder) { List list = Directory.GetFiles(configFolder, "*.cbb", SearchOption.TopDirectoryOnly).ToList(); list.AddRange(Directory.GetFiles(Path.Combine(configFolder, "no_cypher"), "*.cbb", SearchOption.TopDirectoryOnly)); foreach (string item in list) { CrewBoomFilenames.Add(Path.GetFileNameWithoutExtension(item)); } } public static void AddDirectory(string directory) { Directories.Add(directory); Directory.CreateDirectory(directory); } public static void ReloadResources() { CharacterShader = AssetAPI.GetShader((ShaderNames)0); } public static void ReloadCharacters() { foreach (KeyValuePair item in CharacterHandleByGUID) { item.Value.Dispose(); } CharacterHandleByGUID.Clear(); BundlePathByGUID.Clear(); foreach (string directory in Directories) { LoadFromDirectory(directory); } AlreadyLoadedThisSession = true; } public static void LoadFromDirectory(string directory) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Invalid comparison between Unknown and I4 //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Invalid comparison between Unknown and I4 string[] files = Directory.GetFiles(directory, "*.cbb", SearchOption.AllDirectories); foreach (string text in files) { string text2 = "Shit! Error trying to load streamed character " + Path.GetFileName(text); string path = Path.ChangeExtension(text, ".txt"); if (CrewBoomFilenames.Contains(Path.GetFileNameWithoutExtension(text))) { Debug.LogError((object)text2); Debug.LogError((object)"A CBB with the same name already exists in your regular CrewBoom folder."); continue; } if (File.Exists(path)) { Guid guid = Guid.Parse(File.ReadAllText(path)); if (HasCharacter(guid)) { Debug.LogError((object)text2); Debug.LogError((object)("GUID (" + guid.ToString() + ") is already taken by another streamed CrewBoom character.")); } else if ((int)CrewBoomSupport.GetCharacterForGuid(guid, (Characters)(-1)) != -1) { Debug.LogError((object)text2); Debug.LogError((object)("GUID (" + guid.ToString() + ") is already taken by a CrewBoom character.")); } else { Register(guid, text); } continue; } AssetBundle val = null; try { val = AssetBundle.LoadFromFile(text); GameObject[] array = val.LoadAllAssets(); for (int j = 0; j < array.Length; j++) { Component component = array[j].GetComponent(CrewBoomTypes.CharacterDefinitionType); if ((Object)(object)component != (Object)null) { Guid guid2 = Guid.Parse(CharacterDefinitionIdField.GetValue(component) as string); if (HasCharacter(guid2)) { Debug.LogError((object)text2); Debug.LogError((object)("GUID (" + guid2.ToString() + ") is already taken by another streamed CrewBoom character.")); } else if ((int)CrewBoomSupport.GetCharacterForGuid(guid2, (Characters)(-1)) != -1) { Debug.LogError((object)text2); Debug.LogError((object)("GUID (" + guid2.ToString() + ") is already taken by a CrewBoom character.")); } else { Register(guid2, text); File.WriteAllText(path, guid2.ToString()); } break; } } } catch (Exception ex) { Debug.LogError((object)text2); Debug.LogException(ex); } finally { if ((Object)(object)val != (Object)null) { val.Unload(true); } } } } public static bool HasCharacter(Guid guid) { return BundlePathByGUID.ContainsKey(guid); } public static CharacterHandle RequestCharacter(Guid guid, bool isAsync) { if (CharacterHandleByGUID.TryGetValue(guid, out var value)) { value.AddReference(); return value; } if (BundlePathByGUID.TryGetValue(guid, out var value2)) { CharacterHandle characterHandle = new CharacterHandle(guid); if (isAsync) { characterHandle.LoadAsync(value2); } else { characterHandle.Load(value2); } characterHandle.AddReference(); CharacterHandleByGUID[guid] = characterHandle; return characterHandle; } return null; } public static void Tick() { foreach (KeyValuePair item in new Dictionary(CharacterHandleByGUID)) { if (item.Value.References <= 0 && item.Value.Finished) { item.Value.Dispose(); CharacterHandleByGUID.Remove(item.Key); } } } private static void Register(Guid guid, string file) { BundlePathByGUID[guid] = file; } } public static class CrewBoomSupport { public const string SKATE_OFFSET_L = "skateOffsetL"; public const string SKATE_OFFSET_R = "skateOffsetR"; private static Dictionary> _characterIds; private static MethodInfo _customCharactersTryGetValueMethod; private static PropertyInfo _customCharacterDefinitionProperty; private static FieldInfo _characterDefinitionIdField; public static bool Installed { get; private set; } public static void Initialize() { Installed = true; CrewBoomTypes.Initialize(); _characterIds = ReflectionUtility.GetTypeByName("CrewBoom.CharacterDatabase").GetField("_characterIds", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null) as Dictionary>; } public static Characters GetCharacterForGuid(Guid guid, Characters fallback = (Characters)3) { //IL_000e: 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_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_0062: Unknown result type (might be due to invalid IL or missing references) if (guid.Equals(Guid.Empty)) { return fallback; } foreach (KeyValuePair> characterId in _characterIds) { if (characterId.Value != null && characterId.Value.Contains(guid)) { return characterId.Key; } } return fallback; } public static Guid GetGuidForCharacter(Characters character) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) if ((int)character < 26) { return Guid.Empty; } if (_characterIds.TryGetValue(character, out var value)) { return value[0]; } return Guid.Empty; } } public static class CrewBoomTypes { public static Type CharacterDefinitionType; public static Type CharacterOutfitType; public static Type CharacterOutfitRendererType; public static FieldInfo CharacterDefinitionOutfitsField; public static FieldInfo CharacterDefinitionRenderersField; public static FieldInfo CharacterDefinitionCanBlinkField; public static FieldInfo CharacterOutfitEnabledRenderersField; public static FieldInfo CharacterOutfitMaterialContainersField; public static FieldInfo CharacterOutfitRendererMaterialsField; public static FieldInfo CharacterOutfitRendererUseShaderForMaterialField; public static FieldInfo CharacterDefinitionVoiceDieField; public static FieldInfo CharacterDefinitionVoiceDieFallField; public static FieldInfo CharacterDefinitionVoiceTalkField; public static FieldInfo CharacterDefinitionVoiceBoostTrickField; public static FieldInfo CharacterDefinitionVoiceComboField; public static FieldInfo CharacterDefinitionVoiceGetHitField; public static FieldInfo CharacterDefinitionVoiceJumpField; public static void Initialize() { CharacterDefinitionType = ReflectionUtility.GetTypeByName("CrewBoomMono.CharacterDefinition"); CharacterOutfitType = ReflectionUtility.GetTypeByName("CrewBoomMono.CharacterOutfit"); CharacterOutfitRendererType = ReflectionUtility.GetTypeByName("CrewBoomMono.CharacterOutfitRenderer"); CharacterDefinitionOutfitsField = CharacterDefinitionType.GetField("Outfits"); CharacterDefinitionRenderersField = CharacterDefinitionType.GetField("Renderers"); CharacterDefinitionCanBlinkField = CharacterDefinitionType.GetField("CanBlink"); CharacterOutfitEnabledRenderersField = CharacterOutfitType.GetField("EnabledRenderers"); CharacterOutfitMaterialContainersField = CharacterOutfitType.GetField("MaterialContainers"); CharacterOutfitRendererMaterialsField = CharacterOutfitRendererType.GetField("Materials"); CharacterOutfitRendererUseShaderForMaterialField = CharacterOutfitRendererType.GetField("UseShaderForMaterial"); CharacterDefinitionVoiceDieField = CharacterDefinitionType.GetField("VoiceDie"); CharacterDefinitionVoiceDieFallField = CharacterDefinitionType.GetField("VoiceDieFall"); CharacterDefinitionVoiceTalkField = CharacterDefinitionType.GetField("VoiceTalk"); CharacterDefinitionVoiceBoostTrickField = CharacterDefinitionType.GetField("VoiceBoostTrick"); CharacterDefinitionVoiceComboField = CharacterDefinitionType.GetField("VoiceCombo"); CharacterDefinitionVoiceGetHitField = CharacterDefinitionType.GetField("VoiceGetHit"); CharacterDefinitionVoiceJumpField = CharacterDefinitionType.GetField("VoiceJump"); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }