private void RedirectHook(IAssetLoadingContext context) { if (context.Parameters.Name == null || context.Bundle.name == null) { return; } if (typeof(Texture).IsAssignableFrom(context.Parameters.Type)) { string zipPath = $"abdata/{context.Bundle.name.Replace(".unity3d", "", StringComparison.OrdinalIgnoreCase)}/{context.Parameters.Name}.png"; var tex = GetPng(zipPath); if (tex != null) { context.Asset = tex; context.Complete(); return; } } if (context.Parameters.Type == typeof(ExcelData)) { if (TryGetExcelData(context.Bundle.name, context.Parameters.Name, out var excelData)) { context.Asset = excelData; context.Complete(); return; } } if (BundleManager.TryGetObjectFromName(context.Parameters.Name, context.Bundle.name, context.Parameters.Type, out UnityEngine.Object obj)) { context.Asset = obj; context.Complete(); } }
private void ReplacePrefab(IAssetLoadingContext ctx) { var path = $"{ctx.GetNormalizedAssetBundlePath()}\\{ctx.Parameters.Name}".ToLowerInvariant(); if (!prefabReplacements.TryGetValue(path, out var mod)) { return; } ctx.Asset = mod.LoadPrefab(path); ctx.Complete(skipAllPostfixes: false); }
public void LoadBGM(IAssetLoadingContext context) { if (context.Parameters.Name != null && (context.Parameters.Name.StartsWith("bgm", System.StringComparison.InvariantCultureIgnoreCase) || context.Parameters.Name.StartsWith("ai_bgm", System.StringComparison.InvariantCultureIgnoreCase)) && context.Parameters.Name.Length > 4) { int bgmTrack = int.Parse(context.Parameters.Name.Substring(context.Parameters.Name.Length - 2, 2)); var path = BepInEx.Utility.CombinePaths(BGMDirectory, $"BGM{bgmTrack:00}.ogg"); if (File.Exists(path)) { Logger.LogDebug($"Loading BGM track \"{(BGM)bgmTrack}\" from {path}"); context.Asset = AudioLoader.LoadVorbis(path); context.Complete(); } } }
public void LoadIntroClips(IAssetLoadingContext context) { if (context.Bundle.name.StartsWith("sound/data/systemse/brandcall/") || context.Bundle.name.StartsWith("sound/data/systemse/titlecall/")) { var files = Directory.GetFiles(IntroClipsDirectory, "*.wav"); if (files.Length == 0) { return; } var path = files[Random.Range(0, files.Length - 1)]; context.Asset = AudioLoader.LoadAudioClip(path, AudioType.WAV); context.Complete(); } }