// This method will fail if given an object that is not a LevelBehaviorData public static void RemoveLevel(SerializedAssets assets, SerializedAssets.AssetObject obj, Apk.Transaction apk) { LevelBehaviorData level = (obj.data as MonoBehaviorAssetData).data as LevelBehaviorData; // Remove audio file foreach (string s in level.OwnedFiles(assets)) { apk.RemoveFileAt($"assets/bin/Data/{s}"); } // Remove things from bottom up, so that pointers to other assets still are rooted // and so get fixed up by RemoveAssetAt foreach (BeatmapSet s in level.difficultyBeatmapSets) { foreach (BeatmapDifficulty d in s.difficultyBeatmaps) { assets.RemoveAssetAt(d.beatmapData.pathID); } } assets.RemoveAssetAt(level.coverImage.pathID); assets.RemoveAssetAt(level.audioClip.pathID); assets.RemoveAssetAt(obj.pathID); }
public static ulong RemoveLevel(SerializedAssets assets, LevelBehaviorData level) { // We want to find the level object in the assets list of objects so that we can remove it via PathID. // Well, this is quite a messy solution... But it _should work_... // What this is doing: Removing the asset that is a monobehavior, and the monobehavior's data equals this level. // Then it casts that to a level behavior data. // TODO Make this work with Transactions instead of an assets object. // Also remove difficulty beatmaps foreach (BeatmapSet s in level.difficultyBeatmapSets) { foreach (BeatmapDifficulty d in s.difficultyBeatmaps) { assets.RemoveAssetAt(d.beatmapData.pathID); } } // Remove cover image assets.RemoveAssetAt(level.coverImage.pathID); // Remove the file for the audio asset and the audio clip var audioAsset = assets.RemoveAssetAt(level.audioClip.pathID).data as AudioClipAssetData; if (audioAsset == null) { throw new ApplicationException($"Could not find audio asset at PathID: {level.audioClip.pathID}"); } // Remove itself! ulong levelPathID = assets.RemoveAsset(ao => ao.data.GetType().Equals(typeof(MonoBehaviorAssetData)) && (ao.data as MonoBehaviorAssetData).name == level.levelID + "Level").pathID; return(levelPathID); }
public static void ResetColors(SerializedAssets assets) { ColorManager manager = assets.FindScript <ColorManager>(cm => true); // Should only have one color manager if (manager.colorA.pathID != 54) { Console.WriteLine($"Removing CustomColor at PathID: {manager.colorA.pathID}"); assets.RemoveAssetAt(manager.colorA.pathID); manager.colorA.pathID = 54; } if (manager.colorB.pathID != 53) { Console.WriteLine($"Removing CustomColor at PathID: {manager.colorB.pathID}"); assets.RemoveAssetAt(manager.colorB.pathID); manager.colorB.pathID = 53; } }
public static ColorManager CreateColor(SerializedAssets assets, SimpleColor c) { Console.WriteLine($"Creating CustomColor with r: {c.r} g: {c.g} b: {c.b} a: {c.a}"); var dat = assets.FindScript <ColorManager>(cm => true); // Should only have one color manager //var dat = ((MonoBehaviorAssetData)assets.GetAssetAt(52).data).data as ColorManager; if (dat.colorA.pathID != 54) { Console.WriteLine($"Removed existing CustomColor at PathID: {dat.colorA.pathID}"); assets.RemoveAssetAt(dat.colorA.pathID); } if (dat.colorB.pathID != 53) { Console.WriteLine($"Removing existing CustomColor at PathID: {dat.colorB.pathID}"); assets.RemoveAssetAt(dat.colorB.pathID); } return(dat); }