public void ProcessTarget <T>(T t, IntVec3 cell, Map map, ObjectiveType type, Thing thing = null, Pawn pawn = null, PawnInfo pawnInfo = null)
        {
            PawnInfo info = pawnInfo != null ? pawnInfo : new PawnInfo(pawn);

            if (this.type == type)
            {
                if (targetSettings.thingSettings != null)
                {
                    if (thing.ThingIsValid(targetSettings.thingSettings))
                    {
                        int min = targetSettings.thingSettings.minAmount;
                        if ((type == ObjectiveType.Destroy || type == ObjectiveType.ConstructOrCraft) && count < min)
                        {
                            count++;
                        }
                        else if (!trackedThings.Contains(thing) && trackedThings.Count < min)
                        {
                            trackedThings.Add(thing);
                            LastTarget = thing;
                        }
                    }
                }
                if (targetSettings.pawnSettings != null)
                {
                    if (info != null)
                    {
                        if (targetSettings.pawnSettings.PawnSatisfies(info))
                        {
                            int min = targetSettings.pawnSettings.minAmount;
                            if (pawn != null && !trackedPawns.Contains(pawn) && trackedPawns.Count < min)
                            {
                                trackedPawns.Add(pawn);
                                LastTarget = pawn;
                            }
                            else if (count < min)
                            {
                                count++;
                            }
                        }
                    }
                }
                ThingValue tv = TargetsDone.ThingValue(t);
                if (tv != null && TargetsDone[tv] < tv.value && tv.ThingFits(thing))
                {
                    TargetsDone[tv] += 1;
                    LastTarget       = new TargetInfo(cell, map, true);
                }
            }
        }
Example #2
0
 public bool PawnSatisfies(PawnInfo pawn)
 {
     if (def != null && pawn.def != def)
     {
         return(false);
     }
     if (kindDef != null && pawn.kindDef != kindDef)
     {
         return(false);
     }
     if (factionDef != null && (pawn.factionDef != null && pawn.factionDef != factionDef))
     {
         return(false);
     }
     if (gender.HasValue && pawn.gender != gender.Value)
     {
         return(false);
     }
     return(true);
 }
Example #3
0
 public static bool Prefix(Pawn recruiter, Pawn recruitee, float recruitChance, bool useAudiovisualEffects = true)
 {
     def = recruitee.kindDef;
     pawnInfo = new PawnInfo(recruitee);
     return true;
 }