示例#1
0
        object readPlayer(Network.ByteInStream s, Type t)
        {
            Player p;
            ushort id = s.ReadUShort();

            if (Context.GetPlayer(id, out p))
            {
                return(p);
            }

            log.Warn("No player with id #{0} found", id);
            return(null);
        }
示例#2
0
        object readActor(Network.ByteInStream s, Type t)
        {
            Actor  a;
            ushort id = s.ReadUShort();

            if (Context.GetActor(id, out a))
            {
                return(a);
            }

            log.Warn("No actor with id #{0} found", id);
            return(null);
        }
示例#3
0
        public void Unpack(Network.ByteInStream stream)
        {
            if (compressPosition)
            {
                position = new Vector3(
                    HalfUtilities.Unpack(stream.ReadUShort()),
                    HalfUtilities.Unpack(stream.ReadUShort()),
                    HalfUtilities.Unpack(stream.ReadUShort())
                    );
            }
            else
            {
                position = stream.ReadVector3();
            }

            if (yawOnly)
            {
                yaw      = stream.ReadByte() * 1.40625f;
                rotation = Quaternion.RotationAxis(Vector3.Up, yaw * SlimMath.Single.Deg2Rad);
            }
            else
            {
                rotation = Quaternion.RotationAxis(
                    new Vector3(
                        HalfUtilities.Unpack(stream.ReadUShort()),
                        HalfUtilities.Unpack(stream.ReadUShort()),
                        HalfUtilities.Unpack(stream.ReadUShort())
                        ),
                    (stream.ReadByte() * 1.40625f * SlimMath.Single.Deg2Rad)
                    );
            }

            buffer.Push(Actor.Context.Time.GameTime,
                        new State {
                Position = position, Rotation = rotation
            }
                        );
        }