//TODO: We need a way of fingerprinting this class to verify that the other endpoints have // the same encoding/decoding formatting. public EntityDescriptorCache() { FieldCache = new FieldDescriptorCache(this); // This is done to reserve EntityDescriptor.NullTypeID = 0. EntityFactories.Add(null); }
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(); }