コード例 #1
0
        public override void Execute()
        {
            try
            {
                var request = new PawnGenerationRequest(
                    _kindDef,
                    Faction.OfPlayer,
                    allowFood: false,
                    mustBeCapableOfViolence: true,
                    fixedIdeo: Find.FactionManager.OfPlayer.ideos.GetRandomIdeoForNewPawn()
                    );

                Pawn pawn = PawnGenerator.GeneratePawn(request);

                if (!(pawn.Name is NameTriple name))
                {
                    TkUtils.Logger.Warn("Pawn name is not a name triple!");

                    return;
                }

                PurchaseHelper.SpawnPawn(pawn, _loc, _map);
                pawn.Name = new NameTriple(name.First ?? string.Empty, Viewer.username, name.Last ?? string.Empty);
                TaggedString title = "TKUtils.PawnLetter.Title".Localize();
                TaggedString text  = "TKUtils.PawnLetter.Description".LocalizeKeyed(Viewer.username);
                PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref title, pawn);

                Find.LetterStack.ReceiveLetter(title, text, LetterDefOf.PositiveEvent, pawn);
                Current.Game.GetComponent <GameComponentPawns>().AssignUserToPawn(Viewer.username, pawn);

                if (TkSettings.EasterEggs && Basket.TryGetEggFor(Viewer.username, out IEasterEgg egg) && Rand.Chance(egg.Chance) && egg.IsPossible(storeIncident, Viewer))
                {
                    egg.Execute(Viewer, pawn);
                }

                Viewer.Charge(_pawnKindItem.Cost, _pawnKindItem.Data?.KarmaType ?? storeIncident.karmaType);
                MessageHelper.SendConfirmation(Viewer.username, "TKUtils.BuyPawn.Confirmation".Localize());
            }
            catch (Exception e)
            {
                TkUtils.Logger.Error("Could not execute buy pawn", e);
            }
        }
コード例 #2
0
        public override void Execute()
        {
            List <Map> maps = Current.Game.Maps;

            foreach (Map map in maps)
            {
                if (!map.IsPlayerHome || map.GameConditionManager.ConditionIsActive(GameConditionDefOf.Sanctuary))
                {
                    continue;
                }

                map.GameConditionManager.RegisterCondition(GameConditionMaker.MakeCondition(GameConditionDefOf.Sanctuary, Rand.Range(2, 6) * 60000));
            }

            Viewer.Charge(storeIncident);

            Find.LetterStack.ReceiveLetter("TKUtils.SanctuaryLetter.Title".Localize(), "TKUtils.SanctuaryLetter.Description".Localize(), LetterDefOf.PositiveEvent);

            MessageHelper.SendConfirmation(Viewer.username, "TKUtils.Sanctuary.Complete".Localize());
        }
コード例 #3
0
        public override void Execute()
        {
            if (Interests.Active)
            {
                ShuffleWithInterests();
            }
            else
            {
                Shuffle();
            }

            Viewer.Charge(storeIncident);
            MessageHelper.SendConfirmation(Viewer.username, "TKUtils.PassionShuffle.Complete".Localize());

            Find.LetterStack.ReceiveLetter(
                "TKUtils.PassionShuffleLetter.Title".Localize(),
                "TKUtils.PassionShuffleLetter.Description".LocalizeKeyed(Viewer.username),
                LetterDefOf.NeutralEvent,
                _pawn
                );
        }
コード例 #4
0
        private int Heal(object injury, int healed)
        {
            switch (injury)
            {
            case Hediff hediff:
                HealHelper.Cure(hediff);
                healed += 1;

                Viewer.Charge(storeIncident, healed);

                break;

            case BodyPartRecord record:
                _pawn.health.RestorePart(record);
                healed += 1;

                Viewer.Charge(storeIncident, healed);

                break;
            }

            return(healed);
        }
コード例 #5
0
        public override void Execute()
        {
            Backstory previous = _pawn.story.adulthood;

            _pawn.story.adulthood = _backstory;
            _pawn.Notify_DisabledWorkTypesChanged();
            _pawn.workSettings?.Notify_DisabledWorkTypesChanged();
            _pawn.skills?.Notify_SkillDisablesChanged();

            Viewer.Charge(storeIncident);
            MessageHelper.SendConfirmation(Viewer.username, "TKUtils.Adulthood.Complete".LocalizeKeyed(_backstory.TitleCapFor(_pawn.gender)));

            Find.LetterStack.ReceiveLetter(
                "TKUtils.BackstoryLetter.Title".Localize(),
                "TKUtils.BackstoryLetter.AdulthoodDescription".LocalizeKeyed(
                    Viewer.username,
                    previous?.TitleCapFor(_pawn.gender).ToStringSafe(),
                    _backstory.TitleCapFor(_pawn.gender)
                    ),
                LetterDefOf.NeutralEvent,
                _pawn
                );
        }
コード例 #6
0
        public override void Execute()
        {
            if (_map == null || _appointment == null || Viewer == null)
            {
                return;
            }

            Thing   thing = ThingMaker.MakeThing(_appointment.ThingDef);
            IntVec3 spot  = DropCellFinder.TradeDropSpot(_map);

            if (_appointment.ThingDef.Minifiable)
            {
                ThingDef minifiedDef   = _appointment.ThingDef.minifiedDef;
                var      minifiedThing = (MinifiedThing)ThingMaker.MakeThing(minifiedDef);
                minifiedThing.InnerThing = thing;
                minifiedThing.stackCount = _appointment.Quantity;
                PurchaseHelper.SpawnItem(spot, _map, minifiedThing);
            }
            else
            {
                thing.stackCount = _appointment.Quantity;
                PurchaseHelper.SpawnItem(spot, _map, thing);
            }

            _appointment.BookSurgeries();
            Viewer.Charge(_appointment.Cost, _appointment.ItemData?.Weight ?? 1f, _appointment.ItemData?.KarmaType ?? storeIncident.karmaType);

            MessageHelper.SendConfirmation(Viewer.username, "TKUtils.Surgery.Complete".LocalizeKeyed(_appointment.ThingDef.LabelCap));

            Find.LetterStack.ReceiveLetter(
                "TKUtils.SurgeryLetter.Title".Localize(),
                "TKUtils.SurgeryLetter.Description".LocalizeKeyed(Viewer.username, Find.ActiveLanguageWorker.WithDefiniteArticle(thing.LabelCap)),
                LetterDefOf.NeutralEvent,
                new LookTargets(thing)
                );
        }
コード例 #7
0
 public override void Execute()
 {
     _pawn.Map.weatherManager.eventHandler.AddEvent(new WeatherEvent_LightningStrike(_pawn.Map, _pawn.Position));
     Viewer.Charge(storeIncident);
 }