예제 #1
0
 public override IEnumerable <Gizmo> GetCaravanGizmos(Caravan caravan)
 {
     if (this.CanTradeNow && CaravanVisitUtility.SettlementVisitedNow(caravan) == this)
     {
         yield return(CaravanVisitUtility.TradeCommand(caravan));
     }
     if (CaravanArrivalAction_OfferGifts.CanOfferGiftsTo(caravan, this))
     {
         yield return(FactionGiftUtility.OfferGiftsCommand(caravan, this));
     }
     foreach (Gizmo g in base.GetCaravanGizmos(caravan))
     {
         yield return(g);
     }
     if (this.Attackable)
     {
         yield return(new Command_Action
         {
             icon = SettlementBase.AttackCommand,
             defaultLabel = "CommandAttackSettlement".Translate(),
             defaultDesc = "CommandAttackSettlementDesc".Translate(),
             action = delegate
             {
                 SettlementUtility.Attack(caravan, this.$this);
             }
         });
     }
 }
예제 #2
0
        public static Command TradeCommand(Caravan caravan)
        {
            Pawn           bestNegotiator = BestCaravanPawnUtility.FindBestNegotiator(caravan);
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandTrade".Translate();
            command_Action.defaultDesc  = "CommandTradeDesc".Translate();
            command_Action.icon         = CaravanVisitUtility.TradeCommandTex;
            command_Action.action       = delegate
            {
                Settlement settlement = CaravanVisitUtility.SettlementVisitedNow(caravan);
                if (settlement != null && settlement.CanTradeNow)
                {
                    Find.WindowStack.Add(new Dialog_Trade(bestNegotiator, settlement));
                    string empty  = string.Empty;
                    string empty2 = string.Empty;
                    PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(settlement.Goods.OfType <Pawn>(), ref empty, ref empty2, "LetterRelatedPawnsTradingWithSettlement".Translate(), false, true);
                    if (!empty2.NullOrEmpty())
                    {
                        Find.LetterStack.ReceiveLetter(empty, empty2, LetterDefOf.NeutralEvent, settlement, null);
                    }
                }
            };
            if (bestNegotiator == null)
            {
                command_Action.Disable("CommandTradeFailNoNegotiator".Translate());
            }
            if (bestNegotiator != null && bestNegotiator.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)
            {
                command_Action.Disable("CommandTradeFailSocialDisabled".Translate());
            }
            return(command_Action);
        }
 public override IEnumerable <Gizmo> GetCaravanGizmos(Caravan caravan)
 {
     if (ActiveRequest && CaravanVisitUtility.SettlementVisitedNow(caravan) == parent)
     {
         yield return(FulfillRequestCommand(caravan));
     }
 }
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    if (base.ActiveRequest && CaravanVisitUtility.SettlementVisitedNow(caravan) == this.parent)
                    {
                        this.$current = base.FulfillRequestCommand(caravan);
                        if (!this.$disposing)
                        {
                            this.$PC = 1;
                        }
                        return(true);
                    }
                    break;

                case 1u:
                    break;

                default:
                    return(false);
                }
                this.$PC = -1;
                return(false);
            }
