Example #1
0
        static MethodBase GetTargetMethod()
        {
            if (Patch.Debug)
            {
                Log("Finding Inner Type:");
            }
            //	var inner = typeof(WorldManager).GetNestedTypes().First((type) => type.Name.StartsWith("<LoadGameData>"));
            var inner = AccessTools.FindIncludingInnerTypes(typeof(WorldManager), (type) =>
            {
                //type.Name.StartsWith("<LoadGameData>") ? type : null
                if (Patch.Debug)
                {
                    Log($"\tType:{type.Name}");
                }
                return(type.Name.StartsWith("<LoadGameData>") ? type : null);
            });

            if (Patch.Debug)
            {
                Log($"Found type:{inner.Name}");
            }
            var method = AccessTools.Method(inner, "MoveNext");

            if (Patch.Debug)
            {
                Log($"\tMethod:{method.Name}");
            }
            return(method);
        }