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 void Render(IGameContext gameContext, IRenderContext renderContext) { #if PLATFORM_WINDOWS Microsoft.Xna.Framework.Graphics.GraphicsDebugMessage message; if (renderContext.GraphicsDevice.GraphicsDebug != null) { while (renderContext.GraphicsDevice.GraphicsDebug.TryDequeueMessage(out message)) { switch (message.Severity) { case "Corruption": case "Error": _consoleHandle.LogError("DX11 ({0}) ({1}, {2}): {3}", message.Severity, message.Category, message.IdName, message.Message); break; case "Warning": _consoleHandle.LogWarning("DX11 ({0}) ({1}, {2}): {3}", message.Severity, message.Category, message.IdName, message.Message); break; case "Information": _consoleHandle.LogDebug("DX11 ({0}) ({1}, {2}): {3}", message.Severity, message.Category, message.IdName, message.Message); break; } } } #endif }
public override Task<LogResponse> LogDebug(LogRequest request, ServerCallContext context) { return Task.Run(() => { _consoleHandle.LogDebug(request.Message); return Task.FromResult(_logResponse); }); }
public INode Batch(IGameContext gameContext, INode node, IBatchingOptions options) { BatchedControlEntity entity = null; if (options.BatchPhysics) { entity = BatchPhysics(gameContext, node, entity); } if (entity != null) { _consoleHandle.LogDebug("Attached batched control entity to parent of batch request."); _hierarchy.AddChildNode(node, entity.Node); } return(entity?.Node); }
private void StartProtobuild(string args, Action callback) { var processStartInfo = new ProcessStartInfo { FileName = Path.Combine(_project.ProjectPath.FullName, "Protobuild.exe"), Arguments = args, WorkingDirectory = _project.ProjectPath.FullName, UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = true, RedirectStandardError = true }; try { _process = Process.Start(processStartInfo); _process.Exited += (sender, e) => { _process = null; callback?.Invoke(); }; _process.EnableRaisingEvents = true; _process.OutputDataReceived += (sender, e) => { _consoleHandle.LogDebug(e.Data); }; _process.ErrorDataReceived += (sender, e) => { _consoleHandle.LogWarning(e.Data); }; _process.BeginOutputReadLine(); _process.BeginErrorReadLine(); if (_process.HasExited) { _process = null; } } catch (Exception ex) { _process = null; throw; } }
private void _fileSystemWatcher_Renamed(object sender, RenamedEventArgs e) { if (e.OldFullPath != null) { _consoleHandle.LogDebug("Renamed from: " + e.OldFullPath); FileChanged(e.OldFullPath); } if (e.FullPath != null) { _consoleHandle.LogDebug("Renamed to: " + e.FullPath); FileChanged(e.FullPath); } }
public void Update(ComponentizedEntity entity, IServerContext serverContext, IUpdateContext updateContext) { if (!_enabled) { return; } _localTick++; _isRunningOnClient = false; if (_uniqueIdentifierForEntity == null) { _uniqueIdentifierForEntity = _uniqueIdentifierAllocator.Allocate(); _networkEngine.RegisterObjectAsNetworkId(_uniqueIdentifierForEntity.Value, entity); } if (_serverOnly) { return; } // Sync the entity to the client if it hasn't been already. foreach (var dispatcher in _networkEngine.CurrentDispatchers) { foreach (var group in dispatcher.ValidClientGroups) { if (ClientAuthoritiveMode != ClientAuthoritiveMode.None && ClientOwnership != null && OnlySendToAuthoritiveClient) { if (ClientOwnership != group) { // This client doesn't own the entity, and this entity is only // synchronised with clients that own it. _consoleHandle.LogDebug("Entity is owned by " + ClientOwnership + ", and target client is " + group + " who doesn't own it, so I'm not syncing it."); continue; } } if (!_clientsEntityIsKnownOn.Contains(group)) { _consoleHandle.LogDebug("Entity is not known to " + group + ", sending creation message."); // Send an entity creation message to the client. var createMessage = new EntityCreateMessage { EntityID = _uniqueIdentifierForEntity.Value, EntityType = entity.GetType().AssemblyQualifiedName, InitialTransform = entity.Transform.SerializeToNetwork(), FrameTick = _localTick, MessageOrder = _messageOrder++, }; _networkEngine.Send( dispatcher, group, createMessage, true); _clientsEntityIsKnownOn.Add(group); } } } PrepareAndTransmitSynchronisation(entity, _localTick, false, ClientAuthoritiveMode); }
public void LoadFromPath( IConsoleHandle consoleHandle, IBaseDirectory baseDirectory, IBackBufferDimensions backBufferDimensions, string gameAssembly) { // Wrap the backbuffer dimensions service in a proxy, since GraphicsDevice can not // cross the AppDomain boundary. backBufferDimensions = new BackBufferDimensionsProxy(backBufferDimensions); // Load the target assembly. consoleHandle.LogDebug("Loading game assembly from " + gameAssembly + "..."); var assembly = Assembly.LoadFrom(gameAssembly); consoleHandle.LogDebug("Constructing standard kernel..."); var kernel = new StandardKernel(); kernel.Bind <IRawLaunchArguments>() .ToMethod(x => new DefaultRawLaunchArguments(new string[0])) .InSingletonScope(); // Bind our extension hook first so that it runs before everything else. kernel.Bind <IEngineHook>().To <ExtensionEngineHook>().InSingletonScope(); Func <System.Reflection.Assembly, Type[]> TryGetTypes = a => { try { return(a.GetTypes()); } catch { return(new Type[0]); } }; consoleHandle.LogDebug("Finding configuration classes in " + gameAssembly + "..."); var typeSource = new List <Type>(); foreach (var attribute in assembly.GetCustomAttributes(false)) { if (attribute.GetType().FullName == "Protogame.ConfigurationAttribute") { typeSource.Add(((ConfigurationAttribute)attribute).GameConfigurationOrServerClass); } } if (typeSource.Count == 0) { // Scan all types to find implementors of IGameConfiguration typeSource.AddRange(from type in TryGetTypes(assembly) select type); } consoleHandle.LogDebug("Found {0} configuration classes in " + gameAssembly, typeSource.Count); consoleHandle.LogDebug("Constructing game configurations..."); var gameConfigurations = new List <IGameConfiguration>(); foreach (var type in typeSource) { if (typeof(IGameConfiguration).IsAssignableFrom(type) && !type.IsInterface && !type.IsAbstract) { gameConfigurations.Add(Activator.CreateInstance(type) as IGameConfiguration); } } ICoreGame game = null; var hasBoundNewEventEngine = false; consoleHandle.LogDebug("Configuring kernel and constructing game instance ({0} configurations)...", gameConfigurations.Count); foreach (var configuration in gameConfigurations) { consoleHandle.LogDebug("Configuring with {0}...", configuration.GetType().FullName); configuration.ConfigureKernel(kernel); // Rebind services so the game renders correctly inside the editor. kernel.Rebind <IBaseDirectory>().ToMethod(x => baseDirectory).InSingletonScope(); kernel.Rebind <IBackBufferDimensions>().ToMethod(x => backBufferDimensions).InSingletonScope(); kernel.Rebind <IDebugRenderer>().To <DefaultDebugRenderer>().InSingletonScope(); var bindings = kernel.GetCopyOfBindings(); var mustBindNewEventEngine = false; if (bindings.ContainsKey(typeof(IEngineHook))) { if (bindings[typeof(IEngineHook)].Any(x => x.Target == typeof(EventEngineHook))) { mustBindNewEventEngine = !hasBoundNewEventEngine; kernel.UnbindSpecific <IEngineHook>(x => x.Target == typeof(EventEngineHook)); } if (mustBindNewEventEngine) { kernel.Bind <IEngineHook>().ToMethod(ctx => { _editorEventEngineHook = ctx.Kernel.Get <EditorEventEngineHook>(ctx.Parent); return(_editorEventEngineHook); }).InSingletonScope(); } } if (game == null) { game = configuration.ConstructGame(kernel); } } if (game != null) { consoleHandle.LogDebug("Game instance is {0}", game.GetType().FullName); } _game = game; _logShipping = kernel.Get <ILogShipping>(); _consoleHandle = consoleHandle; consoleHandle.LogDebug("LoadFromPath complete"); }
public void LogDebug(string messageFormat) { _realImpl.LogDebug(messageFormat); }
public void Update(IGameContext gameContext, IUpdateContext updateContext) { if (_requiresDelaySync && _gameHostClient != null) { SendTexturesToGameHost(); _requiresDelaySync = false; } if (_projectManager.Project == null || _projectManager.Project.DefaultGameBinPath == null) { return; } if (!_projectManager.Project.DefaultGameBinPath.Exists) { return; } if (_process == null || _process.HasExited || // TODO: Use file watcher... (_executingFile != null && _executingFile.LastWriteTimeUtc != new FileInfo(_executingFile.FullName).LastWriteTimeUtc) || _shouldDebug || _shouldRestart) { var extHostPath = Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName, "Protogame.Editor.GameHost.exe"); var processStartInfo = new ProcessStartInfo { FileName = extHostPath, Arguments = (_shouldDebug ? "--debug " : "") + "--track " + Process.GetCurrentProcess().Id + " --editor-url " + _grpcServer.GetServerUrl() + " --assembly-path \"" + _projectManager.Project.DefaultGameBinPath.FullName + "\"", WorkingDirectory = _projectManager.Project.DefaultGameBinPath.DirectoryName, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true }; // Update last write time. _baseDirectory = _projectManager.Project.DefaultGameBinPath.DirectoryName; _executingFile = new FileInfo(_projectManager.Project.DefaultGameBinPath.FullName); _shouldDebug = false; _shouldRestart = false; if (_process != null) { try { _process.EnableRaisingEvents = false; _process.Kill(); } catch { } _consoleHandle.LogDebug("Game host process was killed for reload: {0}", _projectManager.Project.DefaultGameBinPath.FullName); _process = null; _channel = null; _gameHostClient = null; _loadedGameState = null; // The process may have exited mid-draw, which could keep a texture locked. Destroy // the textures and recreate them to ensure they're not locked. _sharedRendererHost.DestroyTextures(); } _process = Process.Start(processStartInfo); _process.Exited += (sender, e) => { _consoleHandle.LogWarning("Game host process has unexpectedly quit: {0}", _projectManager.Project.DefaultGameBinPath.FullName); _process = null; _channel = null; _gameHostClient = null; _loadedGameState = null; // The process may have exited mid-draw, which could keep a texture locked. Destroy // the textures and recreate them to ensure they're not locked. _sharedRendererHost.DestroyTextures(); }; _process.OutputDataReceived += (sender, e) => { if (e.Data == null) { return; } if (_channel != null) { _consoleHandle.LogDebug(e.Data); return; } var editorGrpcServer = _grpcServer.GetServerUrl(); _consoleHandle.LogDebug("Editor gRPC server is {0}", editorGrpcServer); var url = e.Data?.Trim(); _consoleHandle.LogDebug("Creating gRPC channel on {0}...", url); _channel = new Channel(url, ChannelCredentials.Insecure); _gameHostClient = new GameHostServerClient(_channel); _requiresDelaySync = true; if (_runAfterRestart) { _gameHostClient?.SetPlaybackMode(new SetPlaybackModeRequest { Playing = true }); _runAfterRestart = false; } }; _process.ErrorDataReceived += (sender, e) => { if (e.Data != null) { _consoleHandle.LogError(e.Data); } }; _process.EnableRaisingEvents = true; _process.BeginErrorReadLine(); _process.BeginOutputReadLine(); } }
public void Debug(string message) { _consoleHandle.LogDebug(message); }
public void LogDebug(string messageFormat) { _consoleHandle.LogDebug(messageFormat); }