コード例 #1
0
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map;

            if (!this.TryGetRandomAvailableTargetMap(out map))
            {
                return(false);
            }
            SettlementBase settlementBase = IncidentWorker_QuestTradeRequest.RandomNearbyTradeableSettlement(map.Tile);

            if (settlementBase == null)
            {
                return(false);
            }
            TradeRequestComp component = settlementBase.GetComponent <TradeRequestComp>();

            if (!this.TryGenerateTradeRequest(component, map))
            {
                return(false);
            }
            string text = "LetterCaravanRequest".Translate(new object[]
            {
                settlementBase.Label,
                TradeRequestUtility.RequestedThingLabel(component.requestThingDef, component.requestCount).CapitalizeFirst(),
                (component.requestThingDef.GetStatValueAbstract(StatDefOf.MarketValue, null) * (float)component.requestCount).ToStringMoney("F0"),
                GenThing.ThingsToCommaList(component.rewards, true, true, -1).CapitalizeFirst(),
                GenThing.GetMarketValue(component.rewards).ToStringMoney("F0"),
                (component.expiration - Find.TickManager.TicksGame).ToStringTicksToDays("F0"),
                CaravanArrivalTimeEstimator.EstimatedTicksToArrive(map.Tile, settlementBase.Tile, null).ToStringTicksToDays("0.#")
            });

            GenThing.TryAppendSingleRewardInfo(ref text, component.rewards);
            Find.LetterStack.ReceiveLetter("LetterLabelCaravanRequest".Translate(), text, LetterDefOf.PositiveEvent, settlementBase, settlementBase.Faction, null);
            return(true);
        }
コード例 #2
0
        public override string CompInspectStringExtra()
        {
            string res =
                tradeShip.def.LabelCap + "\n" +
                "TraderShipsLeavingIn".Translate(GenDate.ToStringTicksToPeriod(tradeShip.ticksUntilDeparture));

            if (tradeRequest != null)
            {
                res += "\n" + "TraderShipsQuestRequestInfo".Translate(TradeRequestUtility.RequestedThingLabel(tradeRequest.requestedThingDef, tradeRequest.requestedCount).CapitalizeFirst(), (tradeRequest.requestedThingDef.GetStatValueAbstract(StatDefOf.MarketValue, null) * (float)tradeRequest.requestedCount).ToStringMoney(null));
            }

            return(res);
        }
コード例 #3
0
        public override IEnumerable <Gizmo> CompGetGizmosExtra()
        {
            yield return(new Command_Action
            {
                defaultLabel = "TraderShipsSendAway".Translate(),
                defaultDesc = "TraderShipsSendAwayDesc".Translate(),
                action = new Action(SendAway),
                icon = SendAwayTexture,
            });

            if (tradeRequest != null)
            {
                Command_Action command_Action = new Command_Action();
                command_Action.defaultLabel = "CommandFulfillTradeOffer".Translate();
                command_Action.defaultDesc  = "CommandFulfillTradeOfferDesc".Translate();
                command_Action.icon         = TradeCommandTex;
                command_Action.action       = delegate()
                {
                    if (tradeRequest == null)
                    {
                        Log.Error("Attempted to fulfill an unavailable request", false);
                        return;
                    }

                    WindowStack  windowStack = Find.WindowStack;
                    TaggedString text        = "CommandFulfillTradeOfferConfirm".Translate(GenLabel.ThingLabel(tradeRequest.requestedThingDef, null, tradeRequest.requestedCount));

                    windowStack.Add(Dialog_MessageBox.CreateConfirmation(text, delegate() { FulfillTradeRequest(); }, false, null));
                };

                if (!tradeRequest.CanFulfillRequest(tradeShip))
                {
                    command_Action.Disable("CommandFulfillTradeOfferFailInsufficient".Translate(TradeRequestUtility.RequestedThingLabel(tradeRequest.requestedThingDef, tradeRequest.requestedCount)));
                }

                yield return(command_Action);
            }

            if (Prefs.DevMode)
            {
                yield return(new Command_Action
                {
                    defaultLabel = "Dev: randomize sprite",
                    action = delegate()
                    {
                        Color color = sprite.color;
                        sprite = Props.shipgen.CreateSprite();
                        sprite.color = color;
                        sprite.FinishCreating();
                    },
                });

                yield return(new Command_Action
                {
                    defaultLabel = "Dev: randomize color",
                    action = delegate()
                    {
                        sprite.color = ShipSprite.RandomColor();
                        sprite.FinishCreating();
                    },
                });
            }

            yield break;
        }