public override Entity Create(Region tregion, byte[] data)
        {
            DataStream             ds  = new DataStream(data);
            DataReader             dr  = new DataReader(ds);
            GenericCharacterEntity ent = new GenericCharacterEntity(tregion);

            ent.SetPosition(Location.FromDoubleBytes(dr.ReadBytes(24), 0));
            ent.SetOrientation(new BEPUutilities.Quaternion(dr.ReadFloat(), dr.ReadFloat(), dr.ReadFloat(), dr.ReadFloat()));
            ent.SetMass(dr.ReadFloat());
            ent.CBAirForce         = dr.ReadFloat();
            ent.CBAirSpeed         = dr.ReadFloat();
            ent.CBCrouchSpeed      = dr.ReadFloat();
            ent.CBDownStepHeight   = dr.ReadFloat();
            ent.CBGlueForce        = dr.ReadFloat();
            ent.CBHHeight          = dr.ReadFloat();
            ent.CBJumpSpeed        = dr.ReadFloat();
            ent.CBMargin           = dr.ReadFloat();
            ent.CBMaxSupportSlope  = dr.ReadFloat();
            ent.CBMaxTractionSlope = dr.ReadFloat();
            ent.CBProneSpeed       = dr.ReadFloat();
            ent.CBRadius           = dr.ReadFloat();
            ent.CBSlideForce       = dr.ReadFloat();
            ent.CBSlideJumpSpeed   = dr.ReadFloat();
            ent.CBSlideSpeed       = dr.ReadFloat();
            ent.CBStandSpeed       = dr.ReadFloat();
            ent.CBStepHeight       = dr.ReadFloat();
            ent.CBTractionForce    = dr.ReadFloat();
            ent.PreRot            *= Matrix4d.CreateRotationX(dr.ReadFloat() * Utilities.PI180);
            ent.PreRot            *= Matrix4d.CreateRotationY(dr.ReadFloat() * Utilities.PI180);
            ent.PreRot            *= Matrix4d.CreateRotationZ(dr.ReadFloat() * Utilities.PI180);
            ent.mod_scale          = dr.ReadFloat();
            ent.PreRot             = Matrix4d.Scale(ent.mod_scale) * ent.PreRot;
            ent.color = System.Drawing.Color.FromArgb(dr.ReadInt());
            byte dtx = dr.ReadByte();

            ent.Visible     = (dtx & 1) == 1;
            ent.ShouldShine = (dtx & 32) == 32;
            int solidity = (dtx & (2 | 4 | 8 | 16));

            if (solidity == 2)
            {
                ent.CGroup = CollisionUtil.Solid;
            }
            else if (solidity == 4)
            {
                ent.CGroup = CollisionUtil.NonSolid;
            }
            else if (solidity == (2 | 4))
            {
                ent.CGroup = CollisionUtil.Item;
            }
            else if (solidity == 8)
            {
                ent.CGroup = CollisionUtil.Player;
            }
            else if (solidity == (2 | 8))
            {
                ent.CGroup = CollisionUtil.Water;
            }
            else if (solidity == (2 | 4 | 8))
            {
                ent.CGroup = CollisionUtil.WorldSolid;
            }
            else if (solidity == 16)
            {
                ent.CGroup = CollisionUtil.Character;
            }
            ent.model = tregion.TheClient.Models.GetModel(tregion.TheClient.Network.Strings.StringForIndex(dr.ReadInt()));
            dr.Close();
            return(ent);
        }
 public override Entity Create(Region tregion, byte[] data)
 {
     DataStream ds = new DataStream(data);
     DataReader dr = new DataReader(ds);
     GenericCharacterEntity ent = new GenericCharacterEntity(tregion);
     ent.SetPosition(Location.FromDoubleBytes(dr.ReadBytes(24), 0));
     ent.SetOrientation(new BEPUutilities.Quaternion(dr.ReadFloat(), dr.ReadFloat(), dr.ReadFloat(), dr.ReadFloat()));
     ent.SetMass(dr.ReadFloat());
     ent.CBAirForce = dr.ReadFloat();
     ent.CBAirSpeed = dr.ReadFloat();
     ent.CBCrouchSpeed = dr.ReadFloat();
     ent.CBDownStepHeight = dr.ReadFloat();
     ent.CBGlueForce = dr.ReadFloat();
     ent.CBHHeight = dr.ReadFloat();
     ent.CBJumpSpeed = dr.ReadFloat();
     ent.CBMargin = dr.ReadFloat();
     ent.CBMaxSupportSlope = dr.ReadFloat();
     ent.CBMaxTractionSlope = dr.ReadFloat();
     ent.CBProneSpeed = dr.ReadFloat();
     ent.CBRadius = dr.ReadFloat();
     ent.CBSlideForce = dr.ReadFloat();
     ent.CBSlideJumpSpeed = dr.ReadFloat();
     ent.CBSlideSpeed = dr.ReadFloat();
     ent.CBStandSpeed = dr.ReadFloat();
     ent.CBStepHeight = dr.ReadFloat();
     ent.CBTractionForce = dr.ReadFloat();
     ent.PreRot *= Matrix4d.CreateRotationX(dr.ReadFloat() * Utilities.PI180);
     ent.PreRot *= Matrix4d.CreateRotationY(dr.ReadFloat() * Utilities.PI180);
     ent.PreRot *= Matrix4d.CreateRotationZ(dr.ReadFloat() * Utilities.PI180);
     ent.mod_scale = dr.ReadFloat();
     ent.PreRot = Matrix4d.Scale(ent.mod_scale) * ent.PreRot;
     ent.color = System.Drawing.Color.FromArgb(dr.ReadInt());
     byte dtx = dr.ReadByte();
     ent.Visible = (dtx & 1) == 1;
     int solidity = (dtx & (2 | 4 | 8));
     if (solidity == 2)
     {
         ent.CGroup = CollisionUtil.Solid;
     }
     else if (solidity == 4)
     {
         ent.CGroup = CollisionUtil.NonSolid;
     }
     else if (solidity == (2 | 4))
     {
         ent.CGroup = CollisionUtil.Item;
     }
     else if (solidity == 8)
     {
         ent.CGroup = CollisionUtil.Player;
     }
     else if (solidity == (2 | 8))
     {
         ent.CGroup = CollisionUtil.Water;
     }
     else if (solidity == (2 | 4 | 8))
     {
         ent.CGroup = CollisionUtil.WorldSolid;
     }
     else if (solidity == 16)
     {
         ent.CGroup = CollisionUtil.Character;
     }
     ent.model = tregion.TheClient.Models.GetModel(tregion.TheClient.Network.Strings.StringForIndex(dr.ReadInt()));
     dr.Close();
     return ent;
 }