Example #1
0
        private static DiaOption OfferGiftOption(Map map)
        {
            // TODO: Compare with vanilla method
            int cost = GetCost(Hospitality_MapComponent.Instance(map).GetBribeCount(faction));
            //Log.Message(faction.name + ": " + Hospitality_MapComponent.Instance.GetBribeCount(faction) + " = " + cost);
            int silver = TradeUtility.AllLaunchableThings(map).Where(t => t.def == ThingDefOf.Silver).Sum(t => t.stackCount);

            if (silver < cost)
            {
                var diaOption = new DiaOption("OfferGift".Translate() + " (" + "NeedSilverLaunchable".Translate(new object[]
                {
                    cost
                }) + ")");
                diaOption.Disable("NotEnoughSilver".Translate());
                return(diaOption);
            }
            float goodwillDelta = 12f * negotiator.GetStatValue(StatDefOf.GiftImpact);
            var   diaOption2    = new DiaOption("OfferGift".Translate() + " (" + "SilverForGoodwill".Translate(new object[]
            {
                cost,
                goodwillDelta.ToString("#####0")
            }) + ")");

            diaOption2.action = delegate
            {
                TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, cost, map, null);
                faction.AffectGoodwillWith(Faction.OfPlayer, goodwillDelta);
                Hospitality_MapComponent.Instance(map).Bribe(faction);
            };
            string text = "SilverGiftSent".Translate(new object[]
            {
                faction.Name,
                Mathf.RoundToInt(goodwillDelta)
            });

            diaOption2.link = new DiaNode(text)
            {
                options =
                {
                    new DiaOption("OK".Translate())
                    {
                        linkLateBind = () => Source.FactionDialogFor(negotiator, faction)
                    }
                }
            };
            return(diaOption2);
        }
        public IEnumerable <Thing> ColonyThingsWillingToBuy(Pawn playerNegotiator)
        {
            List <Thing> thingsWillingToBuy = new List <Thing>();

            foreach (Thing thing in TradeUtility.AllLaunchableThings(this.Map))
            {
                thingsWillingToBuy.Add(thing);
            }
            foreach (IntVec3 cell in this.OccupiedRect().Cells)
            {
                foreach (Thing thing in cell.GetThingList(this.Map))
                {
                    if ((TradeUtility.EverTradeable(thing.def)) &&
                        this.TraderKind.WillTrade(thing.def) &&
                        (thingsWillingToBuy.Contains(thing) == false))    // Do not count thing twice.
                    {
                        thingsWillingToBuy.Add(thing);
                    }
                }
            }
            return(thingsWillingToBuy);
        }
            public static bool Replacement(ref DiaOption __result, Map map)
            {
                int cost = GetCost(Hospitality_MapComponent.Instance(map).GetBribeCount(faction));
                //Log.Message(faction.name + ": " + Hospitality_MapComponent.Instance.GetBribeCount(faction) + " = " + cost);
                int silver = TradeUtility.AllLaunchableThings(map).Where(t => t.def == ThingDefOf.Silver).Sum(t => t.stackCount);

                if (silver < cost)
                {
                    var diaOption = new DiaOption("OfferGift".Translate());
                    diaOption.Disable("NeedSilverLaunchable".Translate(cost));
                    __result = diaOption;
                    return(false);
                }
                float goodwillDelta = 12f * negotiator.GetStatValue(StatDefOf.GiftImpact);
                var   diaOption2    = new DiaOption("OfferGift".Translate() + " (" + "SilverForGoodwill".Translate(cost, goodwillDelta.ToString("#####0")) + ")");

                diaOption2.action = delegate {
                    TradeUtility.LaunchThingsOfType(ThingDefOf.Silver, cost, map, null);
                    faction.AffectGoodwillWith(Faction.OfPlayer, goodwillDelta);
                    Hospitality_MapComponent.Instance(map).Bribe(faction);
                };
                string text = "SilverGiftSent".Translate(faction.leader.LabelIndefinite(), Mathf.RoundToInt(goodwillDelta)).CapitalizeFirst();

                diaOption2.link = new DiaNode(text)
                {
                    options =
                    {
                        new DiaOption("OK".Translate())
                        {
                            linkLateBind = () => FactionDialogMaker.FactionDialogFor(negotiator, faction)
                        }
                    }
                };
                __result = diaOption2;
                return(false);
            }
Example #4
0
 private static int AmountSendableSilver(Map map)
 {
     return((from t in TradeUtility.AllLaunchableThings(map)
             where t.def == ThingDefOf.Silver
             select t).Sum((Thing t) => t.stackCount));
 }
Example #5
0
 public bool PlayerHasExtortionAmount()
 {
     return(TradeUtility.AllLaunchableThings(this.rootMap).Where(t => t.def == ThingDefOf.Silver).Sum(s => s.stackCount) >= this.currentExtortionAmount);
 }