예제 #1
0
    private void PatchAttackGoals()
    {
        var aiGoals = ReflectiveEnumerator.GetDerivedTypes <AIGoal>();

        foreach (var aiGoalType in aiGoals)
        {
            var goal = InstantiateGoal(aiGoalType);
            if (goal == null)
            {
                continue;
            }
            if (!goal.IsAttackGoal())
            {
                continue;
            }

            Debug.Log(string.Format("{0}: Patching {1}... ", ModName, goal.GetType().Name));
            var original = aiGoalType.GetMethod("ShouldPerform");
            var prefix   = typeof(GoalAttackPatch).GetMethod("Prefix");
            m_harmony.Patch(original, new HarmonyMethod(prefix));
        }

        Debug.Log(string.Format("{0}: Patching done... ", ModName));
    }