protected override Job TryGiveJob(Pawn pawn) { if (!pawn.HostileTo(Faction.OfPlayer)) { return(null); } bool flag = pawn.natives.IgniteVerb != null && pawn.natives.IgniteVerb.IsStillUsableBy(pawn) && pawn.HostileTo(Faction.OfPlayer); CellRect cellRect = CellRect.CenteredOn(pawn.Position, 5); for (int i = 0; i < 35; i++) { IntVec3 randomCell = cellRect.RandomCell; if (!randomCell.InBounds(pawn.Map)) { continue; } Building edifice = randomCell.GetEdifice(pawn.Map); if (edifice != null && TrashUtility.ShouldTrashBuilding(pawn, edifice) && GenSight.LineOfSight(pawn.Position, randomCell, pawn.Map)) { if (DebugViewSettings.drawDestSearch && Find.CurrentMap == pawn.Map) { Find.CurrentMap.debugDrawer.FlashCell(randomCell, 1f, "trash bld"); } Job job = TrashUtility.TrashJob(pawn, edifice); if (job != null) { return(job); } } if (flag) { Plant plant = randomCell.GetPlant(pawn.Map); if (plant != null && TrashUtility.ShouldTrashPlant(pawn, plant) && GenSight.LineOfSight(pawn.Position, randomCell, pawn.Map)) { if (DebugViewSettings.drawDestSearch && Find.CurrentMap == pawn.Map) { Find.CurrentMap.debugDrawer.FlashCell(randomCell, 0.5f, "trash plant"); } Job job2 = TrashUtility.TrashJob(pawn, plant); if (job2 != null) { return(job2); } } } if (DebugViewSettings.drawDestSearch && Find.CurrentMap == pawn.Map) { Find.CurrentMap.debugDrawer.FlashCell(randomCell, 0f, "trash no"); } } return(null); }
protected override Job TryGiveJob(Pawn pawn) { List <Building> allBuildingsColonist = pawn.Map.listerBuildings.allBuildingsColonist; if (allBuildingsColonist.Count == 0) { return(null); } for (int i = 0; i < 75; i++) { Building building = allBuildingsColonist.RandomElement <Building>(); if (TrashUtility.ShouldTrashBuilding(pawn, building, this.attackAllInert)) { return(TrashUtility.TrashJob(pawn, building)); } } return(null); }