public override void InitFromValue(float rewardValue, RewardsGeneratorParams parms, out float valueActuallyUsed)
        {
            items.Clear();
            bool  flag = true;
            float x2   = (Find.TickManager.TicksGame - Find.History.lastPsylinkAvailable).TicksToDays();

            if (Rand.Chance(QuestTuning.DaysSincePsylinkAvailableToGuaranteedNeuroformerChance.Evaluate(x2)) && ModsConfig.RoyaltyActive && (parms.disallowedThingDefs == null || !parms.disallowedThingDefs.Contains(ThingDefOf.PsychicAmplifier)) && rewardValue >= 600f && parms.giverFaction != Faction.Empire)
            {
                items.Add(ThingMaker.MakeThing(ThingDefOf.PsychicAmplifier));
                rewardValue -= items[0].MarketValue;
                if (rewardValue < 100f)
                {
                    flag = false;
                }
            }
            if (flag)
            {
                FloatRange          value  = rewardValue * new FloatRange(0.7f, 1.3f);
                ThingSetMakerParams parms2 = default(ThingSetMakerParams);
                parms2.totalMarketValueRange = value;
                parms2.makingFaction         = parms.giverFaction;
                if (!parms.disallowedThingDefs.NullOrEmpty())
                {
                    parms2.validator = (ThingDef x) => !parms.disallowedThingDefs.Contains(x);
                }
                items.AddRange(ThingSetMakerDefOf.Reward_ItemsStandard.root.Generate(parms2));
            }
            valueActuallyUsed = TotalMarketValue;
        }
Esempio n. 2
0
 public override void InitFromValue(float rewardValue, RewardsGeneratorParams parms, out float valueActuallyUsed)
 {
     amount            = GenMath.RoundRandom(RewardsGenerator.RewardValueToRoyalFavorCurve.Evaluate(rewardValue));
     amount            = Mathf.Clamp(amount, 1, 12);
     valueActuallyUsed = RewardsGenerator.RewardValueToRoyalFavorCurve.EvaluateInverted(amount);
     faction           = parms.giverFaction;
 }
 public override string GetDescription(RewardsGeneratorParams parms)
 {
     if (parms.giveToCaravan)
     {
         return("Reward_Items_Caravan".Translate(GenLabel.ThingsLabel(items), TotalMarketValue.ToStringMoney()));
     }
     return("Reward_Items".Translate(GenLabel.ThingsLabel(items), TotalMarketValue.ToStringMoney()));
 }
Esempio n. 4
0
 public override string GetDescription(RewardsGeneratorParams parms)
 {
     if (!parms.chosenPawnSignal.NullOrEmpty())
     {
         return("Reward_RoyalFavor_ChoosePawn".Translate(faction, amount, Faction.OfPlayer.def.pawnsPlural).Resolve());
     }
     return("Reward_RoyalFavor".Translate(faction, amount).Resolve());
 }
Esempio n. 5
0
        public override IEnumerable <QuestPart> GenerateQuestParts(int index, RewardsGeneratorParams parms, string customLetterLabel, string customLetterText, RulePack customLetterLabelRules, RulePack customLetterTextRules)
        {
            QuestPart_FactionGoodwillChange questPart_FactionGoodwillChange = new QuestPart_FactionGoodwillChange();

            questPart_FactionGoodwillChange.change   = amount;
            questPart_FactionGoodwillChange.faction  = faction;
            questPart_FactionGoodwillChange.inSignal = RimWorld.QuestGen.QuestGen.slate.Get <string>("inSignal");
            yield return(questPart_FactionGoodwillChange);
        }
Esempio n. 6
0
 public static List <Reward> Generate(RewardsGeneratorParams parms, out float generatedRewardValue)
 {
     try
     {
         return(DoGenerate(parms, out generatedRewardValue));
     }
     finally
     {
     }
 }
