private void OnObjectRecordEntry(UInt16 id, MemoryStream stream) { NFMsg.MsgBase xMsg = NFMsg.MsgBase.Parser.ParseFrom(stream); NFMsg.MultiObjectRecordList xMultiObjectRecordData = NFMsg.MultiObjectRecordList.Parser.ParseFrom(xMsg.msg_data); for (int i = 0; i < xMultiObjectRecordData.multi_player_record.Count; i++) { NFMsg.ObjectRecordList xObjectRecordList = xMultiObjectRecordData.multi_player_record[i]; for (int j = 0; j < xObjectRecordList.record_list.Count; j++) { NFMsg.ObjectRecordBase xObjectRecordBase = xObjectRecordList.record_list[j]; for (int k = 0; k < xObjectRecordBase.row_struct.Count; ++k) { NFMsg.RecordAddRowStruct xAddRowStruct = xObjectRecordBase.row_struct[k]; ADD_ROW(mHelpModule.PBToNF(xObjectRecordList.player_id), xObjectRecordBase.record_name.ToStringUtf8(), xAddRowStruct); } } } }
private void OnObjectRecordEntry(UInt16 id, MemoryStream stream) { NFMsg.MsgBase xMsg = new NFMsg.MsgBase(); xMsg = Serializer.Deserialize <NFMsg.MsgBase>(stream); NFMsg.MultiObjectRecordList xMultiObjectRecordData = new NFMsg.MultiObjectRecordList(); xMultiObjectRecordData = Serializer.Deserialize <NFMsg.MultiObjectRecordList>(new MemoryStream(xMsg.msg_data)); for (int i = 0; i < xMultiObjectRecordData.multi_player_record.Count; i++) { NFMsg.ObjectRecordList xObjectRecordList = xMultiObjectRecordData.multi_player_record[i]; for (int j = 0; j < xObjectRecordList.record_list.Count; j++) { NFMsg.ObjectRecordBase xObjectRecordBase = xObjectRecordList.record_list[j]; for (int k = 0; k < xObjectRecordBase.row_struct.Count; ++k) { NFMsg.RecordAddRowStruct xAddRowStruct = xObjectRecordBase.row_struct[k]; ADD_ROW(mHelpModule.PBToNF(xObjectRecordList.player_id), System.Text.Encoding.Default.GetString(xObjectRecordBase.record_name), xAddRowStruct); } } } }
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); }
public void RequireAddRow(NFGUID objectID, string strRecordName, int nRow) { NFMsg.ObjectRecordAddRow xData = new NFMsg.ObjectRecordAddRow(); xData.PlayerId = mHelpModule.NFToPB(objectID); xData.RecordName = ByteString.CopyFromUtf8(strRecordName); NFMsg.RecordAddRowStruct xRecordAddRowStruct = new NFMsg.RecordAddRowStruct(); xData.RowData.Add(xRecordAddRowStruct); xRecordAddRowStruct.Row = nRow; NFIObject xObject = mKernelModule.GetObject(objectID); NFIRecord xRecord = xObject.GetRecordManager().GetRecord(strRecordName); NFDataList xRowData = xRecord.QueryRow(nRow); for (int i = 0; i < xRowData.Count(); i++) { switch (xRowData.GetType(i)) { case NFDataList.VARIANT_TYPE.VTYPE_INT: { NFMsg.RecordInt xRecordInt = new NFMsg.RecordInt(); xRecordInt.Row = nRow; xRecordInt.Col = i; xRecordInt.Data = xRowData.IntVal(i); xRecordAddRowStruct.RecordIntList.Add(xRecordInt); } break; case NFDataList.VARIANT_TYPE.VTYPE_FLOAT: { NFMsg.RecordFloat xRecordFloat = new NFMsg.RecordFloat(); xRecordFloat.Row = nRow; xRecordFloat.Col = i; xRecordFloat.Data = (float)xRowData.FloatVal(i); xRecordAddRowStruct.RecordFloatList.Add(xRecordFloat); } break; case NFDataList.VARIANT_TYPE.VTYPE_STRING: { NFMsg.RecordString xRecordString = new NFMsg.RecordString(); xRecordString.Row = nRow; xRecordString.Col = i; xRecordString.Data = ByteString.CopyFromUtf8(xRowData.StringVal(i)); xRecordAddRowStruct.RecordStringList.Add(xRecordString); } break; case NFDataList.VARIANT_TYPE.VTYPE_OBJECT: { NFMsg.RecordObject xRecordObject = new NFMsg.RecordObject(); xRecordObject.Row = nRow; xRecordObject.Col = i; xRecordObject.Data = mHelpModule.NFToPB(xRowData.ObjectVal(i)); xRecordAddRowStruct.RecordObjectList.Add(xRecordObject); } break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR2: { NFMsg.RecordVector2 xRecordVector = new NFMsg.RecordVector2(); xRecordVector.Row = nRow; xRecordVector.Col = i; xRecordVector.Data = mHelpModule.NFToPB(xRowData.Vector2Val(i)); xRecordAddRowStruct.RecordVector2List.Add(xRecordVector); } break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR3: { NFMsg.RecordVector3 xRecordVector = new NFMsg.RecordVector3(); xRecordVector.Row = nRow; xRecordVector.Col = i; xRecordVector.Data = mHelpModule.NFToPB(xRowData.Vector3Val(i)); xRecordAddRowStruct.RecordVector3List.Add(xRecordVector); } break; } } mxBody.SetLength(0); xData.WriteTo(mxBody); Debug.Log("send upload record addRow"); SendMsg((int)NFMsg.EGameMsgID.AckAddRow, mxBody); }
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); }
private void AttachObjectData(NFGUID self) { //Debug.Log ("AttachObjectData : " + self.ToString () ); ObjectDataBuff xDataBuff; if (mxObjectDataBuff.TryGetValue(self, out xDataBuff)) { ////////////////record if (xDataBuff.xRecordList != null) { for (int j = 0; j < xDataBuff.xRecordList.RecordList.Count; j++) { NFMsg.ObjectRecordBase xObjectRecordBase = xDataBuff.xRecordList.RecordList[j]; string srRecordName = xObjectRecordBase.RecordName.ToStringUtf8(); for (int k = 0; k < xObjectRecordBase.RowStruct.Count; ++k) { NFMsg.RecordAddRowStruct xAddRowStruct = xObjectRecordBase.RowStruct[k]; ADD_ROW(self, xObjectRecordBase.RecordName.ToStringUtf8(), xAddRowStruct); } } xDataBuff.xRecordList = null; } ////////////////property if (xDataBuff.xPropertyList != null) { /// NFIObject go = mKernelModule.GetObject(mHelpModule.PBToNF(xDataBuff.xPropertyList.PlayerId)); NFIPropertyManager xPropertyManager = go.GetPropertyManager(); for (int j = 0; j < xDataBuff.xPropertyList.PropertyIntList.Count; j++) { string strPropertyName = xDataBuff.xPropertyList.PropertyIntList[j].PropertyName.ToStringUtf8(); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_INT); xProperty = xPropertyManager.AddProperty(strPropertyName, var); } //string className = mKernelModule.QueryPropertyString(self, NFrame.IObject.ClassName); //Debug.LogError (self.ToString() + " " + className + " " + strPropertyName + " : " + xDataBuff.xPropertyList.property_int_list[j].Data); xProperty.SetInt(xDataBuff.xPropertyList.PropertyIntList[j].Data); } for (int j = 0; j < xDataBuff.xPropertyList.PropertyFloatList.Count; j++) { string strPropertyName = xDataBuff.xPropertyList.PropertyFloatList[j].PropertyName.ToStringUtf8(); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_FLOAT); xProperty = xPropertyManager.AddProperty(strPropertyName, var); } xProperty.SetFloat(xDataBuff.xPropertyList.PropertyFloatList[j].Data); } for (int j = 0; j < xDataBuff.xPropertyList.PropertyStringList.Count; j++) { string strPropertyName = xDataBuff.xPropertyList.PropertyStringList[j].PropertyName.ToStringUtf8(); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_STRING); xProperty = xPropertyManager.AddProperty(strPropertyName, var); } //string className = mKernelModule.QueryPropertyString(self, NFrame.IObject.ClassName); //Debug.LogError(self.ToString() + " " + className + " " + strPropertyName + " : " + xDataBuff.xPropertyList.property_string_list[j].Data.ToStringUtf8()); xProperty.SetString(xDataBuff.xPropertyList.PropertyStringList[j].Data.ToStringUtf8()); } for (int j = 0; j < xDataBuff.xPropertyList.PropertyObjectList.Count; j++) { string strPropertyName = xDataBuff.xPropertyList.PropertyObjectList[j].PropertyName.ToStringUtf8(); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_OBJECT); xProperty = xPropertyManager.AddProperty(strPropertyName, var); } xProperty.SetObject(mHelpModule.PBToNF(xDataBuff.xPropertyList.PropertyObjectList[j].Data)); } for (int j = 0; j < xDataBuff.xPropertyList.PropertyVector2List.Count; j++) { string strPropertyName = xDataBuff.xPropertyList.PropertyVector2List[j].PropertyName.ToStringUtf8(); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_VECTOR2); xProperty = xPropertyManager.AddProperty(strPropertyName, var); } xProperty.SetVector2(mHelpModule.PBToNF(xDataBuff.xPropertyList.PropertyVector2List[j].Data)); } for (int j = 0; j < xDataBuff.xPropertyList.PropertyVector3List.Count; j++) { string strPropertyName = xDataBuff.xPropertyList.PropertyVector3List[j].PropertyName.ToStringUtf8(); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_VECTOR3); xProperty = xPropertyManager.AddProperty(strPropertyName, var); } xProperty.SetVector3(mHelpModule.PBToNF(xDataBuff.xPropertyList.PropertyVector3List[j].Data)); } xDataBuff.xPropertyList = null; } } }
public void RequireAddRow(NFrame.NFGUID self, string strRecordName, int nRow) { NFMsg.ObjectRecordAddRow xData = new NFMsg.ObjectRecordAddRow(); xData.player_id = NFBinarySendLogic.NFToPB(self); xData.record_name = System.Text.Encoding.Default.GetBytes(strRecordName); NFMsg.RecordAddRowStruct xRecordAddRowStruct = new NFMsg.RecordAddRowStruct(); xData.row_data.Add(xRecordAddRowStruct); xRecordAddRowStruct.row = nRow; NFIObject xObject = NFCKernelModule.Instance.GetObject(self); NFIRecord xRecord = xObject.GetRecordManager().GetRecord(strRecordName); NFIDataList xRowData = xRecord.QueryRow(nRow); for (int i = 0; i < xRowData.Count(); i++) { switch (xRowData.GetType(i)) { case NFIDataList.VARIANT_TYPE.VTYPE_INT: { NFMsg.RecordInt xRecordInt = new NFMsg.RecordInt(); xRecordInt.row = nRow; xRecordInt.col = i; xRecordInt.data = xRowData.IntVal(i); xRecordAddRowStruct.record_int_list.Add(xRecordInt); } break; case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT: { NFMsg.RecordFloat xRecordFloat = new NFMsg.RecordFloat(); xRecordFloat.row = nRow; xRecordFloat.col = i; xRecordFloat.data = (float)xRowData.FloatVal(i); xRecordAddRowStruct.record_float_list.Add(xRecordFloat); } break; case NFIDataList.VARIANT_TYPE.VTYPE_STRING: { NFMsg.RecordString xRecordString = new NFMsg.RecordString(); xRecordString.row = nRow; xRecordString.col = i; xRecordString.data = System.Text.Encoding.Default.GetBytes(xRowData.StringVal(i)); xRecordAddRowStruct.record_string_list.Add(xRecordString); } break; case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT: { NFMsg.RecordObject xRecordObject = new NFMsg.RecordObject(); xRecordObject.row = nRow; xRecordObject.col = i; xRecordObject.data = NFBinarySendLogic.NFToPB(xRowData.ObjectVal(i)); xRecordAddRowStruct.record_object_list.Add(xRecordObject); } break; case NFIDataList.VARIANT_TYPE.VTYPE_VECTOR2: { NFMsg.RecordVector2 xRecordVector = new NFMsg.RecordVector2(); xRecordVector.row = nRow; xRecordVector.col = i; xRecordVector.data = NFBinarySendLogic.NFToPB(xRowData.Vector2Val(i)); xRecordAddRowStruct.record_vector2_list.Add(xRecordVector); } break; case NFIDataList.VARIANT_TYPE.VTYPE_VECTOR3: { NFMsg.RecordVector3 xRecordVector = new NFMsg.RecordVector3(); xRecordVector.row = nRow; xRecordVector.col = i; xRecordVector.data = NFBinarySendLogic.NFToPB(xRowData.Vector3Val(i)); xRecordAddRowStruct.record_vector3_list.Add(xRecordVector); } break; } } MemoryStream stream = new MemoryStream(); Serializer.Serialize <NFMsg.ObjectRecordAddRow>(stream, xData); Debug.Log("send upload record addRow"); SendMsg(self, NFMsg.EGameMsgID.EGMI_ACK_ADD_ROW, stream); }
private void AttachObjectData(NFGUID self) { ObjectDataBuff xDataBuff; if (mxObjectDataBuff.TryGetValue(self, out xDataBuff)) { ////////////////record for (int j = 0; j < xDataBuff.xRecordList.record_list.Count; j++) { NFMsg.ObjectRecordBase xObjectRecordBase = xDataBuff.xRecordList.record_list[j]; string srRecordName = System.Text.Encoding.Default.GetString(xObjectRecordBase.record_name); for (int k = 0; k < xObjectRecordBase.row_struct.Count; ++k) { NFMsg.RecordAddRowStruct xAddRowStruct = xObjectRecordBase.row_struct[k]; ADD_ROW(self, System.Text.Encoding.Default.GetString(xObjectRecordBase.record_name), xAddRowStruct); } } ////////////////property NFIObject go = NFCKernelModule.Instance.GetObject(NFNetController.PBToNF(xDataBuff.xPropertyList.player_id)); NFIPropertyManager xPropertyManager = go.GetPropertyManager(); for (int j = 0; j < xDataBuff.xPropertyList.property_int_list.Count; j++) { string strPropertyName = System.Text.Encoding.Default.GetString(xDataBuff.xPropertyList.property_int_list[j].property_name); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList varList = new NFDataList(); varList.AddInt(0); xProperty = xPropertyManager.AddProperty(strPropertyName, varList); } xProperty.SetInt(xDataBuff.xPropertyList.property_int_list[j].data); } for (int j = 0; j < xDataBuff.xPropertyList.property_float_list.Count; j++) { string strPropertyName = System.Text.Encoding.Default.GetString(xDataBuff.xPropertyList.property_float_list[j].property_name); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList varList = new NFDataList(); varList.AddFloat(0); xProperty = xPropertyManager.AddProperty(strPropertyName, varList); } xProperty.SetFloat(xDataBuff.xPropertyList.property_float_list[j].data); } for (int j = 0; j < xDataBuff.xPropertyList.property_string_list.Count; j++) { string strPropertyName = System.Text.Encoding.Default.GetString(xDataBuff.xPropertyList.property_string_list[j].property_name); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList varList = new NFDataList(); varList.AddString(""); xProperty = xPropertyManager.AddProperty(strPropertyName, varList); } xProperty.SetString(System.Text.Encoding.Default.GetString(xDataBuff.xPropertyList.property_string_list[j].data)); } for (int j = 0; j < xDataBuff.xPropertyList.property_object_list.Count; j++) { string strPropertyName = System.Text.Encoding.Default.GetString(xDataBuff.xPropertyList.property_object_list[j].property_name); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList varList = new NFDataList(); varList.AddObject(new NFGUID()); xProperty = xPropertyManager.AddProperty(strPropertyName, varList); } xProperty.SetObject(NFNetController.PBToNF(xDataBuff.xPropertyList.property_object_list[j].data)); } } }
public void RequireAddRow(NFrame.NFGUID self, string strRecordName, int nRow) { NFMsg.ObjectRecordAddRow xData = new NFMsg.ObjectRecordAddRow(); xData.player_id = NFBinarySendLogic.NFToPB(self); xData.record_name = System.Text.Encoding.Default.GetBytes(strRecordName); NFMsg.RecordAddRowStruct xRecordAddRowStruct = new NFMsg.RecordAddRowStruct(); xData.row_data.Add(xRecordAddRowStruct); xRecordAddRowStruct.row = nRow; NFIObject xObject = NFCKernelModule.Instance.GetObject(self); NFIRecord xRecord = xObject.GetRecordManager().GetRecord(strRecordName); NFIDataList xRowData = xRecord.QueryRow(nRow); for(int i = 0;i<xRowData.Count();i++) { switch(xRowData.GetType(i)) { case NFIDataList.VARIANT_TYPE.VTYPE_INT: { NFMsg.RecordInt xRecordInt = new NFMsg.RecordInt(); xRecordInt.row = nRow; xRecordInt.col = i; xRecordInt.data = xRowData.IntVal(i); xRecordAddRowStruct.record_int_list.Add(xRecordInt); } break; case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT: { NFMsg.RecordFloat xRecordFloat = new NFMsg.RecordFloat(); xRecordFloat.row = nRow; xRecordFloat.col = i; xRecordFloat.data = (float)xRowData.FloatVal(i); xRecordAddRowStruct.record_float_list.Add(xRecordFloat); } break; case NFIDataList.VARIANT_TYPE.VTYPE_STRING: { NFMsg.RecordString xRecordString = new NFMsg.RecordString(); xRecordString.row = nRow; xRecordString.col = i; xRecordString.data = System.Text.Encoding.Default.GetBytes(xRowData.StringVal(i)); xRecordAddRowStruct.record_string_list.Add(xRecordString); } break; case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT: { NFMsg.RecordObject xRecordObject = new NFMsg.RecordObject(); xRecordObject.row = nRow; xRecordObject.col = i; xRecordObject.data = NFBinarySendLogic.NFToPB(xRowData.ObjectVal(i)); xRecordAddRowStruct.record_object_list.Add(xRecordObject); } break; case NFIDataList.VARIANT_TYPE.VTYPE_VECTOR2: { NFMsg.RecordVector2 xRecordVector = new NFMsg.RecordVector2(); xRecordVector.row = nRow; xRecordVector.col = i; xRecordVector.data = NFBinarySendLogic.NFToPB(xRowData.Vector2Val(i)); xRecordAddRowStruct.record_vector2_list.Add(xRecordVector); } break; case NFIDataList.VARIANT_TYPE.VTYPE_VECTOR3: { NFMsg.RecordVector3 xRecordVector = new NFMsg.RecordVector3(); xRecordVector.row = nRow; xRecordVector.col = i; xRecordVector.data = NFBinarySendLogic.NFToPB(xRowData.Vector3Val(i)); xRecordAddRowStruct.record_vector3_list.Add(xRecordVector); } break; } } MemoryStream stream = new MemoryStream(); Serializer.Serialize<NFMsg.ObjectRecordAddRow>(stream, xData); Debug.Log("send upload record addRow"); SendMsg(self, NFMsg.EGameMsgID.EGMI_ACK_ADD_ROW, stream); }
private void ADD_ROW(NFGUID self, string strRecordName, NFMsg.RecordAddRowStruct xAddStruct) { NFIObject go = mKernelModule.GetObject(self); if (go == null) { Debug.LogError("error id" + self); return; } NFIRecordManager xRecordManager = go.GetRecordManager(); Hashtable recordVecDesc = new Hashtable(); Hashtable recordVecData = new Hashtable(); for (int k = 0; k < xAddStruct.RecordIntList.Count; ++k) { NFMsg.RecordInt addIntStruct = (NFMsg.RecordInt)xAddStruct.RecordIntList[k]; if (addIntStruct.Col >= 0) { recordVecDesc[addIntStruct.Col] = NFDataList.VARIANT_TYPE.VTYPE_INT; recordVecData[addIntStruct.Col] = addIntStruct.Data; } } for (int k = 0; k < xAddStruct.RecordFloatList.Count; ++k) { NFMsg.RecordFloat addFloatStruct = (NFMsg.RecordFloat)xAddStruct.RecordFloatList[k]; if (addFloatStruct.Col >= 0) { recordVecDesc[addFloatStruct.Col] = NFDataList.VARIANT_TYPE.VTYPE_FLOAT; recordVecData[addFloatStruct.Col] = addFloatStruct.Data; } } for (int k = 0; k < xAddStruct.RecordStringList.Count; ++k) { NFMsg.RecordString addStringStruct = (NFMsg.RecordString)xAddStruct.RecordStringList[k]; if (addStringStruct.Col >= 0) { recordVecDesc[addStringStruct.Col] = NFDataList.VARIANT_TYPE.VTYPE_STRING; if (addStringStruct.Data != null) { recordVecData[addStringStruct.Col] = addStringStruct.Data.ToStringUtf8(); } else { recordVecData[addStringStruct.Col] = ""; } } } for (int k = 0; k < xAddStruct.RecordObjectList.Count; ++k) { NFMsg.RecordObject addObjectStruct = (NFMsg.RecordObject)xAddStruct.RecordObjectList[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.RecordVector2List.Count; ++k) { NFMsg.RecordVector2 addObjectStruct = (NFMsg.RecordVector2)xAddStruct.RecordVector2List[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.RecordVector3List.Count; ++k) { NFMsg.RecordVector3 addObjectStruct = (NFMsg.RecordVector3)xAddStruct.RecordVector3List[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) { Debug.Log("Empty record:" + strRecordName); 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()); } if (self.IsNull()) { StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < varListData.Count(); ++i) { stringBuilder.Append(varListData.GetData(i).ToString()); stringBuilder.Append(";"); } Debug.Log(strRecordName + " add row:" + stringBuilder.ToString()); } xRecord.AddRow(xAddStruct.Row, varListData); }