Exemple #1
0
 /// <summary>
 /// Raises event 'ChangeTarget'
 /// </summary>
 protected virtual void OnChangeTarget()
 {
     if (ChangeTarget != null)
     {
         ChangeTarget.Invoke(this, System.EventArgs.Empty);
     }
 }
Exemple #2
0
 public override void Act(CAEntity entity)
 {
     if (entity is CAGraphCellAgent cagca)
     {
         if (cagca.Parent.Parent.Parent.GetRandomDouble() < this.Probability)
         {
             var cellPos  = cagca.Parent.Position;
             var x        = cellPos.Item1 - (cagca.Parent.Parent.Dimensions.Item1 / 2);
             var y        = cellPos.Item2 - (cagca.Parent.Parent.Dimensions.Item2 / 2);
             var distance = Math.Sqrt((x * x) + (y * y));
             //Console.WriteLine("\rDistance from center: " + distance + "                "); // this should be removed...we're only doing this for DLA.
             var targets = ChangeTarget.GetTargets(cagca);
             for (int i = 0; i < targets.Count; i++)
             {
                 var target   = targets[i];
                 var name     = ChangeProperty;
                 var property = target.GetProperty(name); // danger here of getting a property that doesn't exist...
                 //cagca.Parent.Parent.Parent.Trans[(int)property] -= 1;
                 if (Method == ChangeMethod.Value)
                 {
                     dynamic changed = StaticMethods.Operate(property, Operator, ChangeValue);
                     target.AddProperty((name, changed));
                     //cagca.Parent.Parent.Parent.Trans[(int)changed] += 1;
                     if (cagca.Parent.Parent.Parent.Settings.StoreTransitions)
                     {
                         cagca.Parent.Parent.Parent.AddTransition((target.Type, name, property, changed));
                     }
                 }
                 else if (Method == ChangeMethod.Property)
                 {
                     var result = Operation.Operate(target, property);
                     //var type = result.GetType();
                     //dynamic changed = new CAProperty(name, result);
                     target.AddProperty((name, result));
                     //cagca.Parent.Parent.Parent.Trans[(int)result] += 1;
                     if (cagca.Parent.Parent.Parent.Settings.StoreTransitions)
                     {
                         cagca.Parent.Parent.Parent.AddTransition((target.Type, name, property, result));
                     }
                 }
             }
         }
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ChangeTrackingCollection{T}"/> class.
 /// </summary>
 /// <param name="item">The value the container represents</param>
 /// <param name="target"></param>
 /// <param name="action">The action the container represents.</param>
 public ChangeContainerItem(T item, ChangeTarget target, ChangeAction action = ChangeAction.None)
 {
     Target  = target;
     _item   = item;
     _action = action;
 }
Exemple #4
0
 private ChangePath(ChangeTarget target)
 {
     Target = target;
 }
Exemple #5
0
 private ChangePath(IEnumerable <IChangePathPart> parts, ChangeTarget target)
     : this(target)
 {
     Parts = parts.ToList();
 }
Exemple #6
0
 private ChangePath(IEnumerable <IChangePathPart> parts, IChangePathPart newPart, ChangeTarget target)
     : this(target)
 {
     Parts = parts.Append(newPart).ToList();
 }
Exemple #7
0
 /// <summary>
 /// Creates a new <see cref="ChangePath"/> with the specified target.
 /// </summary>
 /// <param name="target">The target of the path.</param>
 /// <returns>A new <see cref="ChangePath"/> with the specified target.</returns>
 public ChangePath WithTarget(ChangeTarget target)
 {
     return(new ChangePath(Parts, target));
 }