/// <summary> /// Schedule flushing of the pending additions, removals, and shows/hides. /// The actual construction or updating of meshes will occur during the next /// LateUpdate(). /// /// If 'onReady' is given, then this will be called in the main thread after /// the construction is complete. /// </summary> public void Flush(OnReady onReady = null) { foreach (var builder in mesh_builders.Values) { Finish(builder); } mesh_builders.Clear(); foreach (var builder in mesh_builders_with_texture.Values) { Finish(builder); } mesh_builders_with_texture.Clear(); if (mesh_builder_for_stems != null) { Finish(mesh_builder_for_stems); mesh_builder_for_stems = null; } if (update_renderer_gindex.Count > 0) { var lst = new List <uint>(update_renderer_gindex); EnqueueUpdater(new RendererUpdater(lst)); update_renderer_gindex.Clear(); } if (onReady != null) { EnqueueUpdater(new ReadyUpdater(onReady)); } }
public void ResetXPosition() { OnZero?.Invoke(); player.transform.position = new Vector3(0, player.transform.position.y, 0); mainCamera.transform.position = new Vector3(platformConfig.CameraOffset, mainCamera.transform.position.y, mainCamera.transform.position.z); OnReady?.Invoke(); }
public void IntroReady() { if (OnReady != null) { OnReady.Invoke(); } }
protected void UpdateNodeCache() { var devices = new List <IDevice>(); foreach (var node in Controller.Nodes) { Utilities.Logger.Debug("Node {0} discovered.", node.Id); if (RgbBulb.IsNodeInstance(node)) { devices.Add(new RgbBulb { Gateway = this, ZWaveNode = node }); } else if (Remote.IsNodeInstance(node)) { devices.Add(new Remote(this, node)); } } Devices = devices; devices .ForEach(d => { if (string.IsNullOrEmpty(d.Name)) { d.Name = "Untitled"; } }); Usher.Config.Devices.Instance.Save(); if (devices.Count > 0) { Thread.Sleep(8000); OnReady?.Invoke(this); } }
public static OnReady create(string jsonString) { JObject jObject = deserializeJson(jsonString); JProperty type = jObject.Property("type"); JProperty handshake = jObject.Property("handshake"); if (type == null || type.Value == null || type.Value.Type != JTokenType.Integer) { return(null); } // Must have handshake if (handshake == null) { return(null); } SimCapiMessageType messageType = type.ToObject <SimCapiMessageType>(); if (messageType != SimCapiMessageType.ON_READY) { return(null); } OnReady onReady = new OnReady(); onReady.handshake = handshake.Value.ToObject <SimCapiHandshake>(); return(onReady); }
private void enqueue(ExecutionPoint point, OnReady <T> onReady) { T value; Exception error; for (;;) { lock (point) { value = point.Value; error = point.Error; if (value != null) { break; } if (error != null) { break; } point.Que.Enqueue(onReady); return; } } invoke(onReady, value, error); }
private async Task CookPizza(Order order) { await Task.Delay(order.Pizza.CookingTime *1000); OnReady?.Invoke(this, order); _ordersDesk.Remove(order); }
private void ProcessCommand(uint commandCode) { switch (commandCode) { case (uint)NppMsg.NPPN_READY: OnReady?.Invoke(); break; case (uint)NppMsg.NPPN_TBMODIFICATION: _funcItems.RefreshItems(); SetToolBarIcons(); break; case (uint)SciMsg.SCN_CHARADDED: break; case (uint)NppMsg.NPPN_SHUTDOWN: OnShutDown?.Invoke(); _funcItems.Dispose(); break; case (uint)NppMsg.NPPN_FILESAVED: OnFileSaved?.Invoke(); break; case (uint)NppMsg.NPPN_BUFFERACTIVATED: OnFileChanged?.Invoke(); break; } }
public void Open(string path, bool autoPlay) { player.source = VideoSource.Url; player.url = path; player.Prepare(); void OnPrepared(VideoPlayer player) { OnReady?.Invoke(); if (autoPlay) { Play(); } } void OnErrorReceived(VideoPlayer player, string message) { OnError?.Invoke(new Exception(message)); } player.prepareCompleted -= OnPrepared; player.prepareCompleted += OnPrepared; player.errorReceived -= OnErrorReceived; player.errorReceived += OnErrorReceived; OnOpen?.Invoke(path); }
private static async UniTask _Init() { var dependencyStatus = await FirebaseApp.CheckAndFixDependenciesAsync(); var success = dependencyStatus == DependencyStatus.Available; if (!success) { Debug.LogError($"Could not resolve all Firebase dependencies: {dependencyStatus}"); } await UniTask.SwitchToMainThread(); Debug.Log($"Firebase Configuration: {success}"); if (success) { var prod = StencilRemote.IsProd(); if (!prod) { FirebaseApp.LogLevel = LogLevel.Debug; } var settings = FirebaseRemoteConfig.Settings; settings.IsDeveloperMode = !prod; FirebaseRemoteConfig.Settings = settings; var cache = settings.IsDeveloperMode ? TimeSpan.Zero : TimeSpan.FromHours(StencilRemote.CacheHours); var _ = OnRemote(cache); SetupPush(); } StencilAuth.Init(); IsReady = success; OnReady?.Invoke(null, success); }
public SpeckleServer(string apiUrl, string _token, string _streamId = null) { token = _token; restEndpoint = apiUrl; streamId = _streamId; var client = new RestClient(apiUrl); var request = new RestRequest(Method.GET); request.AddHeader("speckle-token", token); client.ExecuteAsync(request, response => { dynamic parsedResponse; if (response.StatusCode != System.Net.HttpStatusCode.OK) { OnError?.Invoke(this, new SpeckleEventArgs("Failed to contact server on init.")); return; } parsedResponse = parseResponse(response); if (parsedResponse == null) { OnError?.Invoke(this, new SpeckleEventArgs("Failed to parse server response on init.")); return; } wsEndpoint = parsedResponse.ws; OnReady?.Invoke(this, null); }); }
public void OnHello(Settings settings, string memory) { if (logging) { Debug.Log("[SensoManager] OnHello"); } if (logging) { Debug.Log("Settings: " + JsonUtility.ToJson(settings)); } if (logging) { Debug.Log("Memory: " + memory); } _settings = settings; GenericGameSave save = null; if (memory != null) { if (logging) { Debug.Log("Memory not null. Loading"); } save = JsonUtility.FromJson <GenericGameSave>(memory); } _memory = save; _ready = true; OnReady?.Invoke(); #if !UNITY_EDITOR Play.Ready(); #endif }
private void NotifyIfReady() { if (IsReady) { OnReady?.Invoke(this); } }
static void Ready() { ready = true; if (OnReady != null) { OnReady.Invoke(); } }
private void Awake() { // do your stuff isReady = true; // execute whatever was added as callback OnReady?.Invoke(); }
public GatewayBasedManager(string instance, Dictionary <string, string> config) { Instance = instance; Gateway = GetGateway(instance, config); Gateway.OnDisconnected += delegate(IGateway sender) { OnStop?.Invoke(this); }; Gateway.OnError += delegate(IGateway sender) { OnError?.Invoke(this); }; Gateway.OnReady += delegate(IGateway sender) { OnReady?.Invoke(this); }; }
public void Start() { new Thread(() => { CaptureDeviceList.Instance.Refresh(); OnReady?.Invoke(this, EventArgs.Empty); }).Start(); }
public Motion Reset() { accumulateX = 0; Update(0); state = State.Ready; OnReady?.Invoke(this); return(this); }
private void SetupOBS() { OBSClient = _services.GetRequiredService <OBSWebsocket>(); _notifierMediatorService.Notify("OBS is being setup"); OBSClient.Connected += OnObsConnected; OBSClient.Disconnected += OnObsDisconnected; ConnectOBS(); OnReady?.Invoke(this, EventArgs.Empty); }
/// <summary> /// This Update Loop is used to : /// * Wait the Camera is really ready /// * Bring back Callback to the main thread when using Background Thread /// * To execute image Decoding When not using the background Thread /// </summary> public void Update() { // If not ready, wait if (!Camera.IsReady()) { Log.Warning(this + " Camera Not Ready Yet ..."); if (status != ScannerStatus.Initialize) { Status = ScannerStatus.Initialize; } return; } // If the app start for the first time (select size & onReady Event) if (Status == ScannerStatus.Initialize) { if (WebcamInitialized()) { Log.Info(this + " Camera is Ready ", Camera); Status = ScannerStatus.Paused; if (OnReady != null) { OnReady.Invoke(this, EventArgs.Empty); } } } if (Status == ScannerStatus.Running) { // Call the callback if a result is there if (Result != null) { // Log.Info(Result); Callback(Result.Type, Result.Value); // clean and return Result = null; parserPixelAvailable = false; return; } // Get the image as an array of Color32 pixels = Camera.GetPixels(pixels); parserPixelAvailable = true; // If background thread OFF, do the decode main thread with 500ms of pause for UI if (!Settings.ScannerBackgroundThread && mainThreadLastDecode < Time.realtimeSinceStartup - Settings.ScannerDecodeInterval) { DecodeQR(); mainThreadLastDecode = Time.realtimeSinceStartup; } } }
public Client( string project, string token, string host = null, bool jwt = false, TimeSpan?connectDelay = null, TimeSpan?connectTimeout = null, TimeSpan?closeTimeout = null) { if (string.IsNullOrWhiteSpace(project)) { throw new ArgumentNullException("Must provide a project"); } if (string.IsNullOrWhiteSpace(token)) { throw new ArgumentNullException("Must provide a token"); } if (string.IsNullOrWhiteSpace(host)) { host = "relay.signalwire.com"; } string authentication = null; if (!jwt) { authentication = CreateAuthentication(project, token); } else { authentication = CreateJWTAuthentication(project, token); } UpstreamSession.SessionOptions options = new UpstreamSession.SessionOptions() { Bootstrap = new Uri("wss://" + host), Authentication = authentication, }; if (connectDelay.HasValue) { options.ConnectDelay = connectDelay.Value; } if (connectTimeout.HasValue) { options.ConnectTimeout = connectTimeout.Value; } if (closeTimeout.HasValue) { options.CloseTimeout = closeTimeout.Value; } Session = new UpstreamSession(options); Session.OnReady += s => OnReady?.Invoke(this); Session.OnDisconnected += s => OnDisconnected?.Invoke(this); mSignalwireAPI = new SignalwireAPI(this); mCallingAPI = new CallingAPI(mSignalwireAPI); }
private Task DClient_Ready() { Logger.Info("Discord connection successful. ID: {ID}, Name: {name}", DClient.CurrentUser.Id, DClient.CurrentUser.Username); var args = new ReadyEventArgs { BotID = DClient.CurrentUser.Id }; OnReady?.Invoke(this, args); return(Task.CompletedTask); }
// Should be called to complete initialization protected void SetReady() { if (Ready) { return; } Ready = true; OnReady.Dispatch(); }
public override void _Ready() { PauseMode = PauseModeEnum.Process; if (!_initalized) { GetTree().Connect("idle_frame", this, nameof(_OnIdleFrame)); } OnReady?.Invoke(this); _initalized = true; }
private static void RunSimulation(object simObject) { try { Stages = (simObject as Simulation).RunSimulation(null); if (Stages != null && Stages.Length > 0) { if (logOutput) { foreach (var stage in Stages) { stage.Dump(log); } } LastStage = Stages[Stages.Length - 1]; } } catch (Exception e) { BasicLogger.Exception(e, "SimManager.RunSimulation()"); Stages = null; LastStage = null; failMessage = e.ToString(); } lock (locker) { timer.Stop(); #if TIMERS log.AppendLine("Total simulation time: ", timer.ElapsedMilliseconds, "ms"); #else if (logOutput) { log.AppendLine("Total simulation time: ", timer.ElapsedMilliseconds, "ms"); } #endif delayBetweenSims = minSimTime - timer.Elapsed; if (delayBetweenSims < TimeSpan.Zero) { delayBetweenSims = TimeSpan.Zero; } timer.Reset(); timer.Start(); bRunning = false; if (OnReady != null) { OnReady.Invoke(); } } logOutput = false; }
//private static void RunSimulation(object simObject) private IEnumerator RunSimulation(Simulation simObject) { try { Stages = simObject.RunSimulation(logOutput ? log : null); if (Stages != null && Stages.Length > 0) { if (logOutput) { foreach (var stage in Stages) { stage.Dump(log); } } LastStage = Stages[Stages.Length - 1]; } } catch (Exception e) { Stages = null; LastStage = null; failMessage = e.ToString(); } lock (locker) { timer.Stop(); #if TIMERS log.AppendLine("Total simulation time: ", timer.ElapsedMilliseconds, "ms"); #else if (logOutput) { log.AppendLine("Total simulation time: ", timer.ElapsedMilliseconds, "ms"); } #endif delayBetweenSims = minSimTime - timer.Elapsed; if (delayBetweenSims < TimeSpan.Zero) { delayBetweenSims = TimeSpan.Zero; } timer.Reset(); timer.Start(); bRunning = false; if (OnReady != null) { OnReady.Invoke(); } } logOutput = false; yield return(null); }
private void OnFetchComplete(string response) { isReady = true; if (OnReady != null) { OnReady.Invoke(); } DestroyFetcher(); }
public void SetReady() { if (IsReady) { return; } IsReady = true; OnReady?.Invoke(); }
private Task DClient_Ready() { Settings.conInterface.WriteModuleTextColored("DiscordHandler", Color.Red, $"{Color.Aqua.ToTextColor()}Connection successful! ID: {DClient.CurrentUser.Id}, name: {DClient.CurrentUser.Username}"); var args = new ReadyEventArgs { BotID = DClient.CurrentUser.Id }; OnReady?.Invoke(this, args); return(Task.CompletedTask); }
private void Update() { RemainingTime -= Time.deltaTime; if (RemainingTime <= 0) { RemainingTime += SpawnRate; OnReady?.Invoke(); } }