/// <summary> /// Removes this event from the object, restoring autonomy if appropriate /// </summary> /// <returns>true if the event is successfully detached</returns> private RunStatus Detach(BehaviorObject obj) { // If we were the object's current event, restore autonomy (even if the // object has another pending event -- that event will just stop it) if (obj.CurrentEvent == this) { obj.FinishEvent(); obj.StartBehavior(); } // If we were a pending event, then the response depends if (obj.PendingEvent == this) { // Was the object terminating because of us? If so, wait until it's // done terminating, and then restart it if (obj.Status == BehaviorStatus.Terminating) { return(RunStatus.Running); } // If the object isn't terminating (anymore), restart it if it's // idle and then clear the pending event if (obj.Status == BehaviorStatus.Idle) { obj.StartBehavior(); } obj.PendingEvent = null; // Don't worry if another pending event swoops in and replaces us, // it'll handle the object whether its terminating, running, or idle } return(RunStatus.Success); }
public void StopBehavior() { if (InEvent) { g_BehaviorObject.FinishEvent(); } g_BehaviorObject.StopBehavior(); g_NPCController.Body.StopAllMotion(); }
/// <summary> /// Removes this event from the object, restoring autonomy if appropriate /// </summary> /// <returns>true if the event is successfully detached</returns> private RunStatus Detach(BehaviorObject obj) { // If we were the object's current event, restore autonomy (even if the // object has another pending event -- that event will just stop it) if (obj.CurrentEvent == this) { obj.FinishEvent(); obj.StartBehavior(); } // If we were a pending event, then the response depends if (obj.PendingEvent == this) { // Was the object terminating because of us? If so, wait until it's // done terminating, and then restart it if (obj.Status == BehaviorStatus.Terminating) return RunStatus.Running; // If the object isn't terminating (anymore), restart it if it's // idle and then clear the pending event if (obj.Status == BehaviorStatus.Idle) obj.StartBehavior(); obj.PendingEvent = null; // Don't worry if another pending event swoops in and replaces us, // it'll handle the object whether its terminating, running, or idle } return RunStatus.Success; }