Exemplo n.º 1
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Toil to = new Toil();

            to.initAction = delegate()
            {
                this.ticksLeft = Rand.Range(300, 900);
                int     num = 0;
                IntVec3 c;
                for (;;)
                {
                    c = this.pawn.Position + GenAdj.AdjacentCellsAndInside[Rand.Range(0, 9)];
                    num++;
                    if (num > 12)
                    {
                        break;
                    }
                    if (c.InBounds(this.pawn.Map) && c.Standable(this.pawn.Map))
                    {
                        goto IL_A1;
                    }
                }
                c = this.pawn.Position;
IL_A1:
                this.job.targetA = c;
                this.pawn.pather.StopDead();
            };
            to.tickAction = delegate()
            {
                if (this.ticksLeft % 150 == 149)
                {
                    FilthMaker.MakeFilth(this.job.targetA.Cell, base.Map, ThingDefOf.Filth_Vomit, this.pawn.LabelIndefinite(), 1);
                    if (this.pawn.needs.food.CurLevelPercentage > 0.1f)
                    {
                        this.pawn.needs.food.CurLevel -= this.pawn.needs.food.MaxLevel * 0.04f;
                    }
                }
                this.ticksLeft--;
                if (this.ticksLeft <= 0)
                {
                    base.ReadyForNextToil();
                    TaleRecorder.RecordTale(TaleDefOf.Vomited, new object[]
                    {
                        this.pawn
                    });
                }
            };
            to.defaultCompleteMode = ToilCompleteMode.Never;
            to.WithEffect(EffecterDefOf.Vomit, TargetIndex.A);
            to.PlaySustainerOrSound(() => SoundDefOf.Vomit);
            yield return(to);

            yield break;
        }
Exemplo n.º 2
0
 public void ApparelTrackerTick()
 {
     this.wornApparel.ThingOwnerTick(true);
     if (this.pawn.IsColonist && this.pawn.Spawned && !this.pawn.Dead && this.pawn.IsHashIntervalTick(60000) && this.PsychologicallyNude)
     {
         TaleRecorder.RecordTale(TaleDefOf.WalkedNaked, new object[]
         {
             this.pawn
         });
     }
 }
Exemplo n.º 3
0
        public override void AttachTo(Thing parent)
        {
            base.AttachTo(parent);

            Pawn p = parent as Pawn;

            if (p != null)
            {
                TaleRecorder.RecordTale(TaleDefOf.WasOnFire, p);
            }
        }
Exemplo n.º 4
0
 public void Learn(float xp, bool direct = false)
 {
     if (TotallyDisabled || (xp < 0f && levelInt == 0))
     {
         return;
     }
     if (xp > 0f)
     {
         xp *= LearnRateFactor(direct);
     }
     xpSinceLastLevel += xp;
     if (!direct)
     {
         xpSinceMidnight += xp;
     }
     if (levelInt == 20 && xpSinceLastLevel > XpRequiredForLevelUp - 1f)
     {
         xpSinceLastLevel = XpRequiredForLevelUp - 1f;
     }
     while (xpSinceLastLevel >= XpRequiredForLevelUp)
     {
         xpSinceLastLevel -= XpRequiredForLevelUp;
         levelInt++;
         if (levelInt == 14)
         {
             if (passion == Passion.None)
             {
                 TaleRecorder.RecordTale(TaleDefOf.GainedMasterSkillWithoutPassion, pawn, def);
             }
             else
             {
                 TaleRecorder.RecordTale(TaleDefOf.GainedMasterSkillWithPassion, pawn, def);
             }
         }
         if (levelInt >= 20)
         {
             levelInt         = 20;
             xpSinceLastLevel = Mathf.Clamp(xpSinceLastLevel, 0f, XpRequiredForLevelUp - 1f);
             break;
         }
     }
     do
     {
         if (xpSinceLastLevel < 0f)
         {
             levelInt--;
             xpSinceLastLevel += XpRequiredForLevelUp;
             continue;
         }
         return;
     }while (levelInt > 0);
     levelInt         = 0;
     xpSinceLastLevel = 0f;
 }
