private void _decalEventsProxy_StatusMessage(object sender, StatusMessageEventArgs e) { if (this._giveItemPending.WaitOne(0)) { if (e.Type == (int)StatusMessageType.UnableToGiveItemBusy) { // Ex: //[RT-DEBUG] StatusMessageEventArgs // Text = Town Crier // Type = 30 this._pendingGiveItemTargetName = e.Text; this._pendingGiveItemOutcome = GiveItemOutcome.FailedBusy; } else if (e.Type == (int)StatusMessageType.UnableToGiveItemCannotCarryAnymore) { // Ex: //[RT-DEBUG] StatusMessageEventArgs // Text = Trophy Cache // Type = 43 this._pendingGiveItemTargetName = e.Text; this._pendingGiveItemOutcome = GiveItemOutcome.FailedCannotCarryAnymore; } } }
private void DecalEventsProxy_StatusTextIntercept(object sender, Data.Events.StatusTextInterceptEventArgs e) { // We can provide support for a couple of additional events based on this one. string objectName = string.Empty; // Using Object Text Example(s) : // Hooks_StatusTextIntercept : Text = Using the Portal to Town Network // Hooks_StatusTextIntercept : Text = Using the Ong-Hau Village Portal // Hooks_StatusTextIntercept : Text = Using the Corpse of <Blah...blah> if (e.IsUsingObject(out objectName)) { // Note (3/5/2015) : So far this seems reliable. When this message comes in, you pretty much have to have // the item selected. So grab the id from the current selection. var currentSelectionId = REPlugin.Instance.PluginHost.Actions.CurrentSelection; var eventArgs = new UsingObjectEventArgs(objectName, currentSelectionId); REPlugin.Instance.Debug.WriteObject(eventArgs); if (this.UsingObject != null) { this.UsingObject(sender, eventArgs); } // Once we fire the generic event, check and see if there is a more specific event we can fire this.CheckForAndFireMoreSpecificUsingEvents(sender, objectName, currentSelectionId); return; } // Object Test Example(s) : // Hooks_StatusTextIntercept : Text = Approaching Small Creepy Statue // Hooks_StatusTextIntercept : Text = Approaching Hisham al-Evv // Hooks_StatusTextIntercept : Text = Approaching Umbral Guard if (e.IsApproachingObject(out objectName)) { // Note (3/5/2015) : So far this seems reliable. When this message comes in, you pretty much have to have // the item selected. So grab the id from the current selection. var currentSelectionId = REPlugin.Instance.PluginHost.Actions.CurrentSelection; var eventArgs = new ApproachingObjectEventArgs(objectName, currentSelectionId); REPlugin.Instance.Debug.WriteObject(eventArgs); if (this.ApproachingObject != null) { this.ApproachingObject(sender, eventArgs); } return; } // Too Busy Example : // Text = You're too busy! if (e.IsYoureTooBusy()) { var eventArgs = new YourTooBusyEventArgs(); REPlugin.Instance.Debug.WriteObject(eventArgs); if (this.YourTooBusy != null) { this.YourTooBusy(sender, eventArgs); } } if (this._giveItemPending.WaitOne(0) && e.IsCantBeGiven()) { if (string.IsNullOrEmpty(this._pendingGiveItemTargetName)) { throw new InvalidOperationException("Expected to have a target name at this point, but we do not."); } if (this._pendingGiveItemOutcome == GiveItemOutcome.Undefined) { throw new InvalidOperationException("Expected to know the outcome of the give at this point"); } var eventArgs = new EndGiveItemEventArgs(this._pendingBusyStateId.ToWorldObject().Capture(), this._pendingGiveItemTargetName, this._pendingGiveItemOutcome); REPlugin.Instance.Debug.WriteObject(eventArgs); if (this.EndGiveItem != null) { this.EndGiveItem(sender, eventArgs); } this._giveItemPending.Reset(); this._pendingGiveItemOutcome = GiveItemOutcome.Undefined; } }
void RT_EndGiveItem(object sender, Data.Events.EndGiveItemEventArgs e) { lock (this._stateLock) { this._lastOutcome = e.Outcome; switch (e.Outcome) { case GiveItemOutcome.Successful: this._successfulGives++; this.Successful.Set(); break; case GiveItemOutcome.FailedBusy: // TODO : Don't don't this the same as other failures. Should do more retries than normal Debug.WriteLineToMain("Give Failed - Target Busy"); this.Failed.Set(); break; default: this.Failed.Set(); break; } } }
protected override void DoResetForRetry() { lock (this._stateLock) { this._lastOutcome = GiveItemOutcome.Undefined; } }
void RT_EndGiveItem(object sender, Data.Events.EndGiveItemEventArgs e) { lock (this._stateLock) { this._lastOutcome = e.Outcome; switch (e.Outcome) { case GiveItemOutcome.Successful: this.Successful.Set(); this._successfulGives++; break; default: this.Failed.Set(); break; } } }
public EndGiveItemEventArgs(IWorldObject itemGiven, string targetName, GiveItemOutcome outcome) { this.ItemGiven = itemGiven; this.TargetName = targetName; this.Outcome = outcome; }