private void NotifyItemPurchaseComplete() { MessageHelper.SendConfirmation( Purchaser.username, TkSettings.BuyItemBalance ? "TKUtils.Item.Complete".LocalizeKeyed( Quantity.ToString("N0"), Proxy.AsString(Quantity > 1), Price.ToString("N0"), Purchaser.GetViewerCoins().ToString("N0") ) : "TKUtils.Item.CompleteMinimal".LocalizeKeyed(Quantity.ToString("N0"), Proxy.AsString(Quantity > 1), Price.ToString("N0")) ); }
private void SpawnItem() { ThingDef result = Proxy.Stuff?.Thing; if (!Proxy.Thing.Thing.CanBeStuff(Proxy.Stuff?.Thing)) { var stuffs = new List <ThingDef>(); foreach (ThingDef possible in GenStuff.AllowedStuffsFor(Proxy.Thing.Thing)) { if (!Data.ItemData.TryGetValue(possible.defName, out ItemData data) || !data.IsStuffAllowed) { continue; } stuffs.Add(possible); } result = !stuffs.TryRandomElementByWeight(s => s.stuffProps.commonality, out ThingDef stuff) ? GenStuff.RandomStuffByCommonalityFor(Proxy.Thing.Thing) : stuff; } Thing thing = PurchaseHelper.MakeThing(Proxy.Thing.Thing, result, Proxy.Quality); IntVec3 position = DropCellFinder.TradeDropSpot(Map); if (Proxy.Thing.Thing.Minifiable) { ThingDef minifiedDef = Proxy.Thing.Thing.minifiedDef; var minifiedThing = (MinifiedThing)ThingMaker.MakeThing(minifiedDef); minifiedThing.InnerThing = thing; minifiedThing.stackCount = Quantity; PurchaseHelper.SpawnItem(position, Map, minifiedThing); } else { thing.stackCount = Quantity; PurchaseHelper.SpawnItem(position, Map, thing); } Find.LetterStack.ReceiveLetter( (Quantity > 1 ? Proxy.Thing.Name.Pluralize() : Proxy.Thing.Name).Truncate(15, true).CapitalizeFirst(), "TKUtils.ItemLetter.ItemDescription".LocalizeKeyed(Quantity.ToString("N0"), Proxy.AsString(Quantity > 1), Purchaser.username), ItemHelper.GetLetterFromValue(Price), thing ); }