Пример #1
0
        public static void GiveGift(List <ActiveDropPodInfo> pods, SettlementBase giveTo)
        {
            int goodwillChange = FactionGiftUtility.GetGoodwillChange(pods.Cast <IThingHolder>(), giveTo);

            for (int i = 0; i < pods.Count; i++)
            {
                ThingOwner innerContainer = pods[i].innerContainer;
                for (int j = innerContainer.Count - 1; j >= 0; j--)
                {
                    FactionGiftUtility.GiveGiftInternal(innerContainer[j], innerContainer[j].stackCount, giveTo.Faction);
                    if (j < innerContainer.Count)
                    {
                        innerContainer.RemoveAt(j);
                    }
                }
            }
            Faction          faction         = giveTo.Faction;
            Faction          ofPlayer        = Faction.OfPlayer;
            int              goodwillChange2 = goodwillChange;
            string           reason          = "GoodwillChangedReason_ReceivedGift".Translate();
            GlobalTargetInfo?lookTarget      = new GlobalTargetInfo?(giveTo);

            if (!faction.TryAffectGoodwillWith(ofPlayer, goodwillChange2, true, true, reason, lookTarget))
            {
                FactionGiftUtility.SendGiftNotAppreciatedMessage(giveTo.Faction, giveTo);
            }
        }
Пример #2
0
 public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(CompLaunchable representative, IEnumerable <IThingHolder> pods, SettlementBase settlement)
 {
     return(TransportPodsArrivalActionUtility.GetFloatMenuOptions <TransportPodsArrivalAction_GiveGift>(() => TransportPodsArrivalAction_GiveGift.CanGiveGiftTo(pods, settlement), () => new TransportPodsArrivalAction_GiveGift(settlement), "GiveGiftViaTransportPods".Translate(new object[]
     {
         settlement.Faction.Name,
         FactionGiftUtility.GetGoodwillChange(pods, settlement).ToStringWithSign()
     }), representative, settlement.Tile));
 }
Пример #3
0
        public static int GetGoodwillChange(List <Tradeable> tradeables, Faction theirFaction)
        {
            float num = 0f;

            for (int i = 0; i < tradeables.Count; i++)
            {
                if (tradeables[i].ActionToDo == TradeAction.PlayerSells)
                {
                    int count = Mathf.Min(tradeables[i].CountToTransferToDestination, tradeables[i].CountHeldBy(Transactor.Colony));
                    num += FactionGiftUtility.GetGoodwillChange(tradeables[i].AnyThing, count, tradeables[i].GetPriceFor(TradeAction.PlayerSells), theirFaction);
                }
            }
            return((int)num);
        }
Пример #4
0
        public static int GetGoodwillChange(IEnumerable <IThingHolder> pods, SettlementBase giveTo)
        {
            float num = 0f;

            foreach (IThingHolder thingHolder in pods)
            {
                ThingOwner directlyHeldThings = thingHolder.GetDirectlyHeldThings();
                for (int i = 0; i < directlyHeldThings.Count; i++)
                {
                    float priceFactorSell_TraderPriceType      = (giveTo.TraderKind == null) ? 1f : giveTo.TraderKind.PriceTypeFor(directlyHeldThings[i].def, TradeAction.PlayerSells).PriceMultiplier();
                    float tradePriceImprovementOffsetForPlayer = giveTo.TradePriceImprovementOffsetForPlayer;
                    float pricePlayerSell = TradeUtility.GetPricePlayerSell(directlyHeldThings[i], priceFactorSell_TraderPriceType, 1f, tradePriceImprovementOffsetForPlayer);
                    num += FactionGiftUtility.GetGoodwillChange(directlyHeldThings[i], directlyHeldThings[i].stackCount, pricePlayerSell, giveTo.Faction);
                }
            }
            return((int)num);
        }