Exemplo n.º 5
0
        public bool TryExecute(out bool actuallyTraded)
        {
            if (TradeSession.giftMode)
            {
                this.UpdateCurrencyCount();
                this.LimitCurrencyCountToFunds();
                int goodwillChange = FactionGiftUtility.GetGoodwillChange(this.tradeables, TradeSession.trader.Faction);
                FactionGiftUtility.GiveGift(this.tradeables, TradeSession.trader.Faction, TradeSession.playerNegotiator);
                actuallyTraded = ((float)goodwillChange > 0f);
                return(true);
            }
            if (this.SilverTradeable == null || this.SilverTradeable.CountPostDealFor(Transactor.Colony) < 0)
            {
                Find.WindowStack.WindowOfType <Dialog_Trade>().FlashSilver();
                Messages.Message("MessageColonyCannotAfford".Translate(), MessageTypeDefOf.RejectInput, false);
                actuallyTraded = false;
                return(false);
            }
            this.UpdateCurrencyCount();
            this.LimitCurrencyCountToFunds();
            actuallyTraded = false;
            float num = 0f;

            foreach (Tradeable tradeable in this.tradeables)
            {
                if (tradeable.ActionToDo != TradeAction.None)
                {
                    actuallyTraded = true;
                }
                if (tradeable.ActionToDo == TradeAction.PlayerSells)
                {
                    num += tradeable.CurTotalSilverCostForDestination;
                }
                tradeable.ResolveTrade();
            }
            this.Reset();
            if (TradeSession.trader.Faction != null)
            {
                TradeSession.trader.Faction.Notify_PlayerTraded(num, TradeSession.playerNegotiator);
            }
            Pawn pawn = TradeSession.trader as Pawn;

            if (pawn != null)
            {
                TaleRecorder.RecordTale(TaleDefOf.TradedWith, new object[]
                {
                    TradeSession.playerNegotiator,
                    pawn
                });
            }
            TradeSession.playerNegotiator.mindState.inspirationHandler.EndInspiration(InspirationDefOf.Inspired_Trade);
            return(true);
        }
Exemplo n.º 6
0
 public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
 {
     if (billDoer != null)
     {
         if (base.CheckSurgeryFail(billDoer, pawn, ingredients, part, bill))
         {
             return;
         }
         TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);
     }
     pawn.health.AddHediff(base.recipe.addsHediff, part, null);
 }
 public void FinishProject(ResearchProjectDef proj, bool doCompletionDialog = false, Pawn researcher = null)
 {
     if (proj.prerequisites != null)
     {
         for (int i = 0; i < proj.prerequisites.Count; i++)
         {
             if (!proj.prerequisites[i].IsFinished)
             {
                 this.FinishProject(proj.prerequisites[i], false, null);
             }
         }
     }
     this.progress[proj] = proj.baseCost;
     if (researcher != null)
     {
         TaleRecorder.RecordTale(TaleDefOf.FinishedResearchProject, new object[]
         {
             researcher,
             this.currentProj
         });
     }
     this.ReapplyAllMods();
     if (doCompletionDialog)
     {
         string text = "ResearchFinished".Translate(new object[]
         {
             this.currentProj.LabelCap
         }) + "\n\n" + this.currentProj.description;
         DiaNode diaNode = new DiaNode(text);
         diaNode.options.Add(DiaOption.DefaultOK);
         DiaOption diaOption = new DiaOption("ResearchScreen".Translate());
         diaOption.resolveTree = true;
         diaOption.action      = delegate()
         {
             Find.MainTabsRoot.SetCurrentTab(MainButtonDefOf.Research, true);
         };
         diaNode.options.Add(diaOption);
         Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, false, null));
     }
     if (!proj.discoveredLetterTitle.NullOrEmpty() && Find.Storyteller.difficulty.difficulty >= proj.discoveredLetterMinDifficulty)
     {
         Find.LetterStack.ReceiveLetter(proj.discoveredLetterTitle, proj.discoveredLetterText, LetterDefOf.NeutralEvent, null);
     }
     if (proj.unlockExtremeDifficulty && Find.Storyteller.difficulty.difficulty >= DifficultyDefOf.Rough.difficulty)
     {
         Prefs.ExtremeDifficultyUnlocked = true;
         Prefs.Save();
     }
     if (this.currentProj == proj)
     {
         this.currentProj = null;
     }
 }
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Toil to = new Toil
            {
                initAction = delegate
                {
                    ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0032: stateMachine*/)._0024this.ticksLeft = Rand.Range(300, 900);
                    int     num = 0;
                    IntVec3 c;
                    while (true)
                    {
                        c = ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0032: stateMachine*/)._0024this.pawn.Position + GenAdj.AdjacentCellsAndInside[Rand.Range(0, 9)];
                        num++;
                        if (num > 12)
                        {
                            c = ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0032: stateMachine*/)._0024this.pawn.Position;
                            break;
                        }
                        if (c.InBounds(((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0032: stateMachine*/)._0024this.pawn.Map) && c.Standable(((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0032: stateMachine*/)._0024this.pawn.Map))
                        {
                            break;
                        }
                    }
                    ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0032: stateMachine*/)._0024this.job.targetA = c;
                    ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0032: stateMachine*/)._0024this.pawn.pather.StopDead();
                },
                tickAction = delegate
                {
                    if (((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0049: stateMachine*/)._0024this.ticksLeft % 150 == 149)
                    {
                        FilthMaker.MakeFilth(((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0049: stateMachine*/)._0024this.job.targetA.Cell, ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0049: stateMachine*/)._0024this.Map, ThingDefOf.FilthVomit, ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0049: stateMachine*/)._0024this.pawn.LabelIndefinite(), 1);
                        if (((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0049: stateMachine*/)._0024this.pawn.needs.food.CurLevelPercentage > 0.10000000149011612)
                        {
                            ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0049: stateMachine*/)._0024this.pawn.needs.food.CurLevel -= (float)(((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0049: stateMachine*/)._0024this.pawn.needs.food.MaxLevel * 0.039999999105930328);
                        }
                    }
                    ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0049: stateMachine*/)._0024this.ticksLeft--;
                    if (((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0049: stateMachine*/)._0024this.ticksLeft <= 0)
                    {
                        ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0049: stateMachine*/)._0024this.ReadyForNextToil();
                        TaleRecorder.RecordTale(TaleDefOf.Vomited, ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0049: stateMachine*/)._0024this.pawn);
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Never
            };

            to.WithEffect(EffecterDefOf.Vomit, TargetIndex.A);
            to.PlaySustainerOrSound(() => SoundDef.Named("Vomit"));
            yield return(to);

            /*Error: Unable to find new state assignment for yield return*/;
        }