Esempio n. 7
0
 public override string GetDescription(RewardsGeneratorParams parms)
 {
     if (parms.giveToCaravan)
     {
         return("Reward_Pawn_Caravan".Translate(pawn));
     }
     return(arrivalMode switch
     {
         ArrivalMode.WalkIn => "Reward_Pawn_WalkIn".Translate(pawn),
         ArrivalMode.DropPod => "Reward_Pawn_DropPod".Translate(pawn),
         _ => throw new Exception("Unknown arrival mode: " + arrivalMode),
     });
Esempio n. 8
0
 private static T GenerateReward <T>(float rewardValue, RewardsGeneratorParams parms, out float valueActuallyUsed) where T : Reward, new()
 {
     try
     {
         T val = new T();
         val.InitFromValue(rewardValue, parms, out valueActuallyUsed);
         return(val);
     }
     finally
     {
     }
 }
Esempio n. 9
0
 public override void InitFromValue(float rewardValue, RewardsGeneratorParams parms, out float valueActuallyUsed)
 {
     amount            = GenMath.RoundRandom(RewardsGenerator.RewardValueToGoodwillCurve.Evaluate(rewardValue));
     amount            = Mathf.Min(amount, 100 - parms.giverFaction.PlayerGoodwill);
     amount            = Mathf.Max(amount, 1);
     valueActuallyUsed = RewardsGenerator.RewardValueToGoodwillCurve.EvaluateInverted(amount);
     if (parms.giverFaction.HostileTo(Faction.OfPlayer))
     {
         amount += Mathf.Clamp(-parms.giverFaction.PlayerGoodwill / 2, 0, amount);
         amount  = Mathf.Min(amount, 100 - parms.giverFaction.PlayerGoodwill);
         amount  = Mathf.Max(amount, 1);
     }
     faction = parms.giverFaction;
 }
        public override IEnumerable <QuestPart> GenerateQuestParts(int index, RewardsGeneratorParams parms, string customLetterLabel, string customLetterText, RulePack customLetterLabelRules, RulePack customLetterTextRules)
        {
            Slate slate = RimWorld.QuestGen.QuestGen.slate;

            for (int i = 0; i < items.Count; i++)
            {
                Pawn pawn = items[i] as Pawn;
                if (pawn != null)
                {
                    RimWorld.QuestGen.QuestGen.AddToGeneratedPawns(pawn);
                    if (!pawn.IsWorldPawn())
                    {
                        Find.WorldPawns.PassToWorld(pawn);
                    }
                }
            }
            if (parms.giveToCaravan)
            {
                QuestPart_GiveToCaravan questPart_GiveToCaravan = new QuestPart_GiveToCaravan();
                questPart_GiveToCaravan.inSignal = slate.Get <string>("inSignal");
                questPart_GiveToCaravan.Things   = items;
                yield return(questPart_GiveToCaravan);
            }
            else
            {
                QuestPart_DropPods dropPods = new QuestPart_DropPods();
                dropPods.inSignal = slate.Get <string>("inSignal");
                if (!customLetterLabel.NullOrEmpty() || customLetterLabelRules != null)
                {
                    RimWorld.QuestGen.QuestGen.AddTextRequest("root", delegate(string x)
                    {
                        dropPods.customLetterLabel = x;
                    }, QuestGenUtility.MergeRules(customLetterLabelRules, customLetterLabel, "root"));
                }
                if (!customLetterText.NullOrEmpty() || customLetterTextRules != null)
                {
                    RimWorld.QuestGen.QuestGen.AddTextRequest("root", delegate(string x)
                    {
                        dropPods.customLetterText = x;
                    }, QuestGenUtility.MergeRules(customLetterTextRules, customLetterText, "root"));
                }
                dropPods.mapParent        = slate.Get <Map>("map").Parent;
                dropPods.useTradeDropSpot = true;
                dropPods.Things           = items;
                yield return(dropPods);
            }
            slate.Set("itemsReward_items", items);
            slate.Set("itemsReward_totalMarketValue", TotalMarketValue);
        }
Esempio n. 11
0
        private static Reward GenerateThingReward(float rewardValue, RewardsGeneratorParams parms, out float valueActuallyUsed)
        {
            float         valueActuallyUsedLocal = 0f;
            Func <Reward> func = () => GenerateReward <Reward_Items>(rewardValue, parms, out valueActuallyUsedLocal);
            Func <Reward> b    = () => GenerateReward <Reward_Pawn>(rewardValue, parms, out valueActuallyUsedLocal);

            if (parms.thingRewardItemsOnly)
            {
                Reward result = func();
                valueActuallyUsed = valueActuallyUsedLocal;
                return(result);
            }
            float  weightB = Mathf.Max(0f, 1f * parms.populationIntent);
            Reward result2 = Rand.ElementByWeight(func, 3f, b, weightB)();

            valueActuallyUsed = valueActuallyUsedLocal;
            return(result2);
        }
Esempio n. 12
0
        public override string GetDescription(RewardsGeneratorParams parms)
        {
            if (parms.giveToCaravan)
            {
                return("Reward_Pawn_Caravan".Translate(pawn));
            }
            switch (arrivalMode)
            {
            case ArrivalMode.WalkIn:
                return("Reward_Pawn_WalkIn".Translate(pawn));

            case ArrivalMode.DropPod:
                return("Reward_Pawn_DropPod".Translate(pawn));

            default:
                throw new Exception("Unknown arrival mode: " + arrivalMode);
            }
        }
Esempio n. 13
0
        public override IEnumerable <QuestPart> GenerateQuestParts(int index, RewardsGeneratorParams parms, string customLetterLabel, string customLetterText, RulePack customLetterLabelRules, RulePack customLetterTextRules)
        {
            Slate slate = RimWorld.QuestGen.QuestGen.slate;

            RimWorld.QuestGen.QuestGen.AddToGeneratedPawns(pawn);
            if (!pawn.IsWorldPawn())
            {
                Find.WorldPawns.PassToWorld(pawn);
            }
            if (parms.giveToCaravan)
            {
                QuestPart_GiveToCaravan questPart_GiveToCaravan = new QuestPart_GiveToCaravan();
                questPart_GiveToCaravan.inSignal = slate.Get <string>("inSignal");
                questPart_GiveToCaravan.Things   = Gen.YieldSingle(pawn);
                yield return(questPart_GiveToCaravan);

                yield break;
            }
            QuestPart_PawnsArrive pawnsArrive = new QuestPart_PawnsArrive();

            pawnsArrive.inSignal = slate.Get <string>("inSignal");
            pawnsArrive.pawns.Add(pawn);
            pawnsArrive.arrivalMode = ((arrivalMode == ArrivalMode.DropPod) ? PawnsArrivalModeDefOf.CenterDrop : PawnsArrivalModeDefOf.EdgeWalkIn);
            pawnsArrive.joinPlayer  = true;
            pawnsArrive.mapParent   = slate.Get <Map>("map").Parent;
            if (!customLetterLabel.NullOrEmpty() || customLetterLabelRules != null)
            {
                RimWorld.QuestGen.QuestGen.AddTextRequest("root", delegate(string x)
                {
                    pawnsArrive.customLetterLabel = x;
                }, QuestGenUtility.MergeRules(customLetterLabelRules, customLetterLabel, "root"));
            }
            if (!customLetterText.NullOrEmpty() || customLetterTextRules != null)
            {
                RimWorld.QuestGen.QuestGen.AddTextRequest("root", delegate(string x)
                {
                    pawnsArrive.customLetterText = x;
                }, QuestGenUtility.MergeRules(customLetterTextRules, customLetterText, "root"));
            }
            yield return(pawnsArrive);
        }
Esempio n. 14
0
        public override IEnumerable <QuestPart> GenerateQuestParts(int index, RewardsGeneratorParams parms, string customLetterLabel, string customLetterText, RulePack customLetterLabelRules, RulePack customLetterTextRules)
        {
            Slate slate = RimWorld.QuestGen.QuestGen.slate;
            QuestPart_GiveRoyalFavor questPart_GiveRoyalFavor = new QuestPart_GiveRoyalFavor();

            questPart_GiveRoyalFavor.faction = faction;
            questPart_GiveRoyalFavor.amount  = amount;
            if (!parms.chosenPawnSignal.NullOrEmpty())
            {
                questPart_GiveRoyalFavor.inSignal         = QuestGenUtility.HardcodedSignalWithQuestID(parms.chosenPawnSignal);
                questPart_GiveRoyalFavor.signalListenMode = QuestPart.SignalListenMode.Always;
            }
            else
            {
                questPart_GiveRoyalFavor.inSignal       = slate.Get <string>("inSignal");
                questPart_GiveRoyalFavor.giveToAccepter = true;
            }
            yield return(questPart_GiveRoyalFavor);

            slate.Set("royalFavorReward_amount", amount);
        }
Esempio n. 15
0
        private static Reward GenerateSocialReward(float rewardValue, RewardsGeneratorParams parms, bool allowGoodwill, bool allowRoyalFavor, out float valueActuallyUsed)
        {
            if (!allowGoodwill && !allowRoyalFavor)
            {
                Log.Error("GenerateSocialReward could not generate any reward for parms=" + parms);
                allowGoodwill = true;
            }
            float         valueActuallyUsedLocal = 0f;
            Func <Reward> func = () => GenerateReward <Reward_Goodwill>(rewardValue, parms, out valueActuallyUsedLocal);
            Func <Reward> b    = () => GenerateReward <Reward_RoyalFavor>(rewardValue, parms, out valueActuallyUsedLocal);

            if (allowGoodwill && parms.giverFaction != null && parms.giverFaction.HostileTo(Faction.OfPlayer))
            {
                Reward result = func();
                valueActuallyUsed = valueActuallyUsedLocal;
                return(result);
            }
            float  weightA = (allowGoodwill ? 1f : 0f);
            float  weightB = (allowRoyalFavor ? 9f : 0f);
            Reward result2 = Rand.ElementByWeight(func, weightA, b, weightB)();

            valueActuallyUsed = valueActuallyUsedLocal;
            return(result2);
        }
Esempio n. 16
0
 public override string GetDescription(RewardsGeneratorParams parms)
 {
     return("Reward_PossibleFutureReward".Translate().Resolve());
 }
Esempio n. 17
0
 public override string GetDescription(RewardsGeneratorParams parms)
 {
     return("Reward_CampLoot".Translate().Resolve());
 }
Esempio n. 18
0
 public override IEnumerable <QuestPart> GenerateQuestParts(int index, RewardsGeneratorParams parms, string customLetterLabel, string customLetterText, RulePack customLetterLabelRules, RulePack customLetterTextRules)
 {
     throw new NotImplementedException();
 }
Esempio n. 19
0
 public override void InitFromValue(float rewardValue, RewardsGeneratorParams parms, out float valueActuallyUsed)
 {
     throw new NotImplementedException();
 }
Esempio n. 20
0
 public override string GetDescription(RewardsGeneratorParams parms)
 {
     return("Reward_BestowingCeremony".Translate(targetPawnName.Named("PAWNNAME")).Resolve());
 }
Esempio n. 21
0
 public abstract string GetDescription(RewardsGeneratorParams parms);
Esempio n. 22
0
 public abstract IEnumerable <QuestPart> GenerateQuestParts(int index, RewardsGeneratorParams parms, string customLetterLabel, string customLetterText, RulePack customLetterLabelRules, RulePack customLetterTextRules);
Esempio n. 23
0
 public abstract void InitFromValue(float rewardValue, RewardsGeneratorParams parms, out float valueActuallyUsed);
Esempio n. 24
0
        public static List <Reward> Generate(RewardsGeneratorParams parms)
        {
            float generatedRewardValue;

            return(Generate(parms, out generatedRewardValue));
        }
Esempio n. 25
0
 public override void InitFromValue(float rewardValue, RewardsGeneratorParams parms, out float valueActuallyUsed)
 {
     pawn              = PawnGenerator.GeneratePawn(PawnKindDefOf.SpaceRefugee);
     arrivalMode       = ((!Rand.Bool) ? ArrivalMode.DropPod : ArrivalMode.WalkIn);
     valueActuallyUsed = rewardValue;
 }
Esempio n. 26
0
        private static List <Reward> DoGenerate(RewardsGeneratorParams parms, out float generatedRewardValue)
        {
            List <Reward> list = new List <Reward>();
            string        text = parms.ConfigError();

            if (text != null)
            {
                Log.Error("Invalid reward generation params: " + text);
                generatedRewardValue = 0f;
                return(list);
            }
            parms.rewardValue = Mathf.Max(parms.rewardValue, parms.minGeneratedRewardValue);
            bool flag  = parms.allowGoodwill && parms.giverFaction != null && parms.giverFaction != Faction.OfPlayer && parms.giverFaction.CanEverGiveGoodwillRewards && parms.giverFaction.allowGoodwillRewards && parms.giverFaction.PlayerGoodwill <= 92;
            bool flag2 = parms.allowRoyalFavor && parms.giverFaction != null && parms.giverFaction.allowRoyalFavorRewards && parms.giverFaction.def.HasRoyalTitles;
            bool flag3 = flag2 || flag;
            bool flag4 = parms.giverFaction != null && parms.giverFaction.HostileTo(Faction.OfPlayer);
            bool flag5 = flag2 && parms.giverFaction == Faction.Empire && !parms.thingRewardItemsOnly;
            bool flag6;
            bool flag7;

            if (!parms.thingRewardDisallowed && !flag3)
            {
                flag6 = true;
                flag7 = false;
            }
            else if (parms.thingRewardDisallowed && flag3)
            {
                flag6 = false;
                flag7 = true;
            }
            else if (parms.thingRewardDisallowed && !flag3)
            {
                flag6 = false;
                flag7 = false;
            }
            else
            {
                float num   = (flag2 ? 0.6f : 0.3f);
                float value = Rand.Value;
                if (value < 0.3f && !flag5 && !flag4)
                {
                    flag6 = true;
                    flag7 = false;
                }
                else if (parms.thingRewardRequired)
                {
                    flag6 = true;
                    flag7 = true;
                }
                else if (value < 0.3f + num)
                {
                    flag6 = false;
                    flag7 = true;
                }
                else
                {
                    flag6 = !flag4;
                    flag7 = true;
                }
            }
            float num2;
            float num3;

            if (flag6 && !flag7)
            {
                num2 = parms.rewardValue;
                num3 = 0f;
            }
            else if (!flag6 && flag7)
            {
                num2 = 0f;
                num3 = parms.rewardValue;
            }
            else
            {
                if (!(flag6 && flag7))
                {
                    generatedRewardValue = 0f;
                    return(list);
                }
                float num4 = Rand.Range(0.3f, 0.7f);
                float num5 = 1f - num4;
                num2 = parms.rewardValue * num4;
                num3 = parms.rewardValue * num5;
            }
            float  valueActuallyUsed  = 0f;
            float  valueActuallyUsed2 = 0f;
            Reward reward             = null;
            Reward reward2            = null;

            if (Rand.Value < 0.65f && !flag5)
            {
                if (num2 > 0f)
                {
                    reward = GenerateThingReward(num2, parms, out valueActuallyUsed);
                    if (flag7 || (flag3 && num2 - valueActuallyUsed >= 600f))
                    {
                        num3 += num2 - valueActuallyUsed;
                    }
                }
                if (num3 > 0f)
                {
                    reward2 = GenerateSocialReward(num3, parms, flag, flag2, out valueActuallyUsed2);
                }
            }
            else
            {
                if (num3 > 0f)
                {
                    reward2 = GenerateSocialReward(num3, parms, flag, flag2, out valueActuallyUsed2);
                    if (flag6 || (!parms.thingRewardDisallowed && num3 - valueActuallyUsed2 >= 600f && !flag4))
                    {
                        num2 += num3 - valueActuallyUsed2;
                    }
                }
                if (num2 > 0f)
                {
                    reward = GenerateThingReward(num2, parms, out valueActuallyUsed);
                }
            }
            generatedRewardValue = valueActuallyUsed + valueActuallyUsed2;
            Reward_Items reward_Items = null;
            float        num6         = parms.rewardValue - valueActuallyUsed - valueActuallyUsed2;

            if ((num6 >= 200f || valueActuallyUsed + valueActuallyUsed2 < parms.minGeneratedRewardValue) && !parms.thingRewardDisallowed)
            {
                reward_Items = AddMarketValueFillers(num6, ref generatedRewardValue, reward);
            }
            if (reward != null)
            {
                list.Add(reward);
            }
            if (reward2 != null)
            {
                list.Add(reward2);
            }
            if (reward_Items != null)
            {
                list.Add(reward_Items);
            }
            return(list);
        }
Esempio n. 27
0
 public override string GetDescription(RewardsGeneratorParams parms)
 {
     return("Reward_Goodwill".Translate(faction, amount).Resolve());
 }
Esempio n. 28
0
 public override string GetDescription(RewardsGeneratorParams parms)
 {
     return("Reward_PassageOffworld".Translate().Resolve());
 }