예제 #5
0
 public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan)
 {
     foreach (FloatMenuOption floatMenuOption in base.GetFloatMenuOptions(caravan))
     {
         yield return(floatMenuOption);
     }
     if (CaravanVisitUtility.SettlementVisitedNow(caravan) != this)
     {
         foreach (FloatMenuOption floatMenuOption2 in CaravanArrivalAction_VisitSettlement.GetFloatMenuOptions(caravan, this))
         {
             yield return(floatMenuOption2);
         }
     }
     foreach (FloatMenuOption floatMenuOption3 in CaravanArrivalAction_Trade.GetFloatMenuOptions(caravan, this))
     {
         yield return(floatMenuOption3);
     }
     foreach (FloatMenuOption floatMenuOption4 in CaravanArrivalAction_OfferGifts.GetFloatMenuOptions(caravan, this))
     {
         yield return(floatMenuOption4);
     }
     foreach (FloatMenuOption floatMenuOption5 in CaravanArrivalAction_AttackSettlement.GetFloatMenuOptions(caravan, this))
     {
         yield return(floatMenuOption5);
     }
 }
        public static Command TradeCommand(Caravan caravan)
        {
            Pawn           bestNegotiator = BestCaravanPawnUtility.FindBestNegotiator(caravan);
            Command_Action command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandTrade".Translate();
            command_Action.defaultDesc  = "CommandTradeDesc".Translate();
            command_Action.icon         = CaravanVisitUtility.TradeCommandTex;
            command_Action.action       = delegate
            {
                SettlementBase settlementBase = CaravanVisitUtility.SettlementVisitedNow(caravan);
                if (settlementBase != null && settlementBase.CanTradeNow)
                {
                    Find.WindowStack.Add(new Dialog_Trade(bestNegotiator, settlementBase, false));
                    PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(settlementBase.Goods.OfType <Pawn>(), "LetterRelatedPawnsTradingWithSettlement".Translate(Faction.OfPlayer.def.pawnsPlural), LetterDefOf.NeutralEvent, false, true);
                }
            };
            if (bestNegotiator == null)
            {
                command_Action.Disable("CommandTradeFailNoNegotiator".Translate());
            }
            if (bestNegotiator != null && bestNegotiator.skills.GetSkill(SkillDefOf.Social).TotallyDisabled)
            {
                command_Action.Disable("CommandTradeFailSocialDisabled".Translate());
            }
            return(command_Action);
        }
예제 #7
0
 public override IEnumerable <Gizmo> GetCaravanGizmos(Caravan caravan)
 {
     if (CanTradeNow && CaravanVisitUtility.SettlementVisitedNow(caravan) == this)
     {
         yield return(CaravanVisitUtility.TradeCommand(caravan, base.Faction, TraderKind));
     }
     if ((bool)CaravanArrivalAction_OfferGifts.CanOfferGiftsTo(caravan, this))
     {
         yield return(FactionGiftUtility.OfferGiftsCommand(caravan, this));
     }
     foreach (Gizmo caravanGizmo in base.GetCaravanGizmos(caravan))
     {
         yield return(caravanGizmo);
     }
     if (Attackable)
     {
         Command_Action command_Action = new Command_Action();
         command_Action.icon         = AttackCommand;
         command_Action.defaultLabel = "CommandAttackSettlement".Translate();
         command_Action.defaultDesc  = "CommandAttackSettlementDesc".Translate();
         command_Action.action       = delegate
         {
             SettlementUtility.Attack(caravan, this);
         };
         yield return(command_Action);
     }
 }
예제 #8
0
        public override IEnumerable <Gizmo> GetCaravanGizmos(Caravan caravan)
        {
            if (ActiveRequest && CaravanVisitUtility.SettlementVisitedNow(caravan) == parent)
            {
                yield return((Gizmo)FulfillRequestCommand(caravan));

                /*Error: Unable to find new state assignment for yield return*/;
            }
        }
예제 #9
0
 public override IEnumerable <Gizmo> GetCaravanGizmos(Caravan caravan)
 {
     if (this.CanTradeNow)
     {
         yield return(CaravanVisitUtility.TradeCommand(caravan));
     }
     if (base.GetComponent <CaravanRequestComp>() != null && base.GetComponent <CaravanRequestComp>().ActiveRequest)
     {
         yield return(CaravanVisitUtility.FulfillRequestCommand(caravan));
     }
 }