Exemplo n.º 9
0
        public void CompleteConstruction(Pawn worker)
        {
            resourceContainer.ClearAndDestroyContents();
            Map map = base.Map;

            Destroy();
            if (this.GetStatValue(StatDefOf.WorkToBuild) > 150f && def.entityDefToBuild is ThingDef && ((ThingDef)def.entityDefToBuild).category == ThingCategory.Building)
            {
                SoundDefOf.Building_Complete.PlayOneShot(new TargetInfo(base.Position, map));
            }
            ThingDef thingDef = def.entityDefToBuild as ThingDef;
            Thing    thing    = null;

            if (thingDef != null)
            {
                thing = ThingMaker.MakeThing(thingDef, base.Stuff);
                thing.SetFactionDirect(base.Faction);
                CompQuality compQuality = thing.TryGetComp <CompQuality>();
                if (compQuality != null)
                {
                    QualityCategory q = QualityUtility.GenerateQualityCreatedByPawn(worker, SkillDefOf.Construction);
                    compQuality.SetQuality(q, ArtGenerationContext.Colony);
                    QualityUtility.SendCraftNotification(thing, worker);
                }
                CompArt compArt = thing.TryGetComp <CompArt>();
                if (compArt != null)
                {
                    if (compQuality == null)
                    {
                        compArt.InitializeArt(ArtGenerationContext.Colony);
                    }
                    compArt.JustCreatedBy(worker);
                }
                thing.HitPoints = Mathf.CeilToInt((float)HitPoints / (float)base.MaxHitPoints * (float)thing.MaxHitPoints);
                GenSpawn.Spawn(thing, base.Position, map, base.Rotation, WipeMode.FullRefund);
                Building b;
                if ((b = thing as Building) != null)
                {
                    worker.GetLord()?.AddBuilding(b);
                }
            }
            else
            {
                map.terrainGrid.SetTerrain(base.Position, (TerrainDef)def.entityDefToBuild);
                FilthMaker.RemoveAllFilth(base.Position, map);
            }
            worker.records.Increment(RecordDefOf.ThingsConstructed);
            if (thing != null && thing.GetStatValue(StatDefOf.WorkToBuild) >= 9500f)
            {
                TaleRecorder.RecordTale(TaleDefOf.CompletedLongConstructionProject, worker, thing.def);
            }
        }
Exemplo n.º 10
0
 public void CapturedBy(Faction by, Pawn byPawn = null)
 {
     if (pawn.Faction != null)
     {
         pawn.Faction.Notify_MemberCaptured(pawn, by);
     }
     SetGuestStatus(by, prisoner: true);
     if (IsPrisoner && byPawn != null)
     {
         TaleRecorder.RecordTale(TaleDefOf.Captured, byPawn, pawn);
         byPawn.records.Increment(RecordDefOf.PeopleCaptured);
     }
 }
Exemplo n.º 11
0
        public virtual void Notify_CorpseBuried(Pawn worker)
        {
            CompArt comp = GetComp <CompArt>();

            if (comp != null && !comp.Active)
            {
                comp.JustCreatedBy(worker);
                comp.InitializeArt(Corpse.InnerPawn);
            }
            base.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Things | MapMeshFlag.Buildings);
            worker.records.Increment(RecordDefOf.CorpsesBuried);
            TaleRecorder.RecordTale(TaleDefOf.BuriedCorpse, worker, (Corpse != null) ? Corpse.InnerPawn : null);
        }
Exemplo n.º 12
0
        public override void AttachTo(Thing parent)
        {
            base.AttachTo(parent);
            Pawn pawn = parent as Pawn;

            if (pawn != null)
            {
                TaleRecorder.RecordTale(TaleDefOf.WasOnFire, new object[]
                {
                    pawn
                });
            }
        }
