public static bool TryIssueJobPackage(ThinkNode_PrioritySorter __instance, ref ThinkResult __result, Pawn pawn, JobIssueParams jobParams)
        {
            List <ThinkNode> workingNodes = new List <ThinkNode>();
            int count = __instance.subNodes.Count;

            for (int index = 0; index < count; ++index)
            {
                workingNodes.Insert(Rand.Range(0, workingNodes.Count - 1), __instance.subNodes[index]);
            }
            while (workingNodes.Count > 0)
            {
                float num1   = 0.0f;
                int   index1 = -1;
                for (int index2 = 0; index2 < workingNodes.Count; ++index2)
                {
                    float num2 = 0.0f;
                    try
                    {
                        num2 = workingNodes[index2].GetPriority(pawn);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Exception in " + __instance.GetType() + " GetPriority: " + ex.ToString(), false);
                    }
                    if (num2 > 0.0 && (double)num2 >= __instance.minPriority && num2 > num1)
                    {
                        num1   = num2;
                        index1 = index2;
                    }
                }
                if (index1 != -1)
                {
                    ThinkResult thinkResult = ThinkResult.NoJob;
                    try
                    {
                        thinkResult = workingNodes[index1].TryIssueJobPackage(pawn, jobParams);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Exception in " + __instance.GetType() + " TryIssueJobPackage: " + ex.ToString(), false);
                    }
                    if (thinkResult.IsValid)
                    {
                        __result = thinkResult;
                        return(false);
                    }
                    workingNodes.RemoveAt(index1);
                }
                else
                {
                    break;
                }
            }
            __result = ThinkResult.NoJob;
            return(false);
        }
 public static bool prePatch(ThinkNode_PrioritySorter __instance, Pawn pawn, JobIssueParams jobParams, ref ThinkResult __result)
 {
     __result = TryIssueJobPackage(pawn, jobParams, __instance.subNodes, __instance.minPriority);
     return(false);
 }