コード例 #1
0
        public void GenerateFieldDescriptors(Type type, FieldDescriptorCache fieldGenerator)
        {
            EntityType  = type;
            Constructor = DelegateGenerator.GenerateConstructor <object>(type);

            List <FieldDescriptor> descriptors = new List <FieldDescriptor>();

            AttributeHelper.ForAllFieldsWithAttribute <SynchronisableAttribute>(type,
                                                                                (fieldInfo, attribute) => {
                descriptors.Add(fieldGenerator.GetFieldDescriptor(fieldInfo, attribute.Flags));
            });
            AttributeHelper.ForAllPropertiesWithAttribute <SynchronisableAttribute>(type,
                                                                                    (propInfo, attribute) => {
                descriptors.Add(fieldGenerator.GetFieldDescriptor(propInfo, attribute.Flags));
            });

            if (descriptors.Count >= byte.MaxValue)
            {
                throw new NetcodeItemcountException(string.Format("Type {0} contains more than {1} synchronisable fields.", type.Name, byte.MaxValue));
            }

            Fields = descriptors.ToArray();
        }