public override Job TryGiveJob(Pawn pawn) { if (pawn.equipment == null || pawn.equipment.Primary == null || !pawn.equipment.Primary.def.IsMeleeWeapon) { return(null); } IntVec3 position = IntVec3.Invalid; if (pawn.ownership != null) { Room room = pawn.ownership.OwnedRoom; if (room != null) { if (!room.Cells.Where(x => x.Standable(pawn.Map) && !x.IsForbidden(pawn) && pawn.CanReserveAndReach(x, PathEndMode.OnCell, Danger.None)).TryRandomElement(out position)) { position = AIUtility.FindRandomSpotOutsideColony(pawn, canReach: true, canReserve: true); } } } if (position.IsValid) { return(new Job(IdleJobDefOf.IdleJob_PracticeMelee, pawn.equipment.Primary, position) { locomotionUrgency = modSettings.wanderMovePolicy }); } return(null); }
public override Job TryGiveJob(Pawn pawn) { if (!JoyUtility.EnjoyableOutsideNow(pawn.Map)) { return(null); } IntVec3 position = AIUtility.FindRandomSpotOutsideColony(pawn, def.searchDistance, canReach: false, canReserve: false); if (!position.IsValid) { return(null); } IntVec3 standPosition = IntVec3.Invalid; if (!AIUtility.FindAroundSpotFromTarget(pawn, position, 4.0f, 3.0f, canSee: true, canReach: true, canReserve: true).TryRandomElement(out standPosition)) { return(null); } return(new Job(IdleJobDefOf.IdleJob_ThrowingStone, position, standPosition) { locomotionUrgency = modSettings.wanderMovePolicy }); }