示例#1
0
        private static Toil JumpToCollectNextIntoHandsForBill(Toil gotoGetTargetToil, TargetIndex ind)
        {
            Toil toil = new Toil();

            toil.initAction = delegate
            {
                Pawn actor = toil.actor;
                if (actor.carryTracker.CarriedThing == null)
                {
                    Log.Error("JumpToAlsoCollectTargetInQueue run on " + actor + " who is not carrying something.");
                    return;
                }
                if (actor.carryTracker.Full)
                {
                    return;
                }
                Job curJob = actor.jobs.curJob;
                List <LocalTargetInfo> targetQueue = curJob.GetTargetQueue(ind);
                if (targetQueue.NullOrEmpty <LocalTargetInfo>())
                {
                    return;
                }
                for (int i = 0; i < targetQueue.Count; i++)
                {
                    if (GenAI.CanUseItemForWork(actor, targetQueue[i].Thing))
                    {
                        if (targetQueue[i].Thing.CanStackWith(actor.carryTracker.CarriedThing))
                        {
                            if ((float)(actor.Position - targetQueue[i].Thing.Position).LengthHorizontalSquared <= 64f)
                            {
                                int num  = (actor.carryTracker.CarriedThing != null) ? actor.carryTracker.CarriedThing.stackCount : 0;
                                int num2 = curJob.countQueue[i];
                                num2 = Mathf.Min(num2, targetQueue[i].Thing.def.stackLimit - num);
                                num2 = Mathf.Min(num2, actor.carryTracker.AvailableStackSpace(targetQueue[i].Thing.def));
                                if (num2 > 0)
                                {
                                    curJob.count = num2;
                                    curJob.SetTarget(ind, targetQueue[i].Thing);
                                    List <int> countQueue;
                                    int        index;
                                    (countQueue = curJob.countQueue)[index = i] = countQueue[index] - num2;
                                    if (curJob.countQueue[i] <= 0)
                                    {
                                        curJob.countQueue.RemoveAt(i);
                                        targetQueue.RemoveAt(i);
                                    }
                                    actor.jobs.curDriver.JumpToToil(gotoGetTargetToil);
                                    return;
                                }
                            }
                        }
                    }
                }
            };
            return(toil);
        }
        private static Toil JumpToCollectNextIntoHandsForBill(Toil gotoGetTargetToil, TargetIndex ind)
        {
            Toil toil = new Toil();

            toil.initAction = delegate
            {
                Pawn actor = toil.actor;
                if (actor.carryTracker.CarriedThing == null)
                {
                    Log.Error("JumpToAlsoCollectTargetInQueue run on " + actor + " who is not carrying something.");
                }
                else if (!actor.carryTracker.Full)
                {
                    Job curJob = actor.jobs.curJob;
                    List <LocalTargetInfo> targetQueue = curJob.GetTargetQueue(ind);
                    if (!targetQueue.NullOrEmpty())
                    {
                        int num = 0;
                        int a;
                        while (true)
                        {
                            if (num < targetQueue.Count)
                            {
                                if (GenAI.CanUseItemForWork(actor, targetQueue[num].Thing) && targetQueue[num].Thing.CanStackWith(actor.carryTracker.CarriedThing) && !((float)(actor.Position - targetQueue[num].Thing.Position).LengthHorizontalSquared > 64.0))
                                {
                                    int num2 = (actor.carryTracker.CarriedThing != null) ? actor.carryTracker.CarriedThing.stackCount : 0;
                                    a = curJob.countQueue[num];
                                    a = Mathf.Min(a, targetQueue[num].Thing.def.stackLimit - num2);
                                    a = Mathf.Min(a, actor.carryTracker.AvailableStackSpace(targetQueue[num].Thing.def));
                                    if (a > 0)
                                    {
                                        break;
                                    }
                                }
                                num++;
                                continue;
                            }
                            return;
                        }
                        curJob.count = a;
                        curJob.SetTarget(ind, targetQueue[num].Thing);
                        List <int> countQueue;
                        int        index;
                        (countQueue = curJob.countQueue)[index = num] = countQueue[index] - a;
                        if (curJob.countQueue[num] <= 0)
                        {
                            curJob.countQueue.RemoveAt(num);
                            targetQueue.RemoveAt(num);
                        }
                        actor.jobs.curDriver.JumpToToil(gotoGetTargetToil);
                    }
                }
            };
            return(toil);
        }
        private static Toil JumpToCollectNextIntoHandsForBill(Toil gotoGetTargetToil, TargetIndex ind)
        {
            Toil toil = new Toil();

            toil.initAction = delegate
            {
                Pawn actor = toil.actor;
                if (actor.carryTracker.CarriedThing == null)
                {
                    Log.Error(string.Concat("JumpToAlsoCollectTargetInQueue run on ", actor, " who is not carrying something."));
                }
                else if (!actor.carryTracker.Full)
                {
                    Job curJob = actor.jobs.curJob;
                    List <LocalTargetInfo> targetQueue = curJob.GetTargetQueue(ind);
                    if (!targetQueue.NullOrEmpty())
                    {
                        for (int i = 0; i < targetQueue.Count; i++)
                        {
                            if (GenAI.CanUseItemForWork(actor, targetQueue[i].Thing) && targetQueue[i].Thing.CanStackWith(actor.carryTracker.CarriedThing) && !((float)(actor.Position - targetQueue[i].Thing.Position).LengthHorizontalSquared > 64f))
                            {
                                int num = ((actor.carryTracker.CarriedThing != null) ? actor.carryTracker.CarriedThing.stackCount : 0);
                                int a   = curJob.countQueue[i];
                                a = Mathf.Min(a, targetQueue[i].Thing.def.stackLimit - num);
                                a = Mathf.Min(a, actor.carryTracker.AvailableStackSpace(targetQueue[i].Thing.def));
                                if (a > 0)
                                {
                                    curJob.count = a;
                                    curJob.SetTarget(ind, targetQueue[i].Thing);
                                    curJob.countQueue[i] -= a;
                                    if (curJob.countQueue[i] <= 0)
                                    {
                                        curJob.countQueue.RemoveAt(i);
                                        targetQueue.RemoveAt(i);
                                    }
                                    actor.jobs.curDriver.JumpToToil(gotoGetTargetToil);
                                    break;
                                }
                            }
                        }
                    }
                }
            };
            return(toil);
        }
