Exemple #1
0
 public static void LoadTypes(Type[] types)
 {
     foreach (var type in types)
     {
         var attribute = (ItemAttribute)type.GetCustomAttributes(typeof(ItemAttribute), false).First();
         var initializerType = type;
         if (attribute.InitializerType != null)
             initializerType = attribute.InitializerType;
         var method = initializerType.GetMethods().FirstOrDefault(m => m.Name == attribute.Initializer
             && m.GetParameters().Length == 1 && m.GetParameters()[0].ParameterType == typeof(ItemLogicDescriptor) && !m.IsGenericMethod);
         var descriptor = new ItemLogicDescriptor(type);
         if (method != null)
             descriptor = (ItemLogicDescriptor)method.Invoke(null, new object[] { descriptor });
         ItemLogicDescriptors[attribute.ItemId] = descriptor;
     }
 }
Exemple #2
0
 public static ItemLogicDescriptor Initialize(ItemLogicDescriptor descriptor)
 {
     descriptor.ItemUsedOnBlock = OnItemUsedOnBlock;
     return descriptor;
 }