예제 #1
0
        private void LoadContentPackData(ContentPackModel contentPackData)
        {
            List <int> reservedIDs = GetPackDataReservedIDs(contentPackData.packName);
            int        nextIndex   = GetNextDataIndex(0, contentPackData.packName, reservedIDs);

            foreach (string[] animalAndEggData in contentPackData.animalAndEggData)
            {
                if (!(animalAndEggData[2] == "" || animalAndEggData[3] == ""))
                {
                    modData.customEggsAndHatchedAnimals.Add(nextIndex, new List <string>()
                    {
                        animalAndEggData[0], animalAndEggData[1], animalAndEggData[2], animalAndEggData[3], animalAndEggData[4], animalAndEggData[8], animalAndEggData[9], animalAndEggData[10], contentPackData.packName
                    });
                    nextIndex = GetNextDataIndex(nextIndex, contentPackData.packName, reservedIDs);
                }
                if (!(animalAndEggData[4] == "" || animalAndEggData[5] == ""))
                {
                    modData.customEggsAndHatchedAnimals.Add(nextIndex, new List <string>()
                    {
                        animalAndEggData[0], animalAndEggData[1], animalAndEggData[5], animalAndEggData[6], animalAndEggData[7], animalAndEggData[8], animalAndEggData[9], animalAndEggData[10], contentPackData.packName
                    });
                    nextIndex = GetNextDataIndex(nextIndex, contentPackData.packName, reservedIDs);
                }
            }
            modData.packsLoaded.Add(contentPackData.packName, contentPackData.packVersion);
            if (modData.packsUnloaded.ContainsKey(contentPackData.packName))
            {
                modData.packsUnloaded.Remove(contentPackData.packName);
            }
        }
예제 #2
0
        private void ImportSounds(ContentPackModel contentPackData, IContentPack contentPack)
        {
            string soundsFolderPath = System.IO.Path.Combine("assets", "sounds");

            foreach (string soundName in contentPackData.soundEffects)
            {
                List <SoundEffectInstance> sfx = new List <SoundEffectInstance>();
                string soundDirectory;
                if (contentPack != null)
                {
                    soundDirectory = System.IO.Path.Combine(contentPack.DirectoryPath, soundsFolderPath);
                }
                else
                {
                    soundDirectory = System.IO.Path.Combine(smapiHelper.DirectoryPath, soundsFolderPath);
                }
                if (System.IO.Directory.Exists(soundDirectory))
                {
                    foreach (string soundPath in System.IO.Directory.GetFiles(soundDirectory, soundName + "*.wav"))
                    {
                        sfx.Add(MakeSoundEffect(soundPath));
                    }
                }
                soundEffects.Add(soundName, sfx);
            }
        }
예제 #3
0
 private void ProcessContentPackData(ContentPackModel contentPackData, IContentPack contentPack)
 {
     if (contentPackData != null && contentPackData.packName != "")
     {
         ImportSounds(contentPackData, contentPack);
         if (contentPack != null && !contentPackNames.ContainsKey(contentPackData.packName))
         {
             contentPackNames.Add(contentPackData.packName, contentPack);
         }
         if (!modData.packsLoaded.ContainsKey(contentPackData.packName))
         {
             LoadContentPackData(contentPackData);
         }
         else if (contentPackData.packVersion != modData.packsLoaded[contentPackData.packName])
         {
             UnloadContentPackData(contentPackData.packName);
             LoadContentPackData(contentPackData);
         }
     }
 }
예제 #4
0
        private void LoadContentPacks()
        {
            List <string> packsNotLoaded = new List <string>(modData.packsLoaded.Keys);

            ContentPackModel contentPackData = smapiHelper.Data.ReadJsonFile <ContentPackModel>(contentFileName);

            ProcessContentPackData(contentPackData, null);
            packsNotLoaded.Remove("Chickens Pack");

            foreach (IContentPack contentPack in smapiHelper.ContentPacks.GetOwned())
            {
                contentPackData = contentPack.ReadJsonFile <ContentPackModel>(contentFileName);
                ProcessContentPackData(contentPackData, contentPack);
                packsNotLoaded.Remove(contentPackData.packName);
            }

            foreach (string packNotLoaded in packsNotLoaded)
            {
                UnloadContentPackData(packNotLoaded);
            }
            unloadedEggIDs = GetPackDataReservedIDs("");
            SaveModData();
        }