protected void SubscribeToUpdate(Action method, UpdateReceiver updateReceiver) { switch (updateReceiver) { case UpdateReceiver.FixedUpdate: fixedUpdating = true; fixedUpdate += method; break; case UpdateReceiver.Update: updating = true; update += method; break; case UpdateReceiver.LateUpdate: lateUpdating = true; lateUpdate += method; break; } }
internal void RemoveFromUpdateEvent(Action action, string systemID, UpdateReceiver updateReceiver) { if (updateReceiver == UpdateReceiver.FixedUpdate) { fixedUpdates.Find(d => d.SystemID == systemID).RemoveAction(action); return; } if (updateReceiver == UpdateReceiver.Update) { updates.Find(d => d.SystemID == systemID).RemoveAction(action); } else { lateUpdates.Find(d => d.SystemID == systemID).RemoveAction(action); } }
/// <inheritdoc/> protected override void OnUpdate() { // Setup the presentator on startup or when it was lost/reset if (_presenter == null) { _presenter = new EditorPresenter(renderPanel.Engine, _universe, false) { WireframeTerrain = checkWireframe.Checked }; _presenter.Initialize(); _presenter.HookIn(); renderPanel.AddInputReceiver(_presenter); // Update the presenter based on user input renderPanel.AddInputReceiver(_updateReceiver = new UpdateReceiver(() => renderPanel.Engine.Render())); // Force immediate redraw to give responsive feel UpdatePaintingStatus(null, EventArgs.Empty); #region Monitoring events _presenter.SelectedPositionables.Added += SelectedPositionables_Added; _presenter.SelectedPositionables.Removing += SelectedPositionables_Removing; _presenter.SelectedPositionables.Removed += SelectedPositionables_Removed; _presenter.PostionableMove += presenter_PositionableMove; _presenter.TerrainPaint += presenter_TerrainPaint; #endregion } UpdatePositionablesListBox(); UpdateSelectionControls(); UpdateTextureControls(); _mapPropertiesTool?.UpdateUniverse(_universe); UpdateXml(); UpdateGameTimeSlider(); base.OnUpdate(); }
internal string SubscribeToUpdateEvent(Action action, UpdateReceiver updateReceiver) { bool added = false; if (updateReceiver == UpdateReceiver.FixedUpdate) { while (!added) { for (int i = 0; i < fixedUpdates.Count; i++) { if (fixedUpdates[i].Added < updatesOnDelegate) { fixedUpdates[i].Added++; added = true; return(fixedUpdates[i].AddAction(action)); } } if (!added) { fixedUpdates.Add(new DelegateSystem()); } } } if (updateReceiver == UpdateReceiver.Update) { while (!added) { for (int i = 0; i < updates.Count; i++) { if (updates[i].Added < updatesOnDelegate) { updates[i].Added++; added = true; return(updates[i].AddAction(action)); } } if (!added) { updates.Add(new DelegateSystem()); } } } else { while (!added) { for (int i = 0; i < lateUpdates.Count; i++) { if (lateUpdates[i].Added < updatesOnDelegate) { lateUpdates[i].Added++; added = true; return(lateUpdates[i].AddAction(action)); } } if (!added) { lateUpdates.Add(new DelegateSystem()); } } } return(string.Empty); }