public override bool GizmoDisabled(out string reason) { LordJob_Joinable_Speech lordJob_Joinable_Speech = parent.pawn.GetLord()?.LordJob as LordJob_Joinable_Speech; if (lordJob_Joinable_Speech != null && lordJob_Joinable_Speech.Organizer == parent.pawn) { reason = "AbilitySpeechDisabledAlreadyGivingSpeech".Translate(); return(true); } if (GatheringsUtility.AnyLordJobPreventsNewGatherings(parent.pawn.Map)) { reason = "AbilitySpeechDisabledAnotherGatheringInProgress".Translate(); return(true); } Building_Throne assignedThrone = parent.pawn.ownership.AssignedThrone; if (assignedThrone == null) { reason = "AbilitySpeechDisabledNoThroneAssigned".Translate(); return(true); } if (!parent.pawn.CanReserveAndReach(assignedThrone, PathEndMode.InteractionCell, parent.pawn.NormalMaxDanger())) { reason = "AbilitySpeechDisabledNoThroneIsNotAccessible".Translate(); return(true); } if (parent.pawn.royalty.GetUnmetThroneroomRequirements().Any()) { reason = "AbilitySpeechDisabledNoThroneUndignified".Translate(); return(true); } reason = null; return(false); }
public static Building_Throne FindBestUnassignedThrone(Pawn pawn) { float num = float.PositiveInfinity; Building_Throne result = null; foreach (Thing item in pawn.Map.listerThings.ThingsOfDef(ThingDefOf.Throne)) { Building_Throne building_Throne = item as Building_Throne; if (building_Throne != null && building_Throne.CompAssignableToPawn.HasFreeSlot && building_Throne.Spawned && !building_Throne.IsForbidden(pawn) && pawn.CanReserveAndReach(building_Throne, PathEndMode.InteractionCell, pawn.NormalMaxDanger()) && RoomRoleWorker_ThroneRoom.Validate(building_Throne.GetRoom()) == null) { PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, building_Throne, pawn, PathEndMode.InteractionCell); float num2 = (pawnPath.Found ? pawnPath.TotalCost : float.PositiveInfinity); pawnPath.ReleaseToPool(); if (num > num2) { num = num2; result = building_Throne; } } } if (num == float.PositiveInfinity) { return(null); } return(result); }
public static Building_Throne FindBestUsableThrone(Pawn pawn) { Building_Throne building_Throne = pawn.ownership.AssignedThrone; if (building_Throne != null) { if (!building_Throne.Spawned || building_Throne.IsForbidden(pawn) || !pawn.CanReserveAndReach(building_Throne, PathEndMode.InteractionCell, pawn.NormalMaxDanger())) { return(null); } if (RoomRoleWorker_ThroneRoom.Validate(building_Throne.GetRoom()) != null) { return(null); } } else { building_Throne = FindBestUnassignedThrone(pawn); if (building_Throne == null) { return(null); } pawn.ownership.ClaimThrone(building_Throne); } return(building_Throne); }
public override AcceptanceReport CanAccept() { acceptanceReportUnmetRequirements.Clear(); if (forTitle.throneRoomRequirements.NullOrEmpty()) { return(true); } Building_Throne assignedThrone = forPawn.ownership.AssignedThrone; if (assignedThrone == null) { return("QuestThroneRoomRequirementsUnsatisfied".Translate(forPawn.Named("PAWN"), forTitle.GetLabelFor(forPawn).Named("TITLE"))); } foreach (RoomRequirement throneRoomRequirement in forTitle.throneRoomRequirements) { if (!throneRoomRequirement.Met(assignedThrone.GetRoom(), forPawn)) { acceptanceReportUnmetRequirements.Add(throneRoomRequirement.LabelCap(assignedThrone.GetRoom())); } } if (acceptanceReportUnmetRequirements.Count != 0) { return(new AcceptanceReport("QuestThroneRoomRequirementsUnsatisfied".Translate(forPawn.Named("PAWN"), forTitle.GetLabelFor(forPawn).Named("TITLE")) + ":\n\n" + acceptanceReportUnmetRequirements.ToLineList("- "))); } return(true); }
protected override bool TryFindGatherSpot(Pawn organizer, out IntVec3 spot) { Building_Throne building_Throne = RoyalTitleUtility.FindBestUsableThrone(organizer); if (building_Throne != null) { spot = building_Throne.InteractionCell; return(true); } spot = IntVec3.Invalid; return(false); }
public bool ClaimThrone(Building_Throne newThrone) { if (newThrone.AssignedPawn == pawn) { return(false); } UnclaimThrone(); if (newThrone.AssignedPawn != null) { newThrone.AssignedPawn.ownership.UnclaimThrone(); } newThrone.CompAssignableToPawn.ForceAddPawn(pawn); AssignedThrone = newThrone; return(true); }
public void ExposeData() { Building_Grave refee = AssignedGrave; Building_Throne refee2 = AssignedThrone; Building refee3 = AssignedMeditationSpot; Scribe_References.Look(ref intOwnedBed, "ownedBed"); Scribe_References.Look(ref refee3, "assignedMeditationSpot"); Scribe_References.Look(ref refee, "assignedGrave"); Scribe_References.Look(ref refee2, "assignedThrone"); AssignedGrave = refee; AssignedThrone = refee2; AssignedMeditationSpot = refee3; if (Scribe.mode != LoadSaveMode.PostLoadInit) { return; } if (intOwnedBed != null) { CompAssignableToPawn compAssignableToPawn = intOwnedBed.TryGetComp <CompAssignableToPawn>(); if (compAssignableToPawn != null && !compAssignableToPawn.AssignedPawns.Contains(pawn)) { Building_Bed newBed = intOwnedBed; UnclaimBed(); ClaimBedIfNonMedical(newBed); } } if (AssignedGrave != null) { CompAssignableToPawn compAssignableToPawn2 = AssignedGrave.TryGetComp <CompAssignableToPawn>(); if (compAssignableToPawn2 != null && !compAssignableToPawn2.AssignedPawns.Contains(pawn)) { Building_Grave assignedGrave = AssignedGrave; UnclaimGrave(); ClaimGrave(assignedGrave); } } if (AssignedThrone != null) { CompAssignableToPawn compAssignableToPawn3 = AssignedThrone.TryGetComp <CompAssignableToPawn>(); if (compAssignableToPawn3 != null && !compAssignableToPawn3.AssignedPawns.Contains(pawn)) { Building_Throne assignedThrone = AssignedThrone; UnclaimThrone(); ClaimThrone(assignedThrone); } } }
protected override Job TryGiveJob(Pawn pawn) { PawnDuty duty = pawn.mindState.duty; if (duty == null) { return(null); } Building_Throne building_Throne = duty.focusSecond.Thing as Building_Throne; if (building_Throne == null || building_Throne.AssignedPawn != pawn) { return(null); } if (!pawn.CanReach(building_Throne, PathEndMode.InteractionCell, Danger.None)) { return(null); } return(JobMaker.MakeJob(JobDefOf.GiveSpeech, duty.focusSecond)); }
public override void UpdateAllDuties() { for (int i = 0; i < lord.ownedPawns.Count; i++) { Pawn pawn = lord.ownedPawns[i]; if (pawn == organizer) { Building_Throne firstThing = spot.GetFirstThing <Building_Throne>(base.Map); pawn.mindState.duty = new PawnDuty(DutyDefOf.GiveSpeech, spot, firstThing); pawn.jobs.EndCurrentJob(JobCondition.InterruptForced); } else { PawnDuty pawnDuty = new PawnDuty(DutyDefOf.Spectate); pawnDuty.spectateRect = Data.spectateRect; pawnDuty.spectateRectAllowedSides = Data.spectateRectAllowedSides; pawnDuty.spectateRectPreferredSide = Data.spectateRectPreferredSide; pawn.mindState.duty = pawnDuty; } } }
public static IEnumerable <LocalTargetInfo> AllMeditationSpotCandidates(Pawn pawn, bool allowFallbackSpots = true) { bool flag = false; if (pawn.royalty != null && pawn.royalty.AllTitlesInEffectForReading.Count > 0 && !pawn.IsPrisonerOfColony) { Building_Throne building_Throne = RoyalTitleUtility.FindBestUsableThrone(pawn); if (building_Throne != null) { yield return(building_Throne); flag = true; } } if (!pawn.IsPrisonerOfColony) { foreach (Building item in pawn.Map.listerBuildings.AllBuildingsColonistOfDef(ThingDefOf.MeditationSpot).Where(delegate(Building s) { if (s.IsForbidden(pawn) || !s.Position.Standable(s.Map)) { return(false); } if (s.GetAssignedPawn() != null && s.GetAssignedPawn() != pawn) { return(false); } Room room4 = s.GetRoom(); return((room4 == null || CanUseRoomToMeditate(room4, pawn)) && pawn.CanReserveAndReach(s, PathEndMode.OnCell, pawn.NormalMaxDanger())); })) { yield return(item); flag = true; } } if (flag || !allowFallbackSpots) { yield break; } List <Thing> list = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.MeditationFocus); foreach (Thing item2 in list) { if (item2.def == ThingDefOf.Wall) { continue; } Room room = item2.GetRoom(); if ((room == null || CanUseRoomToMeditate(room, pawn)) && item2.GetStatValueForPawn(StatDefOf.MeditationFocusStrength, pawn) > 0f) { LocalTargetInfo localTargetInfo = MeditationSpotForFocus(item2, pawn); if (localTargetInfo.IsValid) { yield return(localTargetInfo); } } } Building_Bed bed = pawn.ownership.OwnedBed; Room room2 = bed?.GetRoom(); IntVec3 c2; if (room2 != null && !room2.PsychologicallyOutdoors && pawn.CanReserveAndReach(bed, PathEndMode.OnCell, pawn.NormalMaxDanger())) { foreach (LocalTargetInfo item3 in FocusSpotsInTheRoom(pawn, room2)) { yield return(item3); } c2 = RCellFinder.RandomWanderDestFor(pawn, bed.Position, WanderRadius, (Pawn p, IntVec3 c, IntVec3 r) => c.Standable(p.Map) && c.GetDoor(p.Map) == null && WanderRoomUtility.IsValidWanderDest(p, c, r), pawn.NormalMaxDanger()); if (c2.IsValid) { yield return(c2); } } if (pawn.IsPrisonerOfColony) { yield break; } IntVec3 colonyWanderRoot = WanderUtility.GetColonyWanderRoot(pawn); c2 = RCellFinder.RandomWanderDestFor(pawn, colonyWanderRoot, WanderRadius, delegate(Pawn p, IntVec3 c, IntVec3 r) { if (!c.Standable(p.Map) || c.GetDoor(p.Map) != null || !p.CanReserveAndReach(c, PathEndMode.OnCell, p.NormalMaxDanger())) { return(false); } Room room3 = c.GetRoom(p.Map); return((room3 == null || CanUseRoomToMeditate(room3, pawn)) ? true : false); }, pawn.NormalMaxDanger()); if (c2.IsValid) { yield return(c2); } }