コード例 #1
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 1:
            {
                //Properties
                Hold           = reader.ReadItem() as GalleonHold;
                TillerMan      = reader.ReadMobile() as TillerManHS;
                MaxDurability  = reader.ReadUShort();
                _durability    = reader.ReadUShort();
                NextRepairTime = reader.ReadDeltaTime();

                //New Security System
                CanModifySecurity = reader.ReadByte();
                Public            = reader.ReadByte();
                Party             = reader.ReadByte();
                Guild             = reader.ReadByte();

                int listSize = reader.ReadInt();
                PlayerAccess = new Dictionary <PlayerMobile, byte>();
                PlayerMobile player;
                byte         access;
                for (int i = 0; i < listSize; i++)
                {
                    player = (PlayerMobile)reader.ReadMobile();
                    access = (byte)reader.ReadByte();
                    PlayerAccess.Add(player, access);
                }

                //mooring lines
                int toread = reader.ReadInt();
                Ropes = new List <BoatRope>();
                for (int i = 0; i < toread; i++)
                {
                    BoatRope rope = reader.ReadItem() as BoatRope;
                    Ropes.Add(rope);
                }

                goto case 0;
            }

            case 0:
            {
                Status    = (GalleonStatus)(Durability / Math.Ceiling(MaxDurability / 3.0));
                Condition = (GalleonCondition)(Durability / Math.Ceiling(MaxDurability / 4.0));
                ItemID    = GetMultiId(Facing);

                break;
            }
            }
        }
コード例 #2
0
        public override void Serialize(GenericWriter writer)
        {
            base.Serialize(writer);

            writer.Write((int)1);

            //version 1
            //Properties
            writer.Write((Item)Hold);
            writer.Write((Mobile)TillerMan);
            writer.Write((ushort)MaxDurability);
            writer.Write((ushort)Durability);
            writer.WriteDeltaTime(NextRepairTime);

            //New Security System
            writer.Write(CanModifySecurity);
            writer.Write(Public);
            writer.Write(Party);
            writer.Write(Guild);

            int listSize = 0;

            if (PlayerAccess != null)
            {
                listSize = PlayerAccess.Count;
            }

            writer.Write((int)listSize);

            if (listSize > 0)
            {
                foreach (KeyValuePair <PlayerMobile, byte> entry in PlayerAccess)
                {
                    writer.Write((Mobile)entry.Key);
                    writer.Write((byte)entry.Value);
                }
            }

            //Mooring Lines
            writer.Write((int)Ropes.Count);
            for (int i = 0; i < Ropes.Count; i++)
            {
                BoatRope rope = (BoatRope)Ropes[i];
                writer.Write((Item)rope);
            }
        }