private void OnRemoveRow(UInt16 id, MemoryStream stream) { NFMsg.MsgBase xMsg = NFMsg.MsgBase.Parser.ParseFrom(stream); NFMsg.ObjectRecordRemove recordData = NFMsg.ObjectRecordRemove.Parser.ParseFrom(xMsg.msg_data); NFIObject go = mKernelModule.GetObject(mHelpModule.PBToNF(recordData.player_id)); NFIRecordManager recordManager = go.GetRecordManager(); NFIRecord record = recordManager.GetRecord(recordData.record_name.ToStringUtf8()); for (int i = 0; i < recordData.remove_row.Count; i++) { record.Remove(recordData.remove_row[i]); } }
private void OnRecordString(UInt16 id, MemoryStream stream) { NFMsg.MsgBase xMsg = NFMsg.MsgBase.Parser.ParseFrom(stream); NFMsg.ObjectRecordString recordData = NFMsg.ObjectRecordString.Parser.ParseFrom(xMsg.msg_data); NFIObject go = mKernelModule.GetObject(mHelpModule.PBToNF(recordData.player_id)); NFIRecordManager recordManager = go.GetRecordManager(); NFIRecord record = recordManager.GetRecord(recordData.record_name.ToStringUtf8()); for (int i = 0; i < recordData.property_list.Count; i++) { record.SetString(recordData.property_list[i].row, recordData.property_list[i].col, recordData.property_list[i].data.ToStringUtf8()); } }
private void OnAddRow(UInt16 id, MemoryStream stream) { NFMsg.MsgBase xMsg = new NFMsg.MsgBase(); xMsg = Serializer.Deserialize <NFMsg.MsgBase>(stream); NFMsg.ObjectRecordAddRow recordData = new NFMsg.ObjectRecordAddRow(); recordData = Serializer.Deserialize <NFMsg.ObjectRecordAddRow>(new MemoryStream(xMsg.msg_data)); NFIObject go = mKernelModule.GetObject(mHelpModule.PBToNF(recordData.player_id)); NFIRecordManager recordManager = go.GetRecordManager(); for (int i = 0; i < recordData.row_data.Count; i++) { ADD_ROW(mHelpModule.PBToNF(recordData.player_id), System.Text.Encoding.Default.GetString(recordData.record_name), recordData.row_data[i]); } }
private void OnSwapRow(UInt16 id, MemoryStream stream) { NFMsg.MsgBase xMsg = new NFMsg.MsgBase(); xMsg = Serializer.Deserialize <NFMsg.MsgBase>(stream); NFMsg.ObjectRecordSwap recordData = new NFMsg.ObjectRecordSwap(); recordData = Serializer.Deserialize <NFMsg.ObjectRecordSwap>(new MemoryStream(xMsg.msg_data)); NFIObject go = mKernelModule.GetObject(mHelpModule.PBToNF(recordData.player_id)); NFIRecordManager recordManager = go.GetRecordManager(); NFIRecord record = recordManager.GetRecord(System.Text.Encoding.Default.GetString(recordData.origin_record_name)); //目前认为在同一张表中交换吧 record.SwapRow(recordData.row_origin, recordData.row_target); }
private void OnRemoveRow(UInt16 id, MemoryStream stream) { NFMsg.MsgBase xMsg = new NFMsg.MsgBase(); xMsg = Serializer.Deserialize <NFMsg.MsgBase>(stream); NFMsg.ObjectRecordRemove recordData = new NFMsg.ObjectRecordRemove(); recordData = Serializer.Deserialize <NFMsg.ObjectRecordRemove>(new MemoryStream(xMsg.msg_data)); NFIObject go = mKernelModule.GetObject(mHelpModule.PBToNF(recordData.player_id)); NFIRecordManager recordManager = go.GetRecordManager(); NFIRecord record = recordManager.GetRecord(System.Text.Encoding.Default.GetString(recordData.record_name)); for (int i = 0; i < recordData.remove_row.Count; i++) { record.Remove(recordData.remove_row[i]); } }
private void OnRecordFloat(UInt16 id, MemoryStream stream) { NFMsg.MsgBase xMsg = new NFMsg.MsgBase(); xMsg = Serializer.Deserialize <NFMsg.MsgBase>(stream); NFMsg.ObjectRecordFloat recordData = new NFMsg.ObjectRecordFloat(); recordData = Serializer.Deserialize <NFMsg.ObjectRecordFloat>(new MemoryStream(xMsg.msg_data)); NFIObject go = mKernelModule.GetObject(mHelpModule.PBToNF(recordData.player_id)); NFIRecordManager recordManager = go.GetRecordManager(); NFIRecord record = recordManager.GetRecord(System.Text.Encoding.Default.GetString(recordData.record_name)); for (int i = 0; i < recordData.property_list.Count; i++) { record.SetFloat(recordData.property_list[i].row, recordData.property_list[i].col, (float)recordData.property_list[i].data); } }
void InitRecord(NFGUID self, string strClassName) { NFIClass xLogicClass = mxLogicClassModule.GetElement(strClassName); NFDataList xDataList = xLogicClass.GetRecordManager().GetRecordList(); for (int i = 0; i < xDataList.Count(); ++i) { string strRecordyName = xDataList.StringVal(i); NFIRecord xRecord = xLogicClass.GetRecordManager().GetRecord(strRecordyName); NFIObject xObject = GetObject(self); NFIRecordManager xRecordManager = xObject.GetRecordManager(); NFIRecord record = xRecordManager.AddRecord(strRecordyName, xRecord.GetRows(), xRecord.GetColsData(), xRecord.GetTagData()); if (record != null) { record.SetUpload(xRecord.GetUpload()); } } }
private void ADD_ROW(NFGUID self, string strRecordName, NFMsg.RecordAddRowStruct xAddStruct) { NFIObject go = mKernelModule.GetObject(self); if (go == null) { return; } NFIRecordManager xRecordManager = go.GetRecordManager(); Hashtable recordVecDesc = new Hashtable(); Hashtable recordVecData = new Hashtable(); for (int k = 0; k < xAddStruct.record_int_list.Count; ++k) { NFMsg.RecordInt addIntStruct = (NFMsg.RecordInt)xAddStruct.record_int_list[k]; if (addIntStruct.col >= 0) { recordVecDesc[addIntStruct.col] = NFDataList.VARIANT_TYPE.VTYPE_INT; recordVecData[addIntStruct.col] = addIntStruct.data; } } for (int k = 0; k < xAddStruct.record_float_list.Count; ++k) { NFMsg.RecordFloat addFloatStruct = (NFMsg.RecordFloat)xAddStruct.record_float_list[k]; if (addFloatStruct.col >= 0) { recordVecDesc[addFloatStruct.col] = NFDataList.VARIANT_TYPE.VTYPE_FLOAT; recordVecData[addFloatStruct.col] = addFloatStruct.data; } } for (int k = 0; k < xAddStruct.record_string_list.Count; ++k) { NFMsg.RecordString addStringStruct = (NFMsg.RecordString)xAddStruct.record_string_list[k]; if (addStringStruct.col >= 0) { recordVecDesc[addStringStruct.col] = NFDataList.VARIANT_TYPE.VTYPE_STRING; recordVecData[addStringStruct.col] = System.Text.Encoding.Default.GetString(addStringStruct.data); } } for (int k = 0; k < xAddStruct.record_object_list.Count; ++k) { NFMsg.RecordObject addObjectStruct = (NFMsg.RecordObject)xAddStruct.record_object_list[k]; if (addObjectStruct.col >= 0) { recordVecDesc[addObjectStruct.col] = NFDataList.VARIANT_TYPE.VTYPE_OBJECT; recordVecData[addObjectStruct.col] = mHelpModule.PBToNF(addObjectStruct.data); } } for (int k = 0; k < xAddStruct.record_vector2_list.Count; ++k) { NFMsg.RecordVector2 addObjectStruct = (NFMsg.RecordVector2)xAddStruct.record_vector2_list[k]; if (addObjectStruct.col >= 0) { recordVecDesc[addObjectStruct.col] = NFDataList.VARIANT_TYPE.VTYPE_VECTOR2; recordVecData[addObjectStruct.col] = mHelpModule.PBToNF(addObjectStruct.data); } } for (int k = 0; k < xAddStruct.record_vector3_list.Count; ++k) { NFMsg.RecordVector3 addObjectStruct = (NFMsg.RecordVector3)xAddStruct.record_vector3_list[k]; if (addObjectStruct.col >= 0) { recordVecDesc[addObjectStruct.col] = NFDataList.VARIANT_TYPE.VTYPE_VECTOR3; recordVecData[addObjectStruct.col] = mHelpModule.PBToNF(addObjectStruct.data); } } NFDataList varListDesc = new NFDataList(); NFDataList varListData = new NFDataList(); for (int m = 0; m < recordVecDesc.Count; m++) { if (recordVecDesc.ContainsKey(m) && recordVecData.ContainsKey(m)) { NFDataList.VARIANT_TYPE nType = (NFDataList.VARIANT_TYPE)recordVecDesc[m]; switch (nType) { case NFDataList.VARIANT_TYPE.VTYPE_INT: { varListDesc.AddInt(0); varListData.AddInt((Int64)recordVecData[m]); } break; case NFDataList.VARIANT_TYPE.VTYPE_FLOAT: { varListDesc.AddFloat(0.0f); varListData.AddFloat((float)recordVecData[m]); } break; case NFDataList.VARIANT_TYPE.VTYPE_STRING: { varListDesc.AddString(""); varListData.AddString((string)recordVecData[m]); } break; case NFDataList.VARIANT_TYPE.VTYPE_OBJECT: { varListDesc.AddObject(new NFGUID()); varListData.AddObject((NFGUID)recordVecData[m]); } break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR2: { varListDesc.AddVector2(new NFVector2()); varListData.AddVector2((NFVector2)recordVecData[m]); } break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR3: { varListDesc.AddVector3(new NFVector3()); varListData.AddVector3((NFVector3)recordVecData[m]); } break; default: break; } } else { //���� //Debug.LogException(i); } } NFIRecord xRecord = xRecordManager.GetRecord(strRecordName); if (null == xRecord) { string strClassName = mKernelModule.QueryPropertyString(self, NFrame.IObject.ClassName); NFIClass xLogicClass = mClassModule.GetElement(strClassName); NFIRecord xStaticRecord = xLogicClass.GetRecordManager().GetRecord(strRecordName); xRecord = xRecordManager.AddRecord(strRecordName, 512, varListDesc, xStaticRecord.GetTagData()); } xRecord.AddRow(xAddStruct.row, varListData); }
private void ADD_ROW(NFGUID self, string strRecordName, NFMsg.RecordAddRowStruct xAddStruct) { NFIObject go = NFCKernelModule.Instance().GetObject(self); NFIRecordManager xRecordManager = go.GetRecordManager(); Hashtable recordVecDesc = new Hashtable(); Hashtable recordVecData = new Hashtable(); for (int k = 0; k < xAddStruct.record_int_list.Count; ++k) { NFMsg.RecordInt addIntStruct = (NFMsg.RecordInt)xAddStruct.record_int_list[k]; if (addIntStruct.col >= 0) { recordVecDesc[addIntStruct.col] = NFIDataList.VARIANT_TYPE.VTYPE_INT; recordVecData[addIntStruct.col] = addIntStruct.data; } } for (int k = 0; k < xAddStruct.record_float_list.Count; ++k) { NFMsg.RecordFloat addFloatStruct = (NFMsg.RecordFloat)xAddStruct.record_float_list[k]; if (addFloatStruct.col >= 0) { recordVecDesc[addFloatStruct.col] = NFIDataList.VARIANT_TYPE.VTYPE_FLOAT; recordVecData[addFloatStruct.col] = addFloatStruct.data; } } for (int k = 0; k < xAddStruct.record_string_list.Count; ++k) { NFMsg.RecordString addStringStruct = (NFMsg.RecordString)xAddStruct.record_string_list[k]; if (addStringStruct.col >= 0) { recordVecDesc[addStringStruct.col] = NFIDataList.VARIANT_TYPE.VTYPE_STRING; recordVecData[addStringStruct.col] = System.Text.Encoding.Default.GetString(addStringStruct.data); } } for (int k = 0; k < xAddStruct.record_object_list.Count; ++k) { NFMsg.RecordObject addObjectStruct = (NFMsg.RecordObject)xAddStruct.record_object_list[k]; if (addObjectStruct.col >= 0) { recordVecDesc[addObjectStruct.col] = NFIDataList.VARIANT_TYPE.VTYPE_OBJECT; recordVecData[addObjectStruct.col] = PBToNF(addObjectStruct.data); } } NFIDataList varListDesc = new NFCDataList(); NFIDataList varListData = new NFCDataList(); for (int m = 0; m < recordVecDesc.Count; m++) { if (recordVecDesc.ContainsKey(m) && recordVecData.ContainsKey(m)) { NFIDataList.VARIANT_TYPE nType = (NFIDataList.VARIANT_TYPE)recordVecDesc[m]; switch (nType) { case NFIDataList.VARIANT_TYPE.VTYPE_INT: { varListDesc.AddInt(0); varListData.AddInt((Int64)recordVecData[m]); } break; case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT: { varListDesc.AddFloat(0.0f); varListData.AddFloat((float)recordVecData[m]); } break; case NFIDataList.VARIANT_TYPE.VTYPE_STRING: { varListDesc.AddString(""); varListData.AddString((string)recordVecData[m]); } break; case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT: { varListDesc.AddObject(new NFGUID()); varListData.AddObject((NFGUID)recordVecData[m]); } break; default: break; } } else { //报错 //Debug.LogException(i); } } NFIRecord xRecord = xRecordManager.GetRecord(strRecordName); if (null == xRecord) { xRecord = xRecordManager.AddRecord(strRecordName, 512, varListDesc); } xRecord.AddRow(xAddStruct.row, varListData); }