Ejemplo n.º 1
0
 public static bool CanTalkTo(this Pawn talker, Pawn talkee)
 {
     return(talker.MapHeld == talkee.MapHeld &&
            InteractionUtility.CanInitiateInteraction(talker) &&
            InteractionUtility.CanReceiveInteraction(talkee) &&
            CanSee(talker, talkee));
 }
Ejemplo n.º 2
0
 public static bool CanTalkTo(this Pawn talker, Pawn talkee)
 {
     return(talker.MapHeld == talkee.MapHeld &&
            InteractionUtility.CanInitiateInteraction(talker) &&
            InteractionUtility.CanReceiveInteraction(talkee) &&
            (talker.Position - talkee.Position).LengthHorizontalSquared <= 36.0 &&
            GenSight.LineOfSight(talker.Position, talkee.Position, talker.MapHeld, true));
 }
Ejemplo n.º 3
0
 private static bool CanInteractNowWith(Pawn pawn, Pawn recipient) // Had to add, copy
 {
     return(recipient.Spawned &&
            ((pawn.Position - recipient.Position).LengthHorizontalSquared <= 36.0 &&
             InteractionUtility.CanInitiateInteraction(pawn) &&
             (InteractionUtility.CanReceiveInteraction(recipient) &&
              GenSight.LineOfSight(pawn.Position, recipient.Position, pawn.MapHeld, true))));
 }
            static bool SapientAnimalPatch([NotNull] Pawn p, ref bool __result)
            {
                if (p.IsSapientOrFeralFormerHuman())
                {
                    __result = InteractionUtility.CanReceiveInteraction(p) && (!p.Downed && !p.InAggroMentalState);
                    return(false);
                }

                return(true);
            }
Ejemplo n.º 5
0
        static bool Prefix(Pawn pawn, Pawn sick, JoyCategory maxPatientJoy, ref bool __result)
        {
            if (sick.needs.rest != null)
            {
                return(true);
            }

            __result = sick.IsColonist && !sick.Dead && pawn != sick && sick.InBed() &&
                       sick.Awake() && !sick.IsForbidden(pawn) && sick.needs.joy != null &&
                       sick.needs.joy.CurCategory <= maxPatientJoy &&
                       InteractionUtility.CanReceiveInteraction(sick) && !sick.needs.food.Starving &&
                       pawn.CanReserveAndReach(sick, PathEndMode.InteractionCell, Danger.None, 1, -1, null, false);
            return(false);
        }
