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 string GetInspectString() { string inspectString = base.GetInspectString(); Room room = this.GetRoom(); Pawn p = (CompAssignableToPawn.AssignedPawnsForReading.Count == 1) ? CompAssignableToPawn.AssignedPawnsForReading[0] : null; RoyalTitleDef titleStature = TitleStature; inspectString += "\n" + "ThroneTitleStature".Translate((titleStature == null) ? "None".Translate() : (titleStature.GetLabelCapFor(p) + " " + "ThroneRoomImpressivenessInfo".Translate(titleStature.MinThroneRoomImpressiveness.ToString()))); string text = RoomRoleWorker_ThroneRoom.Validate(room); if (text != null) { return(inspectString + "\n" + text); } tmpTitles.Clear(); tmpTitles.AddRange(AllTitlesForThroneStature); int num = tmpTitles.IndexOf(titleStature); int num2 = num - 1; int num3 = num + 1; if (num2 >= 0) { inspectString += "\n" + "ThronePrevTitleStature".Translate(tmpTitles[num2].GetLabelCapFor(p)) + " " + "ThroneRoomImpressivenessInfo".Translate(tmpTitles[num2].MinThroneRoomImpressiveness.ToString()); } if (num3 < tmpTitles.Count) { inspectString += "\n" + "ThroneNextTitleStature".Translate(tmpTitles[num3].GetLabelCapFor(p)) + " " + "ThroneRoomImpressivenessInfo".Translate(tmpTitles[num3].MinThroneRoomImpressiveness.ToString()); } return(inspectString); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_General.Do(delegate { job.SetTarget(TargetIndex.B, Throne.InteractionCell + Throne.Rotation.FacingCell); })); Toil toil = new Toil(); toil.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); toil.FailOn(() => Throne.AssignedPawn != pawn); toil.FailOn(() => RoomRoleWorker_ThroneRoom.Validate(Throne.GetRoom()) != null); toil.tickAction = delegate { pawn.GainComfortFromCellIfPossible(); pawn.skills.Learn(SkillDefOf.Social, 0.3f); if (pawn.IsHashIntervalTick(MoteInterval.RandomInRange)) { MoteMaker.MakeSpeechBubble(pawn, moteIcon); } rotateToFace = TargetIndex.B; }; toil.defaultCompleteMode = ToilCompleteMode.Never; yield return(toil); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); yield return(Toils_General.Do(delegate { job.SetTarget(TargetIndex.B, Throne.InteractionCell + Throne.Rotation.FacingCell); })); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell)); Toil toil = new Toil(); toil.FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell); toil.FailOn(() => Throne.AssignedPawn != pawn); toil.FailOn(() => RoomRoleWorker_ThroneRoom.Validate(Throne.GetRoom()) != null); toil.FailOn(() => !MeditationUtility.CanMeditateNow(pawn) || !MeditationUtility.SafeEnvironmentalConditions(pawn, base.TargetLocA, base.Map)); toil.defaultCompleteMode = ToilCompleteMode.Delay; toil.defaultDuration = job.def.joyDuration; toil.tickAction = delegate { if (pawn.mindState.applyThroneThoughtsTick == 0) { pawn.mindState.applyThroneThoughtsTick = Find.TickManager.TicksGame + 10000; } else if (pawn.mindState.applyThroneThoughtsTick <= Find.TickManager.TicksGame) { pawn.mindState.applyThroneThoughtsTick = Find.TickManager.TicksGame + 60000; ThoughtDef thoughtDef = null; if (Throne.GetRoom().Role == RoomRoleDefOf.ThroneRoom) { thoughtDef = ThoughtDefOf.ReignedInThroneroom; } if (thoughtDef != null) { int scoreStageIndex = RoomStatDefOf.Impressiveness.GetScoreStageIndex(Throne.GetRoom().GetStat(RoomStatDefOf.Impressiveness)); if (thoughtDef.stages[scoreStageIndex] != null) { pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtMaker.MakeThought(thoughtDef, scoreStageIndex)); } } } rotateToFace = TargetIndex.B; MeditationTick(); if (job.ignoreJoyTimeAssignment && pawn.IsHashIntervalTick(300)) { pawn.jobs.CheckForJobOverride(); } }; yield return(toil); }
public override string GetInspectString() { string inspectString = base.GetInspectString(); Room room = this.GetRoom(); Pawn p = ((CompAssignableToPawn.AssignedPawnsForReading.Count == 1) ? CompAssignableToPawn.AssignedPawnsForReading[0] : null); RoyalTitleDef titleStature = TitleStature; inspectString += "\n" + "ThroneMaxSatisfiedTitle".Translate() + ": " + ((titleStature == null) ? "None".Translate() : ((TaggedString)titleStature.GetLabelCapFor(p))); string text = RoomRoleWorker_ThroneRoom.Validate(room); if (text != null) { return(inspectString + "\n" + text); } return(inspectString); }
public override AlertReport GetReport() { List <Map> maps = Find.Maps; for (int i = 0; i < maps.Count; i++) { foreach (Building_Throne item in maps[i].listerThings.ThingsInGroup(ThingRequestGroup.Throne)) { validationInfo = RoomRoleWorker_ThroneRoom.Validate(item.GetRoom()); if (validationInfo != null) { return(AlertReport.CulpritIs(item)); } } } 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); }