示例#4
0
        public static Toil JumpIfAlsoCollectingNextTargetInQueue(Toil gotoGetTargetToil, TargetIndex ind)
        {
            Toil toil = new Toil();

            toil.initAction = delegate
            {
                Pawn actor  = toil.actor;
                Job  curJob = actor.jobs.curJob;
                List <LocalTargetInfo> targetQueue = curJob.GetTargetQueue(ind);
                if (targetQueue.NullOrEmpty <LocalTargetInfo>())
                {
                    return;
                }
                if (curJob.count <= 0)
                {
                    return;
                }
                if (actor.carryTracker.CarriedThing == null)
                {
                    Log.Error("JumpToAlsoCollectTargetInQueue run on " + actor + " who is not carrying something.", false);
                    return;
                }
                if (actor.carryTracker.AvailableStackSpace(actor.carryTracker.CarriedThing.def) <= 0)
                {
                    return;
                }
                for (int i = 0; i < targetQueue.Count; i++)
                {
                    if (!GenAI.CanUseItemForWork(actor, targetQueue[i].Thing))
                    {
                        actor.jobs.EndCurrentJob(JobCondition.Incompletable, true);
                        return;
                    }
                    if (targetQueue[i].Thing.def == actor.carryTracker.CarriedThing.def)
                    {
                        curJob.SetTarget(ind, targetQueue[i].Thing);
                        targetQueue.RemoveAt(i);
                        actor.jobs.curDriver.JumpToToil(gotoGetTargetToil);
                        break;
                    }
                }
            };
            return(toil);
        }