Exemplo n.º 13
0
        public void FinishProject(ResearchProjectDef proj, bool doCompletionDialog = false, Pawn researcher = null)
        {
            if (proj.prerequisites != null)
            {
                for (int i = 0; i < proj.prerequisites.Count; i++)
                {
                    if (!proj.prerequisites[i].IsFinished)
                    {
                        FinishProject(proj.prerequisites[i]);
                    }
                }
            }
            int num = GetTechprints(proj);

            if (num < proj.techprintCount)
            {
                AddTechprints(proj, proj.techprintCount - num);
            }
            progress[proj] = proj.baseCost;
            if (researcher != null)
            {
                TaleRecorder.RecordTale(TaleDefOf.FinishedResearchProject, researcher, currentProj);
            }
            ReapplyAllMods();
            if (doCompletionDialog)
            {
                DiaNode diaNode = new DiaNode((string)("ResearchFinished".Translate(currentProj.LabelCap) + "\n\n" + currentProj.description));
                diaNode.options.Add(DiaOption.DefaultOK);
                DiaOption diaOption = new DiaOption("ResearchScreen".Translate());
                diaOption.resolveTree = true;
                diaOption.action      = delegate
                {
                    Find.MainTabsRoot.SetCurrentTab(MainButtonDefOf.Research);
                };
                diaNode.options.Add(diaOption);
                Find.WindowStack.Add(new Dialog_NodeTree(diaNode, delayInteractivity: true));
            }
            if (!proj.discoveredLetterTitle.NullOrEmpty() && Find.Storyteller.difficulty.difficulty >= proj.discoveredLetterMinDifficulty)
            {
                Find.LetterStack.ReceiveLetter(proj.discoveredLetterTitle, proj.discoveredLetterText, LetterDefOf.NeutralEvent);
            }
            if (proj.unlockExtremeDifficulty && Find.Storyteller.difficulty.difficulty >= DifficultyDefOf.Rough.difficulty)
            {
                Prefs.ExtremeDifficultyUnlocked = true;
                Prefs.Save();
            }
            if (currentProj == proj)
            {
                currentProj = null;
            }
        }
        public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks)
        {
            Thought thought = this.RandomBreakupReason(initiator, recipient);

            if (initiator.relations.DirectRelationExists(PawnRelationDefOf.Spouse, recipient))
            {
                initiator.relations.RemoveDirectRelation(PawnRelationDefOf.Spouse, recipient);
                initiator.relations.AddDirectRelation(PawnRelationDefOf.ExSpouse, recipient);
                recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.DivorcedMe, initiator);
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.GotMarried);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.GotMarried);
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.HoneymoonPhase, recipient);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.HoneymoonPhase, initiator);
            }
            else
            {
                initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.Lover, recipient);
                initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.Fiance, recipient);
                initiator.relations.AddDirectRelation(PawnRelationDefOf.ExLover, recipient);
                recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.BrokeUpWithMe, initiator);
            }
            if (initiator.ownership.OwnedBed != null && initiator.ownership.OwnedBed == recipient.ownership.OwnedBed)
            {
                Pawn pawn = (Rand.Value >= 0.5f) ? recipient : initiator;
                pawn.ownership.UnclaimBed();
            }
            TaleRecorder.RecordTale(TaleDefOf.Breakup, new object[]
            {
                initiator,
                recipient
            });
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine("LetterNoLongerLovers".Translate(new object[]
            {
                initiator.LabelShort,
                recipient.LabelShort
            }));
            if (thought != null)
            {
                stringBuilder.AppendLine();
                stringBuilder.AppendLine("FinalStraw".Translate(new object[]
                {
                    thought.CurStage.label
                }));
            }
            if (PawnUtility.ShouldSendNotificationAbout(initiator) || PawnUtility.ShouldSendNotificationAbout(recipient))
            {
                Find.LetterStack.ReceiveLetter("LetterLabelBreakup".Translate(), stringBuilder.ToString(), LetterDefOf.NegativeEvent, initiator, null);
            }
        }
        // Token: 0x0600001E RID: 30 RVA: 0x000027A0 File Offset: 0x000009A0
        public virtual void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks)
        {
            bool flag = Rand.Value < this.SuccessChance(initiator, recipient);

            if (flag)
            {
                List <Pawn> list;
                this.BreakLoverAndFianceRelations(initiator, out list);
                List <Pawn> list2;
                this.BreakLoverAndFianceRelations(recipient, out list2);
                for (int i = 0; i < list.Count; i++)
                {
                    this.TryAddCheaterThought(list[i], initiator);
                }
                for (int j = 0; j < list2.Count; j++)
                {
                    this.TryAddCheaterThought(list2[j], recipient);
                }
                initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.ExLover, recipient);
                initiator.relations.AddDirectRelation(PawnRelationDefOf.Lover, recipient);
                TaleRecorder.RecordTale(TaleDefOf.BecameLover, new object[]
                {
                    initiator,
                    recipient
                });
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.BrokeUpWithMe, recipient);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.BrokeUpWithMe, initiator);
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMe, recipient);
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMeLowOpinionMood, recipient);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMe, initiator);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMeLowOpinionMood, initiator);
                bool flag2 = initiator.IsColonist || recipient.IsColonist;
                if (flag2)
                {
                    this.SendNewLoversLetter(initiator, recipient, list, list2);
                }
                extraSentencePacks.Add(RulePackDefOf.Sentence_RomanceAttemptAccepted);
                LovePartnerRelationUtility.TryToShareBed(initiator, recipient);
            }
            else
            {
                initiator.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.RebuffedMyRomanceAttempt, recipient);
                recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.FailedRomanceAttemptOnMe, initiator);
                bool flag3 = recipient.relations.OpinionOf(initiator) <= 0;
                if (flag3)
                {
                    recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.FailedRomanceAttemptOnMeLowOpinionMood, initiator);
                }
                extraSentencePacks.Add(RulePackDefOf.Sentence_RomanceAttemptRejected);
            }
        }
 public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef)
 {
     if (Rand.Value < SuccessChance(initiator, recipient))
     {
         BreakLoverAndFianceRelations(initiator, out List <Pawn> oldLoversAndFiances);
         BreakLoverAndFianceRelations(recipient, out List <Pawn> oldLoversAndFiances2);
         for (int i = 0; i < oldLoversAndFiances.Count; i++)
         {
             TryAddCheaterThought(oldLoversAndFiances[i], initiator);
         }
         for (int j = 0; j < oldLoversAndFiances2.Count; j++)
         {
             TryAddCheaterThought(oldLoversAndFiances2[j], recipient);
         }
         initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.ExLover, recipient);
         initiator.relations.AddDirectRelation(PawnRelationDefOf.Lover, recipient);
         TaleRecorder.RecordTale(TaleDefOf.BecameLover, initiator, recipient);
         initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.BrokeUpWithMe, recipient);
         recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.BrokeUpWithMe, initiator);
         initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMe, recipient);
         initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMeLowOpinionMood, recipient);
         recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMe, initiator);
         recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.FailedRomanceAttemptOnMeLowOpinionMood, initiator);
         if (PawnUtility.ShouldSendNotificationAbout(initiator) || PawnUtility.ShouldSendNotificationAbout(recipient))
         {
             GetNewLoversLetter(initiator, recipient, oldLoversAndFiances, oldLoversAndFiances2, out letterText, out letterLabel, out letterDef);
         }
         else
         {
             letterText  = null;
             letterLabel = null;
             letterDef   = null;
         }
         extraSentencePacks.Add(RulePackDefOf.Sentence_RomanceAttemptAccepted);
         LovePartnerRelationUtility.TryToShareBed(initiator, recipient);
     }
     else
     {
         initiator.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.RebuffedMyRomanceAttempt, recipient);
         recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.FailedRomanceAttemptOnMe, initiator);
         if (recipient.relations.OpinionOf(initiator) <= 0)
         {
             recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.FailedRomanceAttemptOnMeLowOpinionMood, initiator);
         }
         extraSentencePacks.Add(RulePackDefOf.Sentence_RomanceAttemptRejected);
         letterText  = null;
         letterLabel = null;
         letterDef   = null;
     }
 }
        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 statValue = actor.GetStatValue(StatDefOf.TrainAnimalChance);
                    statValue *= GenMath.LerpDouble(0f, 1f, 1.5f, 0.5f, pawn.RaceProps.wildness);
                    if (actor.relations.DirectRelationExists(PawnRelationDefOf.Bond, pawn))
                    {
                        statValue *= 5f;
                    }
                    statValue = Mathf.Clamp01(statValue);
                    TrainableDef trainableDef = pawn.training.NextTrainableToTrain();
                    if (trainableDef == null)
                    {
                        Log.ErrorOnce("Attempted to train untrainable animal", 7842936);
                    }
                    else
                    {
                        string text;
                        if (Rand.Value < statValue)
                        {
                            pawn.training.Train(trainableDef, actor);
                            if (pawn.caller != null)
                            {
                                pawn.caller.DoCall();
                            }
                            text = "TextMote_TrainSuccess".Translate(trainableDef.LabelCap, statValue.ToStringPercent());
                            RelationsUtility.TryDevelopBondRelation(actor, pawn, 0.007f);
                            TaleRecorder.RecordTale(TaleDefOf.TrainedAnimal, actor, pawn, trainableDef);
                        }
                        else
                        {
                            text = "TextMote_TrainFail".Translate(trainableDef.LabelCap, statValue.ToStringPercent());
                        }
                        text = text + "\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;
            toil.activeSkill         = () => SkillDefOf.Animals;
            return(toil);
        }
