Untested support for multiple languages when spawning NPCs/Prefixes/Items
This commit is contained in:
parent
43d0ff72cf
commit
55d7b78971
3 changed files with 86 additions and 5 deletions
|
|
@ -48,5 +48,5 @@ using System.Runtime.InteropServices;
|
||||||
// Build Number
|
// Build Number
|
||||||
// MMdd of the build
|
// MMdd of the build
|
||||||
|
|
||||||
[assembly: AssemblyVersion("3.4.5.0118")]
|
[assembly: AssemblyVersion("3.4.5.0119")]
|
||||||
[assembly: AssemblyFileVersion("3.4.5.0118")]
|
[assembly: AssemblyFileVersion("3.4.5.0119")]
|
||||||
|
|
|
||||||
|
|
@ -233,7 +233,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
return new List<Item> {GetItemById(type)};
|
return new List<Item> {GetItemById(type)};
|
||||||
}
|
}
|
||||||
return GetItemByName(idOrName);
|
return GetItemByMultiLingualName(idOrName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item GetItemById(int id)
|
public Item GetItemById(int id)
|
||||||
|
|
@ -273,6 +273,33 @@ namespace TShockAPI
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Item> GetItemByName(string name, int language)
|
||||||
|
{
|
||||||
|
var orilang = Lang.lang;
|
||||||
|
Lang.lang = language;
|
||||||
|
var list = new List<Item>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
list = GetItemByName(name);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Lang.lang = orilang;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Item> GetItemByMultiLingualName(string name)
|
||||||
|
{
|
||||||
|
var list = new List<Item>();
|
||||||
|
for (var i = 1; i < 6; i++)
|
||||||
|
list.AddRange(GetItemByName(name, i));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
public List<NPC> GetNPCByIdOrName(string idOrName)
|
public List<NPC> GetNPCByIdOrName(string idOrName)
|
||||||
{
|
{
|
||||||
int type = -1;
|
int type = -1;
|
||||||
|
|
@ -280,7 +307,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
return new List<NPC> {GetNPCById(type)};
|
return new List<NPC> {GetNPCById(type)};
|
||||||
}
|
}
|
||||||
return GetNPCByName(idOrName);
|
return GetNPCByMultiLingualName(idOrName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public NPC GetNPCById(int id)
|
public NPC GetNPCById(int id)
|
||||||
|
|
@ -314,6 +341,33 @@ namespace TShockAPI
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<NPC> GetNPCByName(string name, int language)
|
||||||
|
{
|
||||||
|
var orilang = Lang.lang;
|
||||||
|
Lang.lang = language;
|
||||||
|
var list = new List<NPC>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
list = GetNPCByName(name);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Lang.lang = orilang;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<NPC> GetNPCByMultiLingualName(string name)
|
||||||
|
{
|
||||||
|
var list = new List<NPC>();
|
||||||
|
for (var i = 1; i < 6; i++)
|
||||||
|
list.AddRange(GetNPCByName(name, i));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
public string GetBuffName(int id)
|
public string GetBuffName(int id)
|
||||||
{
|
{
|
||||||
return (id > 0 && id < Main.maxBuffs) ? Main.buffName[id] : "null";
|
return (id > 0 && id < Main.maxBuffs) ? Main.buffName[id] : "null";
|
||||||
|
|
@ -377,6 +431,33 @@ namespace TShockAPI
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<int> GetPrefixByName(string name, int language)
|
||||||
|
{
|
||||||
|
var orilang = Lang.lang;
|
||||||
|
Lang.lang = language;
|
||||||
|
var list = new List<int>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
list = GetPrefixByName(name);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Lang.lang = orilang;
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<int> GetPrefixByMultiLingualName(string name)
|
||||||
|
{
|
||||||
|
var list = new List<int>();
|
||||||
|
for (var i = 1; i < 6; i++)
|
||||||
|
list.AddRange(GetPrefixByName(name, i));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
public List<int> GetPrefixByIdOrName(string idOrName)
|
public List<int> GetPrefixByIdOrName(string idOrName)
|
||||||
{
|
{
|
||||||
int type = -1;
|
int type = -1;
|
||||||
|
|
@ -384,7 +465,7 @@ namespace TShockAPI
|
||||||
{
|
{
|
||||||
return new List<int> {type};
|
return new List<int> {type};
|
||||||
}
|
}
|
||||||
return GetPrefixByName(idOrName);
|
return GetPrefixByMultiLingualName(idOrName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue