(19307be45) Implement random wearable variants. Should be synced with the server by using the same random seed. Add a console command "loadwearable" as a development feature (could also be used by modders) to enforce a certain variant. Refresh wearable sprite paths when the items are reloaded.

This commit is contained in:
Joonas Rikkonen
2019-04-16 17:09:56 +03:00
parent 9ec8659c89
commit 30a3203051
3 changed files with 98 additions and 33 deletions
@@ -87,7 +87,6 @@ namespace Barotrauma
public string FullPath { get; private set; }
public override string ToString()
{
return FilePath + ": " + sourceRect;
@@ -107,25 +106,7 @@ namespace Barotrauma
{
this.lazyLoad = lazyLoad;
SourceElement = element;
if (file == "")
{
file = SourceElement.GetAttributeString("texture", "");
}
if (file == "")
{
DebugConsole.ThrowError("Sprite " + SourceElement + " doesn't have a texture specified!");
return;
}
if (!string.IsNullOrEmpty(path))
{
if (!path.EndsWith("/")) path += "/";
}
FilePath = path + file;
if (!string.IsNullOrEmpty(FilePath))
{
FullPath = Path.GetFullPath(FilePath);
}
if (!ParseTexturePath(path, file)) { return; }
Name = SourceElement.GetAttributeString("name", null);
Vector4 sourceVector = SourceElement.GetAttributeVector4("sourcerect", Vector4.Zero);
preMultipliedAlpha = preMultiplyAlpha ?? SourceElement.GetAttributeBool("premultiplyalpha", true);
@@ -269,6 +250,29 @@ namespace Barotrauma
ID = GetID(SourceElement);
}
}
public bool ParseTexturePath(string path = "", string file = "")
{
if (file == "")
{
file = SourceElement.GetAttributeString("texture", "");
}
if (file == "")
{
DebugConsole.ThrowError("Sprite " + SourceElement + " doesn't have a texture specified!");
return false;
}
if (!string.IsNullOrEmpty(path))
{
if (!path.EndsWith("/")) path += "/";
}
FilePath = path + file;
if (!string.IsNullOrEmpty(FilePath))
{
FullPath = Path.GetFullPath(FilePath);
}
return true;
}
}
}