我正在尝试构建一个索引类中每个静态方法的字典,以便可以使用字符串查找它们。我似乎无法找到一种方法来实际从 MethodInfo 中获取对该方法的引用。这可能吗?
delegate void SkillEffect(BattleActor actor, BattleActor target);
public static class SkillEffectLookup
{
public static Dictionary<string, SkillEffect> lookup;
public static void Build()
{
lookup = new Dictionary<string, SkillEffect>();
Type type = typeof(SkillEffects);
var methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public);
foreach (MethodInfo methodInfo in methods)
{
lookup.Add(methodInfo.Name, _____________);
}
}
public static class SkillEffects
{
public static Attack(BattleActor actor, BattleActor target)
{
// Do Things
}
public static NonAttack(BattleActor actor, BattleActor target)
{
// Do Other Things
}
}