public void UpdateTextures(GraphicsDevice graphicsDevice)
        {
            if (_mustRecreateTextures)
            {
                _consoleHandle.LogInfo("Recreating shared textures in game host...");

                if (_sharedTextures != null)
                {
                    for (var i = 0; i < _sharedTextures.Length; i++)
                    {
                        _sharedTextures[i].Dispose();
                    }
                }

                if (_sharedTexturePointers != null)
                {
                    _sharedTextures = new RenderTarget2D[_sharedTexturePointers.Length];
                }
                else
                {
                    _sharedTextures = null;
                }

                if (_sharedTextures != null)
                {
                    for (var i = 0; i < _sharedTexturePointers.Length; i++)
                    {
                        _sharedTextures[i] = RenderTarget2D.FromSharedResourceHandle(
                            graphicsDevice,
                            _sharedTexturePointers[i]);
                    }
                }
            }
        }
        public void Update()
        {
            if (_presenceTask == null || _presenceTask.IsCompleted)
            {
                _presenceTask = Task.Run(async() =>
                {
                    if (_client == null)
                    {
                        _client = _editorClientProvider.GetClient <PresenceClient>();
                    }

                    _consoleHandle.LogInfo("Checking for editor presence from {0}...", Assembly.GetEntryAssembly().GetName().Name);

                    try
                    {
                        await _client.CheckAsync(new CheckPresenceRequest(), deadline: DateTime.UtcNow.AddSeconds(3));
                    }
                    catch
                    {
                        System.Console.Error.WriteLine("Unable to contact editor; automatically exiting!");
                        Environment.Exit(1);
                    }

                    await Task.Delay(10000);
                });
            }
        }
Beispiel #3
0
        private void DoDraw(GameTime gameTime)
        {
            /*if (_gameLoader == null || _renderTargetSize == null || !_hasRunGameUpdate)
             * {
             *  return;
             * }*/

            if (_delayAssignSharedResourceHandles)
            {
                _consoleHandle.LogInfo("Delay assigning shared textures from editor for game hosting...");
                _consoleHandle.LogInfo("Shared texture count: " + (_sharedResourceHandles == null ? "<null>" : _sharedResourceHandles.Length.ToString()));
                _consoleHandle.LogInfo("Shared memory mapped filename: " + _sharedMmapName);

                _editorHostGame.SetSharedResourceHandles(_sharedResourceHandles, _sharedMmapName);
                _delayAssignSharedResourceHandles = false;
            }

            if (State != LoadedGameState.Playing)
            {
                return;
            }

            try
            {
                _editorHostGame?.Render(gameTime.TotalGameTime, gameTime.ElapsedGameTime);
            }
            finally
            {
                FlushLogs();
            }

            _editorHostGame?.IncrementWritableTextureIfPossible();

            if (_playingStartTime == null)
            {
                _playingStartTime = DateTime.UtcNow;

                SyncPlaybackStateToEditor();
            }
        }