Ejemplo n.º 1
0
        /// <summary>
        /// Get a new color3 from the incoming message
        /// </summary>
        /// <param name="color"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public static Color3 Deserialize(this Color3 color, Lidgren.Network.NetIncomingMessage msg)
        {
            var cr = msg.ReadByte();
            var cg = msg.ReadByte();
            var cb = msg.ReadByte();

            return(new Color3(BitConverter.ToInt32(new byte[] { cb, cg, cr, 0 }, 0)));
        }
Ejemplo n.º 2
0
 public ItemConnector(Lidgren.Network.NetIncomingMessage r)
 {
     conn_type   = (ItemConnectionType)r.ReadByte();
     target_type = (TargetType)r.ReadByte();
     target_id   = r.ReadInt32();
     data_one    = r.ReadInt32();
     data_two    = r.ReadInt32();
 }
Ejemplo n.º 3
0
 public DamageMove(Lidgren.Network.NetIncomingMessage p)
 {
     time_execute = p.ReadSingle();
     attacker     = (TargetType)p.ReadByte();
     attacker_id  = p.ReadUInt16();
     target       = (TargetType)p.ReadByte();
     target_id    = p.ReadUInt16();
     damage       = p.ReadInt16();
     damage_code  = (CauseDamage)p.ReadByte();
     range        = p.ReadUInt16();
 }
Ejemplo n.º 4
0
 public PlantUnit(Lidgren.Network.NetIncomingMessage r)
 {
     top_left   = new Point(r.ReadUInt16(), r.ReadUInt16());
     width      = r.ReadByte();
     height     = r.ReadByte();
     piece_type = r.ReadString();
     images     = new ushort[r.ReadByte()];
     for (int x = 0; x < images.Length; x++)
     {
         images[x] = r.ReadUInt16();
     }
 }
Ejemplo n.º 5
0
        public static Quaternion ReadQuaternion(Lidgren.Network.NetIncomingMessage im)
        {
            var maxIndex = im.ReadByte();

            if (maxIndex >= 4 && maxIndex <= 7)
            {
                var x = (maxIndex == 4) ? 1f : 0f;
                var y = (maxIndex == 5) ? 1f : 0f;
                var z = (maxIndex == 6) ? 1f : 0f;
                var w = (maxIndex == 7) ? 1f : 0f;
                return(new Quaternion(x, y, z, w));
            }

            var a = (float)im.ReadInt16() / PRECISION;
            var b = (float)im.ReadInt16() / PRECISION;
            var c = (float)im.ReadInt16() / PRECISION;
            var d = (float)Math.Sqrt(1f - (a * a + b * b + c * c));

            if (maxIndex == 0)
            {
                return(new Quaternion(d, a, b, c));
            }
            if (maxIndex == 1)
            {
                return(new Quaternion(a, d, b, c));
            }
            if (maxIndex == 2)
            {
                return(new Quaternion(a, b, d, c));
            }
            return(new Quaternion(a, b, c, d));
        }
Ejemplo n.º 6
0
        public Plant(Lidgren.Network.NetIncomingMessage r)
        {
            is_empty    = false;
            plant_index = r.ReadByte();
            name        = r.ReadString();
            top_left    = new Point(r.ReadUInt16(), r.ReadUInt16());
            height      = r.ReadByte();
            int num_pieces = r.ReadByte();

            pieces = new List <PlantUnit>();
            for (int x = 0; x < num_pieces; x++)
            {
                pieces.Add(new PlantUnit(r));
            }
            passable = Exilania.plant_manager.plants[plant_index].passable;
        }
Ejemplo n.º 7
0
        public ItemPieceEnumeration(Lidgren.Network.NetIncomingMessage r)
        {
            itempiece_id = r.ReadInt32();
            loc          = new Point((int)r.ReadInt16(), (int)r.ReadInt16());
            rotation     = r.ReadByte();
            children     = new Dictionary <int, int>();
            int num_child = r.ReadInt32();

            for (int x = 0; x < num_child; x++)
            {
                children[r.ReadInt32()] = r.ReadInt32();
            }
        }
Ejemplo n.º 8
0
        protected override void ReadFrom(Lidgren.Network.NetIncomingMessage incomingMessage)
        {
            base.ReadFrom(incomingMessage);

            StartUpPositions = new Vector2[4];
            for (var i = 0; i < 4; i++)
            {
                StartUpPositions[i].X = incomingMessage.ReadFloat();
                StartUpPositions[i].Y = incomingMessage.ReadFloat();
            }

            TileSetAssetName = incomingMessage.ReadString();

            //todo: refactor usage
            Data = new MapData[15 * 13];
            for (var i = 0; i < Data.Length; i++)
            {
                Data[i].GroundBlockType = (BlockType)incomingMessage.ReadByte();
                Data[i].FringeBlockType = (BlockType)incomingMessage.ReadByte();
                Data[i].FringeItemType  = (ItemType)incomingMessage.ReadByte();
            }
        }
Ejemplo n.º 9
0
        public ItemChest(Lidgren.Network.NetIncomingMessage r)
        {
            destroyable    = r.ReadBoolean();
            chest_name     = r.ReadString();
            security       = r.ReadString();
            world_top_left = new Point(r.ReadUInt16(), r.ReadUInt16());
            furniture_id   = r.ReadUInt16();
            items          = new List <Cubby>();
            int num_items = r.ReadByte();

            for (int i = 0; i < num_items; i++)
            {
                items.Add(new Cubby(r));
            }
        }
Ejemplo n.º 10
0
 public GrowthEvent(Lidgren.Network.NetIncomingMessage m)
 {
     loc       = new Point(m.ReadUInt16(), m.ReadUInt16());
     growth_id = m.ReadByte();
 }
Ejemplo n.º 11
0
 protected override void ReadFrom(Lidgren.Network.NetIncomingMessage incomingMessage)
 {
     base.ReadFrom(incomingMessage);
     ClientId = incomingMessage.ReadByte();
 }