private void ReadStaticProps(BSPParser bspParser, VPKParser vpkParser, CancellationToken cancelToken, Action <float, string> onProgressChanged = null) { int staticPropCount = Mathf.RoundToInt(bspParser.staticProps.staticPropInfo.Length * ModelLoadPercent); staticProps = new StaticPropData[staticPropCount]; for (int i = 0; i < staticPropCount; i++) { if (cancelToken.IsCancellationRequested) { return; } var currentPropInfo = bspParser.staticProps.staticPropInfo[i]; ushort propType = currentPropInfo.PropType; string modelFullPath = bspParser.staticProps.staticPropDict.names[propType]; modelFullPath = modelFullPath.Substring(0, modelFullPath.LastIndexOf(".")); staticProps[i].model = SourceModel.GrabModel(bspParser, vpkParser, modelFullPath); staticProps[i].debug = currentPropInfo.ToString(); staticProps[i].origin = currentPropInfo.Origin; staticProps[i].angles = currentPropInfo.Angles; totalItemsLoaded++; onProgressChanged?.Invoke(PercentLoaded, currentMessage); } }
public static SourceModel GrabModel(BSPParser bspParser, VPKParser vpkParser, string rawPath) { SourceModel model = null; string fixedLocation = rawPath.Replace("\\", "/").ToLower(); if (loadedModels.ContainsKey(fixedLocation)) { model = loadedModels[fixedLocation]; } else { model = new SourceModel(fixedLocation); model.Parse(bspParser, vpkParser); } return(model); }