コード例 #1
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            foreach (Vehicle_Cart cart in ToolsForHaulUtility.Cart)
            {
                if (cart.mountableComp.IsMounted && !cart.mountableComp.Driver.RaceProps.Animal && cart.mountableComp.Driver.ThingID == pawn.ThingID)
                {
                    cart.despawnAtEdge = true;
                }
            }
            foreach (Vehicle_Turret cart in ToolsForHaulUtility.CartTurret)
            {
                if (cart.mountableComp.IsMounted && !cart.mountableComp.Driver.RaceProps.Animal && cart.mountableComp.Driver.ThingID == pawn.ThingID)
                {
                    cart.despawnAtEdge = true;
                }
            }

            IntVec3 intVec;

            if (!RCellFinder.TryFindBestExitSpot(pawn, out intVec))
            {
                return(null);
            }
            Pawn pawn2 = KidnapAIUtility.ReachableWoundedGuest(pawn);

            if (pawn2 == null)
            {
                return(null);
            }
            return(new Job(JobDefOf.Kidnap)
            {
                targetA = pawn2,
                targetB = intVec,
                maxNumToCarry = 1
            });
        }
コード例 #2
0
 static bool Prefix(ref Trigger_WoundedGuestPresent __instance, ref bool __result, ref Lord lord, ref TriggerSignal signal)
 {
     if (signal.type == TriggerSignalType.Tick && Find.TickManager.TicksGame % 800 < RefcellRespeedConfig.currentTimeMultiplier)
     {
         TriggerData_PawnCycleInd data = __instance.Data;
         ++data.pawnCycleInd;
         if (data.pawnCycleInd >= lord.ownedPawns.Count)
         {
             data.pawnCycleInd = 0;
         }
         if (lord.ownedPawns.Any <Pawn>())
         {
             Pawn ownedPawn = lord.ownedPawns[data.pawnCycleInd];
             if (ownedPawn.Spawned && !ownedPawn.Downed && (!ownedPawn.InMentalState && KidnapAIUtility.ReachableWoundedGuest(ownedPawn) != null))
             {
                 __result = true;
                 return(false);
             }
         }
     }
     __result = false;
     return(false);
 }
コード例 #3
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            List <Thing> steelVehicle = new List <Thing>();

            foreach (Vehicle_Cart vehicle_Cart in ToolsForHaulUtility.Cart)
            {
                if (vehicle_Cart.mountableComp.IsMounted && !vehicle_Cart.mountableComp.Driver.RaceProps.Animal && vehicle_Cart.mountableComp.Driver.ThingID == pawn.ThingID)
                {
                    vehicle_Cart.despawnAtEdge = true;
                    break;
                }
                if (pawn.RaceProps.Animal || !pawn.RaceProps.Humanlike || !pawn.RaceProps.hasGenders)
                {
                    break;
                }

                if (!vehicle_Cart.IsBurning() && vehicle_Cart.Position.InHorDistOf(pawn.Position, 20f) && !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_Turret vehicle_Cart in ToolsForHaulUtility.CartTurret)
            {
                if (vehicle_Cart.mountableComp.IsMounted && !vehicle_Cart.mountableComp.Driver.RaceProps.Animal && vehicle_Cart.mountableComp.Driver.ThingID == pawn.ThingID)
                {
                    vehicle_Cart.despawnAtEdge = true;
                    break;
                }
                if (pawn.RaceProps.Animal || !pawn.RaceProps.Humanlike || !pawn.RaceProps.hasGenders)
                {
                    break;
                }

                if (!vehicle_Cart.IsBurning() && vehicle_Cart.Position.InHorDistOf(pawn.Position, 20f) && !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())
            {
                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);
            }


            IntVec3 intVec;

            if (!RCellFinder.TryFindBestExitSpot(pawn, out intVec))
            {
                return(null);
            }
            Pawn pawn2;

            KidnapAIUtility.TryFindGoodKidnapVictim(pawn, 20f, out pawn2);
            if (pawn2 == null)
            {
                return(null);
            }
            return(new Job(JobDefOf.Kidnap)
            {
                targetA = pawn2,
                targetB = intVec,
                maxNumToCarry = 1
            });
        }
コード例 #4
0
 static bool Prefix(ref Trigger_KidnapVictimPresent __instance, ref bool __result, ref Lord lord, ref TriggerSignal signal)
 {
     if (signal.type == TriggerSignalType.Tick && Find.TickManager.TicksGame % 120 < RefcellRespeedConfig.currentTimeMultiplier)
     {
         if (__instance.data == null || !(__instance.data is TriggerData_PawnCycleInd))
         {
             BackCompatibility.TriggerDataPawnCycleIndNull(__instance);
         }
         if (Find.TickManager.TicksGame - lord.lastPawnHarmTick > 300)
         {
             TriggerData_PawnCycleInd data = __instance.Data;
             ++data.pawnCycleInd;
             if (data.pawnCycleInd >= lord.ownedPawns.Count)
             {
                 data.pawnCycleInd = 0;
             }
             if (lord.ownedPawns.Any <Pawn>())
             {
                 Pawn ownedPawn = lord.ownedPawns[data.pawnCycleInd];
                 if (ownedPawn.Spawned && !ownedPawn.Downed && (ownedPawn.MentalStateDef == null && KidnapAIUtility.TryFindGoodKidnapVictim(ownedPawn, 8f, out Pawn _)) && !GenAI.InDangerousCombat(ownedPawn))
                 {
                     __result = true;
                     return(false);
                 }
             }
         }
     }
     __result = false;
     return(false);
 }