Ejemplo n.º 1
0
 public static object ReadObject(ByteBuffer data, byte dataType)
 {
     if (dataType == ObjectType)
     {
         byte   dataLength = data.ReadByte();
         byte[] fieldData  = data.ReadBytes(dataLength);
         return(SerialUtility.Deserialize(fieldData));
     }
     else
     {
         if (dataType == Vector3Type)
         {
             return(data.ReadVector3());
         }
         else if (dataType == QuaternionType)
         {
             return(data.ReadQuaternion());
         }
         else if (dataType == IntType)
         {
             return(data.ReadInt());
         }
         else if (dataType == FloatType)
         {
             return(data.ReadFloat());
         }
         else if (dataType == LongType)
         {
             return(data.ReadLong());
         }
         else if (dataType == BoolType)
         {
             return(data.ReadBool());
         }
         else if (dataType == StringType)
         {
             return(data.ReadString());
         }
         else if (dataType == BehaviourType)
         {
             long id = data.ReadLong();
             if (id == long.MinValue)
             {
                 return(null);
             }
             if (Side.IsClient)
             {
                 NetworkBehaviour obj = null;
                 ClientRegistry.GetObject(id, out obj);
                 return(obj);
             }
             else
             {
                 ObjectRegistration obj = null;
                 ServerRegistry.GetObject(id, out obj);
                 return(obj.Object);
             }
         }
         else if (dataType == ByteType)
         {
             return(data.ReadByte());
         }
         else
         {
             NetworkBridge.Warn("Invalid serialization type: " + dataType);
             return(null);
         }
     }
 }
Ejemplo n.º 2
0
 public static void Query <T>(string data, QueryObjectCallback <T> then, params object[] args)
 {
     Query(data, raw => then((T)SerialUtility.Deserialize(raw)), args);
 }
Ejemplo n.º 3
0
 public object ReadObject()
 {
     return(SerialUtility.Deserialize(ReadBytes(ReadInt())));
 }