/// <inheritdoc/> void IDragHandler.DragCancelled() { if (draggedInstance == null) { return; } draggedInstance.RemoveFromMap(); draggedInstance.Dispose(); draggedInstance = null; }
/// <inheritdoc/> void IDragHandler.DragStarted() { var inputManager = ScenarioManager.Instance.GetExtension <InputManager>(); draggedInstance = GetElementInstance(selectedVariant); draggedInstance.transform.SetParent(ScenarioManager.Instance.transform); draggedInstance.transform.SetPositionAndRotation(inputManager.MouseRaycastPosition, Quaternion.Euler(0.0f, 0.0f, 0.0f)); ScenarioManager.Instance.SelectedElement = draggedInstance; OnDraggedInstanceMove(); }
/// <inheritdoc/> public override void CopyProperties(ScenarioElement origin) { var originWaypoint = origin.GetComponent <ScenarioWaypoint>(); if (originWaypoint == null) { return; } //Clear triggers object LinkedTrigger.Deinitalize(); LinkedTrigger.Initialize(); CopyProperties(originWaypoint, true); }
/// <inheritdoc/> public override void CopyProperties(ScenarioElement origin) { var originTrigger = origin as ScenarioTrigger; if (originTrigger == null) { ScenarioManager.Instance.logPanel.EnqueueWarning($"Cannot copy properties from {origin.ElementType} to {ElementType}."); return; } TargetAgentType = originTrigger.TargetAgentType; ClearEffectors(); var effectorsAdded = new List <TriggerEffector>(); foreach (var effectorObject in originTrigger.effectorsObjects) { if (effectorObject.Value.IsEmpty) { continue; } if (!effectorsObjects.TryGetValue(effectorObject.Key, out var scenarioEffector)) { var effectorOrigin = originTrigger.Trigger.Effectors.Find(e => e.TypeName == effectorObject.Key); var cloneEffector = effectorOrigin.Clone() as TriggerEffector; scenarioEffector = new ScenarioEffector(); effectorsObjects.Add(effectorObject.Key, scenarioEffector); scenarioEffector.Initialize(this, cloneEffector); Trigger.AddEffector(cloneEffector); effectorsAdded.Add(effectorOrigin); } scenarioEffector.CopyProperties(effectorObject.Value); } foreach (var effector in originTrigger.Trigger.Effectors) { if (effectorsAdded.Contains(effector)) { continue; } var cloneEffector = effector.Clone() as TriggerEffector; Trigger.AddEffector(cloneEffector); } }
/// <inheritdoc/> public override void CopyProperties(ScenarioElement origin) { var originWithVariant = origin as ScenarioElementWithVariant; if (originWithVariant == null) { throw new ArgumentException( $"Could not cast copied element to {nameof(ScenarioElementWithVariant)} type."); } source = originWithVariant.source; variant = originWithVariant.variant; for (var i = 0; i < transform.childCount; i++) { var child = transform.GetChild(i); if (child.name == modelObjectName) { modelInstance = child.gameObject; } } }
/// <inheritdoc/> void IDragHandler.DragFinished() { ScenarioManager.Instance.GetExtension <ScenarioUndoManager>() .RegisterRecord(new UndoAddElement(draggedInstance)); draggedInstance = null; }