public BaseType(AssetsFile assetsFile) : base(assetsFile, assetsFile.Manager.GetScriptObject("BaseType")) { }
public CustomLevelLoader(AssetsFile assetsFile) { _assetsFile = assetsFile; }
public ColorManager(AssetsFile assetsFile) : base(assetsFile, assetsFile.Manager.GetScriptObject("ColorManager")) { }
public TargetableObject(AssetsFile assetsFile) : base(assetsFile, assetsFile.Manager.GetScriptObject("TargetableObject")) { }
public IntPayload(AssetsFile assetsFile) : base(assetsFile, assetsFile.Manager.GetScriptObject("IntPayload")) { }
private void Parse(AssetsFile assetsFile, AssetsObject owner, AssetsReader reader) { BeatmapCharacteristic = SmartPtr <AssetsObject> .Read(assetsFile, owner, reader); DifficultyBeatmaps = reader.ReadArrayOf(x => new DifficultyBeatmap(assetsFile, owner, x)); }
public static T DeepClone <T>(this IObjectInfo <T> source, AssetsFile toFile = null, List <CloneExclusion> exclusions = null, List <AssetsObject> addedObjects = null) where T : AssetsObject { return(Cloner.DeepClone <T>((T)source.Object, toFile, addedObjects, null, exclusions)); }
public static byte[] CreateBundleFromLevel(AssetsManager am, AssetsFileInstance inst) { EditorUtility.DisplayProgressBar("HKEdit", "Reading Files...", 0f); am.UpdateDependencies(); //quicker asset id lookup for (int i = 0; i < am.files.Count; i++) { AssetsFileInstance afi = am.files[i]; EditorUtility.DisplayProgressBar("HKEdit", "Generating QLTs", (float)i / am.files.Count); afi.table.GenerateQuickLookupTree(); } //setup AssetsFile file = inst.file; AssetsFileTable table = inst.table; string folderName = Path.GetDirectoryName(inst.path); List <AssetFileInfoEx> infos = table.pAssetFileInfo.ToList(); List <string> fileNames = new List <string>(); Dictionary <AssetID, byte[]> deps = new Dictionary <AssetID, byte[]>(); fileNames.Add(inst.name); //add own ids to list so we don't reread them foreach (AssetFileInfoEx info in infos) { if (info.curFileType != 1) { continue; } AssetID id = new AssetID(inst.name, (long)info.index); deps.Add(id, null); } //look through each field in each asset in this file for (int i = 0; i < infos.Count; i++) { AssetFileInfoEx info = infos[i]; if (info.curFileType != 1) { continue; } EditorUtility.DisplayProgressBar("HKEdit", "Crawling PPtrs", (float)i / infos.Count); ReferenceCrawler.CrawlPPtrs(am, inst, info.index, fileNames, deps); } //add typetree data for dependencies long curId = 1; List <Type_0D> types = new List <Type_0D>(); List <string> typeNames = new List <string>(); List <AssetsReplacer> assets = new List <AssetsReplacer>(); Dictionary <string, AssetsFileInstance> insts = new Dictionary <string, AssetsFileInstance>(); //asset id is our custom id that uses filename/pathid instead of fileid/pathid //asset id to path id Dictionary <AssetID, long> aidToPid = new Dictionary <AssetID, long>(); //script id to mono id Dictionary <ScriptID, ushort> sidToMid = new Dictionary <ScriptID, ushort>(); uint lastId = 0; ushort nextMonoId = 0; int depCount = 0; foreach (KeyValuePair <AssetID, byte[]> dep in deps) { EditorUtility.DisplayProgressBar("HKEdit", "Fixing Dependencies", (float)depCount / deps.Keys.Count); AssetID id = dep.Key; byte[] assetData = dep.Value; AssetsFileInstance afInst = null; if (insts.ContainsKey(id.fileName)) { afInst = insts[id.fileName]; } else { afInst = am.files.First(f => f.name == id.fileName); } if (afInst == null) { continue; } AssetFileInfoEx inf = afInst.table.getAssetInfo((ulong)id.pathId); if (lastId != inf.curFileType) { lastId = inf.curFileType; } ClassDatabaseType clType = AssetHelper.FindAssetClassByID(am.classFile, inf.curFileType); string clName = clType.name.GetString(am.classFile); ushort monoIndex = 0xFFFF; if (inf.curFileType != 0x72) { if (!typeNames.Contains(clName)) { Type_0D type0d = C2T5.Cldb2TypeTree(am.classFile, clName); type0d.classId = (int)inf.curFileType; //? types.Add(type0d); typeNames.Add(clName); } } else { //unused for now AssetTypeValueField baseField = am.GetATI(afInst.file, inf).GetBaseField(); AssetTypeValueField m_Script = baseField.Get("m_Script"); AssetTypeValueField scriptBaseField = am.GetExtAsset(afInst, m_Script).instance.GetBaseField(); string m_ClassName = scriptBaseField.Get("m_ClassName").GetValue().AsString(); string m_Namespace = scriptBaseField.Get("m_Namespace").GetValue().AsString(); string m_AssemblyName = scriptBaseField.Get("m_AssemblyName").GetValue().AsString(); ScriptID sid = new ScriptID(m_ClassName, m_Namespace, m_AssemblyName); if (!sidToMid.ContainsKey(sid)) { MonoClass mc = new MonoClass(); mc.Read(m_ClassName, Path.Combine(Path.Combine(Path.GetDirectoryName(inst.path), "Managed"), m_AssemblyName), afInst.file.header.format); Type_0D type0d = C2T5.Cldb2TypeTree(am.classFile, clName); TemplateFieldToType0D typeConverter = new TemplateFieldToType0D(); TypeField_0D[] monoFields = typeConverter.TemplateToTypeField(mc.children, type0d); type0d.pStringTable = typeConverter.stringTable; type0d.stringTableLen = (uint)type0d.pStringTable.Length; type0d.scriptIndex = nextMonoId; type0d.pTypeFieldsEx = type0d.pTypeFieldsEx.Concat(monoFields).ToArray(); type0d.typeFieldsExCount = (uint)type0d.pTypeFieldsEx.Length; types.Add(type0d); sidToMid.Add(sid, nextMonoId); nextMonoId++; } monoIndex = sidToMid[sid]; } aidToPid.Add(id, curId); AssetsReplacer rep = new AssetsReplacerFromMemory(0, (ulong)curId, (int)inf.curFileType, monoIndex, assetData); assets.Add(rep); curId++; depCount++; } byte[] blankData = BundleCreator.CreateBlankAssets(ver, types); AssetsFile blankFile = new AssetsFile(new AssetsFileReader(new MemoryStream(blankData))); EditorUtility.DisplayProgressBar("HKEdit", "Writing first file...", 0f); byte[] data = null; using (MemoryStream ms = new MemoryStream()) using (AssetsFileWriter writer = new AssetsFileWriter(ms)) { blankFile.Write(writer, 0, assets.ToArray(), 0); data = ms.ToArray(); } //File.WriteAllBytes("debug.assets", data); MemoryStream msn = new MemoryStream(data); AssetsManager amn = new AssetsManager(); amn.classFile = am.classFile; AssetsFileInstance instn = amn.LoadAssetsFile(msn, ((FileStream)inst.file.reader.BaseStream).Name, false); instn.table.GenerateQuickLookupTree(); deps.Clear(); List <AssetsReplacer> assetsn = new List <AssetsReplacer>(); //gameobject id to mono id Dictionary <long, long> gidToMid = new Dictionary <long, long>(); long nextBehaviourId = (long)instn.table.pAssetFileInfo.Max(i => i.index) + 1; CreateEditDifferTypeTree(amn.classFile, instn); CreateSceneMetadataTypeTree(amn.classFile, instn); Random rand = new Random(); rand.Next(); foreach (KeyValuePair <AssetID, long> kvp in aidToPid) { AssetFileInfoEx inf = instn.table.getAssetInfo((ulong)kvp.Value); if (inf.curFileType == 0x01) { gidToMid.Add(kvp.Value, nextBehaviourId); assetsn.Add(CreateEditDifferMonoBehaviour(kvp.Value, kvp.Key, nextBehaviourId++, rand)); } } for (int i = 0; i < instn.table.pAssetFileInfo.Length; i++) { AssetFileInfoEx inf = instn.table.pAssetFileInfo[i]; EditorUtility.DisplayProgressBar("HKEdit", "Crawling PPtrs", (float)i / instn.table.pAssetFileInfo.Length); ReferenceCrawler.CrawlReplacePPtrs(amn, instn, inf.index, fileNames, deps, aidToPid, gidToMid); } //add monoscript assets to preload table to make unity happy List <AssetPPtr> preloadPptrs = new List <AssetPPtr>(); preloadPptrs.Add(new AssetPPtr(1, 11500000)); preloadPptrs.Add(new AssetPPtr(2, 11500000)); foreach (KeyValuePair <AssetID, byte[]> dep in deps) { AssetID id = dep.Key; byte[] assetData = dep.Value; long pid = id.pathId; if (pid == 1) { assetData = AddMetadataMonobehaviour(assetData, nextBehaviourId); } AssetFileInfoEx inf = instn.table.getAssetInfo((ulong)pid); ushort monoId = instn.file.typeTree.pTypes_Unity5[inf.curFileTypeOrIndex].scriptIndex; assetsn.Add(new AssetsReplacerFromMemory(0, (ulong)pid, (int)inf.curFileType, monoId, assetData)); if (inf.curFileType == 0x73) { preloadPptrs.Add(new AssetPPtr(0, (ulong)pid)); } } List <long> usedIds = assetsn.Select(a => (long)a.GetPathID()).ToList(); //will break if no gameobjects but I don't really care at this point assetsn.Add(CreateSceneMetadataMonoBehaviour(1, nextBehaviourId++, inst.name, usedIds)); instn.file.preloadTable.items = preloadPptrs.ToArray(); instn.file.preloadTable.len = (uint)instn.file.preloadTable.items.Length; //add dependencies to monobehaviours List <AssetsFileDependency> fileDeps = new List <AssetsFileDependency>(); AddScriptDependency(fileDeps, Constants.editDifferMsEditorScriptHash, Constants.editDifferLsEditorScriptHash); AddScriptDependency(fileDeps, Constants.sceneMetadataMsEditorScriptHash, Constants.sceneMetadataLsEditorScriptHash); instn.file.dependencies.pDependencies = fileDeps.ToArray(); instn.file.dependencies.dependencyCount = (uint)fileDeps.Count; EditorUtility.DisplayProgressBar("HKEdit", "Writing second file...", 0f); byte[] datan = null; using (MemoryStream ms = new MemoryStream()) using (AssetsFileWriter writer = new AssetsFileWriter(ms)) { instn.file.Write(writer, 0, assetsn.ToArray(), 0); datan = ms.ToArray(); } EditorUtility.ClearProgressBar(); return(datan); }
public static AssetTypeValueField GetBaseField(AssetsManager am, AssetsFile file, AssetFileInfoEx info) { AssetTypeInstance ati = am.GetATI(file, info); return(ati.GetBaseField()); }
public GameObject(AssetsFile assetsFile) : base(assetsFile, AssetsConstants.ClassID.GameObjectClassID) { IsActive = true; }
public BeatmapCharacteristicObject(AssetsFile assetsFile) : base(assetsFile, assetsFile.Manager.GetScriptObject("BeatmapCharacteristicSO")) { }
public WwiseStateReference(AssetsFile assetsFile) : base(assetsFile, assetsFile.Manager.GetScriptObject("WwiseStateReference")) { }
public WwiseKoreographySet(AssetsFile assetsFile) : base(assetsFile, assetsFile.Manager.GetScriptObject("WwiseKoreographySet")) { }
public BaseType(AssetsFile assetsFile, MonoScriptObject scriptObject) : base(assetsFile, scriptObject) { }
private void RunDownload() { string Extension = (chb_Unity3d.Checked ? ".unity3d" : ""); string[] FileList = lib_File.Items.Cast <string>().ToArray(); tbManager.SetProgressValue(0, FileList.Length); tbManager.SetProgressState(TaskbarProgressBarState.Normal); string Url; if (rdb_ST.Checked) { Url = "http://img.wcproject.so-net.tw/assets/469/"; } else if (rdb_SJ.Checked) { Url = "http://i-wcat-colopl-jp.akamaized.net/assets/465/"; } else if (rdb_SK.Checked) { Url = "http://i-wcat-colopl-kr.akamaized.net/assets/465/"; } else if (rdb_tennis.Checked) { Url = "http://i-tennis-colopl-jp.akamaized.net/asset_bundle/"; } else { Url = txt_URL.Text; } if (rdb_tennis.Checked && RB_A.Checked) { Url += "android/0.0.1/"; } else if (rdb_tennis.Checked && RB_I.Checked) { Url += "ios/0.0.1/"; } else if (!rdb_Custom.Checked && RB_A.Checked) { Url += "a/"; } else if (!rdb_Custom.Checked && RB_I.Checked) { Url += "i/"; } List <DownloadInfo> list = new List <DownloadInfo>(); SetProgressBarValue(0, PB_TotalFile); foreach (string fileName in FileList) { if (fileName == "" || fileName.Substring(0, 1) == "'") { DelListBox(fileName.ToString(), lib_File); } else { string urlAddress = Url + fileName + Extension + "?r=" + DateTime.Now.ToFileTime().ToString(); DownloadInfo info = new DownloadInfo(urlAddress, txt_Save.Text, this, fileName + ".unity3d"); list.Add(info); info.StartDownload(); } } list.ForEach(delegate(DownloadInfo item) { SetToolStripLabelText("下載中 (" + (PB_TotalFile.Value * 100.0 / list.Count).ToString("0.0") + "%)", lab_Status); while (!item.IsDone) { if (!Working) { if (item.WC != null) { item.WC.CancelAsync(); } break; } SetLabelText("下載檔案: " + item.FileName, lab_Download); SetLabelText(string.Format("{0} KB / {1} KB", item.KBytesReceived.ToString("0.0"), item.TotalKBytesToReceive.ToString("0.0")), lab_Speed); SetProgressBarValue(item.KBytesReceived, PB_SingleFile); SetProgressBarMaxValue(item.TotalKBytesToReceive, PB_SingleFile); Thread.Sleep(500); } if (item.IsCancelled) { AddListBoxItem("C." + item.FileName, lib_Error); } else if (item.Error != "") { AddListBoxItem("E." + item.FileName, lib_Error); } SetProgressBarValue(PB_TotalFile.Value + 1, PB_TotalFile); SetToolStripLabelText("錯誤檔案數: " + lib_Error.Items.Count.ToString(), lab_ErrorItem); SetToolStripLabelText("已下載數: " + PB_TotalFile.Value, lab_DownItem); DelListBox(Path.GetFileNameWithoutExtension(item.FileName), lib_File); tbManager.SetProgressValue(PB_TotalFile.Value, FileList.Length); }); list.Clear(); SetProgressBarValue(0, PB_SingleFile); SetProgressBarMaxValue(0, PB_SingleFile); SetLabelText("0 KB / 0 KB", lab_Speed); if (ExtFile.Count != 0) { if (!Directory.Exists(txt_Save.Text)) { Directory.CreateDirectory(txt_Save.Text); } SetToolStripLabelText("檔案數: " + ExtFile.Count, lab_Item); SetProgressBarValue(0, PB_TotalFile); SetProgressBarMaxValue(ExtFile.Count, PB_TotalFile); SetToolStripLabelText("解包中", lab_Status); Parallel.ForEach(ExtFile, (item) => { if (item.Key == null || item.Value == null) { return; } BundleFile BF = new BundleFile(item.Value); if (!TSM_OnlyBundle.Checked) { bool Export = true; if (TSM_UnPrefab.Checked && TSM_Exclude.Text != "") { foreach (string item2 in TSM_Exclude.Text.Split(new char[] { ',' })) { if (Path.GetFileNameWithoutExtension(item.Key).ToLower().Contains(item2.ToLower())) { Export = false; break; } } } if (Export) { SetToolStripLabelText("解包: " + item.Key, lab_Execute); using (EndianStream ES = new EndianStream(BF.MemoryAssetsFileList[0].memStream, EndianType.BigEndian)) { AssetsFile AF = new AssetsFile(item.Key, ES); foreach (var item2 in AF.preloadTable.Values) { string SavePath = ""; switch (item2.Type2) { case 28: SavePath = txt_Save.Text + "Texture\\"; if (!Directory.Exists(SavePath)) { Directory.CreateDirectory(SavePath); } var m_Texture2D = new Texture2D(item2, true); var bitmap = m_Texture2D.ConvertToBitmap(true); if (bitmap != null) { if (!item.Key.Contains("std") && (bitmap.Width == 1024 && bitmap.Height == 1024)) { bitmap = Static_Function.ResizeImage(bitmap, 1024, 1331); } bitmap.Save(SavePath + item.Key + ".png", ImageFormat.Png); bitmap.Dispose(); } m_Texture2D = null; break; case 83: SavePath = txt_Save.Text + "Audio\\"; if (!Directory.Exists(SavePath)) { Directory.CreateDirectory(SavePath); } AudioClip m_AudioClip = new AudioClip(item2, true); File.WriteAllBytes(SavePath + item.Key + ".mp3", m_AudioClip.m_AudioData); m_AudioClip = null; break; case 49: SavePath = txt_Save.Text + "Text\\"; if (!Directory.Exists(SavePath)) { Directory.CreateDirectory(SavePath); } TextAsset TA = new TextAsset(item2, true); File.WriteAllBytes(SavePath + item.Key + ".txt", TA.m_Script); TA = null; break; case 114: SavePath = txt_Save.Text + "Text\\"; if (!Directory.Exists(SavePath)) { Directory.CreateDirectory(SavePath); } MonoBehaviour MB = new MonoBehaviour(item2, true); File.WriteAllText(SavePath + item.Key + ".txt", MB.serializedText); MB = null; break; } } AF = null; } } else { SetToolStripLabelText("略過: " + item.Key, lab_Execute); Static_Function.WriteBundleFile(BF, txt_Save.Text + "CAB-" + item.Key); } } else { SetToolStripLabelText("輸出: " + item.Key, lab_Execute); Static_Function.WriteBundleFile(BF, txt_Save.Text + "CAB-" + item.Key); } BF = null; item.Value.Dispose(); SetProgressBarValue(PB_TotalFile.Value + 1, PB_TotalFile); tbManager.SetProgressValue(PB_TotalFile.Value, ExtFile.Count); SetToolStripLabelText("已解包數: " + PB_TotalFile.Value, lab_DownItem); }); ExtFile.Clear(); GC.Collect(); } SW.Stop(); timer1.Stop(); SetLabelText("下載檔案:無", lab_Download); SetToolStripLabelText("等待中", lab_Status); Work_Event(false); tbManager.SetProgressState(TaskbarProgressBarState.NoProgress); Invoke(new Action(delegate { Text = "清單檔案下載器 "; })); if (Program.autoClose) { Environment.Exit(1); } if (lib_Error.Items.Count <= 0) { SetButtonEnable(false, btn_Save_Error); } Environment.ExitCode = 1; MessageBox.Show("下載完成"); }
public Renderer(AssetsFile assetsFile, int classID) : base(assetsFile, classID) { }
public DifficultyBeatmapSet(AssetsFile assetsFile, AssetsObject owner, AssetsReader reader) { Parse(assetsFile, owner, reader); }
static void Main(string[] args) { if (args.Length == 0) { return; } foreach (var arg in args) { if (!File.Exists(arg)) { continue; } var path = Path.GetFullPath(arg); var bundleFile = new BundleFile(path, new EndianBinaryReader(File.OpenRead(path))); if (bundleFile.fileList.Count == 0) { return; } var assetsFile = new AssetsFile(path, new EndianBinaryReader(bundleFile.fileList[0].stream)); var assets = assetsFile.preloadTable.Select(x => x.Value).ToArray(); var name = Path.GetFileName(path); var destPath = @"live2d\" + name + @"\"; var destTexturePath = @"live2d\" + name + @"\textures\"; var destAnimationPath = @"live2d\" + name + @"\motions\"; Directory.CreateDirectory(destPath); Directory.CreateDirectory(destTexturePath); Directory.CreateDirectory(destAnimationPath); Console.WriteLine($"Extract {name}"); //physics var physics = new TextAsset(assets.First(x => x.Type == ClassIDReference.TextAsset)); File.WriteAllBytes($"{destPath}{physics.m_Name}.json", physics.m_Script); //moc var moc = assets.First(x => x.Type == ClassIDReference.MonoBehaviour); foreach (var assetPreloadData in assets.Where(x => x.Type == ClassIDReference.MonoBehaviour)) { if (assetPreloadData.Size > moc.Size) { moc = assetPreloadData; } } var mocReader = moc.InitReader(); mocReader.Position += 28; mocReader.ReadAlignedString(); var mocBuff = mocReader.ReadBytes(mocReader.ReadInt32()); File.WriteAllBytes($"{destPath}{name}.moc3", mocBuff); //texture var textures = new SortedSet <string>(); foreach (var texture in assets.Where(x => x.Type == ClassIDReference.Texture2D)) { var texture2D = new Texture2D(texture); using (var bitmap = new Texture2DConverter(texture2D).ConvertToBitmap(true)) { textures.Add($"textures/{texture2D.m_Name}.png"); bitmap.Save($"{destTexturePath}{texture2D.m_Name}.png", ImageFormat.Png); } } //motions var motions = new List <string>(); var animatorAsset = assets.First(x => x.Type == ClassIDReference.Animator); var animator = new Animator(animatorAsset); var rootGameObject = new GameObject(animator.m_GameObject.Get()); var animations = assets.Where(x => x.Type == ClassIDReference.AnimationClip).Select(x => new AnimationClip(x)).ToArray(); var converter = new CubismMotion3Converter(rootGameObject, animations); foreach (ImportedKeyframedAnimation animation in converter.AnimationList) { var json = new CubismMotion3Json { Version = 3, Meta = new SerializableMeta { Duration = animation.Duration, Fps = animation.SampleRate, Loop = true, CurveCount = animation.TrackList.Count, UserDataCount = 0, TotalUserDataSize = 0 }, Curves = new SerializableCurve[animation.TrackList.Count] }; int totalSegmentCount = 0; int totalPointCount = 0; for (int i = 0; i < animation.TrackList.Count; i++) { var track = animation.TrackList[i]; json.Curves[i] = new SerializableCurve { Target = track.Target, Id = track.Name, Segments = new List <float> { 0f, track.Curve[0].value } }; var lastTime = 0f; for (var j = 1; j < track.Curve.Count; j++) { var preCurve = track.Curve[j - 1]; var curve = track.Curve[j]; if (preCurve.coeff[0] == 0f && preCurve.coeff[1] == 0f && preCurve.coeff[2] == 0f) //SteppedSegment { json.Curves[i].Segments.Add(2f); json.Curves[i].Segments.Add(curve.time); json.Curves[i].Segments.Add(curve.value); totalSegmentCount++; totalPointCount += 3; lastTime = curve.time; } else //LinearSegment { var interval = (curve.time - preCurve.time) / 20; for (var t = preCurve.time + interval; t < curve.time; t += interval) { json.Curves[i].Segments.Add(0f); json.Curves[i].Segments.Add(t); json.Curves[i].Segments.Add(preCurve.Evaluate(t)); totalSegmentCount++; totalPointCount += 3; lastTime = t; } } } var lastCurve = track.Curve.Last(); if (lastCurve.time > lastTime) { json.Curves[i].Segments.Add(0f); json.Curves[i].Segments.Add(lastCurve.time); json.Curves[i].Segments.Add(lastCurve.value); totalSegmentCount++; totalPointCount += 3; } } json.Meta.TotalSegmentCount = totalSegmentCount; json.Meta.TotalPointCount = totalPointCount; motions.Add($"motions/{animation.Name}.motion3.json"); File.WriteAllText($"{destAnimationPath}{animation.Name}.motion3.json", JsonConvert.SerializeObject(json, Formatting.Indented, new MyJsonConverter())); } //model var job = new JObject(); var jarray = new JArray(); var tempjob = new JObject(); foreach (var motion in motions) { tempjob["File"] = motion; jarray.Add(tempjob); } job[""] = jarray; var model3 = new CubismModel3Json { Version = 3, FileReferences = new SerializableFileReferences { Moc = $"{name}.moc3", Textures = textures.ToArray(), Physics = $"{physics.m_Name}.json", Motions = job }, Groups = new[] { new SerializableGroup { Target = "Parameter", Name = "LipSync", Ids = new[] { "ParamMouthOpenY" } }, new SerializableGroup { Target = "Parameter", Name = "EyeBlink", Ids = new[] { "ParamEyeLOpen", "ParamEyeROpen" } } } }; File.WriteAllText($"{destPath}{name}.model3.json", JsonConvert.SerializeObject(model3, Formatting.Indented)); } Console.WriteLine("Done!"); Console.Read(); }
public void Read(AssetsFile owner, UnityReader reader) { Offset = reader.ReadUInt32(); Size = reader.ReadUInt32(); Path = reader.ReadStringFixed(reader.ReadInt32()); }
public EnemyActionInstant(AssetsFile assetsFile) : base(assetsFile, assetsFile.Manager.GetScriptObject("EnemyActionInstant")) { }
public AlwaysOwnedContentModel(AssetsFile assetsFile) : base(assetsFile, assetsFile.Manager.GetScriptObject("AlwaysOwnedContentModelSO")) { }
public GroundDecorator(AssetsFile assetsFile) : base(assetsFile, assetsFile.Manager.GetScriptObject("GroundDecorator")) { }
public PlayerKiller(AssetsFile assetsFile) : base(assetsFile, assetsFile.Manager.GetScriptObject("PlayerKiller")) { }
public BodyPart(AssetsFile assetsFile) : base(assetsFile, assetsFile.Manager.GetScriptObject("BodyPart")) { }
//public BeatmapLevelCollectionObject(IObjectInfo<AssetsObject> objectInfo) : base(objectInfo) //{ //} public BeatmapLevelCollectionObject(AssetsFile assetsFile) : base(assetsFile, assetsFile.Manager.GetScriptObject("BeatmapLevelCollectionSO")) { BeatmapLevels = new List <ISmartPtr <BeatmapLevelDataObject> >(); }
public BodyPart(AssetsFile assetsFile, MonoScriptObject scriptObject) : base(assetsFile, scriptObject) { }
public EnemyActionRootMotion(AssetsFile assetsFile) : base(assetsFile, assetsFile.Manager.GetScriptObject("EnemyActionRootMotion")) { }
public TextAsset(AssetsFile assetsFile) : base(assetsFile, AssetsConstants.ClassID.TextAssetClassID) { }
private void LoadFSMs(string path) { string folderName = Path.GetDirectoryName(path); curFile = am.LoadAssetsFile(path, true); am.UpdateDependencies(); AssetsFile file = curFile.file; AssetsFileTable table = curFile.table; List <AssetInfo> assetInfos = new List <AssetInfo>(); uint assetCount = table.assetFileInfoCount; uint fsmTypeId = 0; foreach (AssetFileInfoEx info in table.assetFileInfo) { bool isMono = false; if (fsmTypeId == 0) { ushort monoType = file.typeTree.unity5Types[info.curFileTypeOrIndex].scriptIndex; if (monoType != 0xFFFF) { isMono = true; } } else if (info.curFileType == fsmTypeId) { isMono = true; } if (isMono) { AssetTypeInstance monoAti = am.GetATI(file, info); AssetTypeInstance scriptAti = am.GetExtAsset(curFile, monoAti.GetBaseField().Get("m_Script")).instance; AssetTypeInstance goAti = am.GetExtAsset(curFile, monoAti.GetBaseField().Get("m_GameObject")).instance; if (goAti == null) //found a scriptable object, oops { fsmTypeId = 0; continue; } string m_Name = goAti.GetBaseField().Get("m_Name").GetValue().AsString(); string m_ClassName = scriptAti.GetBaseField().Get("m_ClassName").GetValue().AsString(); if (m_ClassName == "PlayMakerFSM") { if (fsmTypeId == 0) { fsmTypeId = info.curFileType; } BinaryReader reader = file.reader; long oldPos = reader.BaseStream.Position; reader.BaseStream.Position = info.absoluteFilePos; reader.BaseStream.Position += 28; uint length = reader.ReadUInt32(); reader.ReadBytes((int)length); long pad = 4 - (reader.BaseStream.Position % 4); if (pad != 4) { reader.BaseStream.Position += pad; } reader.BaseStream.Position += 16; uint length2 = reader.ReadUInt32(); string fsmName = Encoding.UTF8.GetString(reader.ReadBytes((int)length2)); reader.BaseStream.Position = oldPos; assetInfos.Add(new AssetInfo() { id = info.index, size = info.curFileSize, name = m_Name + "-" + fsmName }); } } } assetInfos.Sort((x, y) => x.name.CompareTo(y.name)); FSMSelector selector = new FSMSelector(assetInfos); selector.ShowDialog(); //todo separate into separate method(s) if (selector.selectedID == -1) { return; } AssetFileInfoEx afi = table.GetAssetInfo(selector.selectedID); string tabName = assetInfos.FirstOrDefault(i => i.id == selector.selectedID).name; TabItem tab = new TabItem { Header = tabName }; ignoreChangeEvent = true; fsmTabControl.Items.Add(tab); fsmTabControl.SelectedItem = tab; ignoreChangeEvent = false; SaveAndClearNodes(); mt.Matrix = Matrix.Identity; AssetTypeValueField baseField = am.GetMonoBaseFieldCached(curFile, afi, Path.Combine(Path.GetDirectoryName(curFile.path), "Managed")); AssetTypeValueField fsm = baseField.Get("fsm"); AssetTypeValueField states = fsm.Get("states"); AssetTypeValueField globalTransitions = fsm.Get("globalTransitions"); dataVersion = fsm.Get("dataVersion").GetValue().AsInt(); for (int i = 0; i < states.GetValue().AsArray().size; i++) { AssetTypeValueField state = states.Get(i); //move all of this into node string name = state.Get("name").GetValue().AsString(); AssetTypeValueField rect = state.Get("position"); Rect dotNetRect = new Rect(rect.Get("x").GetValue().AsFloat(), rect.Get("y").GetValue().AsFloat(), rect.Get("width").GetValue().AsFloat(), rect.Get("height").GetValue().AsFloat()); AssetTypeValueField transitions = state.Get("transitions"); int transitionCount = transitions.GetValue().AsArray().size; FsmTransition[] dotNetTransitions = new FsmTransition[transitionCount]; for (int j = 0; j < transitionCount; j++) { dotNetTransitions[j] = new FsmTransition(transitions.Get(j)); } Node node = new Node(state, name, dotNetRect, dotNetTransitions); nodes.Add(node); node.grid.MouseLeftButtonDown += (object sender, MouseButtonEventArgs e) => { foreach (Node node2 in nodes) { node2.Selected = false; } node.Selected = true; SidebarData(node, curFile); }; graphCanvas.Children.Add(node.grid); } for (int i = 0; i < globalTransitions.GetValue().AsArray().size; i++) { AssetTypeValueField transition = globalTransitions.Get(i); FsmTransition dotNetTransition = new FsmTransition(transition); Node toNode = nodes.FirstOrDefault(n => n.name == dotNetTransition.toState); if (toNode == null) { Debug.WriteLine("transition " + dotNetTransition.fsmEvent.name + " going to non-existant node " + dotNetTransition.toState); } else { Rect rect = new Rect( toNode.Transform.X, toNode.Transform.Y - 50, toNode.Transform.Width, 18); if (toNode != null) { Node node = new Node(null, dotNetTransition.fsmEvent.name, rect, new[] { dotNetTransition }); nodes.Add(node); graphCanvas.Children.Add(node.grid); } } } foreach (Node node in nodes) { if (node.transitions.Length <= 0) { continue; } float yPos = 24; foreach (FsmTransition trans in node.transitions) { Node endNode = nodes.FirstOrDefault(n => n.name == trans.toState); if (endNode != null) { Point start, end, startMiddle, endMiddle; if (node.state != null) { start = ComputeLocation(node, endNode, yPos, out bool isLeftStart); end = ComputeLocation(endNode, node, 10, out bool isLeftEnd); double dist = 70; if (isLeftStart == isLeftEnd) { dist *= 0.5; } if (!isLeftStart) { startMiddle = new Point(start.X - dist, start.Y); } else { startMiddle = new Point(start.X + dist, start.Y); } if (!isLeftEnd) { endMiddle = new Point(end.X - dist, end.Y); } else { endMiddle = new Point(end.X + dist, end.Y); } } else { start = new Point(node.Transform.X + node.Transform.Width / 2, node.Transform.Y + node.Transform.Height); end = new Point(endNode.Transform.X + endNode.Transform.Width / 2, endNode.Transform.Y); startMiddle = new Point(start.X, start.Y + 1); endMiddle = new Point(end.X, end.Y - 1); } CurvedArrow arrow = new CurvedArrow() { Points = new PointCollection(new List <Point>() { start, startMiddle, endMiddle, end }), StrokeThickness = 2, Stroke = Brushes.Black, Fill = Brushes.Black, IsHitTestVisible = true }; arrow.MouseEnter += (object sender, MouseEventArgs e) => { arrow.Stroke = Brushes.LightGray; arrow.Fill = Brushes.LightGray; }; arrow.MouseLeave += (object sender, MouseEventArgs e) => { arrow.Stroke = Brushes.Black; arrow.Fill = Brushes.Black; }; Panel.SetZIndex(arrow, -1); graphCanvas.Children.Add(arrow); } else { Debug.WriteLine(node.name + " failed to connect to " + trans.toState); } yPos += 16; } } AssetTypeValueField events = fsm.Get("events"); for (int i = 0; i < events.GetValue().AsArray().size; i++) { AssetTypeValueField @event = events.Get(i); string name = @event.Get("name").GetValue().AsString(); bool isSystemEvent = @event.Get("isSystemEvent").GetValue().AsBool(); bool isGlobal = @event.Get("isGlobal").GetValue().AsBool(); eventList.Children.Add(CreateSidebarRow(name, isSystemEvent, isGlobal)); } AssetTypeValueField variables = fsm.Get("variables"); AssetTypeValueField floatVariables = variables.Get("floatVariables"); AssetTypeValueField intVariables = variables.Get("intVariables"); AssetTypeValueField boolVariables = variables.Get("boolVariables"); AssetTypeValueField stringVariables = variables.Get("stringVariables"); AssetTypeValueField vector2Variables = variables.Get("vector2Variables"); AssetTypeValueField vector3Variables = variables.Get("vector3Variables"); AssetTypeValueField colorVariables = variables.Get("colorVariables"); AssetTypeValueField rectVariables = variables.Get("rectVariables"); AssetTypeValueField quaternionVariables = variables.Get("quaternionVariables"); AssetTypeValueField gameObjectVariables = variables.Get("gameObjectVariables"); AssetTypeValueField objectVariables = variables.Get("objectVariables"); AssetTypeValueField materialVariables = variables.Get("materialVariables"); AssetTypeValueField textureVariables = variables.Get("textureVariables"); AssetTypeValueField arrayVariables = variables.Get("arrayVariables"); AssetTypeValueField enumVariables = variables.Get("enumVariables"); variableList.Children.Add(CreateSidebarHeader("Floats")); for (int i = 0; i < floatVariables.GetValue().AsArray().size; i++) { string name = floatVariables.Get(i).Get("name").GetValue().AsString(); string value = floatVariables.Get(i).Get("value").GetValue().AsFloat().ToString(); variableList.Children.Add(CreateSidebarRow(name, value)); } variableList.Children.Add(CreateSidebarHeader("Ints")); for (int i = 0; i < intVariables.GetValue().AsArray().size; i++) { string name = intVariables.Get(i).Get("name").GetValue().AsString(); string value = intVariables.Get(i).Get("value").GetValue().AsInt().ToString(); variableList.Children.Add(CreateSidebarRow(name, value)); } variableList.Children.Add(CreateSidebarHeader("Bools")); for (int i = 0; i < boolVariables.GetValue().AsArray().size; i++) { string name = boolVariables.Get(i).Get("name").GetValue().AsString(); string value = boolVariables.Get(i).Get("value").GetValue().AsBool().ToString().ToLower(); variableList.Children.Add(CreateSidebarRow(name, value)); } variableList.Children.Add(CreateSidebarHeader("Strings")); for (int i = 0; i < stringVariables.GetValue().AsArray().size; i++) { string name = stringVariables.Get(i).Get("name").GetValue().AsString(); string value = stringVariables.Get(i).Get("value").GetValue().AsString(); variableList.Children.Add(CreateSidebarRow(name, value)); } variableList.Children.Add(CreateSidebarHeader("Vector2s")); for (int i = 0; i < vector2Variables.GetValue().AsArray().size; i++) { string name = vector2Variables.Get(i).Get("name").GetValue().AsString(); AssetTypeValueField vector2 = vector2Variables.Get(i).Get("value"); string value = vector2.Get("x").GetValue().AsFloat().ToString() + ", "; value += vector2.Get("y").GetValue().AsFloat().ToString(); variableList.Children.Add(CreateSidebarRow(name, value)); } variableList.Children.Add(CreateSidebarHeader("Vector3s")); for (int i = 0; i < vector3Variables.GetValue().AsArray().size; i++) { string name = vector3Variables.Get(i).Get("name").GetValue().AsString(); AssetTypeValueField vector3 = vector3Variables.Get(i).Get("value"); string value = vector3.Get("x").GetValue().AsFloat().ToString() + ", "; value += vector3.Get("x").GetValue().AsFloat().ToString() + ", "; value += vector3.Get("z").GetValue().AsFloat().ToString(); variableList.Children.Add(CreateSidebarRow(name, value)); } variableList.Children.Add(CreateSidebarHeader("Colors")); for (int i = 0; i < colorVariables.GetValue().AsArray().size; i++) { string name = colorVariables.Get(i).Get("name").GetValue().AsString(); AssetTypeValueField color = colorVariables.Get(i).Get("value"); string value = ((int)color.Get("r").GetValue().AsFloat() * 255).ToString("X2"); value += ((int)color.Get("g").GetValue().AsFloat() * 255).ToString("X2"); value += ((int)color.Get("b").GetValue().AsFloat() * 255).ToString("X2"); value += ((int)color.Get("a").GetValue().AsFloat() * 255).ToString("X2"); Grid sidebarRow = CreateSidebarRow(name, value); TextBox textBox = sidebarRow.Children.OfType <TextBox>().FirstOrDefault(); textBox.BorderBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#" + value)); variableList.Children.Add(sidebarRow); } variableList.Children.Add(CreateSidebarHeader("Rects")); for (int i = 0; i < rectVariables.GetValue().AsArray().size; i++) { string name = rectVariables.Get(i).Get("name").GetValue().AsString(); AssetTypeValueField rect = rectVariables.Get(i).Get("value"); string value = rect.Get("x").GetValue().AsFloat().ToString() + ", "; value += rect.Get("y").GetValue().AsFloat().ToString() + ", "; value += rect.Get("width").GetValue().AsFloat().ToString() + ", "; value += rect.Get("height").GetValue().AsFloat().ToString(); variableList.Children.Add(CreateSidebarRow(name, value)); } variableList.Children.Add(CreateSidebarHeader("Quaternions")); for (int i = 0; i < quaternionVariables.GetValue().AsArray().size; i++) { string name = quaternionVariables.Get(i).Get("name").GetValue().AsString(); AssetTypeValueField rect = quaternionVariables.Get(i).Get("value"); string value = rect.Get("x").GetValue().AsFloat().ToString() + ", "; value += rect.Get("y").GetValue().AsFloat().ToString() + ", "; value += rect.Get("z").GetValue().AsFloat().ToString() + ", "; value += rect.Get("w").GetValue().AsFloat().ToString(); variableList.Children.Add(CreateSidebarRow(name, value)); } variableList.Children.Add(CreateSidebarHeader("GameObjects")); for (int i = 0; i < gameObjectVariables.GetValue().AsArray().size; i++) { string name = gameObjectVariables.Get(i).Get("name").GetValue().AsString(); AssetTypeValueField gameObject = gameObjectVariables.Get(i).Get("value"); int m_FileID = gameObject.Get("m_FileID").GetValue().AsInt(); long m_PathID = gameObject.Get("m_PathID").GetValue().AsInt64(); string value; if (m_PathID != 0) { value = $"[{m_FileID},{m_PathID}]"; } else { value = ""; } variableList.Children.Add(CreateSidebarRow(name, value)); } currentTab++; tabs.Add(new FSMInstance() { matrix = mt.Matrix, nodes = nodes, dataVersion = dataVersion, graphElements = CopyChildrenToList(graphCanvas), states = CopyChildrenToList(stateList), events = CopyChildrenToList(eventList), variables = CopyChildrenToList(variableList) }); }
public RectTransform(AssetsFile assetsFile) : base(assetsFile, AssetsConstants.ClassID.RectTransformClassID) { }