public override object Clone() { var clone = new ControlTriggerEffector { ControlPolicy = ControlPolicy }; foreach (var uid in ControllablesUIDs) { clone.ControllablesUIDs.Add(uid); } return(clone); }
/// <inheritdoc/> public override void StartEditing(TriggerEditPanel triggerPanel, ScenarioTrigger trigger, TriggerEffector effector) { parentPanel = triggerPanel; editedEffector = (ControlTriggerEffector)effector; policyEditPanel.PolicyUpdated += PolicyEditPanelOnPolicyUpdated; editedTrigger = trigger; editedTrigger.Moved += OnTriggerMoved; var manager = ScenarioManager.Instance.GetExtension <ScenarioControllablesManager>(); //Link to scenario controllables for (var i = 0; i < editedEffector.ControllablesUIDs.Count; i++) { var controllableUID = editedEffector.ControllablesUIDs[i]; var controllableAdded = false; for (var index = 0; index < manager.Controllables.Count; index++) { var controllable = manager.Controllables[index]; if (controllable.Uid != controllableUID) { continue; } linkedControllables.Add(controllable); controllableAdded = true; break; } if (!controllableAdded) { ScenarioManager.Instance.logPanel.EnqueueWarning( $"Could not find controllable with uid: {controllableUID} in the scenario, which edited {nameof(ControlTriggerEffector)} was using."); } } //Setup LineRenderer lineRenderer.positionCount = linkedControllables.Count + 1; lineRenderer.SetPosition(0, trigger.transform.position + LineRendererPositionOffset); for (var i = 0; i < linkedControllables.Count; i++) { var controllable = linkedControllables[i]; lineRenderer.SetPosition(i + 1, controllable.transform.position + LineRendererPositionOffset); } policyEditPanel.Setup(linkedControllables.Count > 0 ? linkedControllables[0].Variant.controllable : null, editedEffector.ControlPolicy); }