protected Toil GetToilTalkWithNearbyPawn()
{
int tickCounter = 0;
IntVec3 facingCell = this.TargetLocA;
Pawn facingPawn = null;
Toil toil = new Toil()
{
initAction = () =>
{
tickCounter = (int)GenTicks.TicksPerRealSecond;
GetFacingCell(ref facingPawn, ref facingCell);
},
tickAction = () =>
{
// Only refresh facing direction once per second.
tickCounter--;
if (tickCounter <= 0)
{
tickCounter = (int)GenTicks.TicksPerRealSecond;
if ((facingPawn == null)
|| (facingPawn.Position.InHorDistOf(this.pawn.Position, 2f) == false))
{
GetFacingCell(ref facingPawn, ref facingCell);
}
}
// Face nearby pawn or cell.
if ((facingPawn != null)
&& (facingPawn.Destroyed == false))
{
this.pawn.Drawer.rotator.FaceCell(facingPawn.Position);
}
else
{
this.pawn.Drawer.rotator.FaceCell(facingCell);
}
// Gain some joy.
this.pawn.needs.joy.GainJoy(this.CurJob.def.joyGainRate * 0.000144f, Util_CampfireParty.JoyKindDefOf_Social);
},
defaultDuration = Rand.Range(180, 300),
defaultCompleteMode = ToilCompleteMode.Delay
};
return toil;
}