mirror of
https://github.com/Yuyi-Oak/BlueArchiveToolkit.git
synced 2026-07-22 01:15:14 +08:00
feat: prepare experiment push package
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use bat_adapters::manifest::{AddressablesCatalogDriver, ManifestDriverRegistry};
|
||||
use bat_adapters::manifest::ManifestDriver;
|
||||
use bat_adapters::manifest::{AddressablesCatalogDriver, ManifestDriverRegistry};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
@@ -10,16 +10,16 @@ async fn main() -> anyhow::Result<()> {
|
||||
let driver = AddressablesCatalogDriver::new();
|
||||
println!("✅ Driver: {}", driver.name());
|
||||
|
||||
// 模拟 Addressables Catalog
|
||||
// 合成 Addressables Catalog,仅用于演示解析接口。
|
||||
println!("\n📦 解析 Addressables Catalog...");
|
||||
let catalog_json = r#"{
|
||||
"m_LocatorId": "AddressablesMainContentCatalog",
|
||||
"m_InternalIdPrefixes": ["https://cdn.example.com/"],
|
||||
"m_InternalIdPrefixes": ["https://synthetic.invalid/"],
|
||||
"m_InternalIds": [
|
||||
"academy-model.bundle",
|
||||
"academy-texture.bundle",
|
||||
"ui-atlas.bundle",
|
||||
"TableBundles-JP.bundle"
|
||||
"synthetic/model.bundle",
|
||||
"synthetic/texture.bundle",
|
||||
"synthetic/ui-atlas.bundle",
|
||||
"synthetic/table-manifest.json"
|
||||
]
|
||||
}"#;
|
||||
|
||||
|
||||
@@ -1,6 +1,65 @@
|
||||
use bat_adapters::unity::{Unity2021_3Adapter, UnityAdapterRegistry};
|
||||
use bat_adapters::unity::RawAssetBundle;
|
||||
use std::sync::Arc;
|
||||
use bat_adapters::unity::{Unity2021_3Adapter, UnityAdapterRegistry};
|
||||
|
||||
fn push_c_string(data: &mut Vec<u8>, value: &str) {
|
||||
data.extend_from_slice(value.as_bytes());
|
||||
data.push(0);
|
||||
}
|
||||
|
||||
fn push_u16(data: &mut Vec<u8>, value: u16) {
|
||||
data.extend_from_slice(&value.to_be_bytes());
|
||||
}
|
||||
|
||||
fn push_u32(data: &mut Vec<u8>, value: u32) {
|
||||
data.extend_from_slice(&value.to_be_bytes());
|
||||
}
|
||||
|
||||
fn push_i32(data: &mut Vec<u8>, value: i32) {
|
||||
data.extend_from_slice(&value.to_be_bytes());
|
||||
}
|
||||
|
||||
fn push_u64(data: &mut Vec<u8>, value: u64) {
|
||||
data.extend_from_slice(&value.to_be_bytes());
|
||||
}
|
||||
|
||||
fn align(data: &mut Vec<u8>, alignment: usize) {
|
||||
let remainder = data.len() % alignment;
|
||||
if remainder != 0 {
|
||||
data.resize(data.len() + alignment - remainder, 0);
|
||||
}
|
||||
}
|
||||
|
||||
fn synthetic_minimal_unityfs_bundle() -> Vec<u8> {
|
||||
let mut blocks_info = Vec::new();
|
||||
blocks_info.extend_from_slice(&[0; 16]);
|
||||
push_i32(&mut blocks_info, 1);
|
||||
push_u32(&mut blocks_info, 4);
|
||||
push_u32(&mut blocks_info, 4);
|
||||
push_u16(&mut blocks_info, 0);
|
||||
push_i32(&mut blocks_info, 1);
|
||||
push_u64(&mut blocks_info, 0);
|
||||
push_u64(&mut blocks_info, 4);
|
||||
push_u32(&mut blocks_info, 0);
|
||||
push_c_string(&mut blocks_info, "SYNTHETIC-DEMO-CAB");
|
||||
|
||||
let mut data = Vec::new();
|
||||
push_c_string(&mut data, "UnityFS");
|
||||
push_u32(&mut data, 8);
|
||||
push_c_string(&mut data, "5.x.x");
|
||||
push_c_string(&mut data, "2021.3.56f2");
|
||||
push_u64(&mut data, 0);
|
||||
push_u32(&mut data, blocks_info.len() as u32);
|
||||
push_u32(&mut data, blocks_info.len() as u32);
|
||||
push_u32(&mut data, 0);
|
||||
align(&mut data, 16);
|
||||
data.extend_from_slice(&blocks_info);
|
||||
data.extend_from_slice(b"data");
|
||||
|
||||
let total_size = data.len() as u64;
|
||||
let total_size_offset = b"UnityFS\0".len() + 4 + b"5.x.x\0".len() + b"2021.3.56f2\0".len();
|
||||
data[total_size_offset..total_size_offset + 8].copy_from_slice(&total_size.to_be_bytes());
|
||||
data
|
||||
}
|
||||
|
||||
fn main() {
|
||||
println!("🎮 BlueArchiveToolkit - Unity 适配器演示");
|
||||
@@ -11,16 +70,11 @@ fn main() {
|
||||
println!("✅ Unity Adapter: {}", adapter.name());
|
||||
println!(" 支持版本: 2021.3.0 - 2021.3.99");
|
||||
|
||||
// 模拟 UnityFS 文件头
|
||||
// 合成最小 UnityFS 文件,仅用于演示版本检测和适配器选择。
|
||||
println!("\n📦 测试 Unity 版本检测...");
|
||||
let mut bundle_data = Vec::new();
|
||||
bundle_data.extend_from_slice(b"UnityFS\0");
|
||||
bundle_data.extend_from_slice(&[0, 0, 0, 8]);
|
||||
bundle_data.extend_from_slice(b"5.x.x\02021.3.56f2\0");
|
||||
|
||||
let bundle = RawAssetBundle {
|
||||
data: bundle_data,
|
||||
path: Some("test.bundle".to_string()),
|
||||
data: synthetic_minimal_unityfs_bundle(),
|
||||
path: Some("synthetic-demo.bundle".to_string()),
|
||||
};
|
||||
|
||||
if adapter.can_handle(&bundle) {
|
||||
@@ -31,8 +85,7 @@ fn main() {
|
||||
|
||||
// 测试 Registry
|
||||
println!("\n🔄 测试 Adapter Registry...");
|
||||
let mut registry = UnityAdapterRegistry::new();
|
||||
registry.register(Arc::new(Unity2021_3Adapter::new()));
|
||||
let registry = UnityAdapterRegistry::with_defaults();
|
||||
println!(" 注册的适配器数量: {}", registry.count());
|
||||
|
||||
match registry.select_adapter(&bundle) {
|
||||
|
||||
Reference in New Issue
Block a user