protected override void DoEnd(WaitForCompleteOutcome finalOutcome) { switch (finalOutcome) { case WaitForCompleteOutcome.Success: if (!this.Requestor.FromSelf) { this.Requestor.GiveFeedback(FeedbackType.Successful, "{0}, right behind ya!", this.Requestor.SourceCharacter); } break; default: this.Requestor.GiveFeedback(FeedbackType.Failed, "{0}, I was left behind!", this.Requestor.SourceCharacter); // If a character fails to use the portal, we should disable nav so that the character stays put. // And also avoids VT freaking out when the character you were following disappears. VTActions.DisableNav(); break; } }
protected override void DoEnd(WaitForCompleteOutcome finalOutcome) { throw new NotImplementedException(); }
protected override void DoEnd(WaitForCompleteOutcome finalOutcome) { switch (finalOutcome) { case WaitForCompleteOutcome.Success: this.Requestor.GiveFeedback(FeedbackType.Successful, "Listing complete"); break; default: throw new DisplayToUserException("Listing failed", this.Requestor); } }
/// <summary> /// Called on a background thread. Called before ShouldCountRetry /// </summary> /// <param name="outcome"></param> /// <returns></returns> protected override bool ShouldRetry(WaitForCompleteOutcome outcome) { lock (this._stateLock) { if (outcome == WaitForCompleteOutcome.Success) { this._givenCount[this._currentGiveIndex]++; if (this._givenCount[this._currentGiveIndex] >= this._foundItemsToGive[this._currentGiveIndex].Count) { this._currentGiveIndex++; } // If we've reached the end of the items to give, then no more retries. if (this._currentGiveIndex >= this._foundItemsToGive.Count) { Debug.WriteLineToMain("All items given"); return false; } return true; } return base.ShouldRetry(outcome); } }
protected override void DoEnd(WaitForCompleteOutcome finalOutcome) { if (_woMutex != null) _woMutex.Dispose(); switch (finalOutcome) { case WaitForCompleteOutcome.Success: if (!this.Requestor.FromSelf) { this.Requestor.GiveFeedback(FeedbackType.Successful, "{0}, I spoke to {1}", this.Requestor.SourceCharacter, this._npcName); } break; default: this.Requestor.GiveFeedback(FeedbackType.Failed, "{0}, I FAILED to speak with {1}", this.Requestor.SourceCharacter, this._npcName); break; } }
protected override void DoEnd(WaitForCompleteOutcome finalOutcome) { switch (finalOutcome) { case WaitForCompleteOutcome.Success: if (!this.Requestor.FromSelf) { this.Requestor.GiveFeedback(FeedbackType.Successful, "{0}, Gave {1} items to {2}, targets", this.Requestor.SourceCharacter, this._successfulGives, this._foundTargets.Count); } break; default: throw new DisplayToUserException(string.Format("Give failed. Target Busy. Items Given = {0}, Cause = {1}", this._currentGiveIndex, this._lastOutcome), this.Requestor); } }
/// <summary> /// Called on the game thread. Called AFTER ShouldRetry /// </summary> /// <param name="outcome"></param> /// <returns></returns> protected override bool ShouldCountRetry(WaitForCompleteOutcome outcome) { lock (this._stateLock) { if (this._lastOutcome == GiveItemOutcome.Successful) { // Don't count successful gives. Piggyback on the retry mechanism to give multiple items. return false; } // Only count failed gives return true; } }
/// <summary> /// Called on a background thread. Called before ShouldCountRetry /// </summary> /// <param name="outcome"></param> /// <returns></returns> protected override bool ShouldRetry(WaitForCompleteOutcome outcome) { lock (this._stateLock) { this._currentGiveIndex++; // If we've reached the end of the items to give, then no more retries. if (this._currentGiveIndex >= this._itemsToGive.Count) { return false; } if (outcome == WaitForCompleteOutcome.Success) { return true; } return base.ShouldRetry(outcome); } }
protected override void DoEnd(WaitForCompleteOutcome finalOutcome) { switch (finalOutcome) { case WaitForCompleteOutcome.Success: if (!this.Requestor.FromSelf) { this.Requestor.GiveFeedback(FeedbackType.Successful, "{0}, Jump Complete", this.Requestor.SourceCharacter); } break; default: this.Requestor.GiveFeedback(FeedbackType.Failed, "{0}, I FAILED to Jump", this.Requestor.SourceCharacter); break; } }
protected virtual bool ShouldCountRetry(WaitForCompleteOutcome outcome) { return true; }
protected virtual bool ShouldRetry(WaitForCompleteOutcome outcome) { switch(outcome) { case WaitForCompleteOutcome.Success: return false; default: return true; } }
protected abstract void DoEnd(WaitForCompleteOutcome finalOutcome);
public void ResetForRetry() { // Note : Do not reset the successful flag. It's possible the action completed while we were resetting. If it did, // we want to keep that information so that WaitForCompletion will immediately end successfully. if (this.ShouldCountRetry(this._outcome)) { this._retryCounter++; } this._retryPlease = false; this._complete.Reset(); this._successful.Reset(); this._failed.Reset(); this._busy.Reset(); this._outcome = WaitForCompleteOutcome.Undefined; }
public void WaitForOutcome() { try { var index = WaitHandle.WaitAny(this._completionCausingHandles, this.WaitTimeoutInMilliseconds); if (index == WaitHandle.WaitTimeout) { this._outcome = WaitForCompleteOutcome.Timeout; } else if (this._completionCausingHandles[index] == this._successful) { this._outcome = WaitForCompleteOutcome.Success; } else if (this._completionCausingHandles[index] == this._failed) { this._outcome = WaitForCompleteOutcome.Failed; } else if (this._completionCausingHandles[index] == this._busy) { this._outcome = WaitForCompleteOutcome.TooBusy; } else { throw new InvalidOperationException(string.Format("Unhandled WaitAny result : {0}", index)); } this._retryPlease = this.ShouldRetry(this._outcome); } finally { this._complete.Set(); } }