コード例 #1
0
 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;
     }
 }
コード例 #2
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 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());
                        }
                        string text2 = text;
                        text = 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);
        }
コード例 #3
0
        public bool TryExecute(out bool actuallyTraded)
        {
            if (TradeSession.giftMode)
            {
                UpdateCurrencyCount();
                LimitCurrencyCountToFunds();
                int goodwillChange = FactionGiftUtility.GetGoodwillChange(tradeables, TradeSession.trader.Faction);
                FactionGiftUtility.GiveGift(tradeables, TradeSession.trader.Faction, TradeSession.playerNegotiator);
                actuallyTraded = ((float)goodwillChange > 0f);
                return(true);
            }
            if (SilverTradeable == null || SilverTradeable.CountPostDealFor(Transactor.Colony) < 0)
            {
                Find.WindowStack.WindowOfType <Dialog_Trade>().FlashSilver();
                Messages.Message("MessageColonyCannotAfford".Translate(), MessageTypeDefOf.RejectInput, historical: false);
                actuallyTraded = false;
                return(false);
            }
            UpdateCurrencyCount();
            LimitCurrencyCountToFunds();
            actuallyTraded = false;
            float num = 0f;

            foreach (Tradeable tradeable in tradeables)
            {
                if (tradeable.ActionToDo != 0)
                {
                    actuallyTraded = true;
                }
                if (tradeable.ActionToDo == TradeAction.PlayerSells)
                {
                    num += tradeable.CurTotalSilverCostForDestination;
                }
                tradeable.ResolveTrade();
            }
            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, TradeSession.playerNegotiator, pawn);
            }
            TradeSession.playerNegotiator.mindState.inspirationHandler.EndInspiration(InspirationDefOf.Inspired_Trade);
            return(true);
        }
コード例 #4
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);
 }
コード例 #5
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);
         }
     }
 }
コード例 #6
0
ファイル: JobDriver_Vomit.cs プロジェクト: potsh/RimWorld
        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;
                    do
                    {
                        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;
                        }
                    }while (!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));
                    ((_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.Filth_Vomit, ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0049: stateMachine*/)._0024this.pawn.LabelIndefinite());
                        if (((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0049: stateMachine*/)._0024this.pawn.needs.food.CurLevelPercentage > 0.1f)
                        {
                            ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0049: stateMachine*/)._0024this.pawn.needs.food.CurLevel -= ((_003CMakeNewToils_003Ec__Iterator0) /*Error near IL_0049: stateMachine*/)._0024this.pawn.needs.food.MaxLevel * 0.04f;
                        }
                    }
                    ((_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(() => SoundDefOf.Vomit);
            yield return(to);

            /*Error: Unable to find new state assignment for yield return*/;
        }
コード例 #7
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);
        }
コード例 #8
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);
        }
コード例 #9
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, new object[]
         {
             billDoer,
             pawn
         });
     }
     pawn.health.AddHediff(this.recipe.addsHediff, part, null, null);
 }
コード例 #10
0
 public override void Interacted(Pawn initiator, Pawn recipient, List <RulePackDef> extraSentencePacks)
 {
     if (Rand.Value < this.SuccessChance(initiator, recipient))
     {
         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);
         if (initiator.IsColonist || recipient.IsColonist)
         {
             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);
         if (recipient.relations.OpinionOf(initiator) <= 0)
         {
             recipient.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.FailedRomanceAttemptOnMeLowOpinionMood, initiator);
         }
         extraSentencePacks.Add(RulePackDefOf.Sentence_RomanceAttemptRejected);
     }
 }
コード例 #11
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;
            }
        }
コード例 #12
0
ファイル: Frame.cs プロジェクト: potsh/RimWorld
        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);
            }
            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);
            }
        }
コード例 #13
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);
        }
コード例 #14
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);
            }
        }
コード例 #15
0
 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);
     }
 }
コード例 #16
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);
        }
コード例 #17
0
        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);
            }
        }
コード例 #18
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.difficultyValues.AllowedBy(proj.discoveredLetterDisabledWhen))
            {
                Find.LetterStack.ReceiveLetter(proj.discoveredLetterTitle, proj.discoveredLetterText, LetterDefOf.NeutralEvent);
            }
            if (currentProj == proj)
            {
                currentProj = null;
            }
        }
