Example #1
0
    public object ReadPrimitive <T>()
    {
        if (typeof(T) == typeof(string))
        {
            throw new UsCmdIOError(UsCmdIOErrorCode.TypeMismatched);
        }
        if (this._readOffset + Marshal.SizeOf(typeof(T)) > this._buffer.Length)
        {
            throw new UsCmdIOError(UsCmdIOErrorCode.ReadOverflow);
        }
        object obj = UsGeneric.Convert <T>(this._buffer, this._readOffset);

        this._readOffset += Marshal.SizeOf(typeof(T));
        return(obj);
    }
Example #2
0
 public void WritePrimitive <T>(T value)
 {
     if (typeof(T) == typeof(string))
     {
         throw new UsCmdIOError(UsCmdIOErrorCode.TypeMismatched);
     }
     if (this._writeOffset + Marshal.SizeOf(typeof(T)) > this._buffer.Length)
     {
         throw new UsCmdIOError(UsCmdIOErrorCode.WriteOverflow);
     }
     byte[] numArray = UsGeneric.Convert <T>(value);
     if (numArray == null)
     {
         throw new UsCmdIOError(UsCmdIOErrorCode.TypeMismatched);
     }
     numArray.CopyTo((Array)this._buffer, this._writeOffset);
     this._writeOffset += Marshal.SizeOf(typeof(T));
 }
 private bool NetHandle_FrameV2_RequestNames(eNetCmd cmd, UsCmd c)
 {
     if (DataCollector.Instance != null)
     {
         foreach (List <int> intList in UsGeneric.Slice <int>(UsCmdUtil.ReadIntList(c), this.SLICE_COUNT))
         {
             UsCmd cmd1 = new UsCmd();
             cmd1.WriteNetCmd(eNetCmd.SV_FrameDataV2_Names);
             cmd1.WriteInt32(intList.Count);
             foreach (int instID in intList)
             {
                 DataCollector.Instance.WriteName(instID, cmd1);
             }
             UsNet.Instance.SendCommand(cmd1);
         }
     }
     return(true);
 }
    private bool NetHandle_FrameV2_RequestNames(eNetCmd cmd, UsCmd c)
    {
        if (usmooth.DataCollector.Instance != null)
        {
            List <int> instIDs = UsCmdUtil.ReadIntList(c);
            foreach (var slice in UsGeneric.Slice(instIDs, SLICE_COUNT))
            {
                UsCmd fragment = new UsCmd();
                fragment.WriteNetCmd(eNetCmd.SV_FrameDataV2_Names);
                fragment.WriteInt32(slice.Count);
                foreach (int instID in slice)
                {
                    usmooth.DataCollector.Instance.WriteName(instID, fragment);
                }
                UsNet.Instance.SendCommand(fragment);
            }
        }

        return(true);
    }
    private bool NetHandle_FrameV2_RequestMeshes(eNetCmd cmd, UsCmd c)
    {
        if (usmooth.DataCollector.Instance != null)
        {
            List <int> meshIDs = UsCmdUtil.ReadIntList(c);
            //Debug.Log(string.Format("requesting meshes - count ({0})", meshIDs.Count));
            foreach (var slice in UsGeneric.Slice(meshIDs, SLICE_COUNT))
            {
                UsCmd fragment = new UsCmd();
                fragment.WriteNetCmd(eNetCmd.SV_FrameDataV2_Meshes);
                fragment.WriteInt32(slice.Count);
                foreach (int meshID in slice)
                {
                    usmooth.DataCollector.Instance.MeshTable.WriteMesh(meshID, fragment);
                }
                UsNet.Instance.SendCommand(fragment);
            }
        }

        return(true);
    }