Beispiel #1
0
 public void ProcessTarget <T>(T t, IntVec3 cell, Map map, ObjectiveType type, Thing craftedThing = null, Pawn pawn = null)
 {
     if (this.type == type)
     {
         if (targetSettings.thingSettings != null)
         {
             if (craftedThing.ThingIsValid(targetSettings.thingSettings))
             {
                 if (type == ObjectiveType.Destroy)
                 {
                     count++;
                 }
                 else
                 if (!CurrentlyOwnedTargets.TryGetValue(craftedThing, out int value))
                 {
                     CurrentlyOwnedTargets.Add(craftedThing, craftedThing.stackCount);
                     LastTarget = craftedThing;
                 }
             }
         }
         else if (targetSettings.pawnSettings != null)
         {
             if (pawn != null)
             {
                 if (targetSettings.pawnSettings.PawnSatisfies(pawn))
                 {
                     if (type == ObjectiveType.Kill)
                     {
                         count++;
                     }
                     else
                     if (!trackedPawns.Contains(pawn))
                     {
                         trackedPawns.Add(pawn);
                         LastTarget = craftedThing;
                     }
                 }
             }
         }
         else
         {
             ThingValue tv = TargetsDone.ThingValue(t);
             if (tv != null && TargetsDone[tv] < tv.value && tv.ThingFits(craftedThing))
             {
                 TargetsDone[tv] += 1;
                 LastTarget       = new TargetInfo(cell, map, true);
             }
         }
     }
 }
        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);
                }
            }
        }