Ejemplo n.º 6
0
        // RimWorld.SickPawnVisitUtility
        public static bool Vamp_CanVisit(ref bool __result, Pawn pawn, Pawn sick, JoyCategory maxPatientJoy)
        {
            if (sick.IsVampire())
            {
                __result = sick.IsColonist && !sick.Dead && pawn != sick && sick.InBed() && sick.Awake() &&
                           !sick.IsForbidden(pawn) && sick.needs.joy != null &&
                           sick.needs.joy.CurCategory <= maxPatientJoy &&
                           InteractionUtility.CanReceiveInteraction(sick) &&
                           pawn.CanReserveAndReach(sick, PathEndMode.InteractionCell, Danger.None) &&
                           !AboutToRecover(sick);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 7
0
        public static bool ShouldImproveRelationship(this Pawn pawn, Pawn guest)
        {
            if (!pawn.IsColonist)
            {
                return(false);
            }
            if (!ViableGuestTarget(guest))
            {
                return(false);
            }
            if (!guest.ImproveRelationship())
            {
                return(false);
            }
            //if (guest.Faction.ColonyGoodwill >= 100) return false;
            if (guest.relations.OpinionOf(pawn) >= 100)
            {
                return(false);
            }
            if (guest.InMentalState)
            {
                return(false);
            }
            if (!guest.IsInGuestZone(guest))
            {
                return(false);
            }
            if (!InteractionUtility.CanInitiateInteraction(pawn))
            {
                return(false);
            }
            if (!InteractionUtility.CanReceiveInteraction(guest))
            {
                return(false);
            }
            if (!pawn.HasReserved(guest) && !pawn.CanReserveAndReach(guest, PathEndMode.OnCell, pawn.NormalMaxDanger()))
            {
                return(false);
            }
            if (guest.CurJob?.def.suspendable == false)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 8
0
        public static bool ShouldMakeFriends(this Pawn pawn, Pawn guest)
        {
            if (!pawn.IsColonist)
            {
                return(false);
            }
            if (!ViableGuestTarget(guest, true))
            {
                return(false);
            }
            if (!guest.MakeFriends())
            {
                return(false);
            }
            if (guest.InMentalState)
            {
                return(false);
            }
            //if (guest.relations.OpinionOf(pawn) >= 100) return false;
            //if (guest.RelativeTrust() < 50) return false;
            if (guest.relations.OpinionOf(pawn) <= -10)
            {
                return(false);
            }
            if (!InteractionUtility.CanInitiateInteraction(pawn))
            {
                return(false);
            }
            if (!InteractionUtility.CanReceiveInteraction(guest))
            {
                return(false);
            }
            if (!pawn.HasReserved(guest) && !pawn.CanReserveAndReach(guest, PathEndMode.OnCell, pawn.NormalMaxDanger()))
            {
                return(false);
            }
            if (guest.CurJob?.def.suspendable == false)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 9
0
 public override void Tick()
 {
     base.Tick();
     if (this.realPawn == null)
     {
         this.realPawn = this.pawn as PsychologyPawn;
     }
     if (this.otherPawn == null)
     {
         this.pawn.health.RemoveHediff(this);
         return;
     }
     if (!this.otherPawn.Spawned || !this.pawn.Spawned || !InteractionUtility.CanReceiveInteraction(this.pawn) || !InteractionUtility.CanReceiveInteraction(this.otherPawn))
     {
         this.pawn.health.RemoveHediff(this);
         return;
     }
     if ((this.pawn.Position - this.otherPawn.Position).LengthHorizontalSquared >= 54f || !GenSight.LineOfSight(this.pawn.Position, this.otherPawn.Position, this.pawn.Map, true))
     {
         this.pawn.health.RemoveHediff(this);
         return;
     }
     if (this.otherPawn.Dead || this.otherPawn.Downed || this.otherPawn.InAggroMentalState)
     {
         this.pawn.health.RemoveHediff(this);
         return;
     }
     if (this.pawn.IsHashIntervalTick(200))
     {
         if (Rand.Value > 1f - (this.ageTicks / 400000f))
         {
             this.pawn.health.RemoveHediff(this);
             return;
         }
         else if (Rand.Value < 0.2f && this.pawn.Map != null)
         {
             MoteMaker.MakeInteractionBubble(this.pawn, otherPawn, InteractionDefOf.DeepTalk.interactionMote, InteractionDefOf.DeepTalk.Symbol);
         }
     }
 }
Ejemplo n.º 10
0
        public static bool ShouldRecruit(this Pawn pawn, Pawn guest)
        {
            if (!ViableGuestTarget(guest, true))
            {
                return(false);
            }
            if (!guest.TryRecruit())
            {
                return(false);
            }
            if (guest.InMentalState)
            {
                return(false);
            }
            //if (guest.relations.OpinionOf(pawn) >= 100) return false;
            //if (guest.RelativeTrust() < 50) return false;
            if (guest.relations.OpinionOf(pawn) <= -10)
            {
                return(false);
            }
            //if (guest.interactions.InteractedTooRecentlyToInteract()) return false;
            //if (pawn.interactions.InteractedTooRecentlyToInteract()) return false;
            if (!InteractionUtility.CanInitiateInteraction(pawn))
            {
                return(false);
            }
            if (!InteractionUtility.CanReceiveInteraction(guest))
            {
                return(false);
            }
            if (!pawn.HasReserved(guest) && !pawn.CanReserveAndReach(guest, PathEndMode.OnCell, pawn.NormalMaxDanger()))
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 11
0
 public override void Tick()
 {
     base.Tick();
     if (this.otherPawn == null)
     {
         this.pawn.health.RemoveHediff(this);
         return;
     }
     if (!this.otherPawn.Spawned || !this.pawn.Spawned || !InteractionUtility.CanReceiveInteraction(this.pawn) || !InteractionUtility.CanReceiveInteraction(this.otherPawn))
     {
         this.pawn.health.RemoveHediff(this);
         return;
     }
     if (this.pawn.Map != null && this.otherPawn.Map != null && ((this.pawn.Position - this.otherPawn.Position).LengthHorizontalSquared >= 54f || !GenSight.LineOfSight(this.pawn.Position, this.otherPawn.Position, this.pawn.Map, true)))
     {
         this.pawn.health.RemoveHediff(this);
         return;
     }
     if (this.otherPawn.Dead || this.otherPawn.Downed || this.otherPawn.InAggroMentalState)
     {
         this.pawn.health.RemoveHediff(this);
         return;
     }
     if (this.pawn.IsHashIntervalTick(200))
     {
         /* When a conversation first starts, the mean time for it to last is 3 hours.
          * When it reaches half an hour, the mean time for it to continue is 2 hours.
          * When it reaches an hour, the mean time for it to continue is 1 hour.
          * When it surpasses 2 hours, it will on average last for half an hour more.
          * Conversations will thus usually not surpass 2 hours, and very rarely surpass 2 and a half hours, but are very likely to last up to an hour.
          */
         float mtb = 3f;
         if (this.ageTicks > GenDate.TicksPerHour * 2)
         {
             mtb = 0.5f;
         }
         else if (this.ageTicks > GenDate.TicksPerHour)
         {
             mtb = 1f;
         }
         else if (this.ageTicks > (GenDate.TicksPerHour / 2))
         {
             mtb = 2f;
         }
         if (pawn.story.traits.HasTrait(TraitDefOfPsychology.Chatty))
         {
             mtb *= 2f;
         }
         if (this.otherPawn.story.traits.HasTrait(TraitDefOfPsychology.Chatty))
         {
             mtb *= 2f;
         }
         if (Rand.MTBEventOccurs(mtb, GenDate.TicksPerHour, 200))
         {
             this.pawn.health.RemoveHediff(this);
             return;
         }
         else if (Rand.Value < 0.2f && this.pawn.Map != null)
         {
             MoteMaker.MakeInteractionBubble(this.pawn, otherPawn, InteractionDefOfPsychology.EndConversation.interactionMote, InteractionDefOfPsychology.EndConversation.Symbol);
         }
     }
 }
Ejemplo n.º 12
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (pawn.interactions.InteractedTooRecentlyToInteract() || lastInteractionTick > Find.TickManager.TicksGame - 500)
            {
                return(null);
            }
            Predicate <Thing> validator = delegate(Thing t)
            {
                Pawn pawn3 = (Pawn)t;
                return(pawn3 != pawn && !pawn3.Dead && !pawn3.Downed && pawn3.Awake() && InteractionUtility.CanReceiveInteraction(pawn3) && pawn3.RaceProps.Humanlike);
            };
            Pawn pawn2 = (Pawn)GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForGroup(ThingRequestGroup.Pawn), PathEndMode.OnCell, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, validator);

            if (pawn2 == null || Rand.Value > 0.5f)
            {
                return(null);
            }
            lastInteractionTick = Find.TickManager.TicksGame;
            return(new Job(JobDefOfPsychology.Abuse, pawn2));
        }
Ejemplo n.º 13
0
        // Token: 0x06000095 RID: 149 RVA: 0x00005528 File Offset: 0x00003728
        protected override Job TryGiveJob(Pawn pawn)
        {
            //IL_003f: Unknown result type (might be due to invalid IL or missing references)
            //IL_0051: Unknown result type (might be due to invalid IL or missing references)
            //IL_0060: Unknown result type (might be due to invalid IL or missing references)
            //IL_0081: Unknown result type (might be due to invalid IL or missing references)
            //IL_0087: Expected O, but got Unknown
            //IL_00ae: Unknown result type (might be due to invalid IL or missing references)
            //IL_00b3: Unknown result type (might be due to invalid IL or missing references)
            //IL_00b9: Expected O, but got Unknown
            if (pawn.interactions.InteractedTooRecentlyToInteract() || lastInteractionTick > Find.TickManager.TicksGame - 500)
            {
                return(null);
            }
            Pawn val = (Pawn)(object)(Pawn)GenClosest.ClosestThingReachable(((Thing)pawn).Position, ((Thing)pawn).Map, ThingRequest.ForGroup((ThingRequestGroup)11), (PathEndMode)1, TraverseParms.For(pawn, (Danger)3, (TraverseMode)0, false), 9999f, (Predicate <Thing>)validator, (IEnumerable <Thing>)null, 0, -1, false, (RegionType)6, false);

            if (val == null || Rand.Value > 0.5f)
            {
                return(null);
            }
            lastInteractionTick = Find.TickManager.TicksGame;
            return((Job)(object)new Job(JobDefOfEvaineQMentalWorker.StormMark, (LocalTargetInfo)val));

            bool validator(Thing t)
            {
                //IL_0001: Unknown result type (might be due to invalid IL or missing references)
                //IL_0007: Expected O, but got Unknown
                Pawn val2 = (Pawn)(object)(Pawn)t;

                if (val2 != pawn && !val2.Dead && !val2.Downed && RestUtility.Awake(val2) && InteractionUtility.CanReceiveInteraction(val2))
                {
                    return(val2.RaceProps.Humanlike);
                }
                return(false);
            }
        }
 public static bool CanChaseAndInsult(Pawn bully, Pawn insulted, bool skipReachabilityCheck = false, bool allowPrisoners = true)
 {
     return(insulted.RaceProps.Humanlike && (insulted.Faction == bully.Faction || (allowPrisoners && insulted.HostFaction == bully.Faction)) && insulted != bully && !insulted.Dead && !insulted.Downed && insulted.Spawned && insulted.Awake() && insulted.Position.InHorDistOf(bully.Position, 40f) && InteractionUtility.CanReceiveInteraction(insulted) && !insulted.HostileTo(bully) && Find.TickManager.TicksGame - insulted.mindState.lastHarmTick >= 833 && (skipReachabilityCheck || bully.CanReach(insulted, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn)));
 }