public CustomSet(IContentPack pack, bool addToCatalogue = true, bool injectTileSheets = true)
        {
            Walls  = pack.HasFile("walls.png") ? pack.LoadAsset <Texture2D>("walls.png") : null;
            Floors = pack.HasFile("floors.png") ? pack.LoadAsset <Texture2D>("floors.png") : null;

            if (pack.HasFile("settings.json"))
            {
                Settings = pack.LoadAsset <Settings>("settings.json");
            }

            Pack = pack;

            if (addToCatalogue)
            {
                AddToCatalogue();
            }

            if (injectTileSheets)
            {
                InjectTileSheets();
            }
        }
Beispiel #2
0
        private Content LoadContentPack(IContentPack contentPack)
        {
            if (!contentPack.HasFile("quests.json"))
            {
                this.Monitor.Log($"Content pack `{contentPack.Manifest.Name}` has no entry file `quests.json`", LogLevel.Error);
                return(null);
            }

            var content = contentPack.ReadJsonFile <Content>("quests.json");

            content.Owner = contentPack;
            this.Prepare(content);

            return(content);
        }
Beispiel #3
0
        /// <summary>Verify the given folder contains all the required files to be loaded.</summary>
        /// <param name="contentPack">The content pack that contains the outerwear to check.</param>
        /// <param name="outerwearFolderName">The outerwear folder to check contains the required files.</param>
        /// <returns>Whether the outerwear folder contains all the required files.</returns>
        private bool VerifyContentPackFilesExist(IContentPack contentPack, string outerwearFolderName)
        {
            bool allFilesExist = true;

            if (!contentPack.HasFile(Path.Combine(outerwearFolderName, "content.json")))
            {
                this.Monitor.Log($"'content.json' file couldn't be found in content pack: {contentPack.Manifest.Name}", LogLevel.Error);
                allFilesExist = false;
            }

            if (!contentPack.HasFile(Path.Combine(outerwearFolderName, "menuicon.png")))
            {
                this.Monitor.Log($"'menuicon.png' couldn't be found in content pack: {contentPack.Manifest.Name}", LogLevel.Error);
                allFilesExist = false;
            }

            if (!contentPack.HasFile(Path.Combine(outerwearFolderName, "equippedtexture.png")))
            {
                this.Monitor.Log($"'equippedtexture.png' couldn't be found in content pack: {contentPack.Manifest.Name}", LogLevel.Error);
                allFilesExist = false;
            }

            return(allFilesExist);
        }
Beispiel #4
0
        private Texture2D LoadTexture(IContentPack pack, string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(null);
            }

            try
            {
                if (pack.HasFile(path))
                {
                    return(pack.LoadAsset <Texture2D>(path));
                }

                return(Game1.content.Load <Texture2D>(path));
            }
            catch (ContentLoadException ex)
            {
                this.Monitor.Log($"({pack.Manifest.UniqueID}) Cannot load texture `{path}`: {ex.Message}");

                return(null);
            }
        }