Example #1
0
        private static void MassPatchFormerHumanChecks([NotNull] Harmony harmonyInstance)
        {
            var staticFlags   = BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public;
            var instanceFlags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;



            List <MethodInfo> methodsToPatch = new List <MethodInfo>();

            //bed stuff
            var bedUtilType     = typeof(RestUtility);
            var canUseBedMethod = bedUtilType.GetMethod(nameof(RestUtility.CanUseBedEver), staticFlags);

            methodsToPatch.Add(canUseBedMethod);

            //animal tabs
            var methods = typeof(MainTabWindow_Animals).GetNestedTypes(staticFlags | instanceFlags)//looking for delegates used by the animal tab
                          .Where(t => t.IsCompilerGenerated())
                          .SelectMany(t => t.GetMethods(instanceFlags).Where(m => m.HasSignature(typeof(Pawn))));

            methodsToPatch.AddRange(methods);

            //map pawns
            methods = typeof(MapPawns).GetMethods(instanceFlags).Where(m => m.HasSignature(typeof(Faction)));
            methodsToPatch.AddRange(methods);


            //jobs and toils
            methodsToPatch.Add(typeof(JobDriver_Ingest).GetMethod("PrepareToIngestToils", instanceFlags));

            //now patch them
            foreach (MethodInfo methodInfo in methodsToPatch)
            {
                if (methodInfo == null)
                {
                    continue;
                }
                harmonyInstance.ILPatchCommonMethods(methodInfo);
            }

            StringBuilder builder = new StringBuilder();

            builder.AppendLine("Patched:");
            foreach (MethodInfo methodInfo in methodsToPatch)
            {
                if (methodInfo == null)
                {
                    continue;
                }
                builder.AppendLine($"{methodInfo.Name}");
            }
            Log.Message(builder.ToString());
            DebugLogUtils.LogMsg(LogLevel.Messages, builder.ToString());
        }
Example #2
0
        private static void MassPatchFormerHumanChecks([NotNull] Harmony harmonyInstance)
        {
            var staticFlags   = BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public;
            var instanceFlags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;



            List <MethodInfo> methodsToPatch = new List <MethodInfo>();

            //bed stuff
            var bedUtilType     = typeof(RestUtility);
            var canUseBedMethod = bedUtilType.GetMethod(nameof(RestUtility.CanUseBedEver), staticFlags);

            methodsToPatch.Add(canUseBedMethod);



            //map pawns
            var methods = typeof(MapPawns).GetMethods(instanceFlags).Where(m => m.HasSignature(typeof(Faction)));

            methodsToPatch.AddRange(methods);


            //jobs and toils
            methodsToPatch.Add(typeof(JobDriver_Ingest).GetMethod("PrepareToIngestToils", instanceFlags));
            methodsToPatch.Add(typeof(GatheringWorker_MarriageCeremony).GetMethod("IsGuest", instanceFlags));

            //now patch them
            foreach (MethodInfo methodInfo in methodsToPatch)
            {
                if (methodInfo == null)
                {
                    continue;
                }
                harmonyInstance.ILPatchCommonMethods(methodInfo);
            }

            StringBuilder builder = new StringBuilder();

            builder.AppendLine("Patched:");
            foreach (MethodInfo methodInfo in methodsToPatch)
            {
                if (methodInfo == null)
                {
                    continue;
                }
                builder.AppendLine($"{methodInfo.Name}");
            }
            Log.Message(builder.ToString());
            DebugLogUtils.LogMsg(LogLevel.Messages, builder.ToString());
        }
        private static void MassPatchFormerHumanChecks([NotNull] Harmony harmonyInstance)
        {
            var staticFlags   = BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public;
            var instanceFlags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;

            List <MethodInfo> methodsToPatch = new List <MethodInfo>();

            //bed stuff
            var bedUtilType     = typeof(RestUtility);
            var canUseBedMethod = bedUtilType.GetMethod(nameof(RestUtility.CanUseBedEver), staticFlags);

            methodsToPatch.Add(canUseBedMethod);

            //now patch them
            foreach (MethodInfo methodInfo in methodsToPatch)
            {
                if (methodInfo == null)
                {
                    continue;
                }
                harmonyInstance.ILPatchCommonMethods(methodInfo);
            }
        }