public static void TryRegister(Type type) { string name = type.Name; var behaviorNodeAttribute = (BehaviorTreeNodeAttribute)type.GetCustomAttributes(typeof(BehaviorTreeNodeAttribute), true).FirstOrDefault(); if (behaviorNodeAttribute != null) { if (!behaviorNodeAttribute.Register) { return; } if (!string.IsNullOrEmpty(behaviorNodeAttribute.Name)) { name = behaviorNodeAttribute.Name; } } if (_registry.ContainsKey(name)) { return; } if (_registry.Values.Any(x => x.NodeType == type)) { return; } var creator = new GenericNodeCreator(type); _registry.Add(name, creator); Global.gEnv.pMonoRuntime.RegisterManagedNodeCreator(name, creator); }
public static void TryRegister(Type type) { if (!typeof(BehaviorTreeNodeBase).IsAssignableFrom(type) || type.IsAbstract) { return; } string name = type.Name; BehaviorTreeNodeAttribute behaviorNodeAttribute = (BehaviorTreeNodeAttribute)type.GetCustomAttributes(typeof(BehaviorTreeNodeAttribute), true).FirstOrDefault(); if (behaviorNodeAttribute != null) { if (!behaviorNodeAttribute.Register) { return; } else if (!String.IsNullOrEmpty(behaviorNodeAttribute.Name)) { name = behaviorNodeAttribute.Name; } } if (s_registry.ContainsKey(name)) { return; } if (s_registry.Values.Any(x => x.NodeType == type)) { return; } GenericNodeCreator creator = new GenericNodeCreator(type); s_registry.Add(name, creator); Global.gEnv.pMonoRuntime.RegisterManagedNodeCreator(name, creator); }