Exemplo n.º 18
0
 public static void Married(Pawn firstPawn, Pawn secondPawn)
 {
     LovePartnerRelationUtility.ChangeSpouseRelationsToExSpouse(firstPawn);
     LovePartnerRelationUtility.ChangeSpouseRelationsToExSpouse(secondPawn);
     firstPawn.relations.RemoveDirectRelation(PawnRelationDefOf.Fiance, secondPawn);
     firstPawn.relations.TryRemoveDirectRelation(PawnRelationDefOf.ExSpouse, secondPawn);
     firstPawn.relations.AddDirectRelation(PawnRelationDefOf.Spouse, secondPawn);
     AddNewlyMarriedThoughts(firstPawn, secondPawn);
     AddNewlyMarriedThoughts(secondPawn, firstPawn);
     firstPawn.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.DivorcedMe, secondPawn);
     secondPawn.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.DivorcedMe, firstPawn);
     LovePartnerRelationUtility.TryToShareBed(firstPawn, secondPawn);
     TaleRecorder.RecordTale(TaleDefOf.Marriage, firstPawn, secondPawn);
 }
Exemplo n.º 19
0
 public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
 {
     if (billDoer != null)
     {
         if (!base.CheckSurgeryFail(billDoer, pawn, ingredients, part, bill))
         {
             TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object[]
             {
                 billDoer,
                 pawn
             });
             MedicalRecipesUtility.RestorePartAndSpawnAllPreviousParts(pawn, part, billDoer.Position, billDoer.Map);
         }
     }
 }
