/// <summary> /// Returns whether or not a texture with the specified name exists. texture will be populated with null if not found, and the texture if found. /// </summary> /// <param name="name">The texture name that is requested</param> /// <param name="texture">The texture itself will be output to this</param> /// <returns>True if the texture is found, false otherwise.</returns> internal static bool TryGetTexture(string name, out Asset <Texture2D> texture) { texture = null; if (Main.dedServ || !TextureExists(name)) { return(false); } SplitName(name, out string modName, out string subName); if (modName == "Terraria") { if ((Main.instance.Content as TMLContentManager).ImageExists(subName)) { texture = Main.Assets.Request <Texture2D>(Path.Combine("Images", subName)); return(true); } return(false); } Mod mod = ModLoader.GetMod(modName); if (mod != null && mod.TextureExists(subName)) { texture = mod.GetTexture(subName); return(true); } return(false); }
/// <summary> /// Returns whether or not a texture with the specified name exists. /// </summary> public static bool TextureExists(string name) { if (Main.dedServ || string.IsNullOrWhiteSpace(name) || !name.Contains('/')) { return(false); } SplitName(name, out string modName, out string subName); if (modName == "Terraria") { return((Main.instance.Content as TMLContentManager).ImageExists(subName)); } Mod mod = ModLoader.GetMod(modName); return(mod != null && mod.TextureExists(subName)); }
/// <summary> /// Returns whether or not a texture with the specified name exists. /// </summary> public static bool TextureExists(string name) { if (!name.Contains('/')) { return(false); } string modName, subName; SplitName(name, out modName, out subName); if (modName == "Terraria") { return(File.Exists(ImagePath + Path.DirectorySeparatorChar + name + ".xnb")); } Mod mod = GetMod(modName); return(mod != null && mod.TextureExists(subName)); }
/// <summary> /// Returns whether or not a texture with the specified name exists. /// </summary> public static bool TextureExists(string name) { if (!name.Contains('/')) { return(false); } string modName, subName; SplitName(name, out modName, out subName); if (modName == "Terraria") { return(!Main.dedServ && (Main.instance.Content as TMLContentManager).ImageExists(subName)); } Mod mod = ModLoader.GetMod(modName); return(mod != null && mod.TextureExists(subName)); }