Exemple #1
0
        /// <summary>
        ///     Forces the comilation of a new Item based ObjectPropertyList and sends it to the specified Mobile
        /// </summary>
        /// <param name="to">Mobile viewer, the Mobile viewing the OPL</param>
        /// <param name="item"></param>
        public static void SendPropertiesTo(Mobile to, Item item)
        {
            if (to == null || item == null)
            {
                return;
            }

            var opl = new ObjectPropertyList(item);

            item.GetProperties(opl);
            item.AppendChildProperties(opl);

            var eopl = new ExtendedOPL(opl);

            InvokeOPLRequest(item, to, eopl);

            eopl.Apply();

            opl = eopl.Opl;

            opl.Terminate();
            opl.SetStatic();

            to.Send(opl);

            Cache.Remove(opl);
        }
Exemple #2
0
        public static ObjectPropertyList ResolveOPL(IEntity e, Mobile v)
        {
            if (e == null || e.Deleted)
            {
                return(null);
            }

            var opl = new ObjectPropertyList(e);

            if (e is Item)
            {
                var item = (Item)e;

                item.GetProperties(opl);
                item.AppendChildProperties(opl);
            }
            else if (e is Mobile)
            {
                var mob = (Mobile)e;

                mob.GetProperties(opl);
            }

            using (var eopl = new ExtendedOPL(opl))
            {
                InvokeOPLRequest(e, v, eopl);
            }

            opl.Terminate();
            opl.SetStatic();

            return(opl);
        }
Exemple #3
0
        public static void AddTo(ObjectPropertyList opl, IEnumerable <object> args)
        {
            if (opl == null || args == null)
            {
                return;
            }

            using (var o = new ExtendedOPL(opl))
            {
                foreach (var a in args)
                {
                    if (a is IEntity)
                    {
                        o.Add((IEntity)a);
                    }
                    else if (a != null)
                    {
                        o.Add(a.ToString());
                    }
                    else
                    {
                        o.Add(String.Empty);
                    }
                }
            }
        }
Exemple #4
0
        public static void AddTo(ObjectPropertyList opl, string[] lines)
        {
            if (opl == null || lines.IsNullOrEmpty())
            {
                return;
            }

            using (var o = new ExtendedOPL(opl))
            {
                o.AddRange(lines);
            }
        }
Exemple #5
0
        private static void OnEncode0xD6(NetState state, PacketReader reader, ref byte[] buffer, ref int length)
        {
            if (state == null || reader == null || buffer == null || length < 0)
            {
                return;
            }

            int pos = reader.Seek(0, SeekOrigin.Current);

            reader.Seek(5, SeekOrigin.Begin);
            Serial serial = reader.ReadInt32();

            reader.Seek(pos, SeekOrigin.Begin);

            var e = World.FindEntity(serial);

            if (e == null || e.Deleted)
            {
                return;
            }

            var opl = new ObjectPropertyList(e);

            if (e is Item)
            {
                var item = (Item)e;

                item.GetProperties(opl);
                item.AppendChildProperties(opl);
            }
            else if (e is Mobile)
            {
                var mob = (Mobile)e;

                mob.GetProperties(opl);
            }

            var eopl = new ExtendedOPL(opl);

            InvokeOPLRequest(e, state.Mobile, eopl);

            eopl.Apply();

            opl.Terminate();
            opl.SetStatic();

            buffer = opl.Compile(state.CompressionEnabled, out length);

            Cache.Remove(opl);
        }
Exemple #6
0
        private static void InvokeItemOPLRequest(Item item, Mobile viewer, ObjectPropertyList list)
        {
            if (item == null || list == null)
            {
                return;
            }

            if (OnItemOPLRequest == null)
            {
                return;
            }

            var eList = new ExtendedOPL(list);

            OnItemOPLRequest(item, viewer, eList);
            eList.Apply();
        }
Exemple #7
0
        private static void InvokeMobileOPLRequest(Mobile mobile, Mobile viewer, ObjectPropertyList list)
        {
            if (mobile == null || list == null)
            {
                return;
            }

            if (OnMobileOPLRequest == null)
            {
                return;
            }

            var eList = new ExtendedOPL(list);

            OnMobileOPLRequest(mobile, viewer, eList);
            eList.Apply();
        }
Exemple #8
0
        public static void AddTo(ObjectPropertyList opl, string line, params object[] args)
        {
            if (opl == null)
            {
                return;
            }

            using (var o = new ExtendedOPL(opl))
            {
                if (!args.IsNullOrEmpty())
                {
                    o.Add(line, args);
                }
                else
                {
                    o.Add(line);
                }
            }
        }
Exemple #9
0
        private static void InvokeOPLRequest(IEntity entity, Mobile viewer, ExtendedOPL eopl)
        {
            if (entity == null || entity.Deleted || eopl == null)
            {
                return;
            }

            if (entity is Mobile && OnMobileOPLRequest != null)
            {
                OnMobileOPLRequest((Mobile)entity, viewer, eopl);
            }

            if (entity is Item && OnItemOPLRequest != null)
            {
                OnItemOPLRequest((Item)entity, viewer, eopl);
            }

            if (OnEntityOPLRequest != null)
            {
                OnEntityOPLRequest(entity, viewer, eopl);
            }
        }
Exemple #10
0
        public static void AddTo(ObjectPropertyList opl, params object[] args)
        {
            if (opl == null || args.IsNullOrEmpty())
            {
                return;
            }

            using (var o = new ExtendedOPL(opl))
            {
                foreach (var a in args)
                {
                    if (a != null)
                    {
                        o.Add(a.ToString());
                    }
                    else
                    {
                        o.Add(String.Empty);
                    }
                }
            }
        }
Exemple #11
0
        public static ObjectPropertyList ResolveOPL(IEntity e, Mobile v, bool headerOnly)
        {
            if (e == null || e.Deleted)
            {
                return(null);
            }

            ObjectPropertyList opl = null;

            if (e is Item)
            {
                var item = (Item)e;

                if (item.BeginAction(_OPLLock))
                {
                    opl = new ObjectPropertyList(item);

                    if (headerOnly)
                    {
                        item.AddNameProperty(opl);
                    }
                    else
                    {
                        item.GetProperties(opl);
                        item.AppendChildProperties(opl);
                    }

                    item.EndAction(_OPLLock);
                }
            }
            else if (e is Mobile)
            {
                var mob = (Mobile)e;

                if (mob.BeginAction(_OPLLock))
                {
                    opl = new ObjectPropertyList(mob);

                    if (headerOnly)
                    {
                        mob.AddNameProperties(opl);
                    }
                    else
                    {
                        mob.GetProperties(opl);
                    }

                    mob.EndAction(_OPLLock);
                }
            }
            else
            {
                opl = new ObjectPropertyList(e);

                if ((e.CallMethod("AddNameProperty", opl) ?? e.CallMethod("AddNameProperties", opl)) == null)
                {
                    opl.Add(e.Name ?? string.Empty);
                }
            }

            if (opl != null)
            {
                if (!headerOnly)
                {
                    using (var eopl = new ExtendedOPL(opl))
                    {
                        InvokeOPLRequest(e, v, eopl);
                    }
                }

                opl.Terminate();
                opl.SetStatic();
            }

            return(opl);
        }