コード例 #19
0
ファイル: ResearchManager.cs プロジェクト: potsh/RimWorld
 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]);
             }
         }
     }
     progress[proj] = proj.baseCost;
     if (researcher != null)
     {
         TaleRecorder.RecordTale(TaleDefOf.FinishedResearchProject, researcher, currentProj);
     }
     ReapplyAllMods();
     if (doCompletionDialog)
     {
         string  text    = "ResearchFinished".Translate(currentProj.LabelCap) + "\n\n" + 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);
         };
         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;
     }
 }
コード例 #20
0
        public virtual void Notify_CorpseBuried(Pawn worker)
        {
            CompArt comp = base.GetComp <CompArt>();

            if (comp != null && !comp.Active)
            {
                comp.JustCreatedBy(worker);
                comp.InitializeArt(this.Corpse.InnerPawn);
            }
            base.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Things | MapMeshFlag.Buildings);
            worker.records.Increment(RecordDefOf.CorpsesBuried);
            TaleRecorder.RecordTale(TaleDefOf.BuriedCorpse, new object[]
            {
                worker,
                (this.Corpse == null) ? null : this.Corpse.InnerPawn
            });
        }
コード例 #21
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);
            }
        }
コード例 #22
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);
     MarriageCeremonyUtility.AddNewlyMarriedThoughts(firstPawn, secondPawn);
     MarriageCeremonyUtility.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, new object[]
     {
         firstPawn,
         secondPawn
     });
 }
コード例 #23
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);
        }
コード例 #24
0
ファイル: Verb_Spawn.cs プロジェクト: KraigXu/GameProject
 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);
 }
コード例 #25
0
        private Toil StartCollectCorpseToil()
        {
            Toil toil = new Toil();

            toil.initAction = delegate()
            {
                if (this.Victim == null)
                {
                    toil.actor.jobs.EndCurrentJob(JobCondition.Incompletable, true);
                }
                else
                {
                    TaleRecorder.RecordTale(TaleDefOf.Hunted, new object[]
                    {
                        this.pawn,
                        this.Victim
                    });
                    Corpse corpse = this.Victim.Corpse;
                    if (corpse == null || !this.pawn.CanReserveAndReach(corpse, PathEndMode.ClosestTouch, Danger.Deadly, 1, -1, null, false))
                    {
                        this.pawn.jobs.EndCurrentJob(JobCondition.Incompletable, true);
                    }
                    else
                    {
                        corpse.SetForbidden(false, true);
                        IntVec3 c;
                        if (StoreUtility.TryFindBestBetterStoreCellFor(corpse, this.pawn, this.Map, StoragePriority.Unstored, this.pawn.Faction, out c, true))
                        {
                            this.pawn.Reserve(corpse, this.job, 1, -1, null);
                            this.pawn.Reserve(c, this.job, 1, -1, null);
                            this.job.SetTarget(TargetIndex.B, c);
                            this.job.SetTarget(TargetIndex.A, corpse);
                            this.job.count    = 1;
                            this.job.haulMode = HaulMode.ToCellStorage;
                        }
                        else
                        {
                            this.pawn.jobs.EndCurrentJob(JobCondition.Succeeded, true);
                        }
                    }
                }
            };
            return(toil);
        }
コード例 #26
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            Toil toil = new Toil();

            toil.initAction = delegate
            {
                ticksLeft = Rand.Range(300, 900);
                int     num = 0;
                IntVec3 c;
                do
                {
                    c = pawn.Position + GenAdj.AdjacentCellsAndInside[Rand.Range(0, 9)];
                    num++;
                    if (num > 12)
                    {
                        c = pawn.Position;
                        break;
                    }
                }while (!c.InBounds(pawn.Map) || !c.Standable(pawn.Map));
                job.targetA = c;
                pawn.pather.StopDead();
            };
            toil.tickAction = delegate
            {
                if (ticksLeft % 150 == 149)
                {
                    FilthMaker.TryMakeFilth(job.targetA.Cell, base.Map, ThingDefOf.Filth_Vomit, pawn.LabelIndefinite());
                    if (pawn.needs.food.CurLevelPercentage > 0.1f)
                    {
                        pawn.needs.food.CurLevel -= pawn.needs.food.MaxLevel * 0.04f;
                    }
                }
                ticksLeft--;
                if (ticksLeft <= 0)
                {
                    ReadyForNextToil();
                    TaleRecorder.RecordTale(TaleDefOf.Vomited, pawn);
                }
            };
            toil.defaultCompleteMode = ToilCompleteMode.Never;
            toil.WithEffect(EffecterDefOf.Vomit, TargetIndex.A);
            toil.PlaySustainerOrSound(() => SoundDefOf.Vomit);
            yield return(toil);
        }
