예제 #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;
 }