Exemple #1
0
        public AssetPtr AddToAssets(SerializedAssets assets, Apk apk)
        {
            // var watch = System.Diagnostics.Stopwatch.StartNew();
            string             levelID      = LevelID();
            AudioClipAssetData audioClip    = CreateAudioAsset(apk, levelID);
            AssetPtr           audioClipPtr = assets.AppendAsset(audioClip);

            AssetPtr environment = new AssetPtr(20, 1); // default environment

            switch (_environmentName)
            {
            case "NiceEnvironment":
                environment = new AssetPtr(38, 3);
                break;

            case "TriangleEnvironment":
                environment = new AssetPtr(0, 252);
                break;

            case "BigMirrorEnvironment":
                environment = new AssetPtr(0, 249);
                break;
            }

            LevelBehaviorData level = new LevelBehaviorData()
            {
                levelID          = levelID,
                songName         = _songName,
                songSubName      = _songSubName,
                songAuthorName   = _songAuthorName,
                levelAuthorName  = _levelAuthorName,
                beatsPerMinute   = _beatsPerMinute,
                songTimeOffset   = _songTimeOffset,
                shuffle          = _shuffle,
                shufflePeriod    = _shufflePeriod,
                previewStartTime = _previewStartTime,
                previewDuration  = _previewDuration,

                audioClip = audioClipPtr,
                // TODO currently $100 bills only valid in sharedassets17
                coverImage  = new AssetPtr(0, 18),
                environment = environment,

                difficultyBeatmapSets = _difficultyBeatmapSets.Select(s => s.ToAssets(assets, levelFolderPath, levelID)).Where(s => s != null).ToList(),
            };

            MonoBehaviorAssetData monob = new MonoBehaviorAssetData()
            {
                script = new AssetPtr(1, LevelBehaviorData.PathID),
                name   = level.levelID + "Level",
                data   = level,
            };

            // watch.Stop();
            // Console.WriteLine("song: " + watch.ElapsedMilliseconds);

            return(assets.AppendAsset(monob));
        }
Exemple #2
0
 public void ApplyTo(SerializedAssets assets)
 {
     Debug.Assert((ulong)(assets.objects.Count + toAdd.Count) == lastPathID, "Can't add anything while transaction is live");
     foreach (AssetData obj in toAdd)
     {
         assets.AppendAsset(obj);
     }
 }
Exemple #3
0
        public BeatmapDifficulty ToAssets(
            SerializedAssets assets,
            string levelFolderPath,
            string levelID,
            Characteristic characteristic
            )
        {
            string          beatmapFile = Path.Combine(levelFolderPath, _beatmapFilename);
            string          jsonData    = File.ReadAllText(beatmapFile);
            BeatmapSaveData saveData    = JsonConvert.DeserializeObject <BeatmapSaveData>(jsonData);

            byte[] projectedData = saveData.SerializeToBinary();

            BeatmapDataBehaviorData beatmapData = new BeatmapDataBehaviorData()
            {
                jsonData      = "",
                signature     = new byte[128], // all zeros
                projectedData = projectedData,
            };
            string characteristicPart   = ((characteristic == Characteristic.Standard) ? "" : characteristic.ToString());
            string assetName            = levelID + characteristicPart + _difficulty.ToString() + "BeatmapData";
            MonoBehaviorAssetData monob = new MonoBehaviorAssetData()
            {
                script = new AssetPtr(1, BeatmapDataBehaviorData.PathID),
                name   = assetName,
                data   = beatmapData,
            };
            AssetPtr assetPtr = assets.AppendAsset(monob);

            return(new BeatmapDifficulty()
            {
                difficulty = (int)_difficulty,
                difficultyRank = _difficultyRank,
                noteJumpMovementSpeed = _noteJumpMovementSpeed,
                noteJumpStartBeatOffset = _noteJumpStartBeatOffset,
                beatmapData = assetPtr,
            });
        }