Пример #5
0
        public static void GiveGift(List <Tradeable> tradeables, Faction giveTo, GlobalTargetInfo lookTarget)
        {
            int goodwillChange = FactionGiftUtility.GetGoodwillChange(tradeables, giveTo);

            for (int i = 0; i < tradeables.Count; i++)
            {
                if (tradeables[i].ActionToDo == TradeAction.PlayerSells)
                {
                    tradeables[i].ResolveTrade();
                }
            }
            Faction          ofPlayer        = Faction.OfPlayer;
            int              goodwillChange2 = goodwillChange;
            string           reason          = "GoodwillChangedReason_ReceivedGift".Translate();
            GlobalTargetInfo?lookTarget2     = new GlobalTargetInfo?(lookTarget);

            if (!giveTo.TryAffectGoodwillWith(ofPlayer, goodwillChange2, true, true, reason, lookTarget2))
            {
                FactionGiftUtility.SendGiftNotAppreciatedMessage(giveTo, lookTarget);
            }
        }
 public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(CompLaunchable representative, IEnumerable <IThingHolder> pods, SettlementBase settlement)
 {
     if (settlement.Faction == Faction.OfPlayer)
     {
         return(Enumerable.Empty <FloatMenuOption>());
     }
     return(TransportPodsArrivalActionUtility.GetFloatMenuOptions(() => CanGiveGiftTo(pods, settlement), () => new TransportPodsArrivalAction_GiveGift(settlement), "GiveGiftViaTransportPods".Translate(settlement.Faction.Name, FactionGiftUtility.GetGoodwillChange(pods, settlement).ToStringWithSign()), representative, settlement.Tile));
 }
 public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(CompLaunchable representative, IEnumerable <IThingHolder> pods, Settlement settlement)
 {
     if (settlement.Faction == Faction.OfPlayer)
     {
         return(Enumerable.Empty <FloatMenuOption>());
     }
     return(TransportPodsArrivalActionUtility.GetFloatMenuOptions(() => CanGiveGiftTo(pods, settlement), () => new TransportPodsArrivalAction_GiveGift(settlement), "GiveGiftViaTransportPods".Translate(settlement.Faction.Name, FactionGiftUtility.GetGoodwillChange(pods, settlement).ToStringWithSign()), representative, settlement.Tile, delegate(Action action)
     {
         TradeRequestComp tradeReqComp = settlement.GetComponent <TradeRequestComp>();
         if (tradeReqComp.ActiveRequest && pods.Any((IThingHolder p) => p.GetDirectlyHeldThings().Contains(tradeReqComp.requestThingDef)))
         {
             Find.WindowStack.Add(new Dialog_MessageBox("GiveGiftViaTransportPodsTradeRequestWarning".Translate(), "Yes".Translate(), delegate
             {
                 action();
             }, "No".Translate()));
         }
         else
         {
             action();
         }
     }));
 }
Пример #8
0
 public override IEnumerable <FloatMenuOption> GetShuttleFloatMenuOptions(IEnumerable <IThingHolder> pods, Action <int, TransportPodsArrivalAction> launchAction)
 {
     foreach (FloatMenuOption shuttleFloatMenuOption in base.GetShuttleFloatMenuOptions(pods, launchAction))
     {
         yield return(shuttleFloatMenuOption);
     }
     if ((bool)TransportPodsArrivalAction_GiveGift.CanGiveGiftTo(pods, this))
     {
         yield return(new FloatMenuOption("GiveGiftViaTransportPods".Translate(base.Faction.Name, FactionGiftUtility.GetGoodwillChange(pods, this).ToStringWithSign()), delegate
         {
             TradeRequestComp tradeReqComp = GetComponent <TradeRequestComp>();
             if (tradeReqComp.ActiveRequest && pods.Any((IThingHolder p) => p.GetDirectlyHeldThings().Contains(tradeReqComp.requestThingDef)))
             {
                 Find.WindowStack.Add(new Dialog_MessageBox("GiveGiftViaTransportPodsTradeRequestWarning".Translate(), "Yes".Translate(), delegate
                 {
                     launchAction(base.Tile, new TransportPodsArrivalAction_GiveGift(this));
                 }, "No".Translate()));
             }
             else
             {
                 launchAction(base.Tile, new TransportPodsArrivalAction_GiveGift(this));
             }
         }));
     }
     if (base.HasMap)
     {
         yield break;
     }
     foreach (FloatMenuOption floatMenuOption in TransportPodsArrivalActionUtility.GetFloatMenuOptions(() => TransportPodsArrivalAction_AttackSettlement.CanAttack(pods, this), () => new TransportPodsArrivalAction_Shuttle(this), "AttackShuttle".Translate(Label), launchAction, base.Tile))
     {
         yield return(floatMenuOption);
     }
 }