Exemplo n.º 20
0
 protected override bool TryCastShot()
 {
     if (currentTarget.HasThing && currentTarget.Thing.Map != caster.Map)
     {
         return(false);
     }
     GenSpawn.Spawn(verbProps.spawnDef, currentTarget.Cell, caster.Map);
     if (verbProps.colonyWideTaleDef != null)
     {
         Pawn pawn = caster.Map.mapPawns.FreeColonistsSpawned.RandomElementWithFallback();
         TaleRecorder.RecordTale(verbProps.colonyWideTaleDef, caster, pawn);
     }
     base.ReloadableCompSource?.UsedOnce();
     return(true);
 }
Exemplo n.º 21
0
        public List <Pawn> ApplyToPawns(IEnumerable <Pawn> pawns, out string blockedInfo)
        {
            List <Pawn> list = new List <Pawn>();
            Dictionary <HediffDef, List <Pawn> > dictionary = new Dictionary <HediffDef, List <Pawn> >();

            foreach (Pawn current in pawns)
            {
                HediffDef hediffDef = null;
                if (Rand.Chance(current.health.immunity.DiseaseContractChanceFactor(this.def.diseaseIncident, out hediffDef, null)))
                {
                    HediffGiverUtility.TryApply(current, this.def.diseaseIncident, this.def.diseasePartsToAffect, false, 1, null);
                    TaleRecorder.RecordTale(TaleDefOf.IllnessRevealed, new object[]
                    {
                        current,
                        this.def.diseaseIncident
                    });
                    list.Add(current);
                }
                else if (hediffDef != null)
                {
                    if (!dictionary.ContainsKey(hediffDef))
                    {
                        dictionary[hediffDef] = new List <Pawn>();
                    }
                    dictionary[hediffDef].Add(current);
                }
            }
            blockedInfo = string.Empty;
            foreach (KeyValuePair <HediffDef, List <Pawn> > current2 in dictionary)
            {
                if (current2.Key != this.def.diseaseIncident)
                {
                    if (blockedInfo.Length != 0)
                    {
                        blockedInfo += "\n\n";
                    }
                    string   arg_19F_0 = blockedInfo;
                    string   arg_19A_0 = "LetterDisease_Blocked";
                    object[] expr_146  = new object[3];
                    expr_146[0] = current2.Key.LabelCap;
                    expr_146[1] = this.def.diseaseIncident.label;
                    expr_146[2] = (from victim in current2.Value
                                   select victim.LabelShort).ToCommaList(true);
                    blockedInfo = arg_19F_0 + arg_19A_0.Translate(expr_146);
                }
            }
            return(list);
        }
Exemplo n.º 22
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnAggroMentalState(TargetIndex.A);
            yield return(Toils_Interpersonal.GotoPrisoner(pawn, Victim, PrisonerInteractionModeDefOf.Execution).FailOn(() => !Victim.IsPrisonerOfColony || !Victim.guest.PrisonerIsSecure));

            Toil execute = new Toil();

            execute.initAction = delegate
            {
                ExecutionUtility.DoExecutionByCut(execute.actor, Victim);
                ThoughtUtility.GiveThoughtsForPawnExecuted(Victim, PawnExecutionKind.GenericBrutal);
                TaleRecorder.RecordTale(TaleDefOf.ExecutedPrisoner, pawn, Victim);
            };
            execute.defaultCompleteMode = ToilCompleteMode.Instant;
            yield return(execute);
        }
