Ejemplo n.º 1
0
 protected override bool TryFindGoodOpportunisticTaskTarget(Pawn pawn, out Thing target, List <Thing> alreadyTakenTargets)
 {
     if (pawn.mindState.duty != null && pawn.mindState.duty.def == DutyDef && pawn.carryTracker.CarriedThing != null)
     {
         target = pawn.carryTracker.CarriedThing;
         return(true);
     }
     return(StealAIUtility.TryFindBestItemToSteal(pawn.Position, pawn.Map, 33f, out target, pawn, alreadyTakenTargets));
 }
Ejemplo n.º 2
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            IntVec3 vec;

            if (!RCellFinder.TryFindBestExitSpot(pawn, out vec))
            {
                return(null);
            }

            List <Thing> steelVehicle = new List <Thing>();

            foreach (Vehicle_Turret vehicle_Cart in ToolsForHaulUtility.CartTurret)
            {
                if (ToolsForHaulUtility.IsDriver(pawn))
                {
                    break;
                }
                if (pawn.RaceProps.Animal || !pawn.RaceProps.Humanlike || !pawn.RaceProps.hasGenders)
                {
                    break;
                }
                if (!vehicle_Cart.IsBurning() && vehicle_Cart.Position.InHorDistOf(pawn.Position, 12f) && !vehicle_Cart.mountableComp.IsMounted && (float)vehicle_Cart.HitPoints / vehicle_Cart.MaxHitPoints > 0.2f && vehicle_Cart.VehicleSpeed >= pawn.GetStatValue(StatDefOf.MoveSpeed) && pawn.CanReserveAndReach(vehicle_Cart, PathEndMode.InteractionCell, Danger.Deadly))
                {
                    steelVehicle.Add(vehicle_Cart);
                }
            }
            foreach (Vehicle_Cart vehicle_Cart in ToolsForHaulUtility.Cart)
            {
                if (ToolsForHaulUtility.IsDriver(pawn))
                {
                    break;
                }
                if (pawn.RaceProps.Animal || !pawn.RaceProps.Humanlike || !pawn.RaceProps.hasGenders)
                {
                    break;
                }
                if (!vehicle_Cart.IsBurning() && vehicle_Cart.Position.InHorDistOf(pawn.Position, 12f) && !vehicle_Cart.mountableComp.IsMounted && (float)vehicle_Cart.HitPoints / vehicle_Cart.MaxHitPoints > 0.2f && vehicle_Cart.VehicleSpeed >= pawn.GetStatValue(StatDefOf.MoveSpeed) && pawn.CanReserveAndReach(vehicle_Cart, PathEndMode.InteractionCell, Danger.Deadly))
                {
                    steelVehicle.Add(vehicle_Cart);
                }
            }
            if (steelVehicle.Any() && !GenAI.InDangerousCombat(pawn))
            {
                IOrderedEnumerable <Thing> orderedEnumerable = steelVehicle.OrderBy(x => x.Position.DistanceToSquared(pawn.Position));
                Job job = new Job(HaulJobDefOf.Mount);
                orderedEnumerable.First().SetFaction(null);
                job.targetA = orderedEnumerable.First();

                return(job);
            }

            Thing thing;

            if (StealAIUtility.TryFindBestItemToSteal(pawn.Position, 12f, out thing, pawn) && !GenAI.InDangerousCombat(pawn))
            {
                return(new Job(JobDefOf.Steal)
                {
                    targetA = thing,
                    targetB = vec,
                    maxNumToCarry = Mathf.Min(thing.stackCount, (int)(pawn.GetStatValue(StatDefOf.CarryingCapacity) / thing.def.VolumePerUnit))
                });
            }
            return(null);
        }