/// <summary> /// Exits the visual scenario editor back to the Loader screen /// </summary> public void ExitEditor() { if (ScenarioManager.Instance.IsScenarioDirty) { var popupData = new ConfirmationPopup.PopupData() { Text = "There are unsaved changes in the scenario, do you wish to discard them?" }; popupData.ConfirmCallback += () => { var loadingProcess = ScenarioManager.Instance.loadingPanel.AddProgress(); loadingProcess.Update("Deinitializing before exiting the visual scenario editor."); //Delay exiting editor so the loading panel can initialize StartCoroutine(DelayedExitEditor(loadingProcess)); }; ScenarioManager.Instance.confirmationPopup.Show(popupData); } else { var loadingProcess = ScenarioManager.Instance.loadingPanel.AddProgress(); loadingProcess.Update("Deinitializing before exiting the visual scenario editor."); //Delay exiting editor so the loading panel can initialize StartCoroutine(DelayedExitEditor(loadingProcess)); } }
/// <summary> /// Paste all the effectors from the copied trigger to this /// </summary> public void PasteEffectors() { if (copiedTrigger == null) { return; } if (copiedTrigger.TargetAgentType != selectedTrigger.TargetAgentType) { ScenarioManager.Instance.logPanel.EnqueueWarning("Cannot paste trigger effectors. Copied trigger targets different agent type."); return; } var pasteAction = new Action(() => { ScenarioManager.Instance.GetExtension <ScenarioUndoManager>() .RegisterRecord(new UndoTriggerCopy(selectedTrigger)); selectedTrigger.CopyProperties(copiedTrigger); }); //If there are any effectors added ask for replacing if (selectedTrigger.Trigger.Effectors.Count > 0) { var popupData = new ConfirmationPopup.PopupData { Text = "Replace currently added effectors with the copied ones?" }; popupData.ConfirmCallback += pasteAction; ScenarioManager.Instance.confirmationPopup.Show(popupData); } else { pasteAction.Invoke(); } }
/// <summary> /// Pastes policy to this panel /// </summary> public void PastePolicy() { if (BoundControllable == null) { ScenarioManager.Instance.logPanel.EnqueueWarning( "Cannot copy policy that is not bound to a controllable."); return; } if (ScenarioManager.Instance.GetExtension <ScenarioControllablesManager>() .GetCopiedPolicy(BoundControllable, out var policy)) { var pasteAction = new Action(() => { ScenarioManager.Instance.GetExtension <ScenarioUndoManager>() .RegisterRecord(new GenericUndo <List <ControlAction> >(Policy, "Undo pasting policy", SetPolicy)); SetPolicy(policy); }); //Do not show confirmation popup if policy is empty if (Policy == null || Policy.Count == 0) { pasteAction.Invoke(); return; } //Ask for replacing current policy var popupData = new ConfirmationPopup.PopupData { Text = "Replace current policy with the copied one?" }; popupData.ConfirmCallback += pasteAction; ScenarioManager.Instance.confirmationPopup.Show(popupData); } else { ScenarioManager.Instance.logPanel.EnqueueWarning( "Cannot paste policy copied from other controllable type."); } }