예제 #10
0
        public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan)
        {
            foreach (FloatMenuOption o in base.GetFloatMenuOptions(caravan))
            {
                yield return(o);
            }
            if (this.Visitable && CaravanVisitUtility.SettlementVisitedNow(caravan) != this)
            {
                yield return(new FloatMenuOption("VisitSettlement".Translate(new object[]
                {
                    this.Label
                }), delegate
                {
                    caravan.pather.StartPath(this.$this.Tile, new CaravanArrivalAction_VisitSettlement(this.$this), true);
                }, MenuOptionPriority.Default, null, null, 0f, null, this));

                if (Prefs.DevMode)
                {
                    yield return(new FloatMenuOption("VisitSettlement".Translate(new object[]
                    {
                        this.Label
                    }) + " (Dev: instantly)", delegate
                    {
                        caravan.Tile = this.$this.Tile;
                        caravan.pather.StopDead();
                        new CaravanArrivalAction_VisitSettlement(this.$this).Arrived(caravan);
                    }, MenuOptionPriority.Default, null, null, 0f, null, this));
                }
            }
            if (this.Attackable)
            {
                yield return(new FloatMenuOption("AttackSettlement".Translate(new object[]
                {
                    this.Label
                }), delegate
                {
                    caravan.pather.StartPath(this.$this.Tile, new CaravanArrivalAction_AttackSettlement(this.$this), true);
                }, MenuOptionPriority.Default, null, null, 0f, null, this));

                if (Prefs.DevMode)
                {
                    yield return(new FloatMenuOption("AttackSettlement".Translate(new object[]
                    {
                        this.Label
                    }) + " (Dev: instantly)", delegate
                    {
                        caravan.Tile = this.$this.Tile;
                        new CaravanArrivalAction_AttackSettlement(this.$this).Arrived(caravan);
                    }, MenuOptionPriority.Default, null, null, 0f, null, this));
                }
            }
        }
예제 #11
0
            internal void <> m__0()
            {
                SettlementBase settlementBase = CaravanVisitUtility.SettlementVisitedNow(this.caravan);

                if (settlementBase != null && settlementBase.CanTradeNow)
                {
                    Find.WindowStack.Add(new Dialog_Trade(this.bestNegotiator, settlementBase, false));
                    PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter_Send(settlementBase.Goods.OfType <Pawn>(), "LetterRelatedPawnsTradingWithSettlement".Translate(new object[]
                    {
                        Faction.OfPlayer.def.pawnsPlural
                    }), LetterDefOf.NeutralEvent, false, true);
                }
            }
