Exemplo n.º 1
0
        public static bool MakeManhunter(this Pawn p, bool MyDebug = false)
        {
            if (p.NegligiblePawn())
            {
                return(false);
            }

            MentalStateDef manhunterState = MentalStateDefOf.Manhunter;

            if (MyDebug)
            {
                Log.Warning(p.LabelShort + " trying to go " + manhunterState.defName);
            }

            if (p.mindState == null || p.mindState.mentalStateHandler == null)
            {
                if (MyDebug)
                {
                    Log.Warning(p.LabelShort + " null mindstate");
                }
                return(false);
            }

            if (MyDebug)
            {
                Log.Warning(p.LabelShort + " got applied " + manhunterState.defName);
            }
            return(p.mindState.mentalStateHandler.TryStartMentalState(manhunterState));
        }
        private void AffectBondedAnimalsOnMyDeath()
        {
            int  num  = 0;
            Pawn pawn = null;

            for (int i = 0; i < directRelations.Count; i++)
            {
                if (directRelations[i].def == PawnRelationDefOf.Bond && directRelations[i].otherPawn.Spawned)
                {
                    pawn = directRelations[i].otherPawn;
                    num++;
                    float          value    = Rand.Value;
                    MentalStateDef stateDef = ((value < 0.25f) ? MentalStateDefOf.Wander_Sad : ((value < 0.5f) ? MentalStateDefOf.Wander_Psychotic : ((!(value < 0.75f)) ? MentalStateDefOf.Manhunter : MentalStateDefOf.Berserk)));
                    directRelations[i].otherPawn.mindState.mentalStateHandler.TryStartMentalState(stateDef, "MentalStateReason_BondedHumanDeath".Translate(this.pawn).Resolve(), forceWake: true);
                }
            }
            if (num == 1)
            {
                Messages.Message(((pawn.Name == null || pawn.Name.Numerical) ? "MessageBondedAnimalMentalBreak".Translate(pawn.LabelIndefinite(), this.pawn.LabelShort, pawn.Named("ANIMAL"), this.pawn.Named("HUMAN")) : "MessageNamedBondedAnimalMentalBreak".Translate(pawn.KindLabelIndefinite(), pawn.Name.ToStringShort, this.pawn.LabelShort, pawn.Named("ANIMAL"), this.pawn.Named("HUMAN"))).CapitalizeFirst(), pawn, MessageTypeDefOf.ThreatSmall);
            }
            else if (num > 1)
            {
                Messages.Message("MessageBondedAnimalsMentalBreak".Translate(num, this.pawn.LabelShort, this.pawn.Named("HUMAN")), pawn, MessageTypeDefOf.ThreatSmall);
            }
        }
        public static void AffectBondedAnimalsOnMyDeath(Pawn_RelationsTracker __instance)
        {
            int  num1  = 0;
            Pawn pawn2 = null;

            for (int index = 0; index < directRelations(__instance).Count; ++index)
            {
                if (directRelations(__instance)[index].def == PawnRelationDefOf.Bond && directRelations(__instance)[index].otherPawn.Spawned)
                {
                    pawn2 = directRelations(__instance)[index].otherPawn;
                    ++num1;
                    float          num2     = Rand.Value;
                    MentalStateDef stateDef = num2 >= 0.25 ? (num2 >= 0.5 ? (num2 >= 0.75 ? MentalStateDefOf.Manhunter : MentalStateDefOf.Berserk) : MentalStateDefOf.Wander_Psychotic) : MentalStateDefOf.Wander_Sad;
                    directRelations(__instance)[index].otherPawn.mindState.mentalStateHandler.TryStartMentalState(stateDef, "MentalStateReason_BondedHumanDeath".Translate(pawn(__instance)).Resolve(), true, false, null, false);
                }
            }
            if (num1 == 1)
            {
                Messages.Message((pawn2.Name == null || pawn2.Name.Numerical ? "MessageBondedAnimalMentalBreak".Translate(pawn2.LabelIndefinite(), pawn(__instance).LabelShort, pawn2.Named("ANIMAL"), pawn(__instance).Named("HUMAN")) : "MessageNamedBondedAnimalMentalBreak".Translate(pawn2.KindLabelIndefinite(), pawn2.Name.ToStringShort, pawn(__instance).LabelShort, pawn2.Named("ANIMAL"), pawn(__instance).Named("HUMAN"))).CapitalizeFirst(), pawn2, MessageTypeDefOf.ThreatSmall, true);
            }
            else
            {
                if (num1 <= 1)
                {
                    return;
                }
                Messages.Message("MessageBondedAnimalsMentalBreak".Translate(num1, pawn(__instance).LabelShort, pawn(__instance).Named("HUMAN")), pawn2, MessageTypeDefOf.ThreatSmall, true);
            }
        }