コード例 #27
0
        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,
                        "."
                    }), false);
                }
                else
                {
                    Messages.Message("MessageSocialFight".Translate(new object[]
                    {
                        this.pawn.LabelShort,
                        otherPawn.LabelShort,
                        thought.LabelCapSocial
                    }), this.pawn, MessageTypeDefOf.ThreatSmall, true);
                }
            }
            MentalStateHandler mentalStateHandler = this.pawn.mindState.mentalStateHandler;
            MentalStateDef     socialFighting     = MentalStateDefOf.SocialFighting;

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

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

            mentalStateHandler2.TryStartMentalState(socialFighting, null, false, false, otherPawn2, false);
            TaleRecorder.RecordTale(TaleDefOf.SocialFight, new object[]
            {
                this.pawn,
                otherPawn
            });
        }
        public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
        {
            bool flag  = MedicalRecipesUtility.IsClean(pawn, part);
            bool flag2 = !PawnGenerator.IsBeingGenerated(pawn) && 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.RestorePartAndSpawnAllPreviousParts(pawn, part, billDoer.Position, billDoer.Map);
            }
            else if (pawn.Map != null)
            {
                MedicalRecipesUtility.RestorePartAndSpawnAllPreviousParts(pawn, part, pawn.Position, pawn.Map);
            }
            else
            {
                pawn.health.RestorePart(part, null, true);
            }
            pawn.health.AddHediff(this.recipe.addsHediff, part, null, null);
            if (flag && flag2 && part.def.spawnThingOnRemoved != null)
            {
                ThoughtUtility.GiveThoughtsForPawnOrganHarvested(pawn);
            }
            if (flag2 && pawn.Faction != null && billDoer != null && billDoer.Faction != null)
            {
                Faction faction        = pawn.Faction;
                Faction faction2       = billDoer.Faction;
                int     goodwillChange = -15;
                string  reason         = "GoodwillChangedReason_NeedlesslyInstalledWorseBodyPart".Translate(new object[]
                {
                    this.recipe.addsHediff.label
                });
                GlobalTargetInfo?lookTarget = new GlobalTargetInfo?(pawn);
                faction.TryAffectGoodwillWith(faction2, goodwillChange, true, true, reason, lookTarget);
            }
        }
コード例 #29
0
 public void ApparelTrackerTick()
 {
     wornApparel.ThingOwnerTick();
     if (pawn.IsColonist && pawn.Spawned && !pawn.Dead && pawn.IsHashIntervalTick(60000) && PsychologicallyNude)
     {
         TaleRecorder.RecordTale(TaleDefOf.WalkedNaked, pawn);
     }
     if (lockedApparel == null)
     {
         return;
     }
     for (int num = lockedApparel.Count - 1; num >= 0; num--)
     {
         if (lockedApparel[num].def.useHitPoints && (float)lockedApparel[num].HitPoints / (float)lockedApparel[num].MaxHitPoints < 0.5f)
         {
             Unlock(lockedApparel[num]);
         }
     }
 }
コード例 #30
0
        public bool TryExecute(IncidentParms parms)
        {
            Map map;

            if ((map = parms.target as Map) != null && def.requireColonistsPresent && map.mapPawns.FreeColonistsSpawnedCount == 0)
            {
                return(true);
            }
            bool flag = TryExecuteWorker(parms);

            if (flag)
            {
                if (def.tale != null)
                {
                    Pawn pawn = null;
                    if (parms.target is Caravan)
                    {
                        pawn = ((Caravan)parms.target).RandomOwner();
                    }
                    else if (parms.target is Map)
                    {
                        pawn = ((Map)parms.target).mapPawns.FreeColonistsSpawned.RandomElementWithFallback();
                    }
                    else if (parms.target is World)
                    {
                        pawn = PawnsFinder.AllMapsCaravansAndTravelingTransportPods_Alive_FreeColonists_NoCryptosleep.RandomElementWithFallback();
                    }
                    if (pawn != null)
                    {
                        TaleRecorder.RecordTale(def.tale, pawn);
                    }
                }
                if (def.category.tale != null)
                {
                    Tale tale = TaleRecorder.RecordTale(def.category.tale);
                    if (tale != null)
                    {
                        tale.customLabel = def.label;
                    }
                }
            }
            return(flag);
        }