示例#1
0
        public override void TryExecute()
        {
            PawnKindDef           pawnKind = PawnKindDef.Named("LotRD_DwarfColonist");
            Faction               ofPlayer = Faction.OfPlayer;
            bool                  pawnMustBeCapableOfViolence = true;
            PawnGenerationRequest request = new PawnGenerationRequest(pawnKind, ofPlayer, PawnGenerationContext.NonPlayer, -1, true, false, false, false, true, pawnMustBeCapableOfViolence, 20f, false, true, true, false, false, false, false, null, null, null, null, null, null, null, null);
            Pawn                  pawn    = PawnGenerator.GeneratePawn(request);
            NameTriple            old     = pawn.Name as NameTriple;

            pawn.Name = new NameTriple(old.First, viewer.username, old.Last);
            GenSpawn.Spawn(pawn, loc, map, WipeMode.Vanish);
            string label = "Viewer Joins";
            string text  = $"A new pawn has been purchased by {viewer.username}, let's welcome them to the colony.";

            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref label, pawn);
            Find.LetterStack.ReceiveLetter(label, text, LetterDefOf.PositiveEvent, pawn, null, null);

            Current.Game.GetComponent <GameComponentPawns>().AssignUserToPawn(viewer.username, pawn);
            viewer.TakeViewerCoins(this.storeIncident.cost);
            viewer.SetViewerKarma(Karma.CalculateNewKarma(viewer.GetViewerKarma(), this.storeIncident.karmaType, this.storeIncident.cost));
            StorePurchaseLogger.LogPurchase(new Purchase(viewer.username, "", this.storeIncident.karmaType, this.storeIncident.cost, "", DateTime.Now));

            Toolkit.client.SendMessage($"@{viewer.username} has purchased a pawn and is joining the colony.", separateChannel);
        }