示例#5
0
        public static Toil JumpIfAlsoCollectingNextTargetInQueue(Toil gotoGetTargetToil, TargetIndex ind)
        {
            Toil toil = new Toil();

            toil.initAction = delegate
            {
                Pawn actor  = toil.actor;
                Job  curJob = actor.jobs.curJob;
                List <LocalTargetInfo> targetQueue = curJob.GetTargetQueue(ind);
                if (!targetQueue.NullOrEmpty() && curJob.count > 0)
                {
                    if (actor.carryTracker.CarriedThing == null)
                    {
                        Log.Error("JumpToAlsoCollectTargetInQueue run on " + actor + " who is not carrying something.");
                    }
                    else if (actor.carryTracker.AvailableStackSpace(actor.carryTracker.CarriedThing.def) > 0)
                    {
                        int num = 0;
                        while (true)
                        {
                            if (num < targetQueue.Count)
                            {
                                if (GenAI.CanUseItemForWork(actor, targetQueue[num].Thing))
                                {
                                    if (targetQueue[num].Thing.def != actor.carryTracker.CarriedThing.def)
                                    {
                                        num++;
                                        continue;
                                    }
                                    break;
                                }
                                actor.jobs.EndCurrentJob(JobCondition.Incompletable, true);
                            }
                            return;
                        }
                        curJob.SetTarget(ind, targetQueue[num].Thing);
                        targetQueue.RemoveAt(num);
                        actor.jobs.curDriver.JumpToToil(gotoGetTargetToil);
                    }
                }
            };
            return(toil);
        }
        // Token: 0x0600001E RID: 30 RVA: 0x00003530 File Offset: 0x00001730
        private static Toil JumpToCollectNextIntoHandsForBill(Toil gotoGetTargetToil, TargetIndex ind)
        {
            Toil toil = new Toil();

            toil.initAction = delegate()
            {
                Pawn actor = toil.actor;
                bool flag  = actor.carryTracker.CarriedThing == null;
                if (flag)
                {
                    string str  = "JumpToAlsoCollectTargetInQueue run on ";
                    Pawn   pawn = actor;
                    Log.Error(str + ((pawn != null) ? pawn.ToString() : null) + " who is not carrying something.", false);
                }
                else
                {
                    bool full = actor.carryTracker.Full;
                    if (!full)
                    {
                        Job curJob = actor.jobs.curJob;
                        List <LocalTargetInfo> targetQueue = curJob.GetTargetQueue(ind);
                        bool flag2 = targetQueue.NullOrEmpty <LocalTargetInfo>();
                        if (!flag2)
                        {
                            for (int i = 0; i < targetQueue.Count; i++)
                            {
                                bool flag3 = GenAI.CanUseItemForWork(actor, targetQueue[i].Thing);
                                if (flag3)
                                {
                                    bool flag4 = targetQueue[i].Thing.CanStackWith(actor.carryTracker.CarriedThing);
                                    if (flag4)
                                    {
                                        bool flag5 = (float)(actor.Position - targetQueue[i].Thing.Position).LengthHorizontalSquared <= 64f;
                                        if (flag5)
                                        {
                                            int num  = (actor.carryTracker.CarriedThing != null) ? actor.carryTracker.CarriedThing.stackCount : 0;
                                            int num2 = curJob.countQueue[i];
                                            num2 = Mathf.Min(num2, targetQueue[i].Thing.def.stackLimit - num);
                                            num2 = Mathf.Min(num2, actor.carryTracker.AvailableStackSpace(targetQueue[i].Thing.def));
                                            bool flag6 = num2 > 0;
                                            if (flag6)
                                            {
                                                curJob.count = num2;
                                                curJob.SetTarget(ind, targetQueue[i].Thing);
                                                List <int> countQueue;
                                                int        index;
                                                (countQueue = curJob.countQueue)[index = i] = countQueue[index] - num2;
                                                bool flag7 = curJob.countQueue[i] <= 0;
                                                if (flag7)
                                                {
                                                    curJob.countQueue.RemoveAt(i);
                                                    targetQueue.RemoveAt(i);
                                                }
                                                actor.jobs.curDriver.JumpToToil(gotoGetTargetToil);
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };
            return(toil);
        }
示例#7
0
        private static Toil JumpToCollectNextIntoHandsForBill(Toil gotoGetTargetToil, TargetIndex ind)
        {
            const float MaxDist = 8;

            Toil toil = new Toil();

            toil.initAction = () =>
            {
                Pawn actor = toil.actor;

                if (actor.carryTracker.CarriedThing == null)
                {
                    Log.Error("JumpToAlsoCollectTargetInQueue run on " + actor + " who is not carrying something.");
                    return;
                }

                //Early-out
                if (actor.carryTracker.Full)
                {
                    return;
                }

                Job curJob      = actor.jobs.curJob;
                var targetQueue = curJob.GetTargetQueue(ind);

                if (targetQueue.NullOrEmpty())
                {
                    return;
                }

                //Find an item in the queue matching what you're carrying
                for (int i = 0; i < targetQueue.Count; i++)
                {
                    //Can't use item - skip
                    if (!GenAI.CanUseItemForWork(actor, targetQueue[i].Thing))
                    {
                        continue;
                    }

                    //Cannot stack with thing in hands - skip
                    if (!targetQueue[i].Thing.CanStackWith(actor.carryTracker.CarriedThing))
                    {
                        continue;
                    }

                    //Too far away - skip
                    if ((actor.Position - targetQueue[i].Thing.Position).LengthHorizontalSquared > MaxDist * MaxDist)
                    {
                        continue;
                    }

                    //Determine num in hands
                    int numInHands = (actor.carryTracker.CarriedThing == null) ? 0 : actor.carryTracker.CarriedThing.stackCount;

                    //Determine num to take
                    int numToTake = curJob.countQueue[i];
                    numToTake = Mathf.Min(numToTake, targetQueue[i].Thing.def.stackLimit - numInHands);
                    numToTake = Mathf.Min(numToTake, actor.carryTracker.AvailableStackSpace(targetQueue[i].Thing.def));

                    //Won't take any - skip
                    if (numToTake <= 0)
                    {
                        continue;
                    }

                    //Set me to go get it
                    curJob.count = numToTake;
                    curJob.SetTarget(ind, targetQueue[i].Thing);

                    //Remove the amount to take from the num to bring list
                    //Remove from queue if I'm going to take all
                    curJob.countQueue[i] -= numToTake;
                    if (curJob.countQueue[i] <= 0)
                    {
                        curJob.countQueue.RemoveAt(i);
                        targetQueue.RemoveAt(i);
                    }

                    //Jump to toil
                    actor.jobs.curDriver.JumpToToil(gotoGetTargetToil);
                    return;
                }
            };

            return(toil);
        }