示例#1
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            tmpChemicalNeeds.Clear();
            List <Need> allNeeds = pawn.needs.AllNeeds;

            for (int i = 0; i < allNeeds.Count; i++)
            {
                if (ShouldSatisfy(allNeeds[i]))
                {
                    tmpChemicalNeeds.Add((Need_Chemical)allNeeds[i]);
                }
            }
            if (!tmpChemicalNeeds.Any())
            {
                return(null);
            }
            tmpChemicalNeeds.SortBy((Need_Chemical x) => x.CurLevel);
            for (int j = 0; j < tmpChemicalNeeds.Count; j++)
            {
                Thing thing = FindDrugFor(pawn, tmpChemicalNeeds[j]);
                if (thing != null)
                {
                    tmpChemicalNeeds.Clear();
                    return(DrugAIUtility.IngestAndTakeToInventoryJob(thing, pawn, 1));
                }
            }
            tmpChemicalNeeds.Clear();
            return(null);
        }
示例#2
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            DrugPolicy currentPolicy = pawn.drugs.CurrentPolicy;

            for (int i = 0; i < currentPolicy.Count; i++)
            {
                if (pawn.drugs.ShouldTryToTakeScheduledNow(currentPolicy[i].drug))
                {
                    Thing thing = FindDrugFor(pawn, currentPolicy[i].drug);
                    if (thing != null)
                    {
                        return(DrugAIUtility.IngestAndTakeToInventoryJob(thing, pawn, 1));
                    }
                }
            }
            return(null);
        }
示例#3
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            Profiler.BeginSample("SatisfyChemicalNeed");
            JobGiver_SatisfyChemicalNeed.tmpChemicalNeeds.Clear();
            List <Need> allNeeds = pawn.needs.AllNeeds;

            for (int i = 0; i < allNeeds.Count; i++)
            {
                if (this.ShouldSatisfy(allNeeds[i]))
                {
                    JobGiver_SatisfyChemicalNeed.tmpChemicalNeeds.Add((Need_Chemical)allNeeds[i]);
                }
            }
            Job result;

            if (!JobGiver_SatisfyChemicalNeed.tmpChemicalNeeds.Any <Need_Chemical>())
            {
                Profiler.EndSample();
                result = null;
            }
            else
            {
                JobGiver_SatisfyChemicalNeed.tmpChemicalNeeds.SortBy((Need_Chemical x) => x.CurLevel);
                for (int j = 0; j < JobGiver_SatisfyChemicalNeed.tmpChemicalNeeds.Count; j++)
                {
                    Thing thing = this.FindDrugFor(pawn, JobGiver_SatisfyChemicalNeed.tmpChemicalNeeds[j]);
                    if (thing != null)
                    {
                        JobGiver_SatisfyChemicalNeed.tmpChemicalNeeds.Clear();
                        Profiler.EndSample();
                        return(DrugAIUtility.IngestAndTakeToInventoryJob(thing, pawn, 1));
                    }
                }
                JobGiver_SatisfyChemicalNeed.tmpChemicalNeeds.Clear();
                Profiler.EndSample();
                result = null;
            }
            return(result);
        }
 protected override Job CreateIngestJob(Thing ingestible, Pawn pawn)
 {
     return(DrugAIUtility.IngestAndTakeToInventoryJob(ingestible, pawn, 9999));
 }