Example #1
0
 public bool Exists(ModManifest mod)
 {
     if (IsXnb)
     {
         return(System.IO.File.Exists(AbsoluteFilePath + ".xnb"));
     }
     if (IsTexture)
     {
         return(TextureRegistry.GetItem(Texture, mod) != null);
     }
     return(false);
 }
Example #2
0
        public void LoadContent(ModManifest mod)
        {
            Logging.Log.Verbose("Loading Content");
            if (Textures != null)
            {
                foreach (var texture in Textures)
                {
                    texture.AbsoluteFilePath = $"{mod.ModDirectory}\\{Constants.ModContentDirectory}\\{texture.File}";

                    if (!texture.Exists())
                    {
                        throw new Exception($"Missing Texture: {texture.AbsoluteFilePath}");
                    }

                    Logging.Log.Verbose($"Registering new texture: {texture.Id}");
                    TextureRegistry.RegisterItem(texture.Id, texture, mod);
                }
            }

            if (Xnb == null)
            {
                return;
            }

            foreach (var file in Xnb)
            {
                if (file.IsXnb)
                {
                    file.AbsoluteFilePath = $"{mod.ModDirectory}\\{Constants.ModContentDirectory}\\{file.File}";
                }
                file.OwningMod = mod;
                if (!file.Exists(mod))
                {
                    if (file.IsXnb)
                    {
                        throw new Exception($"Replacement File: {file.AbsoluteFilePath}");
                    }
                    if (file.IsTexture)
                    {
                        throw new Exception($"Replacement Texture: {file.Texture}");
                    }
                }
                Logging.Log.Verbose("Registering new texture XNB override");
                XnbRegistry.RegisterItem(file.Original, file);
            }
        }