Ejemplo n.º 1
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.º 2
0
 public static Vector3 ReadDirection(Lidgren.Network.NetIncomingMessage om)
 {
     return(new Vector3(
                (float)om.ReadInt16() / short.MaxValue,
                (float)om.ReadInt16() / short.MaxValue,
                (float)om.ReadInt16() / short.MaxValue
                ));
 }
Ejemplo n.º 3
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.º 4
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();
 }