Exemplo n.º 1
0
        /// <summary>
        /// Method invoked when the effector is added to the trigger
        /// </summary>
        /// <param name="effector">Added effector</param>
        private void OnEffectorAdded(TriggerEffector effector)
        {
            if (effectorsObjects.ContainsKey(effector.TypeName))
            {
                return;
            }
            var scenarioEffector = new ScenarioEffector();

            scenarioEffector.Initialize(this, effector);
            effectorsObjects.Add(effector.TypeName, scenarioEffector);
        }
Exemplo n.º 2
0
        /// <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);
            }
        }