Exemplo n.º 1
0
 public override bool ParseBytesAndExecute(byte[] data)
 {
     DataStream ds = new DataStream(data);
     DataReader dr = new DataReader(ds);
     Location pos = Location.FromDoubleBytes(dr.ReadBytes(24), 0);
     Location vel = Location.FromDoubleBytes(dr.ReadBytes(24), 0);
     long cid = dr.ReadLong();
     for (int i = 0; i < TheClient.TheRegion.Clouds.Count; i++)
     {
         if (TheClient.TheRegion.Clouds[i].CID == cid)
         {
             TheClient.TheRegion.Clouds.RemoveAt(i);
             break;
         }
     }
     Cloud cloud = new Cloud(TheClient.TheRegion, pos);
     cloud.Velocity = vel;
     cloud.CID = cid;
     int count = dr.ReadInt();
     for (int i = 0; i < count; i++)
     {
         cloud.Points.Add(Location.FromDoubleBytes(dr.ReadBytes(24), 0));
         cloud.Sizes.Add(dr.ReadFloat());
         cloud.EndSizes.Add(dr.ReadFloat());
     }
     TheClient.TheRegion.Clouds.Add(cloud);
     dr.Close();
     return true;
 }
 public override bool ParseBytesAndExecute(byte[] data)
 {
     DataStream ds = new DataStream(data);
     DataReader dr = new DataReader(ds);
     long PEID = dr.ReadLong();
     byte type = dr.ReadByte();
     Entity e = TheClient.TheRegion.GetEntity(PEID);
     if (type == 0)
     {
         if (e is PlayerEntity)
         {
             ((PlayerEntity)e).InVehicle = true;
             int drivecount = dr.ReadInt();
             int steercount = dr.ReadInt();
             PlayerEntity player = (PlayerEntity)e;
             player.DrivingMotors.Clear();
             player.SteeringMotors.Clear();
             for (int i = 0; i < drivecount; i++)
             {
                 long jid = dr.ReadLong();
                 JointVehicleMotor jvm = (JointVehicleMotor)TheClient.TheRegion.GetJoint(jid);
                 if (jvm == null)
                 {
                     dr.Close();
                     return false;
                 }
                 player.DrivingMotors.Add(jvm);
             }
             for (int i = 0; i < steercount; i++)
             {
                 long jid = dr.ReadLong();
                 JointVehicleMotor jvm = (JointVehicleMotor)TheClient.TheRegion.GetJoint(jid);
                 if (jvm == null)
                 {
                     dr.Close();
                     return false;
                 }
                 player.SteeringMotors.Add(jvm);
             }
             dr.Close();
             return true;
         }
         // TODO: other CharacterEntity's
     }
     else if (type == 1)
     {
         if (e is PlayerEntity)
         {
             long heloid = dr.ReadLong();
             Entity helo = TheClient.TheRegion.GetEntity(heloid);
             if (!(helo is ModelEntity))
             {
                 dr.Close();
                 return false;
             }
             ((PlayerEntity)e).InVehicle = true;
             ((PlayerEntity)e).Vehicle = helo;
             ModelEntity helomod = (ModelEntity)helo;
             helomod.TurnIntoHelicopter((PlayerEntity)e);
             dr.Close();
             return true;
         }
         // TODO: other CharacterEntity's
         dr.Close();
         return true;
     }
     else if (type == 2)
     {
         if (e is PlayerEntity)
         {
             long planeid = dr.ReadLong();
             Entity plane = TheClient.TheRegion.GetEntity(planeid);
             if (!(plane is ModelEntity))
             {
                 dr.Close();
                 return false;
             }
             ((PlayerEntity)e).InVehicle = true;
             ((PlayerEntity)e).Vehicle = plane;
             ModelEntity planemod = (ModelEntity)plane;
             planemod.TurnIntoPlane((PlayerEntity)e);
             dr.Close();
             return true;
         }
         // TODO: other CharacterEntity's
         dr.Close();
         return true;
     }
     dr.Close();
     return false;
 }
Exemplo n.º 3
0
 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;
 }