public static async Task RunDebug(EngineContext engineContext) { var config = AppConfig.GetConfiguration <Config>("ScriptDebug"); var renderingSetup = RenderingSetup.Singleton; engineContext.RenderContext.PrepareEffectPlugins += (effectBuilder, plugins) => { if (effectBuilder.PickingPassMainPlugin != null) { RenderPassPlugin pickingPlugin; if (engineContext.DataContext.RenderPassPlugins.TryGetValue(effectBuilder.Name == "Gizmo" ? "MouseOverPickingPlugin" : "PickingPlugin", out pickingPlugin)) { plugins.Add(new PickingShaderPlugin { RenderPassPlugin = (PickingPlugin)pickingPlugin, MainPlugin = effectBuilder.PickingPassMainPlugin }); } } if (effectBuilder.SupportWireframe) { RenderPassPlugin wireframePlugin; if (engineContext.DataContext.RenderPassPlugins.TryGetValue("WireframePlugin", out wireframePlugin)) { plugins.Add(new WireframeShaderPlugin { RenderPassPlugin = wireframePlugin, MainTargetPlugin = renderingSetup.MainTargetPlugin }); } } }; pickingSystem = new PickingSystem(); pickingSystem.PropertyChanged += pickingSystem_PropertyChanged; engineContext.Scheduler.Add(() => pickingSystem.ProcessGizmoAndPicking(engineContext)); var socketContext = new SocketContext(); var socketContextAsync = new SocketContext(); var currentScheduler = Scheduler.Current; var pendingClient = new PendingClient(); socketContext.Connected = (clientSocketContext) => { lock (pendingClient) { pendingClient.MainSocket = clientSocketContext; if (pendingClient.AsyncSocket != null) { currentScheduler.Add(() => ProcessClient(engineContext, pendingClient.MainSocket, pendingClient.AsyncSocket)); } } }; socketContextAsync.Connected = (clientSocketContext) => { lock (pendingClient) { pendingClient.AsyncSocket = clientSocketContext; if (pendingClient.MainSocket != null) { currentScheduler.Add(() => ProcessClient(engineContext, pendingClient.MainSocket, pendingClient.AsyncSocket)); } } }; socketContext.StartServer(config.Port); socketContextAsync.StartServer(config.Port + 1); }
public static async Task RunDebug(EngineContext engineContext) { var config = AppConfig.GetConfiguration<Config>("ScriptDebug"); var renderingSetup = RenderingSetup.Singleton; engineContext.RenderContext.PrepareEffectPlugins += (effectBuilder, plugins) => { if (effectBuilder.PickingPassMainPlugin != null) { RenderPassPlugin pickingPlugin; if (engineContext.DataContext.RenderPassPlugins.TryGetValue(effectBuilder.Name == "Gizmo" ? "MouseOverPickingPlugin" : "PickingPlugin", out pickingPlugin)) plugins.Add(new PickingShaderPlugin { RenderPassPlugin = (PickingPlugin)pickingPlugin, MainPlugin = effectBuilder.PickingPassMainPlugin }); } if (effectBuilder.SupportWireframe) { RenderPassPlugin wireframePlugin; if (engineContext.DataContext.RenderPassPlugins.TryGetValue("WireframePlugin", out wireframePlugin)) plugins.Add(new WireframeShaderPlugin { RenderPassPlugin = wireframePlugin, MainTargetPlugin = renderingSetup.MainTargetPlugin }); } }; pickingSystem = new PickingSystem(); pickingSystem.PropertyChanged += pickingSystem_PropertyChanged; engineContext.Scheduler.Add(() => pickingSystem.ProcessGizmoAndPicking(engineContext)); var socketContext = new SocketContext(); var socketContextAsync = new SocketContext(); var currentScheduler = Scheduler.Current; var pendingClient = new PendingClient(); socketContext.Connected = (clientSocketContext) => { lock (pendingClient) { pendingClient.MainSocket = clientSocketContext; if (pendingClient.AsyncSocket != null) currentScheduler.Add(() => ProcessClient(engineContext, pendingClient.MainSocket, pendingClient.AsyncSocket)); } }; socketContextAsync.Connected = (clientSocketContext) => { lock (pendingClient) { pendingClient.AsyncSocket = clientSocketContext; if (pendingClient.MainSocket != null) currentScheduler.Add(() => ProcessClient(engineContext, pendingClient.MainSocket, pendingClient.AsyncSocket)); } }; socketContext.StartServer(config.Port); socketContextAsync.StartServer(config.Port + 1); }