Exemplo n.º 4
0
        public virtual bool TryStart(Pawn pawn, string reason, bool causedByMood)
        {
            MentalStateHandler arg_21_0    = pawn.mindState.mentalStateHandler;
            MentalStateDef     mentalState = this.def.mentalState;

            return(arg_21_0.TryStartMentalState(mentalState, reason, false, causedByMood, null, false));
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
            public static void Listener(MentalStateDef stateDef, string reason, bool forceWake, bool causedByMood, Pawn otherPawn, bool transitionSilently, Pawn ___pawn, MentalStateHandler __instance, ref bool __result)
            {
                if (__result && ___pawn.IsSurrogateAndroid())
                {
                    CompAndroidState cas = ___pawn.TryGetComp <CompAndroidState>();

                    if (cas == null || cas.surrogateController == null)
                    {
                        return;
                    }

                    CompSurrogateOwner cso = cas.surrogateController.TryGetComp <CompSurrogateOwner>();
                    if (cso.skyCloudHost != null)
                    {
                        CompSkyCloudCore csc = cso.skyCloudHost.TryGetComp <CompSkyCloudCore>();
                        if (csc == null)
                        {
                            return;
                        }


                        //Ajout a une liste de minds boudant avec timeout
                        csc.setMentalBreak(cas.surrogateController);
                    }
                }
            }
Exemplo n.º 7
0
        //Faction own, Faction forced, int duration
        public static bool MakeManhunter(this Pawn p, bool MyDebug = false)
        {
            if (p.NegligiblePawn())
            {
                return(false);
            }

            MentalStateDef manhunterState = null;

            manhunterState = MentalStateDefOf.Manhunter;
            Tools.Warn(p.LabelShort + " trying to go " + manhunterState.defName, MyDebug);
            //mindTarget.mindState.mentalStateHandler.TryStartMentalState(chosenState, null, true, false, null);
            string reason = "because ";

            if (p.mindState == null || p.mindState.mentalStateHandler == null)
            {
                Tools.Warn(p.LabelShort + " null mindstate", MyDebug);
                return(false);
            }

            Tools.Warn(p.LabelShort + " got applied " + manhunterState.defName, MyDebug);
            p.mindState.mentalStateHandler.TryStartMentalState(manhunterState, reason, true, false, null);

            return(true);
        }
        public static void ComputeRandomMentalState(this HediffComp_RandySpawnUponDeath comp)
        {
            if (!comp.ChosenItem.HasMentalStateParams)
            {
                return;
            }


            MentalStateDef msd = comp.GetWeightedRandomMentalState();

            if (msd == null)
            {
                if (comp.MyDebug)
                {
                    Log.Warning("ComputeRandomMentalState - found no MentalStateDef");
                }
                return;
            }

            comp.RandomMS = msd;
            if (comp.MyDebug)
            {
                Log.Warning("ComputeRandomFaction - found:" + comp.RandomFaction?.GetCallLabel());
            }
        }
        public void StartSocialFight(Pawn otherPawn)
        {
            if (PawnUtility.ShouldSendNotificationAbout(this.pawn) || PawnUtility.ShouldSendNotificationAbout(otherPawn))
            {
                Messages.Message("MessageSocialFight".Translate(new object[]
                {
                    this.pawn.LabelShort,
                    otherPawn.LabelShort
                }), this.pawn, MessageTypeDefOf.ThreatSmall, true);
            }
            MentalStateHandler arg_76_0       = this.pawn.mindState.mentalStateHandler;
            MentalStateDef     socialFighting = MentalStateDefOf.SocialFighting;

            arg_76_0.TryStartMentalState(socialFighting, null, false, false, otherPawn, false);
            MentalStateHandler arg_9A_0 = otherPawn.mindState.mentalStateHandler;

            socialFighting = MentalStateDefOf.SocialFighting;
            Pawn otherPawn2 = this.pawn;

            arg_9A_0.TryStartMentalState(socialFighting, null, false, false, otherPawn2, false);
            TaleRecorder.RecordTale(TaleDefOf.SocialFight, new object[]
            {
                this.pawn,
                otherPawn
            });
        }
        protected override void Impact(Thing hitThing)
        {
            base.Impact(hitThing);

            /*
             * Null checking is very important in RimWorld.
             * 99% of errors reported are from NullReferenceExceptions (NREs).
             * Make sure your code checks if things actually exist, before they
             * try to use the code that belongs to said things.
             */
            if (Def != null && hitThing != null && hitThing is Pawn hitPawn) //Fancy way to declare a variable inside an if statement. - Thanks Erdelf.
            {
                var rand = Rand.Value;                                       // This is a random percentage between 0% and 100%
                if (rand <= Def.AddHediffChance)                             // If the percentage falls under the chance, success!
                {
                    /*
                     * Messages.Message flashes a message on the top of the screen.
                     * You may be familiar with this one when a colonist dies, because
                     * it makes a negative sound and mentioneds "So and so has died of _____".
                     *
                     * Here, we're using the "Translate" function. More on that later in
                     * the localization section.
                     */
                    //Messages.Message("def name= " + UW_ThoughtDefs.UltimateWeaponsMod_ifarted.defName.ToString(), MessageTypeDefOf.PositiveEvent);
                    // //Messages.Message("thought class= " + UW_ThoughtDefs.UltimateWeaponsMod_ifarted.thoughtClass.ToString(), MessageTypeDefOf.PositiveEvent);
                    //Messages.Message("def package= " + UW_ThoughtDefs.UltimateWeaponsMod_ifarted.defPackage.ToString(), MessageTypeDefOf.PositiveEvent);
                    //Messages.Message("Test", MessageTypeDefOf.NegativeHealthEvent);
                    //Console.WriteLine("This is console writeline");
                    Random           rnd         = new Random();
                    int              random      = rnd.Next(0, 5);
                    MentalStateDef[] mentalArray = new MentalStateDef[6];
                    mentalArray[0] = MentalStateDefOf.Manhunter;
                    mentalArray[1] = MentalStateDefOf.SocialFighting;
                    mentalArray[2] = MentalStateDefOf.Wander_OwnRoom;
                    mentalArray[3] = MentalStateDefOf.Wander_Psychotic;
                    mentalArray[4] = MentalStateDefOf.Wander_Sad;
                    mentalArray[5] = MentalStateDefOf.Berserk;
                    if (hitPawn.InMentalState == true)
                    {
                        hitPawn.MentalState.RecoverFromState();
                        MoteMaker.ThrowText(hitThing.PositionHeld.ToVector3(), hitThing.MapHeld, hitPawn.Name.ToString() + "  is no longer in a mental state", 12f);
                    }
                    else
                    {
                        hitPawn.mindState.mentalStateHandler.TryStartMentalState(mentalArray[random], "Because the magic tree lady told " + hitPawn.gender.GetPronoun() + " to.", true, false);
                        MoteMaker.ThrowText(hitThing.PositionHeld.ToVector3(), hitThing.MapHeld, hitPawn.Name.ToString() + " has been affected with " + mentalArray[random].defName, 12f);
                    }
                }
                else //failure!
                {
                    /*
                     * Motes handle all the smaller visual effects in RimWorld.
                     * Dust plumes, symbol bubbles, and text messages floating next to characters.
                     * This mote makes a small text message next to the character.
                     */
                    MoteMaker.ThrowText(hitThing.PositionHeld.ToVector3(), hitThing.MapHeld, "missed", 12f);
                }
            }
        }
Exemplo n.º 11
0
        public virtual bool TryStart(Pawn pawn, string reason, bool causedByMood)
        {
            MentalStateHandler mentalStateHandler = pawn.mindState.mentalStateHandler;
            MentalStateDef     mentalState        = def.mentalState;
            bool causedByMood2 = causedByMood;

            return(mentalStateHandler.TryStartMentalState(mentalState, reason, forceWake: false, causedByMood2));
        }
Exemplo n.º 12
0
 public static void DoEffectOn(Pawn target, MentalStateDef mdef)
 {
     if (target.Dead)
     {
         return;
     }
     Log.Message(mdef.ToString());
     target.mindState.mentalStateHandler.TryStartMentalState(mdef, null, false);
 }
Exemplo n.º 13
0
        public virtual bool TryStart(Pawn pawn, Thought reason, bool causedByMood)
        {
            string             text        = (reason == null) ? null : reason.LabelCap;
            MentalStateHandler arg_33_0    = pawn.mindState.mentalStateHandler;
            MentalStateDef     mentalState = this.def.mentalState;
            string             reason2     = text;

            return(arg_33_0.TryStartMentalState(mentalState, reason2, false, causedByMood, null));
        }
Exemplo n.º 14
0
 private static bool Prefix(Pawn ___pawn, ref bool __result, MentalStateDef stateDef, string reason = null, bool forceWake = false,
                            bool causedByMood = false, Pawn otherPawn = null, bool transitionSilently = false)
 {
     if (___pawn is Wendigo && ___pawn.GetLord()?.LordJob is LordJob_AssaultColonyWendigo)
     {
         __result = false;
         return(false);
     }
     return(true);
 }
 private static bool Prefix(Pawn ___pawn, ref bool __result, MentalStateDef stateDef, string reason = null, bool forceWake = false,
                            bool causedByMood = false, Pawn otherPawn = null, bool transitionSilently = false)
 {
     if (___pawn.HasTrait(VTEDefOf.VTE_Schizoid) && !stateDef.IsExtreme)
     {
         __result = false;
         return(false);
     }
     return(true);
 }
Exemplo n.º 16
0
 public static void TryInstantBreak(Pawn pawn, float chance, MentalStateDef breakDef)
 {
     if (pawn.Downed || pawn.jobs.curDriver.asleep || pawn.InMentalState)
     {
         return;
     }
     if (Rand.Chance(chance))
     {
         pawn.mindState.mentalStateHandler.TryStartMentalState(breakDef, "ReasonArmedExplosiveCollar".Translate(pawn.Name.ToStringShort));
     }
 }
 public static void TryGiveMentalStateWithDuration(MentalStateDef def, Pawn p, AbilityDef ability, StatDef multiplierStat)
 {
     if (p.mindState.mentalStateHandler.TryStartMentalState(def, null, forceWake: true))
     {
         float num = ability.statBases.GetStatValueFromList(StatDefOf.Ability_Duration, 10f);
         if (multiplierStat != null)
         {
             num *= p.GetStatValue(multiplierStat);
         }
         p.mindState.mentalStateHandler.CurState.forceRecoverAfterTicks = num.SecondsToTicks();
     }
 }
Exemplo n.º 18
0
        public void SaveMemory()
        {
            if (pawn.mindState.mentalStateHandler.CurStateDef == SS_MentalStateDefOf.CryptoStasis)
            {
                revertMentalStateDef = MentalStateDefOf.Berserk;
            }

            else
            {
                revertMentalStateDef = pawn.mindState.mentalStateHandler.CurStateDef;
            }
        }
Exemplo n.º 19
0
        public override bool ValidateAttackTarget(Pawn searcher, Thing target)
        {
            Pawn pawn = target as Pawn;

            if (pawn == null)
            {
                return(true);
            }
            MentalStateDef mentalStateDef = pawn.MentalStateDef;

            return(mentalStateDef == null || !mentalStateDef.escapingPrisonersIgnore);
        }
        static void Postfix(MentalStateHandler __instance, MentalStateDef stateDef, ref Pawn ___pawn)
        {
            if (stateDef != MentalStateDefOf.PanicFlee)
            {
                return;
            }
            CompRunAndGun comp = ___pawn.TryGetComp <CompRunAndGun>();

            if (comp != null && Base.enableForAI.Value)
            {
                comp.isEnabled = shouldRunAndGun();
            }
        }
Exemplo n.º 21
0
            public static void Listener(MentalStateDef stateDef, string reason, bool forceWake, bool causedByMood, Pawn otherPawn, bool transitionSilently, Pawn ___pawn,
                                        MentalStateHandler __instance, ref bool __result)
            {
                if (!__result || !___pawn.IsSurrogateAndroid())
                {
                    return;
                }

                var cas = ___pawn.TryGetComp <CompAndroidState>();
                var cso = cas?.surrogateController?.TryGetComp <CompSurrogateOwner>();
                var csc = cso?.skyCloudHost?.TryGetComp <CompSkyCloudCore>();


                csc?.setMentalBreak(cas.surrogateController);
            }
Exemplo n.º 22
0
        static void Postfix(MentalStateHandler __instance, MentalStateDef stateDef)
        {
            if (stateDef != MentalStateDefOf.PanicFlee)
            {
                return;
            }
            Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();

            CompRunAndGun comp = pawn.TryGetComp <CompRunAndGun>();

            if (comp != null && Base.enableForAI.Value)
            {
                comp.isEnabled = shouldRunAndGun();
            }
        }
 static bool Prefix(MentalStateHandler __instance, MentalStateDef stateDef)
 {
     if (stateDef == MentalStateDefOf.PanicFlee)
     {
         Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue <Pawn>();
         if (pawn.CurJob != null && pawn.CurJob.def == GUC_JobDefOf.Mounted)
         {
             ExtendedPawnData pawnData = Base.Instance.GetExtendedDataStorage().GetExtendedDataFor(pawn);
             if (pawnData.ownedBy != null && !pawnData.ownedBy.Dead && !pawnData.ownedBy.Downed)
             {
                 return(false);
             }
         }
     }
     return(true);
 }
        public MentalBreakIntensity TargetMentalBreakIntensity(LocalTargetInfo target)
        {
            MentalStateDef mentalStateDef = target.Pawn?.MentalStateDef;

            if (mentalStateDef != null)
            {
                List <MentalBreakDef> allDefsListForReading = DefDatabase <MentalBreakDef> .AllDefsListForReading;
                for (int i = 0; i < allDefsListForReading.Count; i++)
                {
                    if (allDefsListForReading[i].mentalState == mentalStateDef)
                    {
                        return(allDefsListForReading[i].intensity);
                    }
                }
            }
            return(MentalBreakIntensity.Minor);
        }
Exemplo n.º 25
0
        // Token: 0x06000056 RID: 86 RVA: 0x00003870 File Offset: 0x00001A70
        private void startFightingState(Fighter f)
        {
            f.p.mindState.enemyTarget = this.getOtherFighter(f).p;
            f.p.jobs.StopAll(false);
            f.p.mindState.mentalStateHandler.Reset();
            MentalStateHandler mentalStateHandler = f.p.mindState.mentalStateHandler;
            MentalStateDef     ArenaFighting      = MentalStateDefOfArena.Fighter;
            Pawn           pawn      = f.p;
            MentalStateDef stateDef  = ArenaFighting;
            Pawn           otherPawn = this.getOtherFighter(f).p;

            mentalStateHandler.TryStartMentalState(stateDef, "", false, false, null, true);
            MentalState_Fighter mentalState = f.p.MentalState as MentalState_Fighter;

            mentalState.otherPawn = this.getOtherFighter(f).p;
            mentalState.bellRef   = this;
        }
Exemplo n.º 26
0
        /// <summary>
        /// Applies the post tf effects.
        /// this should be called just before the original pawn is cleaned up
        /// </summary>
        /// <param name="original">The original.</param>
        /// <param name="transformedPawn">The transformed pawn.</param>
        /// <param name="request">The transformation request</param>
        protected virtual void ApplyPostTfEffects([NotNull] Pawn original, [NotNull] Pawn transformedPawn, [NotNull] TransformationRequest request)
        {
            if (original == null)
            {
                throw new ArgumentNullException(nameof(original));
            }
            if (transformedPawn == null)
            {
                throw new ArgumentNullException(nameof(transformedPawn));
            }
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            List <Aspect> aspects = new List <Aspect>();

            foreach (AspectGiver aspectGiver in def.tfAspectGivers.MakeSafe())
            {
                aspects.Clear();
                if (aspectGiver.TryGiveAspects(original, aspects))
                {
                    foreach (Aspect aspect in aspects) //make sure we add them to both pawns
                    {
                        var aDef    = aspect;
                        var tracker = transformedPawn.GetAspectTracker();
                        tracker?.Add(aDef, aspect.StageIndex);
                    }
                }
            }


            float manhunterChance = GetManhunterChance(request);

            if (manhunterChance > FormerHumanUtilities.MANHUNTER_EPSILON && Rand.Value < manhunterChance)
            {
                MentalStateDef stateDef = MentalStateDefOf.Manhunter;

                transformedPawn.mindState?.mentalStateHandler?.TryStartMentalState(stateDef, forceWake: true);
            }
            else if (def.appliesTfParalysis)
            {
                //don't add tf paralysis on manhunter
                transformedPawn.health.AddHediff(TfHediffDefOf.TransformationParalysis);
            }
        }
Exemplo n.º 27
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map         map       = parms.target as Map;
            Pawn        pawn      = null;
            List <Pawn> listeners = map.mapPawns.AllPawnsSpawned.FindAll(x => x.RaceProps.intelligence == Intelligence.Humanlike);

            bool[] flag = new bool[listeners.Count];
            for (int i = 0; i < listeners.Count; i++)
            {
                pawn = listeners[i];
                if (pawn.Faction == Faction.OfPlayer || (!pawn.Faction.HostileTo(Faction.OfPlayer)) || pawn.guest.IsPrisoner)
                {
                    Cthulhu.Utility.ApplySanityLoss(pawn, Rand.Range(0.2f, 0.8f));
                }
                else
                {
                    MentalStateDef defaultState = MentalStateDefOf.Berserk;
                    int            tempRand     = Rand.Range(1, 10);
                    switch (tempRand)
                    {
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                    case 6:
                        break;

                    case 7:
                    case 8:
                    case 9:
                        defaultState = MentalStateDefOf.PanicFlee;
                        break;

                    case 10:
                        defaultState = CultsDefOf.FireStartingSpree;
                        break;
                    }
                    Cthulhu.Utility.ApplySanityLoss(pawn, 1.0f);
                    pawn.mindState.mentalStateHandler.TryStartMentalState(defaultState, null, false);
                }
            }

            return(true);
        }