Exemplo n.º 23
0
        public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks, out string letterText, out string letterLabel, out LetterDef letterDef)
        {
            Thought thought = RandomBreakupReason(initiator, recipient);

            if (initiator.relations.DirectRelationExists(PawnRelationDefOf.Spouse, recipient))
            {
                initiator.relations.RemoveDirectRelation(PawnRelationDefOf.Spouse, recipient);
                initiator.relations.AddDirectRelation(PawnRelationDefOf.ExSpouse, recipient);
                recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.DivorcedMe, initiator);
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.GotMarried);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.GotMarried);
                initiator.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.HoneymoonPhase, recipient);
                recipient.needs.mood.thoughts.memories.RemoveMemoriesOfDefWhereOtherPawnIs(ThoughtDefOf.HoneymoonPhase, initiator);
            }
            else
            {
                initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.Lover, recipient);
                initiator.relations.TryRemoveDirectRelation(PawnRelationDefOf.Fiance, recipient);
                initiator.relations.AddDirectRelation(PawnRelationDefOf.ExLover, recipient);
                recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.BrokeUpWithMe, initiator);
            }
            if (initiator.ownership.OwnedBed != null && initiator.ownership.OwnedBed == recipient.ownership.OwnedBed)
            {
                Pawn pawn = (!(Rand.Value < 0.5f)) ? recipient : initiator;
                pawn.ownership.UnclaimBed();
            }
            TaleRecorder.RecordTale(TaleDefOf.Breakup, initiator, recipient);
            if (PawnUtility.ShouldSendNotificationAbout(initiator) || PawnUtility.ShouldSendNotificationAbout(recipient))
            {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.AppendLine("LetterNoLongerLovers".Translate(initiator.LabelShort, recipient.LabelShort, initiator.Named("PAWN1"), recipient.Named("PAWN2")));
                if (thought != null)
                {
                    stringBuilder.AppendLine();
                    stringBuilder.AppendLine("FinalStraw".Translate(thought.CurStage.label.CapitalizeFirst()));
                }
                letterLabel = "LetterLabelBreakup".Translate();
                letterText  = stringBuilder.ToString().TrimEndNewlines();
                letterDef   = LetterDefOf.NegativeEvent;
            }
            else
            {
                letterLabel = null;
                letterText  = null;
                letterDef   = null;
            }
        }
 public void CapturedBy(Faction by, Pawn byPawn = null)
 {
     if (this.pawn.Faction != null)
     {
         this.pawn.Faction.Notify_MemberCaptured(this.pawn, by);
     }
     this.SetGuestStatus(by, true);
     if (this.IsPrisoner && byPawn != null)
     {
         TaleRecorder.RecordTale(TaleDefOf.Captured, new object[]
         {
             byPawn,
             this.pawn
         });
         byPawn.records.Increment(RecordDefOf.PeopleCaptured);
     }
 }
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            if (billDoer != null)
            {
                TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);
            }
            Hediff_ImplantWithLevel hediff_ImplantWithLevel = (Hediff_ImplantWithLevel)pawn.health.hediffSet.hediffs.FirstOrDefault((Hediff h) => Operable(h, recipe) && h.Part == part);

            if (hediff_ImplantWithLevel != null)
            {
                if (IsViolationOnPawn(pawn, part, Faction.OfPlayer))
                {
                    ReportViolation(pawn, billDoer, pawn.FactionOrExtraMiniOrHomeFaction, -70, "GoodwillChangedReason_DowngradedImplant".Translate(hediff_ImplantWithLevel.Label));
                }
                hediff_ImplantWithLevel.ChangeLevel(recipe.hediffLevelOffset);
            }
        }
Exemplo n.º 26
0
        private void ActionFight(Caravan caravan, List <Pawn> attackers)
        {
            Faction enemyFaction = attackers[0].Faction;

            TaleRecorder.RecordTale(TaleDefOf.CaravanAmbushedByHumanlike, caravan.RandomOwner());
            LongEventHandler.QueueLongEvent(delegate
            {
                Map map = CaravanIncidentUtility.SetupCaravanAttackMap(caravan, attackers, sendLetterIfRelatedPawns: true);
                LordJob_AssaultColony lordJob_AssaultColony = new LordJob_AssaultColony(enemyFaction, canKidnap: true, canTimeoutOrFlee: false);
                if (lordJob_AssaultColony != null)
                {
                    LordMaker.MakeNewLord(enemyFaction, lordJob_AssaultColony, map, attackers);
                }
                Find.TickManager.Notify_GeneratedPotentiallyHostileMap();
                CameraJumper.TryJump(attackers[0]);
            }, "GeneratingMapForNewEncounter", doAsynchronously: false, null);
        }