예제 #12
0
        public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan)
        {
            using (IEnumerator <FloatMenuOption> enumerator = base.GetFloatMenuOptions(caravan).GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    FloatMenuOption o = enumerator.Current;
                    yield return(o);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            if (CaravanVisitUtility.SettlementVisitedNow(caravan) != this)
            {
                using (IEnumerator <FloatMenuOption> enumerator2 = CaravanArrivalAction_VisitSettlement.GetFloatMenuOptions(caravan, this).GetEnumerator())
                {
                    if (enumerator2.MoveNext())
                    {
                        FloatMenuOption f3 = enumerator2.Current;
                        yield return(f3);

                        /*Error: Unable to find new state assignment for yield return*/;
                    }
                }
            }
            using (IEnumerator <FloatMenuOption> enumerator3 = CaravanArrivalAction_OfferGifts.GetFloatMenuOptions(caravan, this).GetEnumerator())
            {
                if (enumerator3.MoveNext())
                {
                    FloatMenuOption f2 = enumerator3.Current;
                    yield return(f2);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            using (IEnumerator <FloatMenuOption> enumerator4 = CaravanArrivalAction_AttackSettlement.GetFloatMenuOptions(caravan, this).GetEnumerator())
            {
                if (enumerator4.MoveNext())
                {
                    FloatMenuOption f = enumerator4.Current;
                    yield return(f);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            yield break;
IL_029a:
            /*Error near IL_029b: Unexpected return in MoveNext()*/;
        }
예제 #13
0
        public override IEnumerable <Gizmo> GetCaravanGizmos(Caravan caravan)
        {
            _003CGetCaravanGizmos_003Ec__Iterator1 _003CGetCaravanGizmos_003Ec__Iterator = (_003CGetCaravanGizmos_003Ec__Iterator1) /*Error near IL_0040: stateMachine*/;

            if (CanTradeNow && CaravanVisitUtility.SettlementVisitedNow(caravan) == this)
            {
                yield return((Gizmo)CaravanVisitUtility.TradeCommand(caravan));

                /*Error: Unable to find new state assignment for yield return*/;
            }
            if ((bool)CaravanArrivalAction_OfferGifts.CanOfferGiftsTo(caravan, this))
            {
                yield return((Gizmo)FactionGiftUtility.OfferGiftsCommand(caravan, this));

                /*Error: Unable to find new state assignment for yield return*/;
            }
            using (IEnumerator <Gizmo> enumerator = base.GetCaravanGizmos(caravan).GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    Gizmo g = enumerator.Current;
                    yield return(g);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            if (Attackable)
            {
                yield return((Gizmo) new Command_Action
                {
                    icon = AttackCommand,
                    defaultLabel = "CommandAttackSettlement".Translate(),
                    defaultDesc = "CommandAttackSettlementDesc".Translate(),
                    action = delegate
                    {
                        SettlementUtility.Attack(caravan, _003CGetCaravanGizmos_003Ec__Iterator._0024this);
                    }
                });

                /*Error: Unable to find new state assignment for yield return*/;
            }
            yield break;
IL_022e:
            /*Error near IL_022f: Unexpected return in MoveNext()*/;
        }
예제 #14
0
        public override IEnumerable <Gizmo> GetCaravanGizmos(Caravan caravan)
        {
            if (this.CanTradeNow)
            {
                yield return((Gizmo)CaravanVisitUtility.TradeCommand(caravan));

                /*Error: Unable to find new state assignment for yield return*/;
            }
            if (base.GetComponent <CaravanRequestComp>() == null)
            {
                yield break;
            }
            if (!base.GetComponent <CaravanRequestComp>().ActiveRequest)
            {
                yield break;
            }
            yield return((Gizmo)CaravanVisitUtility.FulfillRequestCommand(caravan));

            /*Error: Unable to find new state assignment for yield return*/;
        }
예제 #15
0
 public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan)
 {
     foreach (FloatMenuOption o in this.< GetFloatMenuOptions > __BaseCallProxy2(caravan))
     {
         yield return(o);
     }
     if (CaravanVisitUtility.SettlementVisitedNow(caravan) != this)
     {
         foreach (FloatMenuOption f in CaravanArrivalAction_VisitSettlement.GetFloatMenuOptions(caravan, this))
         {
             yield return(f);
         }
     }
     foreach (FloatMenuOption f2 in CaravanArrivalAction_OfferGifts.GetFloatMenuOptions(caravan, this))
     {
         yield return(f2);
     }
     foreach (FloatMenuOption f3 in CaravanArrivalAction_AttackSettlement.GetFloatMenuOptions(caravan, this))
     {
         yield return(f3);
     }
     yield break;
 }
예제 #16
0
        public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan)
        {
            _003CGetFloatMenuOptions_003Ec__Iterator2 _003CGetFloatMenuOptions_003Ec__Iterator = (_003CGetFloatMenuOptions_003Ec__Iterator2) /*Error near IL_0044: stateMachine*/;

            using (IEnumerator <FloatMenuOption> enumerator = this._003CGetFloatMenuOptions_003E__BaseCallProxy1(caravan).GetEnumerator())
            {
                if (enumerator.MoveNext())
                {
                    FloatMenuOption o = enumerator.Current;
                    yield return(o);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            if (this.Visitable && CaravanVisitUtility.SettlementVisitedNow(caravan) != this)
            {
                yield return(new FloatMenuOption("VisitSettlement".Translate(this.Label), delegate
                {
                    caravan.pather.StartPath(_003CGetFloatMenuOptions_003Ec__Iterator._0024this.Tile, new CaravanArrivalAction_VisitSettlement(_003CGetFloatMenuOptions_003Ec__Iterator._0024this), true);
                }, MenuOptionPriority.Default, null, null, 0f, null, this));

                /*Error: Unable to find new state assignment for yield return*/;
            }
            if (!this.Attackable)
            {
                yield break;
            }
            yield return(new FloatMenuOption("AttackSettlement".Translate(this.Label), delegate
            {
                caravan.pather.StartPath(_003CGetFloatMenuOptions_003Ec__Iterator._0024this.Tile, new CaravanArrivalAction_AttackSettlement(_003CGetFloatMenuOptions_003Ec__Iterator._0024this), true);
            }, MenuOptionPriority.Default, null, null, 0f, null, this));

            /*Error: Unable to find new state assignment for yield return*/;
IL_02d3:
            /*Error near IL_02d4: Unexpected return in MoveNext()*/;
        }
예제 #17
0
파일: Caravan.cs 프로젝트: potsh/RimWorld
        public override string GetInspectString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(base.GetInspectString());
            if (stringBuilder.Length != 0)
            {
                stringBuilder.AppendLine();
            }
            int num  = 0;
            int num2 = 0;
            int num3 = 0;
            int num4 = 0;
            int num5 = 0;

            for (int i = 0; i < pawns.Count; i++)
            {
                if (pawns[i].IsColonist)
                {
                    num++;
                }
                else if (pawns[i].RaceProps.Animal)
                {
                    num2++;
                }
                else if (pawns[i].IsPrisoner)
                {
                    num3++;
                }
                if (pawns[i].Downed)
                {
                    num4++;
                }
                if (pawns[i].InMentalState)
                {
                    num5++;
                }
            }
            stringBuilder.Append("CaravanColonistsCount".Translate(num, (num != 1) ? Faction.OfPlayer.def.pawnsPlural : Faction.OfPlayer.def.pawnSingular));
            if (num2 == 1)
            {
                stringBuilder.Append(", " + "CaravanAnimal".Translate());
            }
            else if (num2 > 1)
            {
                stringBuilder.Append(", " + "CaravanAnimalsCount".Translate(num2));
            }
            if (num3 == 1)
            {
                stringBuilder.Append(", " + "CaravanPrisoner".Translate());
            }
            else if (num3 > 1)
            {
                stringBuilder.Append(", " + "CaravanPrisonersCount".Translate(num3));
            }
            stringBuilder.AppendLine();
            if (num5 > 0)
            {
                stringBuilder.Append("CaravanPawnsInMentalState".Translate(num5));
            }
            if (num4 > 0)
            {
                if (num5 > 0)
                {
                    stringBuilder.Append(", ");
                }
                stringBuilder.Append("CaravanPawnsDowned".Translate(num4));
            }
            if (num5 > 0 || num4 > 0)
            {
                stringBuilder.AppendLine();
            }
            if (pather.Moving)
            {
                if (pather.ArrivalAction != null)
                {
                    stringBuilder.Append(pather.ArrivalAction.ReportString);
                }
                else
                {
                    stringBuilder.Append("CaravanTraveling".Translate());
                }
            }
            else
            {
                SettlementBase settlementBase = CaravanVisitUtility.SettlementVisitedNow(this);
                if (settlementBase != null)
                {
                    stringBuilder.Append("CaravanVisiting".Translate(settlementBase.Label));
                }
                else
                {
                    stringBuilder.Append("CaravanWaiting".Translate());
                }
            }
            if (pather.Moving)
            {
                float num6 = (float)CaravanArrivalTimeEstimator.EstimatedTicksToArrive(this, allowCaching: true) / 60000f;
                stringBuilder.AppendLine();
                stringBuilder.Append("CaravanEstimatedTimeToDestination".Translate(num6.ToString("0.#")));
            }
            if (AllOwnersDowned)
            {
                stringBuilder.AppendLine();
                stringBuilder.Append("AllCaravanMembersDowned".Translate());
            }
            else if (AllOwnersHaveMentalBreak)
            {
                stringBuilder.AppendLine();
                stringBuilder.Append("AllCaravanMembersMentalBreak".Translate());
            }
            else if (ImmobilizedByMass)
            {
                stringBuilder.AppendLine();
                stringBuilder.Append("CaravanImmobilizedByMass".Translate());
            }
            if (needs.AnyPawnOutOfFood(out string malnutritionHediff))
            {
                stringBuilder.AppendLine();
                stringBuilder.Append("CaravanOutOfFood".Translate());
                if (!malnutritionHediff.NullOrEmpty())
                {
                    stringBuilder.Append(" ");
                    stringBuilder.Append(malnutritionHediff);
                    stringBuilder.Append(".");
                }
            }
            if (!pather.MovingNow)
            {
                int usedBedCount = beds.GetUsedBedCount();
                stringBuilder.AppendLine();
                stringBuilder.Append(CaravanBedUtility.AppendUsingBedsLabel("CaravanResting".Translate(), usedBedCount));
            }
            else
            {
                string inspectStringLine = carryTracker.GetInspectStringLine();
                if (!inspectStringLine.NullOrEmpty())
                {
                    stringBuilder.AppendLine();
                    stringBuilder.Append(inspectStringLine);
                }
                string inBedForMedicalReasonsInspectStringLine = beds.GetInBedForMedicalReasonsInspectStringLine();
                if (!inBedForMedicalReasonsInspectStringLine.NullOrEmpty())
                {
                    stringBuilder.AppendLine();
                    stringBuilder.Append(inBedForMedicalReasonsInspectStringLine);
                }
            }
            return(stringBuilder.ToString());
        }
예제 #18
0
        public static Command FulfillRequestCommand(Caravan caravan)
        {
            Func <Thing, bool> validator      = (Thing thing) => thing.GetRotStage() == RotStage.Fresh;
            Command_Action     command_Action = new Command_Action();

            command_Action.defaultLabel = "CommandFulfillTradeOffer".Translate();
            command_Action.defaultDesc  = "CommandFulfillTradeOfferDesc".Translate();
            command_Action.icon         = CaravanVisitUtility.TradeCommandTex;
            command_Action.action       = delegate
            {
                Settlement         settlement2    = CaravanVisitUtility.SettlementVisitedNow(caravan);
                CaravanRequestComp caravanRequest = (settlement2 == null) ? null : settlement2.GetComponent <CaravanRequestComp>();
                if (caravanRequest != null)
                {
                    if (!caravanRequest.ActiveRequest)
                    {
                        Log.Error("Attempted to fulfill an unavailable request");
                        return;
                    }
                    if (!CaravanInventoryUtility.HasThings(caravan, caravanRequest.requestThingDef, caravanRequest.requestCount, validator))
                    {
                        Messages.Message("CommandFulfillTradeOfferFailInsufficient".Translate(new object[]
                        {
                            GenLabel.ThingLabel(caravanRequest.requestThingDef, null, caravanRequest.requestCount)
                        }), MessageTypeDefOf.RejectInput);
                        return;
                    }
                    Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("CommandFulfillTradeOfferConfirm".Translate(new object[]
                    {
                        GenLabel.ThingLabel(caravanRequest.requestThingDef, null, caravanRequest.requestCount),
                        caravanRequest.rewards[0].Label
                    }), delegate
                    {
                        int remaining     = caravanRequest.requestCount;
                        List <Thing> list = CaravanInventoryUtility.TakeThings(caravan, delegate(Thing thing)
                        {
                            if (caravanRequest.requestThingDef != thing.def)
                            {
                                return(0);
                            }
                            int num    = Mathf.Min(remaining, thing.stackCount);
                            remaining -= num;
                            return(num);
                        });
                        for (int i = 0; i < list.Count; i++)
                        {
                            list[i].Destroy(DestroyMode.Vanish);
                        }
                        while (caravanRequest.rewards.Count > 0)
                        {
                            Thing thing2 = caravanRequest.rewards[caravanRequest.rewards.Count - 1];
                            caravanRequest.rewards.Remove(thing2);
                            CaravanInventoryUtility.GiveThing(caravan, thing2);
                        }
                        caravanRequest.Disable();
                    }, false, null));
                }
            };
            Settlement         settlement         = CaravanVisitUtility.SettlementVisitedNow(caravan);
            CaravanRequestComp caravanRequestComp = (settlement == null) ? null : settlement.GetComponent <CaravanRequestComp>();

            if (!CaravanInventoryUtility.HasThings(caravan, caravanRequestComp.requestThingDef, caravanRequestComp.requestCount, validator))
            {
                command_Action.Disable("CommandFulfillTradeOfferFailInsufficient".Translate(new object[]
                {
                    GenLabel.ThingLabel(caravanRequestComp.requestThingDef, null, caravanRequestComp.requestCount)
                }));
            }
            return(command_Action);
        }
예제 #19
0
        public override string GetInspectString()
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(base.GetInspectString());
            if (stringBuilder.Length != 0)
            {
                stringBuilder.AppendLine();
            }
            if (this.Resting)
            {
                stringBuilder.Append("CaravanResting".Translate());
            }
            else if (this.AnyPawnHasExtremeMentalBreak)
            {
                stringBuilder.Append("CaravanMemberMentalBreak".Translate(new object[]
                {
                    this.FirstPawnWithExtremeMentalBreak.LabelShort
                }));
            }
            else if (this.AllOwnersDowned)
            {
                stringBuilder.Append("AllCaravanMembersDowned".Translate());
            }
            else if (this.AllOwnersHaveMentalBreak)
            {
                stringBuilder.Append("AllCaravanMembersMentalBreak".Translate());
            }
            else if (this.pather.Moving)
            {
                if (this.pather.arrivalAction != null)
                {
                    stringBuilder.Append(this.pather.arrivalAction.ReportString);
                }
                else
                {
                    stringBuilder.Append("CaravanTraveling".Translate());
                }
            }
            else
            {
                Settlement settlement = CaravanVisitUtility.SettlementVisitedNow(this);
                if (settlement != null)
                {
                    stringBuilder.Append("CaravanVisiting".Translate(new object[]
                    {
                        settlement.Label
                    }));
                }
                else
                {
                    stringBuilder.Append("CaravanWaiting".Translate());
                }
            }
            if (this.pather.Moving)
            {
                float num = (float)CaravanArrivalTimeEstimator.EstimatedTicksToArrive(this, true) / 60000f;
                stringBuilder.AppendLine();
                stringBuilder.Append("CaravanEstimatedTimeToDestination".Translate(new object[]
                {
                    num.ToString("0.#")
                }));
            }
            if (this.ImmobilizedByMass)
            {
                stringBuilder.AppendLine();
                stringBuilder.Append("CaravanImmobilizedByMass".Translate());
            }
            string text;

            if (CaravanPawnsNeedsUtility.AnyPawnOutOfFood(this, out text))
            {
                stringBuilder.AppendLine();
                stringBuilder.Append("CaravanOutOfFood".Translate());
                if (!text.NullOrEmpty())
                {
                    stringBuilder.Append(" ");
                    stringBuilder.Append(text);
                    stringBuilder.Append(".");
                }
            }
            else if (this.DaysWorthOfFood.First < 1000f)
            {
                Pair <float, float> daysWorthOfFood = this.DaysWorthOfFood;
                stringBuilder.AppendLine();
                if (daysWorthOfFood.Second < 1000f)
                {
                    stringBuilder.Append("CaravanDaysOfFoodRot".Translate(new object[]
                    {
                        daysWorthOfFood.First.ToString("0.#"),
                        daysWorthOfFood.Second.ToString("0.#")
                    }));
                }
                else
                {
                    stringBuilder.Append("CaravanDaysOfFood".Translate(new object[]
                    {
                        daysWorthOfFood.First.ToString("0.#")
                    }));
                }
            }
            stringBuilder.AppendLine();
            stringBuilder.AppendLine(string.Concat(new string[]
            {
                "CaravanBaseMovementTime".Translate(),
                ": ",
                ((float)this.TicksPerMove / 2500f).ToString("0.##"),
                " ",
                "CaravanHoursPerTile".Translate()
            }));
            stringBuilder.AppendLine("CurrentTileMovementTime".Translate() + ": " + Caravan_PathFollower.CostToDisplay(this, base.Tile, this.pather.nextTile, -1f).ToStringTicksToPeriod(true, false, true));
            stringBuilder.Append("StealthFactor".Translate() + ": " + CaravanIncidentUtility.CalculateCaravanStealthFactor(this.PawnsListForReading.Count).ToString("F1"));
            return(stringBuilder.ToString());
        }