示例#1
0
        private void FlushLogs()
        {
            var logs = _logShipping.GetAndFlushLogs();

            foreach (var l in logs)
            {
                switch (l.LogLevel)
                {
                case ConsoleLogLevel.Debug:
                    _consoleHandle.LogDebug(l.Message);
                    break;

                case ConsoleLogLevel.Info:
                    _consoleHandle.LogInfo(l.Message);
                    break;

                case ConsoleLogLevel.Warning:
                    _consoleHandle.LogWarning(l.Message);
                    break;

                case ConsoleLogLevel.Error:
                    _consoleHandle.LogError(l.Message);
                    break;
                }
            }
        }
 public override Task<LogResponse> LogInfo(LogRequest request, ServerCallContext context)
 {
     return Task.Run(() =>
     {
         _consoleHandle.LogInfo(request.Message);
         return Task.FromResult(_logResponse);
     });
 }
        private async Task FinalizeAssets()
        {
            while (true)
            {
                Tuple <IAsset, ISingleAssetReference <IAsset> > assetTuple;
                if (_assetsToFinalize.TryDequeue(out assetTuple))
                {
                    var asset          = assetTuple.Item1 as INativeAsset;
                    var assetReference = assetTuple.Item2;
                    if (asset == null)
                    {
                        _consoleHandle.LogInfo(assetReference.Name + ": No native component; immediately marking as ready.");
                        assetReference.Update(assetTuple.Item1, AssetReferenceState.Ready);
                        continue;
                    }

                    // Perform the asset finalization on the game thread.
                    try
                    {
                        _consoleHandle.LogInfo(assetReference.Name + ": Requesting load of native components.");
                        asset.ReadyOnGameThread();
                        assetReference.Update(assetTuple.Item1, AssetReferenceState.Ready);
                        _consoleHandle.LogInfo(assetReference.Name + ": Native components loaded successfully; asset marked as ready.");
                    }
                    catch (NoAssetContentManagerException)
                    {
                        assetReference.Update(assetTuple.Item1, AssetReferenceState.Ready);
                        _consoleHandle.LogInfo(assetReference.Name + ": No asset content manager Native components loaded successfully; asset marked as ready.");
                    }
                    catch (Exception ex)
                    {
                        LogExceptions(assetReference.Name, ex);

                        // Only store exceptions if we don't already have a readied
                        // asset (due to live reload scenarios).
                        if (!assetReference.IsReady)
                        {
                            assetReference.Update(ex);
                        }
                    }
                }

                await Task.Yield();
            }
        }
        private async Task FinalizeAssets()
        {
            while (true)
            {
                ISingleAssetReference <IAsset> assetReference;
                if (_assetsToFinalize.TryDequeue(out assetReference))
                {
                    var asset = assetReference.Asset as INativeAsset;
                    if (asset == null)
                    {
                        _consoleHandle.LogInfo(assetReference.Name + ": No native component; immediately marking as ready.");
                        assetReference.Update(AssetReferenceState.Ready);
                        continue;
                    }

                    // Perform the asset finalization on the game thread.
                    try
                    {
                        _consoleHandle.LogInfo(assetReference.Name + ": Requesting load of native components.");
                        asset.ReadyOnGameThread();
                        assetReference.Update(AssetReferenceState.Ready);
                        _consoleHandle.LogInfo(assetReference.Name + ": Native components loaded successfully; asset marked as ready.");
                    }
                    catch (NoAssetContentManagerException)
                    {
                        assetReference.Update(AssetReferenceState.Ready);
                        _consoleHandle.LogInfo(assetReference.Name + ": No asset content manager Native components loaded successfully; asset marked as ready.");
                    }
                    catch (Exception ex)
                    {
                        assetReference.Update(ex);
                    }
                }

                await Task.Yield();
            }
        }
        private void SendTexturesToGameHost()
        {
            _consoleHandle.LogInfo("Sending textures and memory mapped filename to game host from editor...");

            var req = new SetRenderTargetsRequest();

            req.SharedPointer.AddRange(_sharedRendererHost.WritableTextureIntPtrs.Select(x => x.ToInt64()));
            req.SyncMmappedFileName = _sharedRendererHost.SynchronisationMemoryMappedFileName;
            try
            {
                _gameHostClient.SetRenderTargets(req);
            }
            catch
            {
                _requiresDelaySync = true;
            }
        }
        private BatchedControlEntity BatchPhysics(IGameContext gameContext, INode node, BatchedControlEntity entity)
        {
            var physicsComponentsToProcess = new List <Tuple <INode, PhysicalBaseRigidBodyComponent> >();

            FindPhysicsComponentsUnderNode(node, physicsComponentsToProcess);

            var transformedShapes = new List <CompoundShape.TransformedShape>();

            foreach (var pair in physicsComponentsToProcess)
            {
                foreach (var body in pair.Item2.RigidBodies)
                {
                    transformedShapes.Add(new CompoundShape.TransformedShape(
                                              body.Shape,
                                              JMatrix.CreateFromQuaternion(pair.Item2.FinalTransform.AbsoluteRotation.ToJitterQuaternion()),
                                              pair.Item2.FinalTransform.AbsolutePosition.ToJitterVector()));
                }
            }

            if (transformedShapes.Count == 0)
            {
                return(entity);
            }

            var compoundShape = new CompoundShape(transformedShapes);

            if (entity == null)
            {
                entity = CreateBatchedControlEntity();
            }

            foreach (var pair in physicsComponentsToProcess)
            {
                pair.Item2.SetBatchedEntity(entity);
            }

            entity.AttachBatchedPhysics(compoundShape);

            _hierarchy.MoveNode(node, _hierarchy.Lookup(entity));

            _consoleHandle.LogInfo("Batching physics objected combined " + transformedShapes.Count + " shapes.");

            return(entity);
        }
        public void WriteThumbnailIfNecessary(IGameContext gameContext, IRenderContext renderContext)
        {
            var path = _projectManager?.Project?.ProjectPath;

            if (path == null || !path.Exists)
            {
                return;
            }

            var editorPath = Path.Combine(Path.Combine(path.FullName, "Build", "Editor"));

            Directory.CreateDirectory(editorPath);

            var thumbnailFile = new FileInfo(Path.Combine(editorPath, "Thumbnail.png"));

            var startTime = _loadedGame.GetPlayingStartTime();

            if (startTime != null && (DateTime.UtcNow - startTime.Value).TotalMinutes >= 1)
            {
                if (!thumbnailFile.Exists || thumbnailFile.LastWriteTimeUtc < DateTime.UtcNow.AddHours(-4))
                {
                    _consoleHandle.LogInfo("Sampling current game screen as thumbnail for project...");

                    var srt = _loadedGame.GetCurrentGameRenderTarget();
                    var rt  = new RenderTarget2D(renderContext.GraphicsDevice, 128, 128, false, SurfaceFormat.Color, DepthFormat.None);
                    _graphicsBlit.Blit(renderContext, srt, rt);

                    try
                    {
                        using (var writer = new FileStream(thumbnailFile.FullName, FileMode.Create, FileAccess.Write))
                        {
                            rt.SaveAsPng(writer, 128, 128);
                        }
                    }
                    catch
                    {
                        thumbnailFile.Delete();
                        throw;
                    }

                    rt.Dispose();
                }
            }
        }
 public void LogInfo(string messageFormat)
 {
     _realImpl.LogInfo(messageFormat);
 }
示例#9
0
 public void Info(string message)
 {
     _consoleHandle.LogInfo(message);
 }
 public void LogInfo(string messageFormat)
 {
     _consoleHandle.LogInfo(messageFormat);
 }