public static int JoyKindsOnMapCount(Map map) { List <JoyKindDef> list = JoyUtility.JoyKindsOnMapTempList(map); int count = list.Count; list.Clear(); return(count); }
protected virtual void WatchTickAction() { this.pawn.rotationTracker.FaceCell(base.TargetA.Cell); this.pawn.GainComfortFromCellIfPossible(); Pawn pawn = this.pawn; Building joySource = (Building)base.TargetThingA; JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, 1f, joySource); }
protected virtual void WatchTickAction() { base.pawn.rotationTracker.FaceCell(base.TargetA.Cell); base.pawn.GainComfortFromCellIfPossible(); float statValue = base.TargetThingA.GetStatValue(StatDefOf.EntertainmentStrengthFactor, true); Pawn pawn = base.pawn; float extraJoyGainFactor = statValue; JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor); }
protected override void WaitTickAction() { float num = ArtThing.GetStatValue(StatDefOf.Beauty) / ArtThing.def.GetStatValueAbstract(StatDefOf.Beauty); float num2 = (!(num > 0f)) ? 0f : num; base.pawn.GainComfortFromCellIfPossible(); Pawn pawn = base.pawn; float extraJoyGainFactor = num2; JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor, (Building)ArtThing); }
protected override void WaitTickAction() { float num = this.ArtThing.GetStatValue(StatDefOf.Beauty, true) / this.ArtThing.def.GetStatValueAbstract(StatDefOf.Beauty, null); float num2 = (num <= 0f) ? 0f : num; this.pawn.GainComfortFromCellIfPossible(); Pawn pawn = this.pawn; float extraJoyGainFactor = num2; JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor, (Building)this.ArtThing); }
private bool ShouldBeCalledOff() { if (!PartyUtility.AcceptableGameConditionsToContinueParty(base.Map)) { return(true); } if (!spot.Roofed(base.Map) && !JoyUtility.EnjoyableOutsideNow(base.Map)) { return(true); } return(false); }
public override string GetExplanation() { Map map = this.BadMap(); int value = JoyUtility.JoyKindsOnMapCount(map); string label = map.info.parent.Label; ExpectationDef expectationDef = ExpectationsUtility.CurrentExpectationFor(map); int joyKindsNeeded = expectationDef.joyKindsNeeded; string value2 = "AvailableRecreationTypes".Translate() + ":\n\n" + JoyUtility.JoyKindsOnMapString(map); string value3 = "MissingRecreationTypes".Translate() + ":\n\n" + JoyUtility.JoyKindsNotOnMapString(map); return("NeedJoySourceDesc".Translate(value, label, expectationDef.label, joyKindsNeeded, value2, value3)); }
public override Job TryGiveJob(Pawn pawn) { if (!JoyUtility.EnjoyableOutsideNow(pawn) || pawn.Map.weatherManager.curWeather.rainRate > 0.1f) { return(null); } if (!RCellFinder.TryFindSkygazeCell(pawn.Position, pawn, out var result)) { return(null); } return(JobMaker.MakeJob(def.jobDef, result)); }
protected override void WaitTickAction() { float num = 1f; Room room = pawn.GetRoom(); if (room != null) { num *= room.GetStat(RoomStatDefOf.GraveVisitingJoyGainFactor); } pawn.GainComfortFromCellIfPossible(); JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, num, Grave); }
public static bool IsValidMarriageSpot(IntVec3 cell, Map map, StringBuilder outFailReason = null) { if (!cell.Standable(map)) { if (outFailReason != null) { outFailReason.Append("MarriageSpotNotStandable".Translate()); } return(false); } return(cell.Roofed(map) || JoyUtility.EnjoyableOutsideNow(map, outFailReason)); }
public static bool TryFindGatheringSpot(Pawn organizer, GatheringDef gatheringDef, out IntVec3 result) { bool enjoyableOutside = JoyUtility.EnjoyableOutsideNow(organizer); Map map = organizer.Map; Predicate <IntVec3> baseValidator = (IntVec3 cell) => GatheringsUtility.ValidateGatheringSpot(cell, gatheringDef, organizer, enjoyableOutside); List <ThingDef> gatherSpotDefs = gatheringDef.gatherSpotDefs; try { foreach (ThingDef item in gatherSpotDefs) { foreach (Building item2 in map.listerBuildings.AllBuildingsColonistOfDef(item)) { tmpSpotThings.Add(item2); } } if ((from x in tmpSpotThings where baseValidator(x.Position) select x.Position).TryRandomElement(out result)) { return(true); } } finally { tmpSpotThings.Clear(); } Predicate <IntVec3> noPartySpotValidator = delegate(IntVec3 cell) { Room room = cell.GetRoom(map); return((room == null || room.IsHuge || room.PsychologicallyOutdoors || room.CellCount >= 10) ? true : false); }; foreach (CompGatherSpot item3 in map.gatherSpotLister.activeSpots.InRandomOrder()) { for (int i = 0; i < 10; i++) { IntVec3 intVec = CellFinder.RandomClosewalkCellNear(item3.parent.Position, item3.parent.Map, 4); if (baseValidator(intVec) && noPartySpotValidator(intVec)) { result = intVec; return(true); } } } if (CellFinder.TryFindRandomCellNear(organizer.Position, organizer.Map, 25, (IntVec3 cell) => baseValidator(cell) && noPartySpotValidator(cell), out result)) { return(true); } result = IntVec3.Invalid; return(false); }
public override Job TryGiveJob(Pawn pawn) { bool allowedOutside = JoyUtility.EnjoyableOutsideNow(pawn, null); try { JoyGiver_ViewArt.candidates.AddRange(pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Art).Where(delegate(Thing thing) { if (thing.Faction == Faction.OfPlayer && !thing.IsForbidden(pawn) && (allowedOutside || thing.Position.Roofed(thing.Map)) && pawn.CanReserveAndReach(thing, PathEndMode.Touch, Danger.None, 1, -1, null, false) && thing.IsPoliticallyProper(pawn)) { CompArt compArt = thing.TryGetComp <CompArt>(); if (compArt == null) { Log.Error("No CompArt on thing being considered for viewing: " + thing); return(false); } if (compArt.CanShowArt && compArt.Props.canBeEnjoyedAsArt) { Room room = thing.GetRoom(RegionType.Set_Passable); if (room == null) { return(false); } if (room.Role != RoomRoleDefOf.Bedroom && room.Role != RoomRoleDefOf.Barracks && room.Role != RoomRoleDefOf.PrisonCell && room.Role != RoomRoleDefOf.PrisonBarracks && room.Role != RoomRoleDefOf.Hospital) { goto IL_014a; } if (pawn.ownership != null && pawn.ownership.OwnedRoom != null && pawn.ownership.OwnedRoom == room) { goto IL_014a; } return(false); } return(false); } return(false); IL_014a: return(true); })); Thing t = default(Thing); if (!((IEnumerable <Thing>)JoyGiver_ViewArt.candidates).TryRandomElementByWeight <Thing>((Func <Thing, float>)((Thing target) => Mathf.Max(target.GetStatValue(StatDefOf.Beauty, true), 0.5f)), out t)) { return(null); } return(new Job(base.def.jobDef, t)); } finally { JoyGiver_ViewArt.candidates.Clear(); } }
public override Job TryGiveJob(Pawn pawn) { if (JoyUtility.EnjoyableOutsideNow(pawn, null) && !(pawn.Map.weatherManager.curWeather.rainRate > 0.10000000149011612)) { IntVec3 c = default(IntVec3); if (!RCellFinder.TryFindSkygazeCell(pawn.Position, pawn, out c)) { return(null); } return(new Job(base.def.jobDef, c)); } return(null); }
protected override Action GetWaitTickAction() { return(delegate { float statValue = this.ArtThing.GetStatValue(StatDefOf.EntertainmentStrengthFactor, true); float num = this.ArtThing.GetStatValue(StatDefOf.Beauty, true) / this.ArtThing.def.GetStatValueAbstract(StatDefOf.Beauty, null); statValue = (float)(statValue * ((!(num > 0.0)) ? 0.0 : num)); base.pawn.GainComfortFromCellIfPossible(); Pawn pawn = base.pawn; float extraJoyGainFactor = statValue; JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor); }); }
protected override Action GetWaitTickAction() { return(delegate { float num = this.ArtThing.GetStatValue(StatDefOf.EntertainmentStrengthFactor, true); float num2 = this.ArtThing.GetStatValue(StatDefOf.Beauty, true) / this.ArtThing.def.GetStatValueAbstract(StatDefOf.Beauty, null); num *= ((num2 <= 0f) ? 0f : num2); this.pawn.GainComfortFromCellIfPossible(); Pawn pawn = this.pawn; float extraJoyGainFactor = num; JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor); }); }
protected override IEnumerable <Toil> MakeNewToils() { this.EndOnDespawnedOrNull(TargetIndex.A, JobCondition.Incompletable); Toil chooseCell = Toils_Misc.FindRandomAdjacentReachableCell(TargetIndex.A, TargetIndex.B); yield return(chooseCell); yield return(Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null)); yield return(Toils_Goto.GotoCell(TargetIndex.B, PathEndMode.OnCell)); Toil play = new Toil(); play.initAction = delegate() { this.job.locomotionUrgency = LocomotionUrgency.Walk; }; play.tickAction = delegate() { this.pawn.rotationTracker.FaceCell(base.TargetA.Thing.OccupiedRect().ClosestCellTo(this.pawn.Position)); if (this.ticksLeftThisToil == 300) { SoundDefOf.PlayBilliards.PlayOneShot(new TargetInfo(this.pawn.Position, this.pawn.Map, false)); } if (Find.TickManager.TicksGame > this.startTick + this.job.def.joyDuration) { base.EndJobWith(JobCondition.Succeeded); } else { Pawn pawn = this.pawn; Building joySource = (Building)base.TargetThingA; JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, 1f, joySource); } }; play.handlingFacing = true; play.socialMode = RandomSocialMode.SuperActive; play.defaultCompleteMode = ToilCompleteMode.Delay; play.defaultDuration = 600; play.AddFinishAction(delegate { JoyUtility.TryGainRecRoomThought(this.pawn); }); yield return(play); yield return(Toils_Reserve.Release(TargetIndex.B)); yield return(Toils_Jump.Jump(chooseCell)); yield break; }
public override float GetPriority(Pawn pawn) { if (pawn.needs.joy == null) { return(0f); } if (Find.TickManager.TicksGame < 5000) { return(0f); } if (JoyUtility.LordPreventsGettingJoy(pawn)) { return(0f); } float curLevel = pawn.needs.joy.CurLevel; TimeAssignmentDef timeAssignmentDef = (pawn.timetable == null) ? TimeAssignmentDefOf.Anything : pawn.timetable.CurrentAssignment; if (!timeAssignmentDef.allowJoy) { return(0f); } if (timeAssignmentDef == TimeAssignmentDefOf.Anything) { if (curLevel < 0.35f) { return(6f); } return(0f); } if (timeAssignmentDef == TimeAssignmentDefOf.Joy) { if (curLevel < 0.95f) { return(7f); } return(0f); } if (timeAssignmentDef == TimeAssignmentDefOf.Sleep) { if (curLevel < 0.95f) { return(2f); } return(0f); } if (timeAssignmentDef == TimeAssignmentDefOf.Meditate) { return(0f); } throw new NotImplementedException(); }
public override Job TryGiveJob(Pawn pawn) { if (!JoyUtility.EnjoyableOutsideNow(pawn, null) || pawn.Map.weatherManager.curWeather.rainRate > 0.1f) { return(null); } IntVec3 c; if (!RCellFinder.TryFindSkygazeCell(pawn.Position, pawn, out c)) { return(null); } return(new Job(this.def.jobDef, c)); }
public override Job TryGiveJob(Pawn pawn) { Job result; if (!JoyUtility.EnjoyableOutsideNow(pawn, null)) { result = null; } else if (PawnUtility.WillSoonHaveBasicNeed(pawn)) { result = null; } else { Predicate <IntVec3> cellValidator = (IntVec3 x) => !PawnUtility.KnownDangerAt(x, pawn.Map, pawn) && !x.GetTerrain(pawn.Map).avoidWander&& x.Standable(pawn.Map) && !x.Roofed(pawn.Map); Predicate <Region> validator = delegate(Region x) { IntVec3 intVec; return(x.Room.PsychologicallyOutdoors && !x.IsForbiddenEntirely(pawn) && x.TryFindRandomCellInRegionUnforbidden(pawn, cellValidator, out intVec)); }; Region reg; IntVec3 root; List <IntVec3> list; if (!CellFinder.TryFindClosestRegionWith(pawn.GetRegion(RegionType.Set_Passable), TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), validator, 100, out reg, RegionType.Set_Passable)) { result = null; } else if (!reg.TryFindRandomCellInRegionUnforbidden(pawn, cellValidator, out root)) { result = null; } else if (!WalkPathFinder.TryFindWalkPath(pawn, root, out list)) { result = null; } else { Job job = new Job(this.def.jobDef, list[0]); job.targetQueueA = new List <LocalTargetInfo>(); for (int i = 1; i < list.Count; i++) { job.targetQueueA.Add(list[i]); } job.locomotionUrgency = LocomotionUrgency.Walk; result = job; } } return(result); }
protected override void WaitTickAction() { float num = 1f; Room room = this.pawn.GetRoom(RegionType.Set_Passable); if (room != null) { num *= room.GetStat(RoomStatDefOf.GraveVisitingJoyGainFactor); } this.pawn.GainComfortFromCellIfPossible(); Pawn pawn = this.pawn; float extraJoyGainFactor = num; JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor, this.Grave); }
private bool NeedJoySource(Map map) { if (!map.IsPlayerHome) { return(false); } if (!map.mapPawns.AnyColonistSpawned) { return(false); } int num = JoyUtility.JoyKindsOnMapCount(map); int joyKindsNeeded = ExpectationsUtility.CurrentExpectationFor(map).joyKindsNeeded; return(num < joyKindsNeeded); }
public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; switch (num) { case 0u: this.EndOnDespawnedOrNull(TargetIndex.A, JobCondition.Incompletable); this.EndOnDespawnedOrNull(TargetIndex.B, JobCondition.Incompletable); this.$current = Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.OnCell); if (!this.$disposing) { this.$PC = 1; } return(true); case 1u: play = new Toil(); play.tickAction = delegate() { this.pawn.rotationTracker.FaceTarget(base.TargetA); this.pawn.GainComfortFromCellIfPossible(); Pawn pawn = this.pawn; Building joySource = (Building)base.TargetThingA; JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, 1f, joySource); }; play.handlingFacing = true; play.defaultCompleteMode = ToilCompleteMode.Delay; play.defaultDuration = this.job.def.joyDuration; play.AddFinishAction(delegate { JoyUtility.TryGainRecRoomThought(this.pawn); }); this.ModifyPlayToil(play); this.$current = play; if (!this.$disposing) { this.$PC = 2; } return(true); case 2u: this.$PC = -1; break; } return(false); }
protected override Job TryGiveJob(Pawn pawn) { if (pawn.needs.joy == null) { return(null); } if (Find.TickManager.TicksGame < 60000) { return(null); } if (JoyUtility.LordPreventsGettingJoy(pawn) || JoyUtility.TimetablePreventsGettingJoy(pawn)) { return(null); } return(base.TryGiveJob(pawn)); }
protected override Action GetWaitTickAction() { return(delegate { float num = this.Grave.GetStatValue(StatDefOf.EntertainmentStrengthFactor, true); Room room = this.pawn.GetRoom(RegionType.Set_Passable); if (room != null) { num *= room.GetStat(RoomStatDefOf.GraveVisitingJoyGainFactor); } this.pawn.GainComfortFromCellIfPossible(); Pawn pawn = this.pawn; float extraJoyGainFactor = num; JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor); }); }
public bool BoredOfAllAvailableJoyKinds(Pawn pawn) { List <JoyKindDef> list = JoyUtility.JoyKindsOnMapTempList(pawn.MapHeld); bool result = true; for (int i = 0; i < list.Count; i++) { if (!bored[list[i]]) { result = false; break; } } list.Clear(); return(result); }
public override string GetExplanation() { StringBuilder stringBuilder = new StringBuilder(); Pawn pawn = null; foreach (Pawn current in this.BoredPawns()) { stringBuilder.AppendLine(" " + current.Label); if (pawn == null) { pawn = current; } } string value = JoyUtility.JoyKindsOnMapString(pawn.Map); return("BoredomDesc".Translate(stringBuilder.ToString().TrimEndNewlines(), pawn.LabelShort, value, pawn.Named("PAWN"))); }
public override TaggedString GetExplanation() { StringBuilder stringBuilder = new StringBuilder(); Pawn pawn = null; foreach (Pawn boredPawn in BoredPawns) { stringBuilder.AppendLine(" " + boredPawn.Label); if (pawn == null) { pawn = boredPawn; } } string value = (pawn != null) ? JoyUtility.JoyKindsOnMapString(pawn.Map) : ""; return("BoredomDesc".Translate(stringBuilder.ToString().TrimEndNewlines(), pawn.LabelShort, value, pawn.Named("PAWN"))); }
public override string GetTipString() { string text = base.GetTipString(); string text2 = this.tolerances.TolerancesString(); if (!string.IsNullOrEmpty(text2)) { text = text + "\n\n" + text2; } Map mapHeld = this.pawn.MapHeld; if (mapHeld != null) { ExpectationDef expectationDef = ExpectationsUtility.CurrentExpectationFor(this.pawn); text = text + "\n\n" + "CurrentExpectationsAndRecreation".Translate(new object[] { expectationDef.label, expectationDef.joyToleranceDropPerDay.ToStringPercent(), expectationDef.joyKindsNeeded }); text = text + "\n\n" + JoyUtility.JoyKindsOnMapString(this.pawn.MapHeld); } else { Caravan caravan = this.pawn.GetCaravan(); if (caravan != null) { float num = caravan.needs.GetCurrentJoyGainPerTick(this.pawn) * 2500f; if (num > 0f) { string text3 = text; text = string.Concat(new string[] { text3, "\n\n", "GainingJoyBecauseCaravanNotMoving".Translate(), ": +", num.ToStringPercent(), "/", "LetterHour".Translate() }); } } } return(text); }
public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; switch (num) { case 0u: this.$current = Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.OnCell); if (!this.$disposing) { this.$PC = 1; } return(true); case 1u: gaze = new Toil(); gaze.initAction = delegate() { this.pawn.jobs.posture = PawnPosture.LayingOnGroundFaceUp; }; gaze.tickAction = delegate() { float num2 = this.pawn.Map.gameConditionManager.AggregateSkyGazeJoyGainFactor(this.pawn.Map); Pawn pawn = this.pawn; float extraJoyGainFactor = num2; JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.EndJob, extraJoyGainFactor, null); }; gaze.defaultCompleteMode = ToilCompleteMode.Delay; gaze.defaultDuration = this.job.def.joyDuration; gaze.FailOn(() => this.pawn.Position.Roofed(this.pawn.Map)); gaze.FailOn(() => !JoyUtility.EnjoyableOutsideNow(this.pawn, null)); this.$current = gaze; if (!this.$disposing) { this.$PC = 2; } return(true); case 2u: this.$PC = -1; break; } return(false); }
public override Job TryGiveJob(Pawn pawn) { bool allowedOutside = JoyUtility.EnjoyableOutsideNow(pawn); if (!pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Grave).Where(delegate(Thing x) { Building_Grave building_Grave = (Building_Grave)x; return(x.Faction == Faction.OfPlayer && building_Grave.HasCorpse && !building_Grave.IsForbidden(pawn) && building_Grave.Corpse.InnerPawn.Faction == Faction.OfPlayer && (allowedOutside || building_Grave.Position.Roofed(building_Grave.Map)) && pawn.CanReserveAndReach(x, PathEndMode.Touch, Danger.None) && building_Grave.IsPoliticallyProper(pawn)); }).TryRandomElementByWeight(delegate(Thing x) { float lengthHorizontal = (x.Position - pawn.Position).LengthHorizontal; return(Mathf.Max(150f - lengthHorizontal, 5f)); }, out var result)) { return(null); } return(JobMaker.MakeJob(def.jobDef, result)); }