public void Yield(PriorityBehavior priorityBehavior) { if (this.Active == priorityBehavior) { this.Deactivate(priorityBehavior); } }
private void Deactivate(PriorityBehavior priorityBehavior) { if (this.Active == priorityBehavior) { this.Active.Deactivate(); this.Active = null; } }
private void Activate(PriorityBehavior priorityBehavior) { if (this.Active == null) { this.Active = priorityBehavior; this.Active.Activate(); } }
public void Register(PriorityBehavior priorityBehavior) { if (this.priorityBehaviors.ContainsKey(priorityBehavior.Priority)) { Debug.LogError(string.Format("Multiple PriorityBehaviors registered with Priority: {0}", priorityBehavior.Priority)); return; } this.priorityBehaviors[priorityBehavior.Priority] = priorityBehavior; }
private void Update() { foreach (KeyValuePair <float, PriorityBehavior> priority in this.priorityBehaviors) { PriorityBehavior priorityBehavior = priority.Value; if (priorityBehavior.Query()) { if (this.Active == null) { this.Activate(priorityBehavior); } else if (this.Active.Interrupt(priorityBehavior)) { this.Deactivate(this.Active); this.Activate(priorityBehavior); } } } if (this.Active != null) { this.Active.Pump(); } }
public virtual bool Interrupt(PriorityBehavior priorityBehavior) { return(false); }