public IModel LoadModel(string modelName) { if (modelName == null) { throw new ArgumentNullException(nameof(modelName)); } if (_models == null) { throw new InvalidOperationException($"Cannot load model \"{modelName}\"; network string list not created yet"); } var platformModelName = NetUtilities.ConvertToPlatformPath(modelName); var networkModelName = NetUtilities.ConvertToNetworkPath(modelName); if (!_nameToIndex.TryGetValue(networkModelName, out var index)) { //See if it's a server loaded model index = _models.IndexOf(networkModelName); index = InternalLoadModel(networkModelName, platformModelName, index != -1 ? index : (int?)null); } return(_modelManager[platformModelName]); }
public IModel LoadModel(string modelName) { if (modelName == null) { throw new ArgumentNullException(nameof(modelName)); } if (_models == null) { throw new InvalidOperationException($"Cannot load model \"{modelName}\"; network string list not created yet"); } var platformModelName = NetUtilities.ConvertToPlatformPath(modelName); //TODO: could rework string lists to internally handle this at some point var networkModelName = NetUtilities.ConvertToNetworkPath(modelName); var index = _models.IndexOf(networkModelName); if (index == -1) { var model = _modelManager.Load(platformModelName); //All models loaded by the server are required by default index = _models.Add(networkModelName, new ModelPrecacheData { Flags = (uint)ModelPrecacheFlags.Required }); } return(_modelManager[platformModelName]); }
public void LoadFallbackModel() { //The manager needs to know that the fallback model is loaded, so this has to be called explicitly _modelManager.LoadFallbackModel(NetUtilities.ConvertToPlatformPath(_fallbackModelName)); //Add it to our list LoadModel(_fallbackModelName); }
private void _modelPrecache_OnStringAdded(IReadOnlyNetworkStringList list, int index) { var data = list.GetBinaryData(index) as ModelPrecacheData; /*var model = */ //Load the model now InternalLoadModel(list[index], NetUtilities.ConvertToPlatformPath(list[index]), index); //TODO: need to implement consistency checking and enforce models if requested by server /* * if (model == null && ((ModelPrecacheFlags)data.Flags & ModelPrecacheFlags.Required) != 0) * { * //TODO: use a new exception type, handle error higher up * throw new InvalidOperationException($"Cannot continue without \"{list[index]}\", disconnecting"); * } */ }
public void MapLoadBegin() { var mapName = CachedMapName; var worldModel = _engine.Models.LoadModel(mapName); //This should never happen since the map file is compared by CRC before being loaded //TODO: use proper exception type that engine can catch if (!(worldModel is BSPModel bspWorldModel)) { throw new InvalidOperationException($"Model {mapName} is not a map"); } MapInfo = new MapInfo(NetUtilities.ConvertToPlatformPath(mapName), MapInfo?.Name, bspWorldModel); _clientUI.MapLoadBegin(); _renderer.LoadModels(MapInfo.Model, _engine.ModelManager); _entities.MapLoadBegin(); }