예제 #1
0
        protected override ThoughtState CurrentSocialStateInternal(Pawn pawn, Pawn other)
        {
            if (!other.RaceProps.Humanlike || !RelationsUtility.PawnsKnowEachOther(pawn, other))
            {
                return(false);
            }
            if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Sight))
            {
                return(false);
            }
            int num = other.story.traits.DegreeOfTrait(TraitDefOf.Beauty);

            if (num == -1)
            {
                return(ThoughtState.ActiveAtStage(0));
            }
            if (num == -2)
            {
                return(ThoughtState.ActiveAtStage(1));
            }
            return(false);
        }
        protected override ThoughtState CurrentSocialStateInternal(Pawn pawn, Pawn other)
        {
            if (other.RaceProps.Humanlike && RelationsUtility.PawnsKnowEachOther(pawn, other))
            {
                if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Sight))
                {
                    return(false);
                }
                switch (other.story.traits.DegreeOfTrait(TraitDefOf.Beauty))
                {
                case -1:
                    return(ThoughtState.ActiveAtStage(0));

                case -2:
                    return(ThoughtState.ActiveAtStage(1));

                default:
                    return(false);
                }
            }
            return(false);
        }
예제 #3
0
        protected override ThoughtState CurrentSocialStateInternal(Pawn pawn, Pawn other)
        {
            ThoughtState result;

            if (!other.RaceProps.Humanlike || !RelationsUtility.PawnsKnowEachOther(pawn, other))
            {
                result = false;
            }
            else if (!other.story.traits.HasTrait(TraitDefOf.AnnoyingVoice))
            {
                result = false;
            }
            else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Hearing))
            {
                result = false;
            }
            else
            {
                result = true;
            }
            return(result);
        }
예제 #4
0
        private static IEnumerable <Widgets.DropdownMenuElement <Pawn> > MasterSelectButton_GenerateMenu(Pawn p)
        {
            yield return(new Widgets.DropdownMenuElement <Pawn>
            {
                option = new FloatMenuOption("(" + "NoneLower".Translate() + ")", delegate
                {
                    p.playerSettings.Master = null;
                }, MenuOptionPriority.Default, null, null, 0f, null, null),
                payload = null
            });

            foreach (Pawn col in PawnsFinder.AllMaps_FreeColonistsSpawned)
            {
                string lab      = RelationsUtility.LabelWithBondInfo(col, p);
                Action action   = null;
                int    level    = col.skills.GetSkill(SkillDefOf.Animals).Level;
                int    minLevel = TrainableUtility.MinimumHandlingSkill(p);
                if (level < minLevel)
                {
                    action = null;
                    lab    = lab + " (" + "SkillTooLow".Translate(SkillDefOf.Animals.LabelCap, level, minLevel) + ")";
                }
                else if (TrainableUtility.CanBeMaster(col, p, true))
                {
                    action = delegate
                    {
                        p.playerSettings.Master = col;
                    };
                }
                yield return(new Widgets.DropdownMenuElement <Pawn>
                {
                    option = new FloatMenuOption(lab, action, MenuOptionPriority.Default, null, null, 0f, null, null),
                    payload = col
                });
            }
        }
