public bool CheckSocialFightStart(InteractionDef interaction, Pawn initiator) { bool result; if (!DebugSettings.enableRandomMentalStates) { result = false; } else if (this.pawn.needs.mood == null || TutorSystem.TutorialMode) { result = false; } else if (!InteractionUtility.HasAnySocialFightProvokingThought(this.pawn, initiator)) { result = false; } else if (DebugSettings.alwaysSocialFight || Rand.Value < this.SocialFightChance(interaction, initiator)) { this.StartSocialFight(initiator); result = true; } else { result = false; } return(result); }
protected override Job TryGiveJob(Pawn pawn) { Job result; if (pawn.RaceProps.Humanlike && pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { result = null; } else { Pawn otherPawn = ((MentalState_SocialFighting)pawn.MentalState).otherPawn; Verb verbToUse; if (!InteractionUtility.TryGetRandomVerbForSocialFight(pawn, out verbToUse)) { result = null; } else { result = new Job(JobDefOf.SocialFight, otherPawn) { maxNumMeleeAttacks = 1, verbToUse = verbToUse }; } } return(result); }
protected override Job TryGiveJob(Pawn pawn) { MentalState_Tantrum mentalState_Tantrum = pawn.MentalState as MentalState_Tantrum; if (mentalState_Tantrum == null || mentalState_Tantrum.target == null || !pawn.CanReach(mentalState_Tantrum.target, PathEndMode.Touch, Danger.Deadly)) { return(null); } Verb verb = null; Pawn pawn2 = mentalState_Tantrum.target as Pawn; if (pawn2 != null) { if (pawn2.Downed) { return(null); } if (!InteractionUtility.TryGetRandomVerbForSocialFight(pawn, out verb)) { return(null); } } Job job = JobMaker.MakeJob(JobDefOf.AttackMelee, mentalState_Tantrum.target); job.maxNumMeleeAttacks = 1; job.verbToUse = verb; return(job); }
private bool TryInteractRandomly() { if (this.InteractedTooRecentlyToInteract()) { return(false); } if (!InteractionUtility.CanInitiateRandomInteraction(this.pawn)) { return(false); } List <Pawn> collection = this.pawn.Map.mapPawns.SpawnedPawnsInFaction(this.pawn.Faction); Pawn_InteractionsTracker.workingList.Clear(); Pawn_InteractionsTracker.workingList.AddRange(collection); Pawn_InteractionsTracker.workingList.Shuffle <Pawn>(); List <InteractionDef> allDefsListForReading = DefDatabase <InteractionDef> .AllDefsListForReading; for (int i = 0; i < Pawn_InteractionsTracker.workingList.Count; i++) { Pawn p = Pawn_InteractionsTracker.workingList[i]; if (p != this.pawn && this.CanInteractNowWith(p) && InteractionUtility.CanReceiveRandomInteraction(p) && !this.pawn.HostileTo(p)) { InteractionDef intDef; if (allDefsListForReading.TryRandomElementByWeight((InteractionDef x) => x.Worker.RandomSelectionWeight(this.pawn, p), out intDef)) { if (this.TryInteractWith(p, intDef)) { return(true); } Log.Error(this.pawn + " failed to interact with " + p); } } } return(false); }
protected override Job TryGiveJob(Pawn pawn) { MentalState_Tantrum mentalState_Tantrum = pawn.MentalState as MentalState_Tantrum; if (mentalState_Tantrum == null || mentalState_Tantrum.target == null || !pawn.CanReach(mentalState_Tantrum.target, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn)) { return(null); } Verb verbToUse = null; Pawn pawn2 = mentalState_Tantrum.target as Pawn; if (pawn2 != null) { if (pawn2.Downed) { return(null); } if (!InteractionUtility.TryGetRandomVerbForSocialFight(pawn, out verbToUse)) { return(null); } } return(new Job(JobDefOf.AttackMelee, mentalState_Tantrum.target) { maxNumMeleeAttacks = 1, verbToUse = verbToUse }); }
private bool TryInteractRandomly() { if (InteractedTooRecentlyToInteract()) { return(false); } if (!InteractionUtility.CanInitiateRandomInteraction(pawn)) { return(false); } List <Pawn> collection = pawn.Map.mapPawns.SpawnedPawnsInFaction(pawn.Faction); workingList.Clear(); workingList.AddRange(collection); workingList.Shuffle(); List <InteractionDef> allDefsListForReading = DefDatabase <InteractionDef> .AllDefsListForReading; for (int i = 0; i < workingList.Count; i++) { Pawn p = workingList[i]; if (p != pawn && CanInteractNowWith(p) && InteractionUtility.CanReceiveRandomInteraction(p) && !pawn.HostileTo(p) && allDefsListForReading.TryRandomElementByWeight((InteractionDef x) => (!CanInteractNowWith(p, x)) ? 0f : x.Worker.RandomSelectionWeight(pawn, p), out InteractionDef result)) { if (TryInteractWith(p, result)) { workingList.Clear(); return(true); } Log.Error(pawn + " failed to interact with " + p); } } workingList.Clear(); return(false); }
internal void <> m__1() { Pawn actor = this.toil.actor; Pawn pawn = (Pawn)((Thing)actor.CurJob.GetTarget(this.target)); Map map = actor.Map; if (InteractionUtility.IsGoodPositionForInteraction(actor, pawn) && actor.Position.InHorDistOf(pawn.Position, (float)Mathf.CeilToInt(3f)) && (!actor.pather.Moving || actor.pather.nextCell.GetDoor(map) == null)) { actor.pather.StopDead(); actor.jobs.curDriver.ReadyForNextToil(); } else if (!actor.pather.Moving) { IntVec3 intVec = IntVec3.Invalid; for (int i = 0; i < 8; i++) { IntVec3 intVec2 = pawn.Position + GenAdj.AdjacentCells[i]; if (intVec2.InBounds(map) && intVec2.Standable(map) && intVec2 != actor.Position && InteractionUtility.IsGoodPositionForInteraction(intVec2, pawn.Position, map) && actor.CanReach(intVec2, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn) && (!intVec.IsValid || actor.Position.DistanceToSquared(intVec2) < actor.Position.DistanceToSquared(intVec))) { intVec = intVec2; } } if (intVec.IsValid) { actor.pather.StartPath(intVec, PathEndMode.OnCell); } else { actor.jobs.curDriver.EndJobWith(JobCondition.Incompletable); } } }
public void StartSocialFight(Pawn otherPawn) { if (PawnUtility.ShouldSendNotificationAbout(this.pawn) || PawnUtility.ShouldSendNotificationAbout(otherPawn)) { Thought thought = default(Thought); if (!InteractionUtility.TryGetRandomSocialFightProvokingThought(this.pawn, otherPawn, out thought)) { Log.Warning("Pawn " + this.pawn + " started a social fight with " + otherPawn + ", but he has no negative opinion thoughts towards " + otherPawn + "."); } else { Messages.Message("MessageSocialFight".Translate(this.pawn.LabelShort, otherPawn.LabelShort, thought.LabelCapSocial), this.pawn, MessageTypeDefOf.ThreatSmall); } } MentalStateHandler mentalStateHandler = this.pawn.mindState.mentalStateHandler; MentalStateDef socialFighting = MentalStateDefOf.SocialFighting; mentalStateHandler.TryStartMentalState(socialFighting, null, false, false, otherPawn); MentalStateHandler mentalStateHandler2 = otherPawn.mindState.mentalStateHandler; socialFighting = MentalStateDefOf.SocialFighting; Pawn otherPawn2 = this.pawn; mentalStateHandler2.TryStartMentalState(socialFighting, null, false, false, otherPawn2); TaleRecorder.RecordTale(TaleDefOf.SocialFight, this.pawn, otherPawn); }
public static Toil GotoInteractablePosition(TargetIndex target) { Toil toil = new Toil(); toil.initAction = delegate { Pawn actor = toil.actor; Pawn pawn = (Pawn)((Thing)actor.CurJob.GetTarget(target)); if (InteractionUtility.IsGoodPositionForInteraction(actor, pawn)) { actor.jobs.curDriver.ReadyForNextToil(); } else { actor.pather.StartPath(pawn, PathEndMode.Touch); } }; toil.tickAction = delegate { Pawn actor = toil.actor; Pawn pawn = (Pawn)((Thing)actor.CurJob.GetTarget(target)); Map map = actor.Map; if (InteractionUtility.IsGoodPositionForInteraction(actor, pawn) && actor.Position.InHorDistOf(pawn.Position, (float)Mathf.CeilToInt(3f)) && (!actor.pather.Moving || actor.pather.nextCell.GetDoor(map) == null)) { actor.pather.StopDead(); actor.jobs.curDriver.ReadyForNextToil(); } else if (!actor.pather.Moving) { IntVec3 intVec = IntVec3.Invalid; for (int i = 0; i < 9; i++) { if (i == 8 && intVec.IsValid) { break; } IntVec3 intVec2 = pawn.Position + GenAdj.AdjacentCellsAndInside[i]; if (intVec2.InBounds(map) && intVec2.Walkable(map) && intVec2 != actor.Position && InteractionUtility.IsGoodPositionForInteraction(intVec2, pawn.Position, map) && actor.CanReach(intVec2, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn) && (!intVec.IsValid || actor.Position.DistanceToSquared(intVec2) < actor.Position.DistanceToSquared(intVec))) { intVec = intVec2; } } if (intVec.IsValid) { actor.pather.StartPath(intVec, PathEndMode.OnCell); } else { actor.jobs.curDriver.EndJobWith(JobCondition.Incompletable); } } }; toil.socialMode = RandomSocialMode.Off; toil.defaultCompleteMode = ToilCompleteMode.Never; return(toil); }
public float SocialFightChance(InteractionDef interaction, Pawn initiator) { if (!pawn.RaceProps.Humanlike || !initiator.RaceProps.Humanlike) { return(0f); } if (!InteractionUtility.HasAnyVerbForSocialFight(pawn) || !InteractionUtility.HasAnyVerbForSocialFight(initiator)) { return(0f); } if (pawn.WorkTagIsDisabled(WorkTags.Violent)) { return(0f); } if (initiator.Downed || pawn.Downed) { return(0f); } float socialFightBaseChance = interaction.socialFightBaseChance; socialFightBaseChance *= Mathf.InverseLerp(0.3f, 1f, pawn.health.capacities.GetLevel(PawnCapacityDefOf.Manipulation)); socialFightBaseChance *= Mathf.InverseLerp(0.3f, 1f, pawn.health.capacities.GetLevel(PawnCapacityDefOf.Moving)); List <Hediff> hediffs = pawn.health.hediffSet.hediffs; for (int i = 0; i < hediffs.Count; i++) { if (hediffs[i].CurStage != null) { socialFightBaseChance *= hediffs[i].CurStage.socialFightChanceFactor; } } float num = pawn.relations.OpinionOf(initiator); socialFightBaseChance = ((!(num < 0f)) ? (socialFightBaseChance * GenMath.LerpDouble(0f, 100f, 1f, 0.6f, num)) : (socialFightBaseChance * GenMath.LerpDouble(-100f, 0f, 4f, 1f, num))); if (pawn.RaceProps.Humanlike) { List <Trait> allTraits = pawn.story.traits.allTraits; for (int j = 0; j < allTraits.Count; j++) { socialFightBaseChance *= allTraits[j].CurrentData.socialFightChanceFactor; } } int num2 = Mathf.Abs(pawn.ageTracker.AgeBiologicalYears - initiator.ageTracker.AgeBiologicalYears); if (num2 > 10) { if (num2 > 50) { num2 = 50; } socialFightBaseChance *= GenMath.LerpDouble(10f, 50f, 1f, 0.25f, num2); } return(Mathf.Clamp01(socialFightBaseChance)); }
public static bool CanReceiveRandomInteraction(Pawn p) { if (!InteractionUtility.CanReceiveInteraction(p)) { return(false); } if (p.RaceProps.Humanlike && !p.Downed && !p.InAggroMentalState) { return(true); } return(false); }
public override Job TryGiveJob(Pawn pawn) { if (!InteractionUtility.CanInitiateInteraction(pawn)) { return null; } Pawn pawn2 = SickPawnVisitUtility.FindRandomSickPawn(pawn, JoyCategory.Low); if (pawn2 == null) { return null; } return new Job(base.def.jobDef, pawn2, SickPawnVisitUtility.FindChair(pawn, pawn2)); }
internal void <> m__0() { Pawn actor = this.toil.actor; Pawn pawn = (Pawn)((Thing)actor.CurJob.GetTarget(this.target)); if (InteractionUtility.IsGoodPositionForInteraction(actor, pawn)) { actor.jobs.curDriver.ReadyForNextToil(); } else { actor.pather.StartPath(pawn, PathEndMode.Touch); } }
public bool CanInteractNowWith(Pawn recipient, InteractionDef interactionDef = null) { if (!recipient.Spawned) { return(false); } if (!InteractionUtility.IsGoodPositionForInteraction(pawn, recipient)) { return(false); } if (!InteractionUtility.CanInitiateInteraction(pawn, interactionDef) || !InteractionUtility.CanReceiveInteraction(recipient, interactionDef)) { return(false); } return(true); }
public bool CanInteractNowWith(Pawn recipient) { if (!recipient.Spawned) { return(false); } if (!InteractionUtility.IsGoodPositionForInteraction(this.pawn, recipient)) { return(false); } if (InteractionUtility.CanInitiateInteraction(this.pawn) && InteractionUtility.CanReceiveInteraction(recipient)) { return(true); } return(false); }
public bool CheckSocialFightStart(InteractionDef interaction, Pawn initiator) { if (this.pawn.needs.mood == null || TutorSystem.TutorialMode) { return(false); } if (!InteractionUtility.HasAnySocialFightProvokingThought(this.pawn, initiator)) { return(false); } if (DebugSettings.alwaysSocialFight || Rand.Value < this.SocialFightChance(interaction, initiator)) { this.StartSocialFight(initiator); return(true); } return(false); }
public override bool ShouldSkip(Pawn pawn, bool forced = false) { if (!InteractionUtility.CanInitiateInteraction(pawn)) { return(true); } List <Pawn> list = pawn.Map.mapPawns.SpawnedPawnsInFaction(Faction.OfPlayer); for (int i = 0; i < list.Count; i++) { if (list[i].InBed()) { return(false); } } return(true); }
protected override Job TryGiveJob(Pawn pawn) { if (pawn.RaceProps.Humanlike && pawn.WorkTagIsDisabled(WorkTags.Violent)) { return(null); } Pawn otherPawn = ((MentalState_SocialFighting)pawn.MentalState).otherPawn; if (!InteractionUtility.TryGetRandomVerbForSocialFight(pawn, out var verb)) { return(null); } Job job = JobMaker.MakeJob(JobDefOf.SocialFight, otherPawn); job.maxNumMeleeAttacks = 1; job.verbToUse = verb; return(job); }
public void StartSocialFight(Pawn otherPawn) { if (PawnUtility.ShouldSendNotificationAbout(this.pawn) || PawnUtility.ShouldSendNotificationAbout(otherPawn)) { Thought thought; if (!InteractionUtility.TryGetRandomSocialFightProvokingThought(this.pawn, otherPawn, out thought)) { Log.Warning(string.Concat(new object[] { "Pawn ", this.pawn, " started a social fight with ", otherPawn, ", but he has no negative opinion thoughts towards ", otherPawn, "." })); } else { Messages.Message("MessageSocialFight".Translate(new object[] { this.pawn.LabelShort, otherPawn.LabelShort, thought.LabelCapSocial }), this.pawn, MessageTypeDefOf.ThreatSmall); } } MentalStateHandler arg_D6_0 = this.pawn.mindState.mentalStateHandler; MentalStateDef socialFighting = MentalStateDefOf.SocialFighting; arg_D6_0.TryStartMentalState(socialFighting, null, false, false, otherPawn); MentalStateHandler arg_F9_0 = otherPawn.mindState.mentalStateHandler; socialFighting = MentalStateDefOf.SocialFighting; Pawn otherPawn2 = this.pawn; arg_F9_0.TryStartMentalState(socialFighting, null, false, false, otherPawn2); TaleRecorder.RecordTale(TaleDefOf.SocialFight, new object[] { this.pawn, otherPawn }); }
public override Job TryGiveJob(Pawn pawn) { Job result; if (!InteractionUtility.CanInitiateInteraction(pawn)) { result = null; } else { Pawn pawn2 = SickPawnVisitUtility.FindRandomSickPawn(pawn, JoyCategory.Low); if (pawn2 == null) { result = null; } else { result = new Job(this.def.jobDef, pawn2, SickPawnVisitUtility.FindChair(pawn, pawn2)); } } return(result); }
// Token: 0x0600006E RID: 110 RVA: 0x0000463C File Offset: 0x0000283C public override Job TryGiveJob(Pawn pawn) { bool flag = !InteractionUtility.CanInitiateInteraction(pawn, null); Job result; if (flag) { result = null; } else { Pawn pawn2 = SickPawnVisitUtility.FindRandomSickPawn(pawn, JoyCategory.Low); bool flag2 = pawn2 == null; if (flag2) { result = null; } else { result = new Job(WPJobDefOf.WPVisitSickPawn, pawn2, SickPawnVisitUtility.FindChair(pawn, pawn2)); } } return(result); }
public override bool ShouldSkip(Pawn pawn) { return(!InteractionUtility.CanInitiateInteraction(pawn)); }
public static bool IsGoodPositionForInteraction(Pawn p, Pawn recipient) { return(InteractionUtility.IsGoodPositionForInteraction(p.Position, recipient.Position, p.Map)); }
public static bool CanInitiateRandomInteraction(Pawn p) { return(InteractionUtility.CanInitiateInteraction(p) && p.RaceProps.Humanlike && !p.Downed && !p.InAggroMentalState && p.Faction != null); }
public static bool HasAnySocialFightProvokingThought(Pawn pawn, Pawn otherPawn) { Thought thought = default(Thought); return(InteractionUtility.TryGetRandomSocialFightProvokingThought(pawn, otherPawn, out thought)); }
public bool CanInteractNowWith(Pawn recipient) { return(recipient.Spawned && InteractionUtility.IsGoodPositionForInteraction(this.pawn, recipient) && InteractionUtility.CanInitiateInteraction(this.pawn) && InteractionUtility.CanReceiveInteraction(recipient)); }
// Token: 0x060000C5 RID: 197 RVA: 0x00006290 File Offset: 0x00004490 public override bool ShouldSkip(Pawn pawn, bool forced = false) { return(!InteractionUtility.CanInitiateInteraction(pawn, null)); }
public static bool CanReceiveRandomInteraction(Pawn p) { return(InteractionUtility.CanReceiveInteraction(p) && p.RaceProps.Humanlike && !p.Downed && !p.InAggroMentalState); }
public static bool CanVisit(Pawn pawn, Pawn sick, JoyCategory maxPatientJoy) { return(sick.IsColonist && !sick.Dead && pawn != sick && sick.InBed() && sick.Awake() && !sick.IsForbidden(pawn) && sick.needs.joy != null && (int)sick.needs.joy.CurCategory <= (int)maxPatientJoy && InteractionUtility.CanReceiveInteraction(sick) && !sick.needs.food.Starving && sick.needs.rest.CurLevel > 0.33000001311302185 && pawn.CanReserveAndReach(sick, PathEndMode.InteractionCell, Danger.None, 1, -1, null, false) && !SickPawnVisitUtility.AboutToRecover(sick)); }
public float SocialFightChance(InteractionDef interaction, Pawn initiator) { float result; if (!this.pawn.RaceProps.Humanlike || !initiator.RaceProps.Humanlike) { result = 0f; } else if (!InteractionUtility.HasAnyVerbForSocialFight(this.pawn) || !InteractionUtility.HasAnyVerbForSocialFight(initiator)) { result = 0f; } else if (this.pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { result = 0f; } else if (initiator.Downed || this.pawn.Downed) { result = 0f; } else { float num = interaction.socialFightBaseChance; num *= Mathf.InverseLerp(0.3f, 1f, this.pawn.health.capacities.GetLevel(PawnCapacityDefOf.Manipulation)); num *= Mathf.InverseLerp(0.3f, 1f, this.pawn.health.capacities.GetLevel(PawnCapacityDefOf.Moving)); List <Hediff> hediffs = this.pawn.health.hediffSet.hediffs; for (int i = 0; i < hediffs.Count; i++) { if (hediffs[i].CurStage != null) { num *= hediffs[i].CurStage.socialFightChanceFactor; } } float num2 = (float)this.pawn.relations.OpinionOf(initiator); if (num2 < 0f) { num *= GenMath.LerpDouble(-100f, 0f, 4f, 1f, num2); } else { num *= GenMath.LerpDouble(0f, 100f, 1f, 0.6f, num2); } if (this.pawn.RaceProps.Humanlike) { List <Trait> allTraits = this.pawn.story.traits.allTraits; for (int j = 0; j < allTraits.Count; j++) { num *= allTraits[j].CurrentData.socialFightChanceFactor; } } int num3 = Mathf.Abs(this.pawn.ageTracker.AgeBiologicalYears - initiator.ageTracker.AgeBiologicalYears); if (num3 > 10) { if (num3 > 50) { num3 = 50; } num *= GenMath.LerpDouble(10f, 50f, 1f, 0.25f, (float)num3); } result = Mathf.Clamp01(num); } return(result); }