Пример #1
0
        // Scene handling

        private Task UpdateScene(MapDocument md, IEnumerable <IMapObject> affected)
        {
            var waitTask = Task.CompletedTask;

            lock (_lock)
            {
                if (_sceneBuilder == null)
                {
                    _sceneBuilder = new SceneBuilder(_engine.Value);
                    _engine.Value.Add(_sceneBuilder.SceneBuilderRenderable);
                    affected = null;
                }

                using (_engine.Value.Pause())
                {
                    if (affected == null || md == null)
                    {
                        foreach (var r in _sceneBuilder.GetAllRenderables())
                        {
                            _engine.Value.Remove(r);
                            if (r is IUpdateable u)
                            {
                                _engine.Value.Remove(u);
                            }
                        }
                        _sceneBuilder.Clear();
                    }

                    if (md != null)
                    {
                        var resourceCollector = new ResourceCollector();
                        waitTask = _converter.Value.Convert(md, _sceneBuilder, affected, resourceCollector)
                                   .ContinueWith(t => HandleResources(md.Environment, resourceCollector));
                    }
                }
            }

            return(waitTask);
        }
Пример #2
0
 public SceneBuilderRenderable(SceneBuilder sceneBuilder)
 {
     _sceneBuilder = sceneBuilder;
 }