public override void UpdateAllDuties() { foreach (Pawn pawn in this.lord.ownedPawns) { CarnivalRole role = pawn.GetCarnivalRole(); // can't use switch case because some roles have multiple bit-flags if (role.Is(CarnivalRole.Worker)) { DutyUtility.BuildCarnival(pawn, Info.setupCentre, Info.baseRadius); } else if (role.Is(CarnivalRole.Guard)) { DutyUtility.GuardCircuit(pawn); } else if (role.Is(CarnivalRole.Carrier)) { IntVec3 pos; if (Info.rememberedPositions.TryGetValue(pawn, out pos)) { DutyUtility.HitchToSpot(pawn, pos); } else { DutyUtility.HitchToSpot(pawn, pawn.Position); } } else { DutyUtility.MeanderAndHelp(pawn, Info.setupCentre, Info.baseRadius); } } }
public override void UpdateAllDuties() { var wanderRect = CellRect.CenteredOn(Info.setupCentre, 8); int numActiveGuards = Mathf.RoundToInt(Info.pawnsWithRole[CarnivalRole.Guard].Count / 2f); IntVec3 pos; foreach (var pawn in this.lord.ownedPawns) { CarnivalRole pawnRole = pawn.GetCarnivalRole(); if (pawnRole.Is(CarnivalRole.Guard)) { if (numActiveGuards > 0 && pawn.needs.rest.CurCategory == RestCategory.Rested) { DutyUtility.GuardCircuit(pawn); numActiveGuards--; } else { // rest on the off shift if not assigned a position DutyUtility.ForceRest(pawn); } } else if (pawnRole.IsAny(CarnivalRole.Vendor, CarnivalRole.Carrier)) { if (Info.rememberedPositions.TryGetValue(pawn, out pos)) { DutyUtility.HitchToSpot(pawn, pos); } else { DutyUtility.HitchToSpot(pawn, pawn.Position); } } else if (pawnRole.Is(CarnivalRole.Entertainer)) { if (Info.rememberedPositions.TryGetValue(pawn, out pos)) { DutyUtility.HitchToSpot(pawn, pos); } } else if (pawnRole.Is(CarnivalRole.Worker)) { DutyUtility.MeanderAndHelp(pawn, Info.AverageLodgeTentPos, 10f); } else { DutyUtility.MeanderAndHelp(pawn, wanderRect.RandomCell, Info.baseRadius); } } }
private Toil FindTicketTaker() { return(new Toil { initAction = delegate { var ticketTaker = Info.GetBestEntertainer(false); if (ticketTaker == null) { Log.Error("[Carnivale] Found no ticket taker to give silver to."); base.EndJobWith(JobCondition.Errored); } DutyUtility.HitchToSpot(ticketTaker, ticketTaker.Position); CurJob.SetTarget(TargetIndex.B, ticketTaker); } }); }