Exemple #1
0
        private AudioClipAssetData CreateAudioAsset(Apk apk, string levelID)
        {
            string audioClipFile  = Path.Combine(levelFolderPath, _songFilename);
            string sourceFileName = levelID + ".ogg";

            if (apk != null)
            {
                apk.CopyFileInto(audioClipFile, $"assets/bin/Data/{sourceFileName}");
            }
            ulong fileSize = (ulong)new FileInfo(audioClipFile).Length;

            NVorbis.VorbisReader v = new NVorbis.VorbisReader(audioClipFile);
            return(new AudioClipAssetData()
            {
                name = levelID,
                loadType = 1,
                channels = v.Channels,
                frequency = v.SampleRate,
                bitsPerSample = 16,
                length = (Single)v.TotalTime.TotalSeconds,
                isTracker = false,
                subsoundIndex = 0,
                preloadAudio = false,
                backgroundLoad = true,
                legacy3D = true,
                compressionFormat = 1, // vorbis
                source = sourceFileName,
                offset = 0,
                size = fileSize,
            });
        }
Exemple #2
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 #3
0
 public void ApplyTo(Apk apk)
 {
     foreach (var copy in copies)
     {
         apk.CopyFileInto(copy.Item1, copy.Item2);
     }
     foreach (string item in deletions)
     {
         apk.RemoveFileAt(item);
     }
 }