예제 #5
0
        public static void OpenMasterSelectMenu(Pawn p)
        {
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            list.Add(new FloatMenuOption("(" + "NoneLower".Translate() + ")", delegate
            {
                p.playerSettings.master = null;
            }, MenuOptionPriority.Default, null, null, 0f, null, null));
            foreach (Pawn current in PawnsFinder.AllMaps_FreeColonistsSpawned)
            {
                string text  = RelationsUtility.LabelWithBondInfo(current, p);
                int    level = current.skills.GetSkill(SkillDefOf.Animals).Level;
                int    num   = TrainableUtility.MinimumHandlingSkill(p);
                Action action;
                if (level >= num)
                {
                    Pawn localCol = current;
                    action = delegate
                    {
                        p.playerSettings.master = localCol;
                    };
                }
                else
                {
                    action = null;
                    text   = text + " (" + "SkillTooLow".Translate(new object[]
                    {
                        SkillDefOf.Animals.LabelCap,
                        level,
                        num
                    }) + ")";
                }
                list.Add(new FloatMenuOption(text, action, MenuOptionPriority.Default, null, null, 0f, null, null));
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
예제 #6
0
 protected override ThoughtState CurrentSocialStateInternal(Pawn p, Pawn other)
 {
     if (!p.RaceProps.Humanlike)
     {
         return(false);
     }
     if (!p.story.traits.HasTrait(TraitDefOf.DislikesMen))
     {
         return(false);
     }
     if (!RelationsUtility.PawnsKnowEachOther(p, other))
     {
         return(false);
     }
     if (other.def != p.def)
     {
         return(false);
     }
     if (other.gender != Gender.Male)
     {
         return(false);
     }
     return(true);
 }
예제 #7
0
 // Token: 0x06000A02 RID: 2562 RVA: 0x0004F2B0 File Offset: 0x0004D6B0
 protected override ThoughtState CurrentSocialStateInternal(Pawn p, Pawn other)
 {
     if (p == other || other == null)
     {
         return(false);
     }
     if (!p.RaceProps.Humanlike || !other.RaceProps.Humanlike)
     {
         return(false);
     }
     if (p.kindDef.race != YautjaDefOf.RRY_Alien_Yautja || other.kindDef.race != YautjaDefOf.RRY_Alien_Yautja)
     {
         return(false);
     }
     if (other.story.adulthood == null)
     {
         return(false);
     }
     if (other.story.adulthood.identifier.Contains("RRY_Yautja_BadBlood"))
     {
         return(false);
     }
     if (RelationsUtility.PawnsKnowEachOther(p, other))
     {
         return(false);
     }
     if (p.story.adulthood == null)
     {
         return(false);
     }
     if (p.story.adulthood.identifier.Contains("RRY_Yautja_BadBlood"))
     {
         return(true);
     }
     return(false);
 }
 protected override ThoughtState CurrentSocialStateInternal(Pawn p, Pawn other)
 {
     if (!p.RaceProps.Humanlike)
     {
         return(false);
     }
     if (!p.IsTeetotaler())
     {
         return(false);
     }
     if (!other.RaceProps.Humanlike)
     {
         return(false);
     }
     if (!RelationsUtility.PawnsKnowEachOther(p, other))
     {
         return(false);
     }
     if (other.story.traits.DegreeOfTrait(TraitDefOf.DrugDesire) <= 0)
     {
         return(false);
     }
     return(true);
 }
 public static bool PawnsKnowEachOther(Pawn p1, Pawn p2)
 {
     if (p1.Faction != null && p1.Faction == p2.Faction)
     {
         return(true);
     }
     if (p1.RaceProps.IsFlesh && p1.relations.DirectRelations.Find((DirectPawnRelation x) => x.otherPawn == p2) != null)
     {
         return(true);
     }
     if (p2.RaceProps.IsFlesh && p2.relations.DirectRelations.Find((DirectPawnRelation x) => x.otherPawn == p1) != null)
     {
         return(true);
     }
     if (RelationsUtility.HasAnySocialMemoryWith(p1, p2))
     {
         return(true);
     }
     if (RelationsUtility.HasAnySocialMemoryWith(p2, p1))
     {
         return(true);
     }
     return(false);
 }
예제 #10
0
 public static string MasterString(Pawn pawn)
 {
     return((pawn.playerSettings.Master == null) ? ("(" + "NoneLower".Translate() + ")") : RelationsUtility.LabelWithBondInfo(pawn.playerSettings.Master, pawn));
 }
예제 #11
0
 public static void DoTend(Pawn doctor, Pawn patient, Medicine medicine)
 {
     if (patient.health.HasHediffsNeedingTend(false))
     {
         if (medicine != null && medicine.Destroyed)
         {
             Log.Warning("Tried to use destroyed medicine.");
             medicine = null;
         }
         float num  = (float)((medicine == null) ? 0.30000001192092896 : medicine.def.GetStatValueAbstract(StatDefOf.MedicalPotency, null));
         float num2 = (float)((doctor == null) ? 0.75 : doctor.GetStatValue(StatDefOf.MedicalTendQuality, true));
         num2 *= num;
         Building_Bed building_Bed = patient.CurrentBed();
         if (building_Bed != null)
         {
             num2 += building_Bed.GetStatValue(StatDefOf.MedicalTendQualityOffset, true);
         }
         if (doctor == patient)
         {
             num2 = (float)(num2 * 0.699999988079071);
         }
         num2 = Mathf.Clamp01(num2);
         TendUtility.GetOptimalHediffsToTendWithSingleTreatment(patient, medicine != null, TendUtility.tmpHediffsToTend, null);
         for (int i = 0; i < TendUtility.tmpHediffsToTend.Count; i++)
         {
             TendUtility.tmpHediffsToTend[i].Tended(num2, i);
         }
         if (doctor != null && doctor.Faction != null && patient.HostFaction == null && patient.Faction != null && patient.Faction != doctor.Faction)
         {
             patient.Faction.AffectGoodwillWith(doctor.Faction, 0.3f);
         }
         if (doctor != null && doctor.IsColonistPlayerControlled)
         {
             patient.records.AccumulateStoryEvent(StoryEventDefOf.TendedByPlayer);
         }
         if (doctor != null && doctor.RaceProps.Humanlike && patient.RaceProps.Animal && RelationsUtility.TryDevelopBondRelation(doctor, patient, 0.004f) && doctor.Faction != null && doctor.Faction != patient.Faction)
         {
             InteractionWorker_RecruitAttempt.DoRecruit(doctor, patient, 1f, false);
         }
         patient.records.Increment(RecordDefOf.TimesTendedTo);
         if (doctor != null)
         {
             doctor.records.Increment(RecordDefOf.TimesTendedOther);
         }
         if (medicine != null)
         {
             if ((patient.Spawned || (doctor != null && doctor.Spawned)) && num > ThingDefOf.Medicine.GetStatValueAbstract(StatDefOf.MedicalPotency, null))
             {
                 SoundDefOf.TechMedicineUsed.PlayOneShot(new TargetInfo(patient.Position, patient.Map, false));
             }
             if (medicine.stackCount > 1)
             {
                 medicine.stackCount--;
             }
             else if (!medicine.Destroyed)
             {
                 medicine.Destroy(DestroyMode.Vanish);
             }
         }
     }
 }
        public static void DoRecruit(Pawn recruiter, Pawn recruitee, float recruitChance, bool useAudiovisualEffects = true)
        {
            recruitChance = Mathf.Clamp01(recruitChance);
            string text = recruitee.LabelIndefinite();

            if (recruitee.guest != null)
            {
                recruitee.guest.SetGuestStatus(null, false);
            }
            bool flag = recruitee.Name != null;

            if (recruitee.Faction != recruiter.Faction)
            {
                recruitee.SetFaction(recruiter.Faction, recruiter);
            }
            if (recruitee.RaceProps.Humanlike)
            {
                if (useAudiovisualEffects)
                {
                    Find.LetterStack.ReceiveLetter("LetterLabelMessageRecruitSuccess".Translate(), "MessageRecruitSuccess".Translate(new object[]
                    {
                        recruiter,
                        recruitee,
                        recruitChance.ToStringPercent()
                    }), LetterDefOf.PositiveEvent, recruitee, null, null);
                }
                TaleRecorder.RecordTale(TaleDefOf.Recruited, new object[]
                {
                    recruiter,
                    recruitee
                });
                recruiter.records.Increment(RecordDefOf.PrisonersRecruited);
                recruitee.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.RecruitedMe, recruiter);
            }
            else
            {
                if (useAudiovisualEffects)
                {
                    if (!flag)
                    {
                        Messages.Message("MessageTameAndNameSuccess".Translate(new object[]
                        {
                            recruiter.LabelShort,
                            text,
                            recruitChance.ToStringPercent(),
                            recruitee.Name.ToStringFull
                        }).AdjustedFor(recruitee, "PAWN"), recruitee, MessageTypeDefOf.PositiveEvent, true);
                    }
                    else
                    {
                        Messages.Message("MessageTameSuccess".Translate(new object[]
                        {
                            recruiter.LabelShort,
                            text,
                            recruitChance.ToStringPercent()
                        }), recruitee, MessageTypeDefOf.PositiveEvent, true);
                    }
                    if (recruiter.Spawned && recruitee.Spawned)
                    {
                        MoteMaker.ThrowText((recruiter.DrawPos + recruitee.DrawPos) / 2f, recruiter.Map, "TextMote_TameSuccess".Translate(new object[]
                        {
                            recruitChance.ToStringPercent()
                        }), 8f);
                    }
                }
                recruiter.records.Increment(RecordDefOf.AnimalsTamed);
                RelationsUtility.TryDevelopBondRelation(recruiter, recruitee, 0.01f);
                float chance = Mathf.Lerp(0.02f, 1f, recruitee.RaceProps.wildness);
                if (Rand.Chance(chance) || recruitee.IsWildMan())
                {
                    TaleRecorder.RecordTale(TaleDefOf.TamedAnimal, new object[]
                    {
                        recruiter,
                        recruitee
                    });
                }
                if (PawnsFinder.AllMapsWorldAndTemporary_Alive.Count((Pawn p) => p.playerSettings != null && p.playerSettings.Master == recruiter) >= 5)
                {
                    TaleRecorder.RecordTale(TaleDefOf.IncreasedMenagerie, new object[]
                    {
                        recruiter,
                        recruitee
                    });
                }
            }
            if (recruitee.caller != null)
            {
                recruitee.caller.DoCall();
            }
        }
예제 #13
0
        public static Toil TryTrain(TargetIndex traineeInd)
        {
            Toil toil = new Toil();

            toil.initAction = delegate()
            {
                Pawn actor = toil.actor;
                Pawn pawn  = (Pawn)actor.jobs.curJob.GetTarget(traineeInd).Thing;
                if (pawn.Spawned && pawn.Awake() && actor.interactions.TryInteractWith(pawn, InteractionDefOf.TrainAttempt))
                {
                    float num = actor.GetStatValue(StatDefOf.TrainAnimalChance, true);
                    num *= GenMath.LerpDouble(0f, 1f, 1.5f, 0.5f, pawn.RaceProps.wildness);
                    if (actor.relations.DirectRelationExists(PawnRelationDefOf.Bond, pawn))
                    {
                        num *= 5f;
                    }
                    num = Mathf.Clamp01(num);
                    TrainableDef trainableDef = pawn.training.NextTrainableToTrain();
                    if (trainableDef == null)
                    {
                        Log.ErrorOnce("Attempted to train untrainable animal", 7842936, false);
                        return;
                    }
                    string text;
                    if (Rand.Value < num)
                    {
                        pawn.training.Train(trainableDef, actor, false);
                        if (pawn.caller != null)
                        {
                            pawn.caller.DoCall();
                        }
                        text = "TextMote_TrainSuccess".Translate(new object[]
                        {
                            trainableDef.LabelCap,
                            num.ToStringPercent()
                        });
                        RelationsUtility.TryDevelopBondRelation(actor, pawn, 0.007f);
                        TaleRecorder.RecordTale(TaleDefOf.TrainedAnimal, new object[]
                        {
                            actor,
                            pawn,
                            trainableDef
                        });
                    }
                    else
                    {
                        text = "TextMote_TrainFail".Translate(new object[]
                        {
                            trainableDef.LabelCap,
                            num.ToStringPercent()
                        });
                    }
                    string text2 = text;
                    text = string.Concat(new object[]
                    {
                        text2,
                        "\n",
                        pawn.training.GetSteps(trainableDef),
                        " / ",
                        trainableDef.steps
                    });
                    MoteMaker.ThrowText((actor.DrawPos + pawn.DrawPos) / 2f, actor.Map, text, 5f);
                }
            };
            toil.defaultCompleteMode = ToilCompleteMode.Delay;
            toil.defaultDuration     = 100;
            return(toil);
        }
예제 #14
0
        public static void DoTend(Pawn doctor, Pawn patient, Medicine medicine)
        {
            if (!patient.health.HasHediffsNeedingTend(false))
            {
                return;
            }
            if (medicine != null && medicine.Destroyed)
            {
                Log.Warning("Tried to use destroyed medicine.", false);
                medicine = null;
            }
            float quality = TendUtility.CalculateBaseTendQuality(doctor, patient, (medicine == null) ? null : medicine.def);

            TendUtility.GetOptimalHediffsToTendWithSingleTreatment(patient, medicine != null, TendUtility.tmpHediffsToTend, null);
            for (int i = 0; i < TendUtility.tmpHediffsToTend.Count; i++)
            {
                TendUtility.tmpHediffsToTend[i].Tended(quality, i);
            }
            if (doctor != null && doctor.Faction == Faction.OfPlayer && patient.Faction != doctor.Faction && !patient.IsPrisoner && patient.Faction != null)
            {
                patient.mindState.timesGuestTendedToByPlayer++;
            }
            if (doctor != null && doctor.IsColonistPlayerControlled)
            {
                patient.records.AccumulateStoryEvent(StoryEventDefOf.TendedByPlayer);
            }
            if (doctor != null && doctor.RaceProps.Humanlike && patient.RaceProps.Animal && RelationsUtility.TryDevelopBondRelation(doctor, patient, 0.004f) && doctor.Faction != null && doctor.Faction != patient.Faction)
            {
                InteractionWorker_RecruitAttempt.DoRecruit(doctor, patient, 1f, false);
            }
            patient.records.Increment(RecordDefOf.TimesTendedTo);
            if (doctor != null)
            {
                doctor.records.Increment(RecordDefOf.TimesTendedOther);
            }
            if (doctor == patient && !doctor.Dead)
            {
                doctor.mindState.Notify_SelfTended();
            }
            if (medicine != null)
            {
                if ((patient.Spawned || (doctor != null && doctor.Spawned)) && medicine != null && medicine.GetStatValue(StatDefOf.MedicalPotency, true) > ThingDefOf.MedicineIndustrial.GetStatValueAbstract(StatDefOf.MedicalPotency, null))
                {
                    SoundDefOf.TechMedicineUsed.PlayOneShot(new TargetInfo(patient.Position, patient.Map, false));
                }
                if (medicine.stackCount > 1)
                {
                    medicine.stackCount--;
                }
                else if (!medicine.Destroyed)
                {
                    medicine.Destroy(DestroyMode.Vanish);
                }
            }
        }
예제 #15
0
		public static void DoRecruit(Pawn recruiter, Pawn recruitee, float recruitChance, out string letterLabel, out string letter, bool useAudiovisualEffects = true, bool sendLetter = true)
		{
			letterLabel = null;
			letter = null;
			recruitChance = Mathf.Clamp01(recruitChance);
			string value = recruitee.LabelIndefinite();
			if (recruitee.apparel != null && recruitee.apparel.LockedApparel != null)
			{
				List<Apparel> lockedApparel = recruitee.apparel.LockedApparel;
				for (int num = lockedApparel.Count - 1; num >= 0; num--)
				{
					recruitee.apparel.Unlock(lockedApparel[num]);
				}
			}
			if (recruitee.royalty != null)
			{
				foreach (RoyalTitle item in recruitee.royalty.AllTitlesForReading)
				{
					if (item.def.replaceOnRecruited != null)
					{
						recruitee.royalty.SetTitle(item.faction, item.def.replaceOnRecruited, grantRewards: false, rewardsOnlyForNewestTitle: false, sendLetter: false);
					}
				}
			}
			if (recruitee.guest != null)
			{
				recruitee.guest.SetGuestStatus(null);
			}
			bool flag = recruitee.Name != null;
			if (recruitee.Faction != recruiter.Faction)
			{
				recruitee.SetFaction(recruiter.Faction, recruiter);
			}
			if (recruitee.RaceProps.Humanlike)
			{
				if (useAudiovisualEffects)
				{
					letterLabel = "LetterLabelMessageRecruitSuccess".Translate() + ": " + recruitee.LabelShortCap;
					if (sendLetter)
					{
						Find.LetterStack.ReceiveLetter(letterLabel, "MessageRecruitSuccess".Translate(recruiter, recruitee, recruitChance.ToStringPercent(), recruiter.Named("RECRUITER"), recruitee.Named("RECRUITEE")), LetterDefOf.PositiveEvent, recruitee);
					}
				}
				TaleRecorder.RecordTale(TaleDefOf.Recruited, recruiter, recruitee);
				recruiter.records.Increment(RecordDefOf.PrisonersRecruited);
				if (recruitee.needs.mood != null)
				{
					recruitee.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.RecruitedMe, recruiter);
				}
				QuestUtility.SendQuestTargetSignals(recruitee.questTags, "Recruited", recruitee.Named("SUBJECT"));
			}
			else
			{
				if (useAudiovisualEffects)
				{
					if (!flag)
					{
						Messages.Message("MessageTameAndNameSuccess".Translate(recruiter.LabelShort, value, recruitChance.ToStringPercent(), recruitee.Name.ToStringFull, recruiter.Named("RECRUITER"), recruitee.Named("RECRUITEE")).AdjustedFor(recruitee), recruitee, MessageTypeDefOf.PositiveEvent);
					}
					else
					{
						Messages.Message("MessageTameSuccess".Translate(recruiter.LabelShort, value, recruitChance.ToStringPercent(), recruiter.Named("RECRUITER")), recruitee, MessageTypeDefOf.PositiveEvent);
					}
					if (recruiter.Spawned && recruitee.Spawned)
					{
						MoteMaker.ThrowText((recruiter.DrawPos + recruitee.DrawPos) / 2f, recruiter.Map, "TextMote_TameSuccess".Translate(recruitChance.ToStringPercent()), 8f);
					}
				}
				recruiter.records.Increment(RecordDefOf.AnimalsTamed);
				RelationsUtility.TryDevelopBondRelation(recruiter, recruitee, 0.01f);
				if (Rand.Chance(Mathf.Lerp(0.02f, 1f, recruitee.RaceProps.wildness)) || recruitee.IsWildMan())
				{
					TaleRecorder.RecordTale(TaleDefOf.TamedAnimal, recruiter, recruitee);
				}
				if (PawnsFinder.AllMapsWorldAndTemporary_Alive.Count((Pawn p) => p.playerSettings != null && p.playerSettings.Master == recruiter) >= 5)
				{
					TaleRecorder.RecordTale(TaleDefOf.IncreasedMenagerie, recruiter, recruitee);
				}
			}
			if (recruitee.caller != null)
			{
				recruitee.caller.DoCall();
			}
		}