/// <summary>
    /// Inserts an action into a dictionary based on its priority
    /// </summary>
    public void InsertAction(NPCActionable action)
    {
        switch (action.Priority)
        {
        case 3:
            InsertVeryHighPriority(action);
            break;

        case 2:
            InsertHighPriority(action);
            break;

        case 1:
            InsertMedPriority(action);
            break;

        case 0:
            InsertLowPriority(action);
            break;

        case -1:
            InsertConstantPriority(action);
            break;

        default:
            break;
        }
    }
 /// <summary>
 /// Inserts an action into the constant priority dictionary
 /// </summary>
 public void InsertConstantPriority(NPCActionable action)
 {
     if (!constantActions.Contains(action))
     {
         constantActions.Add(action);
     }
 }
 /// <summary>
 /// Inserts an action into the low priority dictionary
 /// </summary>
 public void InsertLowPriority(NPCActionable action)
 {
     if (!lowPriorityAction.ContainsKey(action.Id))
     {
         lowPriorityAction.Add(action.Id, action);
         UpdatePriority();
     }
 }
示例#4
0
 /// <summary>
 /// Inserts an action into the high priority dictionary
 /// </summary>
 public void InsertHighPriority(NPCActionable action)
 {
     if (!highPriorityAction.ContainsKey(action.id))
     {
         highPriorityAction.Add(action.id, action);
         UpdatePriority();
     }
 }
 /// <summary>
 /// Inserts an action into the very high priority dictionary
 /// </summary>
 public void InsertVeryHighPriority(NPCActionable action)
 {
     if (!veryHighPriorityAction.ContainsKey(action.Id))
     {
         veryHighPriorityAction.Add(action.Id, action);
         UpdatePriority();
     }
 }
 /// <summary>
 /// Removes an action from the constant priority dictionary
 /// </summary>
 public bool RemoveConstantAction(NPCActionable action)
 {
     if (constantActions.Contains(action))
     {
         constantActions.Remove(action);
         return(true);
     }
     return(false);
 }
示例#7
0
 /// <summary>
 /// Removes an action from the list of actions to perform
 /// using an action type
 /// </summary>
 protected void RemoveAction(NPCActionable action)
 {
     if (action == null || !action.CanBeCancelled())
     {
         return;
     }
     // Unsubscribe from events before removing the action
     action.ActionComplete -= OnActionComplete;
     actions.RemoveAction(action.id);
 }
    /// <summary>
    /// Returns the action with the specified ID
    /// </summary>
    public NPCActionable GetAction(string id)
    {
        NPCActionable action = null;

        if (veryHighPriorityAction.ContainsKey(id))
        {
            action = veryHighPriorityAction[id];
        }
        else if (highPriorityAction.ContainsKey(id))
        {
            action = highPriorityAction[id];
        }
        else if (medPriorityAction.ContainsKey(id))
        {
             action = medPriorityAction[id];
        }
        else if (lowPriorityAction.ContainsKey(id))
        {
            action = lowPriorityAction[id];
        }
        return(action);
    }
 /// <summary>
 /// Inserts an action into the constant priority dictionary
 /// </summary>
 public void InsertConstantPriority(NPCActionable action)
 {
     if (!constantActions.Contains(action))
     {
         constantActions.Add(action);
     }
 }
 /// <summary>
 /// Removes an action from the list of actions to perform
 /// using an action type
 /// </summary>
 protected void RemoveAction(NPCActionable action)
 {
     if (action == null || !action.CanBeCancelled())
     {
         return;
     }
     // Unsubscribe from events before removing the action
     action.ActionComplete -= OnActionComplete;
     actions.RemoveAction(action.id);
 }
 /// <summary>
 /// Removes the completed action from the list of actions to perform.
 /// </summary>
 protected void OnActionComplete(NPCActionable completedAction)
 {
     actions.RemoveAction(completedAction.id);
 }
 /// <summary>
 /// Adds an action to the priority dictionary
 /// </summary>
 protected void AddAction(NPCActionable action)
 {
     action.ActionComplete += OnActionComplete;
     actions.InsertAction(action);
 }
 /// <summary>
 /// Removes an action from the constant priority dictionary
 /// </summary>
 public bool RemoveConstantAction(NPCActionable action)
 {
     if (constantActions.Contains(action))
     {
         constantActions.Remove(action);
         return true;
     }
     return false;
 }
 /// <summary>
 /// Inserts an action into the very high priority dictionary
 /// </summary>
 public void InsertVeryHighPriority(NPCActionable action)
 {
     if (!veryHighPriorityAction.ContainsKey(action.id))
     {
         veryHighPriorityAction.Add(action.id, action);
         UpdatePriority();
     }
 }
 /// <summary>
 /// Inserts an action into the medium priority dictionary
 /// </summary>
 public void InsertMedPriority(NPCActionable action)
 {
     if (!medPriorityAction.ContainsKey(action.id))
     {
         medPriorityAction.Add(action.id, action);
         UpdatePriority();
     }
 }
示例#16
0
 private void ChildActionComplete(NPCActionable childAction)
 {
     // Call ActionCompleted() to notify subscribers that the parent action is complete
     ActionCompleted();
 }
示例#17
0
 /// <summary>
 /// Adds an action to the priority dictionary
 /// </summary>
 protected void AddAction(NPCActionable action)
 {
     action.ActionComplete += OnActionComplete;
     actions.InsertAction(action);
 }
 private void ChildActionComplete(NPCActionable childAction)
 {
     // Call ActionCompleted() to notify subscribers that the parent action is complete
     ActionCompleted();
 }
示例#19
0
 /// <summary>
 /// Removes the completed action from the list of actions to perform.
 /// </summary>
 protected void OnActionComplete(NPCActionable completedAction)
 {
     actions.RemoveAction(completedAction.id);
 }
 /// <summary>
 /// Inserts an action into a dictionary based on its priority
 /// </summary>
 public void InsertAction(NPCActionable action)
 {
     switch (action.priority)
     {
         case 3:
             InsertVeryHighPriority(action);
             break;
         case 2:
             InsertHighPriority(action);
             break;
         case 1:
             InsertMedPriority(action);
             break;
         case 0:
             InsertLowPriority(action);
             break;
         case -1:
             InsertConstantPriority(action);
             break;
         default:
             break;
     }
 }