-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModContent.cs
More file actions
39 lines (33 loc) · 1.15 KB
/
ModContent.cs
File metadata and controls
39 lines (33 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Terraria;
using Terraria.ModLoader;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Terraria.ModLoader.Exceptions;
using System.IO;
namespace CustomNPCNames
{
class ModContent
{
public static void SplitName(string name, out string domain, out string subName)
{
int slash = name.IndexOf('/');
if (slash < 0)
throw new MissingResourceException("Missing mod qualifier: " + name);
domain = name.Substring(0, slash);
subName = name.Substring(slash + 1);
}
public static Texture2D GetTexture(string name)
{
if (Main.dedServ)
return null;
string modName, subName;
SplitName(name, out modName, out subName);
if (modName == "Terraria")
return Main.instance.Content.Load<Texture2D>("Images" + Path.DirectorySeparatorChar + subName);
Mod mod = ModLoader.GetMod(modName);
if (mod == null)
throw new MissingResourceException("Missing mod: " + name);
return mod.GetTexture(subName);
}
}
}