Created
April 3, 2021 07:00
-
-
Save lmcintyre/f80a44b3e308135638fc6955e93e6f02 to your computer and use it in GitHub Desktop.
material resoltuion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string ResolveRelativeMaterialPath(string relativePath, int variantId) | |
{ | |
Regex reg = new Regex( "(.)([0-9]{4})(.)([0-9]{4})" ); | |
var match = reg.Match( relativePath ); | |
if( !match.Success || match.Groups.Count != 5) | |
throw new ArgumentException( "RelativePath was not in the proper form." ); | |
var id1 = match.Groups[ 1 ].Captures[ 0 ].Value; | |
var val1 = match.Groups[ 2 ].Captures[ 0 ].Value; | |
var id2 = match.Groups[ 3 ].Captures[ 0 ].Value; | |
var val2 = match.Groups[ 4 ].Captures[ 0 ].Value; | |
if( id1 == "c" ) | |
{ | |
switch (id2) | |
{ | |
case "a": | |
return $"chara/accessory/a{val2}/material/v{variantId:D4}{relativePath}"; | |
case "b": | |
return $"chara/human/c{val1}/obj/body/b{val2}/material/v{variantId:D4}{relativePath}"; | |
case "e": | |
return $"chara/equipment/e{val2}/material/v{variantId:D4}{relativePath}"; | |
case "f": | |
return $"chara/human/c{val1}/obj/face/f{val2}/material{relativePath}"; | |
case "h": | |
return $"chara/human/c{val1}/obj/hair/h{val2}/material/v{variantId:D4}{relativePath}"; | |
case "t": | |
return $"chara/human/c{val1}/obj/tail/t{val2}/material/v{variantId:D4}{relativePath}"; | |
case "z": | |
return $"chara/human/c{val1}/obj/zear/z{val2}/material{relativePath}"; | |
} | |
} | |
if( id1 == "d" && id2 == "e" ) | |
return $"chara/demihuman/d{val1}/obj/equipment/e{val2}/material/v{variantId:D4}{relativePath}"; | |
if( id1 == "m" && id2 == "b" ) | |
return $"chara/monster/m{val1}/obj/body/b{val2}/material/v{variantId:D4}{relativePath}"; | |
if( id1 == "w" && id2 == "b" ) | |
return $"chara/weapon/w{val1}/obj/body/b{val2}/material/v{variantId:D4}{relativePath}"; | |
return ""; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment