Пример #1
0
        public virtual void Add(Behavior behavior)
        {
            var containsTypeOfBehavior = false;

            BehaviorsCollection.ForEach(action =>
            {
                containsTypeOfBehavior = (action.GetType().Equals(behavior.GetType()));
            });
            if (containsTypeOfBehavior)
            {
                throw new CoreException("A Behavior of the same Type is already present in the collection. You can use only one Behavior type per Agent");
            }

            behavior.Agent = this;
            BehaviorsCollection.Add(behavior);
            Behaviors = new ReadonlyBehaviorCollection(BehaviorsCollection);
            behavior.Initialize();
        }
Пример #2
0
 public virtual void Remove(Behavior behavior)
 {
     BehaviorsCollection.Remove(behavior);
     Behaviors = new ReadonlyBehaviorCollection(BehaviorsCollection);
 }
Пример #3
0
 protected Agent()
 {
     Enabled             = true;
     BehaviorsCollection = new List <Behavior>();
     Behaviors           = new ReadonlyBehaviorCollection(BehaviorsCollection);
 }