Пример #1
0
 private static CDTIPlane buildPlanes(double px, double py, double pz, double vx, double vy, double vz, string id)
 {
     CDTIPlane toReturn = new CDTIPlane();
     Vector v = new Vector();
     Vector p = new Vector();
     p.N = (float)px;
     p.E = (float)py;
     p.D = (float)pz;
     v.N = (float)vx;
     v.E = (float)vy;
     v.D = (float)vz;
     toReturn.Position = p;
     toReturn.Velocity = v;
     toReturn.Id = id;
     return toReturn;
 }
Пример #2
0
 /// <summary>Helper: Serialize with a varint length prefix</summary>
 public static void SerializeLengthDelimited(Stream stream, Vector instance)
 {
     var data = SerializeToBytes(instance);
     global::SilentOrbit.ProtocolBuffers.ProtocolParser.WriteUInt32(stream, (uint)data.Length);
     stream.Write(data, 0, data.Length);
 }
Пример #3
0
 /// <summary>Helper: Serialize into a MemoryStream and return its byte array</summary>
 public static byte[] SerializeToBytes(Vector instance)
 {
     using (var ms = new MemoryStream())
     {
         Serialize(ms, instance);
         return ms.ToArray();
     }
 }
Пример #4
0
 /// <summary>Serialize the instance into the stream</summary>
 public static void Serialize(Stream stream, Vector instance)
 {
     BinaryWriter bw = new BinaryWriter(stream);
     var msField = global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Pop();
     // Key for field: 1, Fixed32
     stream.WriteByte(13);
     bw.Write(instance.N);
     // Key for field: 2, Fixed32
     stream.WriteByte(21);
     bw.Write(instance.E);
     // Key for field: 3, Fixed32
     stream.WriteByte(29);
     bw.Write(instance.D);
     global::SilentOrbit.ProtocolBuffers.ProtocolParser.Stack.Push(msField);
 }
Пример #5
0
 /// <summary>Helper: create a new instance to deserializing into</summary>
 public static Vector DeserializeLengthDelimited(Stream stream)
 {
     Vector instance = new Vector();
     DeserializeLengthDelimited(stream, instance);
     return instance;
 }
Пример #6
0
 /// <summary>Helper: create a new instance to deserializing into</summary>
 public static Vector DeserializeLength(Stream stream, int length)
 {
     Vector instance = new Vector();
     DeserializeLength(stream, length, instance);
     return instance;
 }
Пример #7
0
 /// <summary>Helper: put the buffer into a MemoryStream and create a new instance to deserializing into</summary>
 public static Vector Deserialize(byte[] buffer)
 {
     Vector instance = new Vector();
     using (var ms = new MemoryStream(buffer))
         Deserialize(ms, instance);
     return instance;
 }
Пример #8
0
 /// <summary>Helper: create a new instance to deserializing into</summary>
 public static Vector Deserialize(Stream stream)
 {
     Vector instance = new Vector();
     Deserialize(stream, instance);
     return instance;
 }