Seriosk
Programmer;
- Oct 29, 2016
- 256
- 105
Hello. I have seen many RP emulators released with different types of approaches to this situation, some use the same, some go a totally different way and try and make it some complex function that's rammed with loops.
Today I am releasing a simple function that will convert figure codes into uniform. You can ask yourself, "but why"? isn't there many released already.. yes, but these ones I have found to be inconsistent, some even require you to only specifically include the parts you want to be applied to the main figure and none else, with this function you can actually pass a string list, or just let it replace every part in the figure code.
Hopefully its easy enough for you all to use, and hopefully it teaches a few people something...
I'm not saying every single one of these SplitFigure methods are horrible because I have actually seen some really nice ones on various emulators, but hopefully this one helps a lot of people..
Not saying its perfect, but its worked perfectly fine in any situation when using it in various projects.
Whats better about this one than others?
Its not going to break when you enter a wrong formatted figure code, but no.. in all seriousness its just easily customizable to work with what ever you need it for really.
What if I need to get certain parts from a full figure?
I've had a few ask this because they plan on just throwing a full figure and using it for the uniform, I'll code a method for this once I have finished posting this that will allow you to pick the parts you want out of a full figure, usually people just want the chest and legs though, the default layout for a uniform, sometimes shoes..
Usage:
The figure codes above aren't valid figure codes (I don't think) I didn't really have a spare database with figure codes in around so I just typed the part and random colors etc, anyway... have fun with this.
Main Code:
Today I am releasing a simple function that will convert figure codes into uniform. You can ask yourself, "but why"? isn't there many released already.. yes, but these ones I have found to be inconsistent, some even require you to only specifically include the parts you want to be applied to the main figure and none else, with this function you can actually pass a string list, or just let it replace every part in the figure code.
Hopefully its easy enough for you all to use, and hopefully it teaches a few people something...
I'm not saying every single one of these SplitFigure methods are horrible because I have actually seen some really nice ones on various emulators, but hopefully this one helps a lot of people..
Not saying its perfect, but its worked perfectly fine in any situation when using it in various projects.
Whats better about this one than others?
Its not going to break when you enter a wrong formatted figure code, but no.. in all seriousness its just easily customizable to work with what ever you need it for really.
What if I need to get certain parts from a full figure?
I've had a few ask this because they plan on just throwing a full figure and using it for the uniform, I'll code a method for this once I have finished posting this that will allow you to pick the parts you want out of a full figure, usually people just want the chest and legs though, the default layout for a uniform, sometimes shoes..
Usage:
Code:
// Replacing legs, shoes and chest...
ReturnUniform("lg-285-76.ch-293-29.sh-392-34", "hd-629-1390.hr-515-31.sh-3035-73.ch-650-80.lg-715-80.", "lg,sh,ch");
// Replacing legs and chest...
ReturnUniform("lg-285-76.ch-293-29.sh-392-34", "hd-629-1390.hr-515-31.sh-3035-73.ch-650-80.lg-715-80.", "lg,ch");
// Replacing everything...
ReturnUniform("lg-285-76.ch-293-29.sh-392-34", "hd-629-1390.hr-515-31.sh-3035-73.ch-650-80.lg-715-80.");
The figure codes above aren't valid figure codes (I don't think) I didn't really have a spare database with figure codes in around so I just typed the part and random colors etc, anyway... have fun with this.
Main Code:
Code:
public static string ReturnUniform(string uniform, string figure, string replaceParts = "")
{
List<string> uniformParts = uniform.Split('.').ToList();
List<string> figureParts = figure.Split('.').ToList();
List<string> partsToReplace = replaceParts.Split(',').ToList();
foreach (string uniformPart in uniformParts)
{
string[] parts = uniformPart.Split('-');
string part = parts[0];
if (partsToReplace.Any() && !partsToReplace.Contains(part))
{
continue;
}
if (figure.Contains(part + "-"))
{
var indexOfItem = figureParts.ToList().FindIndex(value => value.StartsWith(part));
figureParts[indexOfItem] = uniformPart;
}
else
{
figureParts.Add(uniformPart);
}
}
return string.Join(".", figureParts);
}