public void SetPropertyValue(int propertyId, byte[] valueBytes) { var server = false; #if SERVER server = true; #endif var propertyCollection = EntityDefine.PropertyCollectionMap[EntityDefine.GetTypeId(GetType())]; var reactPropertyCollection = EntityDefine.ReactPropertyCollectionMap[EntityDefine.GetTypeId(GetType())]; var propertyInfo = propertyCollection[propertyId]; var reactPropertyInfo = reactPropertyCollection[propertyId]; if (propertyInfo == null) { Log.Error($"Error {propertyId} propertyInfo == null {propertyInfo}"); return; } if (propertyInfo.PropertyType == typeof(int)) { if (server) { propertyInfo.SetValue(this, MongoHelper.ToInt(valueBytes)); } else { typeof(ReactProperty <int>).GetProperty("Value").SetValue(reactPropertyInfo.GetValue(this), MongoHelper.ToInt(valueBytes)); } } if (propertyInfo.PropertyType == typeof(float)) { if (server) { propertyInfo.SetValue(this, MongoHelper.ToFloat(valueBytes)); } else { typeof(ReactProperty <float>).GetProperty("Value").SetValue(reactPropertyInfo.GetValue(this), MongoHelper.ToFloat(valueBytes)); } } if (propertyInfo.PropertyType == typeof(string)) { if (server) { propertyInfo.SetValue(this, MongoHelper.ToString(valueBytes)); } else { typeof(ReactProperty <string>).GetProperty("Value").SetValue(reactPropertyInfo.GetValue(this), MongoHelper.ToString(valueBytes)); } } if (propertyInfo.PropertyType == typeof(Vector3)) { if (server) { propertyInfo.SetValue(this, MongoHelper.FromBson <Vector3>(valueBytes)); } else { typeof(ReactProperty <Vector3>).GetProperty("Value").SetValue(reactPropertyInfo.GetValue(this), MongoHelper.FromBson <Vector3>(valueBytes)); } } }