public void Init(string name, GameFileCache gfc, bool hidef = true) { Name = name; var modelnamel = name.ToLowerInvariant(); MetaHash modelhash = JenkHash.GenHash(modelnamel); MetaHash modelhashhi = JenkHash.GenHash(modelnamel + "_hi"); var yfthash = hidef ? modelhashhi : modelhash; VehicleInitData vid = null; if (gfc.VehiclesInitDict.TryGetValue(modelhash, out vid)) { bool vehiclechange = NameHash != modelhash; ConvRoofDict = null; ConvRoofClip = null; ModelHash = yfthash; NameHash = modelhash; InitData = vid; Yft = gfc.GetYft(ModelHash); while ((Yft != null) && (!Yft.Loaded)) { Thread.Sleep(20);//kinda hacky Yft = gfc.GetYft(ModelHash); } DisplayMake = GlobalText.TryGetString(JenkHash.GenHash(vid.vehicleMakeName.ToLowerInvariant())); DisplayName = GlobalText.TryGetString(JenkHash.GenHash(vid.gameName.ToLowerInvariant())); if (!string.IsNullOrEmpty(vid.animConvRoofDictName) && (vid.animConvRoofDictName.ToLowerInvariant() != "null")) { var ycdhash = JenkHash.GenHash(vid.animConvRoofDictName.ToLowerInvariant()); var cliphash = JenkHash.GenHash(vid.animConvRoofName?.ToLowerInvariant()); ConvRoofDict = gfc.GetYcd(ycdhash); while ((ConvRoofDict != null) && (!ConvRoofDict.Loaded)) { Thread.Sleep(20);//kinda hacky ConvRoofDict = gfc.GetYcd(ycdhash); } ClipMapEntry cme = null; ConvRoofDict?.ClipMap?.TryGetValue(cliphash, out cme); ConvRoofClip = cme; } } else { ModelHash = 0; NameHash = 0; InitData = null; Yft = null; DisplayMake = "-"; DisplayName = "-"; ConvRoofDict = null; ConvRoofClip = null; } UpdateEntity(); }
public void Init(MetaHash pedhash, GameFileCache gfc) { Name = string.Empty; NameHash = 0; InitData = null; Ydd = null; Ytd = null; Yld = null; Ycd = null; Yed = null; Yft = null; Ymt = null; AnimClip = null; for (int i = 0; i < 12; i++) { Drawables[i] = null; Textures[i] = null; Expressions[i] = null; } CPedModelInfo__InitData initdata = null; if (!gfc.PedsInitDict.TryGetValue(pedhash, out initdata)) { return; } var ycdhash = JenkHash.GenHash(initdata.ClipDictionaryName.ToLowerInvariant()); var yedhash = JenkHash.GenHash(initdata.ExpressionDictionaryName.ToLowerInvariant()); //bool pedchange = NameHash != pedhash; //Name = pedname; NameHash = pedhash; InitData = initdata; Ydd = gfc.GetYdd(pedhash); Ytd = gfc.GetYtd(pedhash); Ycd = gfc.GetYcd(ycdhash); Yed = gfc.GetYed(yedhash); Yft = gfc.GetYft(pedhash); PedFile pedFile = null; gfc.PedVariationsDict?.TryGetValue(pedhash, out pedFile); Ymt = pedFile; Dictionary <MetaHash, RpfFileEntry> peddict = null; gfc.PedDrawableDicts.TryGetValue(NameHash, out peddict); DrawableFilesDict = peddict; DrawableFiles = DrawableFilesDict?.Values.ToArray(); gfc.PedTextureDicts.TryGetValue(NameHash, out peddict); TextureFilesDict = peddict; TextureFiles = TextureFilesDict?.Values.ToArray(); gfc.PedClothDicts.TryGetValue(NameHash, out peddict); ClothFilesDict = peddict; ClothFiles = ClothFilesDict?.Values.ToArray(); RpfFileEntry clothFile = null; if (ClothFilesDict?.TryGetValue(pedhash, out clothFile) ?? false) { Yld = gfc.GetFileUncached <YldFile>(clothFile); while ((Yld != null) && (!Yld.Loaded)) { Thread.Sleep(1);//kinda hacky gfc.TryLoadEnqueue(Yld); } } while ((Ydd != null) && (!Ydd.Loaded)) { Thread.Sleep(1);//kinda hacky Ydd = gfc.GetYdd(pedhash); } while ((Ytd != null) && (!Ytd.Loaded)) { Thread.Sleep(1);//kinda hacky Ytd = gfc.GetYtd(pedhash); } while ((Ycd != null) && (!Ycd.Loaded)) { Thread.Sleep(1);//kinda hacky Ycd = gfc.GetYcd(ycdhash); } while ((Yed != null) && (!Yed.Loaded)) { Thread.Sleep(1);//kinda hacky Yed = gfc.GetYed(yedhash); } while ((Yft != null) && (!Yft.Loaded)) { Thread.Sleep(1);//kinda hacky Yft = gfc.GetYft(pedhash); } Skeleton = Yft?.Fragment?.Drawable?.Skeleton?.Clone(); MetaHash cliphash = JenkHash.GenHash("idle"); ClipMapEntry cme = null; Ycd?.ClipMap?.TryGetValue(cliphash, out cme); AnimClip = cme; var exprhash = JenkHash.GenHash(initdata.ExpressionName.ToLowerInvariant()); Expression expr = null; Yed?.ExprMap?.TryGetValue(exprhash, out expr); Expression = expr; UpdateEntity(); }