コード例 #1
0
 public override bool ActivateOn(Lord lord, TriggerSignal signal)
 {
     if (signal.type == TriggerSignalType.Tick && Find.TickManager.TicksGame % 120 == 0)
     {
         if (base.data == null || !(base.data is TriggerData_PawnCycleInd))
         {
             BackCompatibility.TriggerDataPawnCycleIndNull(this);
         }
         if (Find.TickManager.TicksGame - lord.lastPawnHarmTick > 300)
         {
             TriggerData_PawnCycleInd data = Data;
             data.pawnCycleInd++;
             if (data.pawnCycleInd >= lord.ownedPawns.Count)
             {
                 data.pawnCycleInd = 0;
             }
             if (lord.ownedPawns.Any())
             {
                 Pawn pawn = lord.ownedPawns[data.pawnCycleInd];
                 if (pawn.Spawned && !pawn.Downed && pawn.MentalStateDef == null && KidnapAIUtility.TryFindGoodKidnapVictim(pawn, 8f, out var _) && !GenAI.InDangerousCombat(pawn))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
コード例 #2
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);
 }