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(); }
public virtual void Remove(Behavior behavior) { BehaviorsCollection.Remove(behavior); Behaviors = new ReadonlyBehaviorCollection(BehaviorsCollection); }
protected Agent() { Enabled = true; BehaviorsCollection = new List <Behavior>(); Behaviors = new ReadonlyBehaviorCollection(BehaviorsCollection); }