Exemplo n.º 28
0
        public void StartSocialFight(Pawn otherPawn)
        {
            if (PawnUtility.ShouldSendNotificationAbout(pawn) || PawnUtility.ShouldSendNotificationAbout(otherPawn))
            {
                Messages.Message("MessageSocialFight".Translate(pawn.LabelShort, otherPawn.LabelShort, pawn.Named("PAWN1"), otherPawn.Named("PAWN2")), pawn, MessageTypeDefOf.ThreatSmall);
            }
            MentalStateHandler mentalStateHandler = pawn.mindState.mentalStateHandler;
            MentalStateDef     socialFighting     = MentalStateDefOf.SocialFighting;

            mentalStateHandler.TryStartMentalState(socialFighting, null, forceWake: false, causedByMood: false, otherPawn);
            MentalStateHandler mentalStateHandler2 = otherPawn.mindState.mentalStateHandler;

            socialFighting = MentalStateDefOf.SocialFighting;
            Pawn otherPawn2 = pawn;

            mentalStateHandler2.TryStartMentalState(socialFighting, null, forceWake: false, causedByMood: false, otherPawn2);
            TaleRecorder.RecordTale(TaleDefOf.SocialFight, pawn, otherPawn);
        }
        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
            });
        }
Exemplo n.º 30
0
        static bool Prefix(MentalStateHandler __instance, ref bool __result, MentalStateDef stateDef, string reason, bool forceWake, bool causedByMood, Pawn otherPawn)
        {
            if (!causedByMood)
            {
                return(true);
            }

            Pawn pawn = (Pawn)(typeof(MentalStateHandler).GetField("pawn", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance));

            if (pawn.IsPrisonerOfColony)
            {
                var need = pawn.needs.TryGetNeed <Need_Treatment>();
                if (need != null)
                {
                    TreatmentCategory treatmentCat = need.CurCategory;
                    bool  suspended = false;
                    float chance    = 0f;

                    switch (treatmentCat)
                    {
                    case TreatmentCategory.Normal:
                        chance = 0.1f;
                        break;

                    case TreatmentCategory.Bad:
                        chance = 0.5f;
                        break;

                    case TreatmentCategory.VeryBad:
                        chance = 1f;
                        break;
                    }

                    suspended = UnityEngine.Random.value < chance;

                    if (suspended)
                    {
                        __result = false;
                        return(false);
                    }
                }
            }
            return(true);
        }