public Ability() { object[] objAttributes = GetType().GetCustomAttributes(typeof(SynthActionAttribute), false); Debug.Assert(objAttributes.Length == 1); SynthActionAttribute attributes = (SynthActionAttribute)objAttributes[0]; cp = attributes.CP; name = attributes.Name; id = attributes.ActionId; type = attributes.ActionType; }
public void AddAllActions() { Assembly thisAssembly = Assembly.GetExecutingAssembly(); foreach (Type info in thisAssembly.GetTypes()) { object[] attributes = info.GetCustomAttributes(typeof(SynthActionAttribute), false); if (attributes.Length == 1) { SynthActionAttribute attribute = (SynthActionAttribute)attributes[0]; if (!attribute.Disabled) { object action = info.GetConstructor(Type.EmptyTypes).Invoke(null); AddAction((Ability)action); } } } }