//default parameters interval = -1, start = true public void addBehavior(string behaviorName, double interval, bool start) { if (getBehaviorByBame(behaviorName) != null) { return; } AgentBehavior behavior = new AgentBehavior(behaviorName); Dictionary <string, ValueSpecification> param = new Dictionary <string, ValueSpecification>(); BehaviorExecution be = behavior.createBehaviorExecution((InstanceSpecification)this, param, false); //if(be as OneShotBehaviorExecution !=null && start) { be = BehaviorScheduler.Instance.executeBehavior((Behavior)behavior, (InstanceSpecification)this, param, false); if (interval > 0.00) { SimpleBehaviorExecution sbe = (SimpleBehaviorExecution)be; if (sbe != null) { sbe.Interval = interval; } } behaviorsExecution.Add((AgentBehaviorExecution)be); } behaviors.Add(behavior); }
public AgentBehaviorExecution executeOneShotBehavior(string behaviorName) { AgentBehavior behavior = getBehaviorByBame(behaviorName); Dictionary <string, ValueSpecification> param = new Dictionary <string, ValueSpecification>(); BehaviorExecution be = behavior.createBehaviorExecution((InstanceSpecification)this, param, false); if (be as OneShotBehaviorExecution != null) { be = BehaviorScheduler.Instance.executeBehavior((Behavior)behavior, (InstanceSpecification)this, param, false); return((AgentBehaviorExecution)be); } return(null); }
//default parameters interval = -1, start = true public void addBehavior(string behaviorName, double interval, bool start) { if (getBehaviorByBame(behaviorName) != null) return; AgentBehavior behavior = new AgentBehavior(behaviorName); Dictionary<string, ValueSpecification> param = new Dictionary<string, ValueSpecification>(); BehaviorExecution be = behavior.createBehaviorExecution((InstanceSpecification)this, param, false); //if(be as OneShotBehaviorExecution !=null && start) { be = BehaviorScheduler.Instance.executeBehavior((Behavior)behavior, (InstanceSpecification)this, param, false); if (interval > 0.00) { SimpleBehaviorExecution sbe = (SimpleBehaviorExecution)be; if (sbe != null) sbe.Interval = interval; } behaviorsExecution.Add((AgentBehaviorExecution)be); } behaviors.Add(behavior); }