Exemplo n.º 27
0
        public override void NeedInterval()
        {
            if (!IsFrozen)
            {
                if (Resting)
                {
                    float num = lastRestEffectiveness;
                    num *= pawn.GetStatValue(StatDefOf.RestRateMultiplier);
                    if (num > 0f)
                    {
                        CurLevel += 0.005714286f * num;
                    }
                }
                else
                {
                    CurLevel -= RestFallPerTick * 150f;
                }
            }
            if (CurLevel < 0.0001f)
            {
                ticksAtZero += 150;
            }
            else
            {
                ticksAtZero = 0;
            }
            if (ticksAtZero <= 1000 || !pawn.Spawned)
            {
                return;
            }
            float mtb = (ticksAtZero < 15000) ? 0.25f : ((ticksAtZero < 30000) ? 0.125f : ((ticksAtZero >= 45000) ? 0.0625f : 0.0833333358f));

            if (Rand.MTBEventOccurs(mtb, 60000f, 150f) && (pawn.CurJob == null || pawn.CurJob.def != JobDefOf.LayDown))
            {
                pawn.jobs.StartJob(JobMaker.MakeJob(JobDefOf.LayDown, pawn.Position), JobCondition.InterruptForced, null, resumeCurJobAfterwards: false, cancelBusyStances: true, null, JobTag.SatisfyingNeeds);
                if (pawn.InMentalState && pawn.MentalStateDef.recoverFromCollapsingExhausted)
                {
                    pawn.mindState.mentalStateHandler.CurState.RecoverFromState();
                }
                if (PawnUtility.ShouldSendNotificationAbout(pawn))
                {
                    Messages.Message("MessageInvoluntarySleep".Translate(pawn.LabelShort, pawn), pawn, MessageTypeDefOf.NegativeEvent);
                }
                TaleRecorder.RecordTale(TaleDefOf.Exhausted, pawn);
            }
        }
Exemplo n.º 28
0
        private void ActionFight(Caravan caravan, List <Pawn> attackers)
        {
            Faction enemyFaction = attackers[0].Faction;

            TaleRecorder.RecordTale(TaleDefOf.CaravanAmbushedByHumanlike, caravan.RandomOwner());
            LongEventHandler.QueueLongEvent(delegate
            {
                Map map = CaravanIncidentUtility.SetupCaravanAttackMap(caravan, attackers);
                LordJob_AssaultColony lordJob_AssaultColony = new LordJob_AssaultColony(enemyFaction, true, false, false, false, true);
                if (lordJob_AssaultColony != null)
                {
                    LordMaker.MakeNewLord(enemyFaction, lordJob_AssaultColony, map, attackers);
                }
                Find.TickManager.CurTimeSpeed = TimeSpeed.Paused;
                CameraJumper.TryJump(attackers[0]);
            }, "GeneratingMapForNewEncounter", false, null);
        }
Exemplo n.º 29
0
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            bool flag  = MedicalRecipesUtility.IsClean(pawn, part);
            bool flag2 = this.IsViolationOnPawn(pawn, part, Faction.OfPlayer);

            if (billDoer != null)
            {
                if (base.CheckSurgeryFail(billDoer, pawn, ingredients, part, bill))
                {
                    return;
                }
                TaleRecorder.RecordTale(TaleDefOf.DidSurgery, new object[]
                {
                    billDoer,
                    pawn
                });
                MedicalRecipesUtility.SpawnNaturalPartIfClean(pawn, part, billDoer.Position, billDoer.Map);
                MedicalRecipesUtility.SpawnThingsFromHediffs(pawn, part, billDoer.Position, billDoer.Map);
            }
            DamageDef surgicalCut      = DamageDefOf.SurgicalCut;
            float     amount           = 99999f;
            float     armorPenetration = 999f;

            pawn.TakeDamage(new DamageInfo(surgicalCut, amount, armorPenetration, -1f, null, part, null, DamageInfo.SourceCategory.ThingOrUnknown, null));
            if (flag)
            {
                if (pawn.Dead)
                {
                    ThoughtUtility.GiveThoughtsForPawnExecuted(pawn, PawnExecutionKind.OrganHarvesting);
                }
                ThoughtUtility.GiveThoughtsForPawnOrganHarvested(pawn);
            }
            if (flag2 && pawn.Faction != null && billDoer.Faction != null)
            {
                Faction faction        = pawn.Faction;
                Faction faction2       = billDoer.Faction;
                int     goodwillChange = -15;
                string  reason         = "GoodwillChangedReason_RemovedBodyPart".Translate(new object[]
                {
                    part.LabelShort
                });
                GlobalTargetInfo?lookTarget = new GlobalTargetInfo?(pawn);
                faction.TryAffectGoodwillWith(faction2, goodwillChange, true, true, reason, lookTarget);
            }
        }
Exemplo n.º 30
0
 protected override bool TryCastShot()
 {
     if (currentTarget.HasThing && currentTarget.Thing.Map != caster.Map)
     {
         return(false);
     }
     GenSpawn.Spawn(verbProps.spawnDef, currentTarget.Cell, caster.Map);
     if (verbProps.colonyWideTaleDef != null)
     {
         Pawn pawn = caster.Map.mapPawns.FreeColonistsSpawned.RandomElementWithFallback();
         TaleRecorder.RecordTale(verbProps.colonyWideTaleDef, caster, pawn);
     }
     if (base.EquipmentSource != null && !base.EquipmentSource.Destroyed)
     {
         base.EquipmentSource.Destroy();
     }
     return(true);
 }