(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:
@@ -1519,7 +1519,7 @@ namespace Barotrauma
|
||||
character.AnimController.ResetRagdoll();
|
||||
}, isCheat: true));
|
||||
|
||||
commands.Add(new Command("reloadwearables|reloadlimbs", "Reloads the sprites of all limbs and wearable sprites (clothing) of the controlled character. Provide id or name if you want to target another character.", args =>
|
||||
commands.Add(new Command("reloadwearables", "Reloads the sprites of all limbs and wearable sprites (clothing) of the controlled character. Provide id or name if you want to target another character.", args =>
|
||||
{
|
||||
var character = (args.Length == 0) ? Character.Controlled : FindMatchingCharacter(args, true);
|
||||
if (character == null)
|
||||
@@ -1530,6 +1530,26 @@ namespace Barotrauma
|
||||
ReloadWearables(character);
|
||||
}, isCheat: true));
|
||||
|
||||
commands.Add(new Command("loadwearable", "Force select certain variant for the selected character.", args =>
|
||||
{
|
||||
var character = Character.Controlled;
|
||||
if (character == null)
|
||||
{
|
||||
ThrowError("Not controlling any character.");
|
||||
return;
|
||||
}
|
||||
if (args.Length == 0)
|
||||
{
|
||||
ThrowError("No arguments provided! Give an index number for the variant starting from 1.");
|
||||
return;
|
||||
}
|
||||
if (int.TryParse(args[0], out int variant))
|
||||
{
|
||||
ReloadWearables(character, variant);
|
||||
}
|
||||
|
||||
}, isCheat: true));
|
||||
|
||||
commands.Add(new Command("reloadsprite|reloadsprites", "Reloads the sprites of the selected item(s)/structure(s) (hovering over or selecting in the subeditor) or the controlled character. Can also reload sprites by entity id or by the name attribute (sprite element). Example 1: reloadsprite id itemid. Example 2: reloadsprite name \"Sprite name\"", args =>
|
||||
{
|
||||
if (Screen.Selected is SpriteEditorScreen)
|
||||
@@ -1677,7 +1697,7 @@ namespace Barotrauma
|
||||
}, isCheat: true));
|
||||
}
|
||||
|
||||
private static void ReloadWearables(Character character)
|
||||
private static void ReloadWearables(Character character, int variant = 0)
|
||||
{
|
||||
foreach (var limb in character.AnimController.Limbs)
|
||||
{
|
||||
@@ -1686,11 +1706,17 @@ namespace Barotrauma
|
||||
limb.DeformSprite?.Sprite.ReloadTexture();
|
||||
foreach (var wearable in limb.WearingItems)
|
||||
{
|
||||
if (variant > 0 && wearable.Variant > 0)
|
||||
{
|
||||
wearable.Variant = variant;
|
||||
}
|
||||
wearable.RefreshPath();
|
||||
wearable.Sprite.ReloadXML();
|
||||
wearable.Sprite.ReloadTexture();
|
||||
}
|
||||
foreach (var wearable in limb.OtherWearables)
|
||||
{
|
||||
wearable.RefreshPath();
|
||||
wearable.Sprite.ReloadXML();
|
||||
wearable.Sprite.ReloadTexture();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user