Fix race outfit loading

This commit is contained in:
Jacob Tarun
2022-09-27 14:44:17 +08:00
parent ede4ab91a3
commit ce2b1378fd
+33 -18
View File
@@ -71,6 +71,7 @@ public class UmaViewerBuilder : MonoBehaviour
socks = (string)charaData["socks"], socks = (string)charaData["socks"],
bust = (string)charaData["bust"], bust = (string)charaData["bust"],
sex = (string)charaData["sex"], sex = (string)charaData["sex"],
shape = (string)charaData["shape"],
costumeIdShort = ""; costumeIdShort = "";
UmaDatabaseEntry asset = null; UmaDatabaseEntry asset = null;
@@ -83,12 +84,19 @@ public class UmaViewerBuilder : MonoBehaviour
CurrentUMAContainer.VarSkin = skin; CurrentUMAContainer.VarSkin = skin;
CurrentUMAContainer.VarSocks = socks; CurrentUMAContainer.VarSocks = socks;
CurrentUMAContainer.VarHeight = height; CurrentUMAContainer.VarHeight = height;
//Not sure about the pattern, some models are missing
// Pattern for generic body type is as follows:
//
// (costume id)_(body_type_sub)_(body_setting)_(height)_(shape)_(bust)
//
// body_type_sub is used for variants like the summer/winter uniform or the swimsuit/towel
// body_setting is used for subvariants of each variant like the big belly version of the uniform, and the genders for the tracksuits
//
// Some models will naturally be missing due to how this system is designed.
string body = ""; string body = "";
if (costumeId.Split('_')[2] == "03") body = UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/pfb_bdy{costumeId}_{height}_{shape}_{bust}";
body = UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/pfb_bdy{costumeId}_{sex}_{0}_{(bust == "0" ? "1" : bust == "4" ? "3" : bust)}";
else
body = UmaDatabaseController.BodyPath + $"bdy{costumeIdShort}/pfb_bdy{costumeId}_{sex}_{0}_{(bust == "0" ? "1" : bust == "4" ? "3" : bust)}";
Debug.Log("Looking for " + body); Debug.Log("Looking for " + body);
asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name == body); asset = UmaViewerMain.Instance.AbList.FirstOrDefault(a => a.Name == body);
} }
@@ -101,14 +109,15 @@ public class UmaViewerBuilder : MonoBehaviour
} }
else if (genericCostume) else if (genericCostume)
{ {
string texPattern1 = "", texPattern2 = "", texPattern3 = "", texPattern4 = ""; string texPattern1 = "", texPattern2 = "", texPattern3 = "", texPattern4 = "", texPattern5 = "";
switch (costumeId.Split('_')[0]) switch (costumeId.Split('_')[0])
{ {
case "0001": case "0001":
texPattern1 = $"tex_bdy{costumeIdShort}_00_{skin}_{bust}_0{socks}"; texPattern1 = $"tex_bdy{costumeIdShort}_00_{skin}_{bust}_0{socks}";
texPattern2 = $"tex_bdy{costumeIdShort}_00_0_{bust}_00_"; texPattern2 = $"tex_bdy{costumeIdShort}_00_0_{bust}";
texPattern3 = $"tex_bdy{costumeIdShort}_00_waku"; texPattern3 = $"tex_bdy{costumeIdShort}_zekken";
texPattern4 = $"tex_bdy{costumeIdShort}_num"; texPattern4 = $"tex_bdy{costumeIdShort}_00_waku";
texPattern5 = $"tex_bdy{costumeIdShort}_num";
break; break;
case "0003": case "0003":
texPattern1 = $"tex_bdy{costumeIdShort}_00_{skin}_{bust}"; texPattern1 = $"tex_bdy{costumeIdShort}_00_{skin}_{bust}";
@@ -129,7 +138,8 @@ public class UmaViewerBuilder : MonoBehaviour
&& (a.Name.Contains(texPattern1) && (a.Name.Contains(texPattern1)
|| a.Name.Contains(texPattern2) || a.Name.Contains(texPattern2)
|| (string.IsNullOrEmpty(texPattern3) ? false : a.Name.Contains(texPattern3)) || (string.IsNullOrEmpty(texPattern3) ? false : a.Name.Contains(texPattern3))
|| (string.IsNullOrEmpty(texPattern4) ? false : a.Name.Contains(texPattern4))))) || (string.IsNullOrEmpty(texPattern4) ? false : a.Name.Contains(texPattern4))
|| (string.IsNullOrEmpty(texPattern5) ? false : a.Name.Contains(texPattern5)))))
{ {
RecursiveLoadAsset(asset1); RecursiveLoadAsset(asset1);
} }
@@ -376,7 +386,7 @@ public class UmaViewerBuilder : MonoBehaviour
if (BGawb != null) if (BGawb != null)
{ {
var BGclip = LoadAudio(BGawb); var BGclip = LoadAudio(BGawb);
if (BGclip.Count>0) if (BGclip.Count > 0)
{ {
AddAudioSource(BGclip[0]); AddAudioSource(BGclip[0]);
} }
@@ -416,7 +426,7 @@ public class UmaViewerBuilder : MonoBehaviour
var sampleProvider = stream.ToSampleProvider(); var sampleProvider = stream.ToSampleProvider();
int channels = stream.WaveFormat.Channels; int channels = stream.WaveFormat.Channels;
int bytesPerSample = stream.WaveFormat.BitsPerSample / 8; int bytesPerSample = stream.WaveFormat.BitsPerSample / 8;
int sampleRate = stream.WaveFormat.SampleRate; int sampleRate = stream.WaveFormat.SampleRate;
AudioClip clip = AudioClip.Create( AudioClip clip = AudioClip.Create(
@@ -578,7 +588,7 @@ public class UmaViewerBuilder : MonoBehaviour
{ {
foreach (Material m in r.sharedMaterials) foreach (Material m in r.sharedMaterials)
{ {
string mainTex = "", toonMap = "", tripleMap = "", optionMap = ""; string mainTex = "", toonMap = "", tripleMap = "", optionMap = "", zekkenNumberTex = "";
if (CurrentUMAContainer.IsMini) if (CurrentUMAContainer.IsMini)
{ {
@@ -604,12 +614,15 @@ public class UmaViewerBuilder : MonoBehaviour
optionMap = $"tex_bdy{costumeIdShort}_00_0_{bust}_00_ctrl"; optionMap = $"tex_bdy{costumeIdShort}_00_0_{bust}_00_ctrl";
break; break;
case 2: case 2:
mainTex = $"tex_bdy0001_00_num01"; int color = UnityEngine.Random.Range(0, 4);
toonMap = $"tex_bdy0001_00_num01"; mainTex = $"tex_bdy0001_00_zekken{color}_{bust}_diff";
tripleMap = $"tex_bdy0001_00_num01"; toonMap = $"tex_bdy0001_00_zekken{color}_{bust}_shad_c";
optionMap = $"tex_bdy0001_00_num01"; tripleMap = $"tex_bdy0001_00_zekken0_{bust}_base";
optionMap = $"tex_bdy0001_00_zekken0_{bust}_ctrl";
break; break;
} }
zekkenNumberTex = $"tex_bdy0001_00_num{UnityEngine.Random.Range(1, 18):d2}";
break; break;
case "0003": case "0003":
mainTex = $"tex_bdy{costumeIdShort}_00_{skin}_{bust}_diff"; mainTex = $"tex_bdy{costumeIdShort}_00_{skin}_{bust}_diff";
@@ -642,8 +655,10 @@ public class UmaViewerBuilder : MonoBehaviour
m.SetTexture("_ToonMap", textures.FirstOrDefault(t => t.name == toonMap)); m.SetTexture("_ToonMap", textures.FirstOrDefault(t => t.name == toonMap));
m.SetTexture("_TripleMaskMap", textures.FirstOrDefault(t => t.name == tripleMap)); m.SetTexture("_TripleMaskMap", textures.FirstOrDefault(t => t.name == tripleMap));
m.SetTexture("_OptionMaskMap", textures.FirstOrDefault(t => t.name == optionMap)); m.SetTexture("_OptionMaskMap", textures.FirstOrDefault(t => t.name == optionMap));
}
if (!string.IsNullOrEmpty(zekkenNumberTex))
m.SetTexture("_ZekkenNumberTex", textures.FirstOrDefault(t => t.name == zekkenNumberTex));
}
} }
} }
} }