OnValueChanged() публичный статический Метод

public static OnValueChanged ( object obj, PropertyInfo prop, Stack stack ) : void
obj object
prop System.Reflection.PropertyInfo
stack System.Collections.Stack
Результат void
            protected override void OnTarget(Mobile from, object targeted)
            {
                IPoint3D p = targeted as IPoint3D;

                if (p != null)
                {
                    try
                    {
                        Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, new Point2D(p).ToString());
                        m_Property.SetValue(m_Object, new Point2D(p), null);
                        PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);

                        if (Miscellanious.ValidateLabeling(m_Object))
                        {
                            if (m_Object is Item)
                            {
                                ((Item)m_Object).Cheater_Name = String.Format("This item modified by GM {0}", m_Mobile.Name);
                            }

                            if (m_Object is Mobile)
                            {
                                ((Mobile)m_Object).Cheater_Name = String.Format("This mobile modified by GM {0}", m_Mobile.Name);
                            }
                        }
                    }
                    catch
                    {
                        m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                    }
                }
            }
        protected override void OnTarget(Mobile from, object targeted)
        {
            try
            {
                if (m_Type == typeof(Type))
                {
                    targeted = targeted.GetType();
                }
                else if ((m_Type == typeof(BaseAddon) || m_Type.IsAssignableFrom(typeof(BaseAddon))) && targeted is AddonComponent)
                {
                    targeted = ((AddonComponent)targeted).Addon;
                }

                if (m_Type.IsAssignableFrom(targeted.GetType()))
                {
                    Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, targeted.ToString());
                    m_Property.SetValue(m_Object, targeted, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);

                    if (Miscellanious.ValidateLabeling(m_Object))
                    {
                        if (m_Object is Item)
                        {
                            ((Item)m_Object).Cheater_Name = String.Format("This item modified by GM {0}", m_Mobile.Name);
                        }

                        if (m_Object is Mobile)
                        {
                            ((Mobile)m_Object).Cheater_Name = String.Format("This mobile modified by GM {0}", m_Mobile.Name);
                        }
                    }
                }
                else
                {
                    m_Mobile.SendMessage("That cannot be assigned to a property of type : {0}", m_Type.Name);
                }
            }
            catch
            {
                m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
            }
        }
Пример #3
0
        public override void OnResponse(NetState sender, RelayInfo relayInfo)
        {
            int index = relayInfo.ButtonID - 1;

            if (index >= 0 && index < this.m_Names.Length)
            {
                try
                {
                    MethodInfo info = this.m_Property.PropertyType.GetMethod("Parse", new Type[] { typeof(string) });

                    string result = "";

                    if (info != null)
                    {
                        result = Properties.SetDirect(this.m_Mobile, this.m_Object, this.m_Object, this.m_Property, this.m_Property.Name, info.Invoke(null, new object[] { this.m_Names[index] }), true);
                    }
                    else if (this.m_Property.PropertyType == typeof(Enum) || this.m_Property.PropertyType.IsSubclassOf(typeof(Enum)))
                    {
                        result = Properties.SetDirect(this.m_Mobile, this.m_Object, this.m_Object, this.m_Property, this.m_Property.Name, Enum.Parse(this.m_Property.PropertyType, this.m_Names[index], false), true);
                    }

                    this.m_Mobile.SendMessage(result);

                    if (result == "Property has been set.")
                    {
                        PropertiesGump.OnValueChanged(this.m_Object, this.m_Property, this.m_Stack);
                    }
                }
                catch
                {
                    this.m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            this.m_Mobile.SendGump(new PropertiesGump(this.m_Mobile, this.m_Object, this.m_Stack, this.m_List, this.m_Page));
        }
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Point2D toSet;
            bool    shouldSet, shouldSend;

            switch (info.ButtonID)
            {
            case 1:                     // Current location
            {
                toSet      = new Point2D(m_Mobile.Location);
                shouldSet  = true;
                shouldSend = true;

                break;
            }

            case 2:                     // Pick location
            {
                m_Mobile.Target = new InternalTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List);

                toSet      = Point2D.Zero;
                shouldSet  = false;
                shouldSend = false;

                break;
            }

            case 3:                     // Use values
            {
                TextRelay x = info.GetTextEntry(0);
                TextRelay y = info.GetTextEntry(1);

                toSet      = new Point2D(x == null ? 0 : Utility.ToInt32(x.Text), y == null ? 0 : Utility.ToInt32(y.Text));
                shouldSet  = true;
                shouldSend = true;

                break;
            }

            default:
            {
                toSet      = Point2D.Zero;
                shouldSet  = false;
                shouldSend = true;

                break;
            }
            }

            if (shouldSet)
            {
                try
                {
                    Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet.ToString());
                    m_Property.SetValue(m_Object, toSet, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);

                    if (Miscellanious.ValidateLabeling(m_Object))
                    {
                        if (m_Object is Item)
                        {
                            ((Item)m_Object).Cheater_Name = String.Format("This item modified by GM {0}", m_Mobile.Name);
                        }

                        if (m_Object is Mobile)
                        {
                            ((Mobile)m_Object).Cheater_Name = String.Format("This mobile modified by GM {0}", m_Mobile.Name);
                        }
                    }
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            if (shouldSend)
            {
                m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
            }
        }