示例#1
0
        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;
            }
        }
示例#2
0
        internal void WriteObject(ApproachingObjectEventArgs obj)
        {
            if (ActiveSettings.Instance.DebugLevel == DebugLevel.None)
                return;

            lock (this._writeLock)
            {
                using (StreamWriter stream = new StreamWriter(this._currentPath, true))
                {
                    this.LogRawMessage(this.FormatWithPrefix("ApproachingObjectEventArgs"), stream);
                    this.LogRawMessage(string.Format("  ObjectName = {0}", obj.ObjectName), stream);
                    this.LogRawMessage(string.Format("  ObjectId = {0}", obj.ObjectId), stream);

                    //this.WriteCurrentStateStuff(stream, false);

                    this.LogRawMessage("", stream);
                }
            }
        }