Exemple #1
0
        public override void Resolve(ResolveParams rp)
        {
            Map map = BaseGen.globalSettings.map;
            ThingSetMakerDef    thingSetMakerDef    = rp.thingSetMakerDef ?? ThingSetMakerDefOf.MapGen_DefaultStockpile;
            ThingSetMakerParams?thingSetMakerParams = rp.thingSetMakerParams;
            ThingSetMakerParams parms;

            if (thingSetMakerParams != null)
            {
                parms = rp.thingSetMakerParams.Value;
            }
            else
            {
                int num = rp.rect.Cells.Count((IntVec3 x) => x.Standable(map) && x.GetFirstItem(map) == null);
                parms            = default(ThingSetMakerParams);
                parms.countRange = new IntRange?(new IntRange(num, num));
                parms.techLevel  = new TechLevel?((rp.faction == null) ? TechLevel.Undefined : rp.faction.def.techLevel);
            }
            List <Thing> list = thingSetMakerDef.root.Generate(parms);

            for (int i = 0; i < list.Count; i++)
            {
                ResolveParams resolveParams = rp;
                resolveParams.singleThingToSpawn = list[i];
                BaseGen.symbolStack.Push("thing", resolveParams);
            }
        }
        public override string GenerateRewards(Pawn pawn, Caravan caravan, Predicate <ThingDef> globalValidator,
                                               ThingSetMakerDef thingSetMakerDef)
        {
            var rewards = string.Empty;

            if (thingSetMakerDef != eventDef.rewardFirstLoser)
            {
                return(base.GenerateRewards(pawn, caravan, globalValidator, thingSetMakerDef));
            }

            foreach (var performer in caravan.PlayerPawnsForStoryteller)
            {
                if (performer.WorkTagIsDisabled(WorkTags.Artistic))
                {
                    continue;
                }

                pawn.skills.Learn(SkillDefOf.Artistic, eventDef.xPGainFirstLoser, true);
                TryAppendExpGainInfo(ref rewards, performer, SkillDefOf.Artistic, eventDef.xPGainFirstLoser);
            }

            return(rewards + (Rand.Bool ? new TaggedString(string.Empty) :
                              Rand.Bool ? new TaggedString("\n\n---\n\n")
                              + "MFI_AnnualExpoMedicalEmergency".Translate() :
                              "\n\n---\n\n" + "MFI_AnnualExpoMedicalEmergencySerious".Translate()));
        }
Exemple #3
0
        public void GenerateRewards(ThingSetMakerDef maker, FloatRange totalValue, IntRange?countRange)
        {
            ThingSetMakerParams parms = default(ThingSetMakerParams);

            parms.totalMarketValueRange = totalValue;
            parms.countRange            = countRange;

            Rewards = maker.root.Generate(parms);
        }
Exemple #4
0
        public override void Resolve(ResolveParams rp)
        {
            Map map = BaseGen.globalSettings.map;

            if (rp.stockpileConcreteContents != null)
            {
                this.CalculateFreeCells(rp.rect, 0f);
                int num = 0;
                for (int i = rp.stockpileConcreteContents.Count - 1; i >= 0; i--)
                {
                    if (num >= this.cells.Count)
                    {
                        break;
                    }
                    GenSpawn.Spawn(rp.stockpileConcreteContents[i], this.cells[num], map, WipeMode.Vanish);
                    num++;
                }
                for (int j = rp.stockpileConcreteContents.Count - 1; j >= 0; j--)
                {
                    if (!rp.stockpileConcreteContents[j].Spawned)
                    {
                        rp.stockpileConcreteContents[j].Destroy(DestroyMode.Vanish);
                    }
                }
                rp.stockpileConcreteContents.Clear();
            }
            else
            {
                this.CalculateFreeCells(rp.rect, 0.45f);
                ThingSetMakerDef    thingSetMakerDef    = rp.thingSetMakerDef ?? ThingSetMakerDefOf.MapGen_DefaultStockpile;
                ThingSetMakerParams?thingSetMakerParams = rp.thingSetMakerParams;
                ThingSetMakerParams value;
                if (thingSetMakerParams != null)
                {
                    value = rp.thingSetMakerParams.Value;
                }
                else
                {
                    value           = default(ThingSetMakerParams);
                    value.techLevel = new TechLevel?((rp.faction == null) ? TechLevel.Undefined : rp.faction.def.techLevel);
                    value.validator = ((ThingDef x) => rp.faction == null || x.techLevel >= rp.faction.def.techLevel || !x.IsWeapon || x.GetStatValueAbstract(StatDefOf.MarketValue, GenStuff.DefaultStuffFor(x)) >= 100f);
                    float?stockpileMarketValue = rp.stockpileMarketValue;
                    float num2 = (stockpileMarketValue == null) ? Mathf.Min((float)this.cells.Count * 130f, 1800f) : stockpileMarketValue.Value;
                    value.totalMarketValueRange = new FloatRange?(new FloatRange(num2, num2));
                }
                IntRange?countRange = value.countRange;
                if (countRange == null)
                {
                    value.countRange = new IntRange?(new IntRange(this.cells.Count, this.cells.Count));
                }
                ResolveParams rp2 = rp;
                rp2.thingSetMakerDef    = thingSetMakerDef;
                rp2.thingSetMakerParams = new ThingSetMakerParams?(value);
                BaseGen.symbolStack.Push("thingSet", rp2);
            }
        }
Exemple #5
0
        // from IncidentWorker_QuestItemStash
        protected List <Thing> GenerateItems(Faction siteFaction, float siteThreatPoints)
        {
            ThingSetMakerParams parms = default(ThingSetMakerParams);

            parms.totalMarketValueRange = new FloatRange(0.7f, 1.3f);

            ThingSetMakerDef thingSetMakerDef = DefDatabase <ThingSetMakerDef> .GetNamedSilentFail("Reward_Incidents_ItemStashQuestContents");

            return(thingSetMakerDef.root.Generate(parms));
        }
        public override void Resolve(ResolveParams rp)
        {
            Map map = BaseGen.globalSettings.map;

            if (rp.stockpileConcreteContents != null)
            {
                CalculateFreeCells(rp.rect, 0f);
                int num  = 0;
                int num2 = rp.stockpileConcreteContents.Count - 1;
                while (num2 >= 0 && num < cells.Count)
                {
                    GenSpawn.Spawn(rp.stockpileConcreteContents[num2], cells[num], map);
                    num++;
                    num2--;
                }
                for (int num3 = rp.stockpileConcreteContents.Count - 1; num3 >= 0; num3--)
                {
                    if (!rp.stockpileConcreteContents[num3].Spawned)
                    {
                        rp.stockpileConcreteContents[num3].Destroy();
                    }
                }
                rp.stockpileConcreteContents.Clear();
                return;
            }
            CalculateFreeCells(rp.rect, 0.45f);
            ThingSetMakerDef    thingSetMakerDef = rp.thingSetMakerDef ?? ThingSetMakerDefOf.MapGen_DefaultStockpile;
            ThingSetMakerParams value;

            if (rp.thingSetMakerParams.HasValue)
            {
                value = rp.thingSetMakerParams.Value;
            }
            else
            {
                value               = default(ThingSetMakerParams);
                value.techLevel     = ((rp.faction != null) ? rp.faction.def.techLevel : TechLevel.Undefined);
                value.makingFaction = rp.faction;
                value.validator     = ((ThingDef x) => (rp.faction == null || (int)x.techLevel >= (int)rp.faction.def.techLevel || !x.IsWeapon || !(x.GetStatValueAbstract(StatDefOf.MarketValue, GenStuff.DefaultStuffFor(x)) < 100f)) ? true : false);
                float num4 = rp.stockpileMarketValue ?? Mathf.Min((float)cells.Count * 130f, 1800f);
                value.totalMarketValueRange = new FloatRange(num4, num4);
            }
            if (!value.countRange.HasValue)
            {
                value.countRange = new IntRange(cells.Count, cells.Count);
            }
            ResolveParams resolveParams = rp;

            resolveParams.thingSetMakerDef    = thingSetMakerDef;
            resolveParams.thingSetMakerParams = value;
            BaseGen.symbolStack.Push("thingSet", resolveParams);
        }
        private string MaybeTheySuckAndDontHaveItYet(Buff buff, Caravan caravan,
                                                     ThingSetMakerDef thingSetMakerDef)
        {
            if (thingSetMakerDef != eventDef.rewardFirstPlace ||
                MFI_Utilities.CaravanOrRichestColonyHasAnyOf(buff.RelevantThingDef(), caravan, out _))
            {
                return(string.Empty);
            }

            var thing = ThingMaker.MakeThing(buff.RelevantThingDef());

            thing.stackCount = Mathf.Min(thing.def.stackLimit, 75); //suck it, stackXXL users.
            CaravanInventoryUtility.GiveThing(caravan, thing);
            var anReward = Find.ActiveLanguageWorker.WithDefiniteArticlePostProcessed(thing.Label);

            return("\n\n" + "MFI_SinceYouSuckAndDidntHaveIt".Translate(anReward));
        }
        private static void SpawnThingSet()
        {
            List <DebugMenuOption>  list = new List <DebugMenuOption>();
            List <ThingSetMakerDef> allDefsListForReading = DefDatabase <ThingSetMakerDef> .AllDefsListForReading;

            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                ThingSetMakerDef localGenerator = allDefsListForReading[i];
                list.Add(new DebugMenuOption(localGenerator.defName, DebugMenuOptionMode.Tool, delegate
                {
                    if (UI.MouseCell().InBounds(Find.CurrentMap))
                    {
                        StringBuilder stringBuilder   = new StringBuilder();
                        string nonNullFieldsDebugInfo = Gen.GetNonNullFieldsDebugInfo(localGenerator.debugParams);
                        List <Thing> list2            = localGenerator.root.Generate(localGenerator.debugParams);
                        stringBuilder.Append(localGenerator.defName + " generated " + list2.Count + " things");
                        if (!nonNullFieldsDebugInfo.NullOrEmpty())
                        {
                            stringBuilder.Append(" (used custom debug params: " + nonNullFieldsDebugInfo + ")");
                        }
                        stringBuilder.AppendLine(":");
                        float num  = 0f;
                        float num2 = 0f;
                        for (int j = 0; j < list2.Count; j++)
                        {
                            stringBuilder.AppendLine("   - " + list2[j].LabelCap);
                            num += list2[j].MarketValue * (float)list2[j].stackCount;
                            if (!(list2[j] is Pawn))
                            {
                                num2 += list2[j].GetStatValue(StatDefOf.Mass) * (float)list2[j].stackCount;
                            }
                            if (!GenPlace.TryPlaceThing(list2[j], UI.MouseCell(), Find.CurrentMap, ThingPlaceMode.Near))
                            {
                                list2[j].Destroy();
                            }
                        }
                        stringBuilder.AppendLine("Total market value: " + num.ToString("0.##"));
                        stringBuilder.AppendLine("Total mass: " + num2.ToStringMass());
                        Log.Message(stringBuilder.ToString());
                    }
                }));
            }
            Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
        }
Exemple #9
0
        public override string GenerateRewards(Pawn pawn, Caravan caravan, Predicate <ThingDef> globalValidator,
                                               ThingSetMakerDef thingSetMakerDef)
        {
            if (thingSetMakerDef == eventDef.rewardFirstPlace)
            {
                GiveHappyThoughtsToCaravan(caravan, 20);
            }

            if (thingSetMakerDef == eventDef.rewardFirstLoser)
            {
                GiveHappyThoughtsToCaravan(caravan, 15);
            }

            if (thingSetMakerDef == eventDef.rewardFirstOther)
            {
                GiveHappyThoughtsToCaravan(caravan, 10);
            }

            return(base.GenerateRewards(pawn, caravan, globalValidator, thingSetMakerDef));
        }
        public override string GenerateRewards(Pawn pawn, Caravan caravan, Predicate <ThingDef> globalValidator,
                                               ThingSetMakerDef thingSetMakerDef)
        {
            if (thingSetMakerDef != eventDef.rewardFirstOther)
            {
                return(base.GenerateRewards(pawn, caravan, globalValidator, thingSetMakerDef));
            }

            string rewards = "MFI_AnnualExpoMedicalEmergency".Translate();

            foreach (var brawler in caravan.PlayerPawnsForStoryteller)
            {
                if (brawler.WorkTagIsDisabled(WorkTags.Violent))
                {
                    continue;
                }

                brawler.skills.Learn(SkillDefOf.Melee, eventDef.xPGainFirstPlace, true);
                TryAppendExpGainInfo(ref rewards, brawler, SkillDefOf.Melee, eventDef.xPGainFirstPlace);
            }

            return(rewards);
        }
Exemple #11
0
        public override void ResolveReferences()
        {
            if (this.terrain != null)
            {
                this.terrainDef = DefDatabase <TerrainDef> .GetNamed(this.terrain, VFECore.VFEGlobal.settings.enableVerboseLogging);
            }
            if (this.thing != null)
            {
                this.thingDef = DefDatabase <ThingDef> .GetNamed(this.thing, VFECore.VFEGlobal.settings.enableVerboseLogging);
            }
            if (this.stuff != null)
            {
                this.stuffDef = DefDatabase <ThingDef> .GetNamed(this.stuff, VFECore.VFEGlobal.settings.enableVerboseLogging);
            }
            if (this.pawnKindDef != null)
            {
                this.pawnKindDefNS = DefDatabase <PawnKindDef> .GetNamed(this.pawnKindDef, VFECore.VFEGlobal.settings.enableVerboseLogging);
            }
            if (this.thingSetMakerDef == null)
            {
                this.thingSetMakerDef = ThingSetMakerDefOf.MapGen_AncientComplexRoomLoot_Default;
            }

            // Obsolete
            if (this.containPawnKind != null)
            {
                this.containPawnKindDef = DefDatabase <PawnKindDef> .GetNamed(this.containPawnKind, VFECore.VFEGlobal.settings.enableVerboseLogging);

                Log.Warning($"{this.defName} is using obsolete field containPawnKind. Report this to {this.modContentPack.Name}");
            }
            if (this.containPawnKindForPlayer != null)
            {
                this.containPawnKindDefForPlayer = DefDatabase <PawnKindDef> .GetNamed(this.containPawnKindForPlayer, VFECore.VFEGlobal.settings.enableVerboseLogging);

                Log.Warning($"{this.defName} is using obsolete field containPawnKindDefForPlayer. Report this to {this.modContentPack.Name}");
            }
        }
Exemple #12
0
        public virtual string GenerateRewards(Pawn pawn, Caravan caravan, Predicate <ThingDef> globalValidator,
                                              ThingSetMakerDef thingSetMakerDef)
        {
            var rewards = new List <Thing>();

            if (thingSetMakerDef != null)
            {
                ThingSetMakerParams parms = default;
                parms.validator        = globalValidator;
                parms.qualityGenerator = QualityGenerator.Reward;
                rewards = thingSetMakerDef.root.Generate(parms);
            }

            var rewardsToCommaList = GenThing.ThingsToCommaList(rewards);

            TryAppendSingleRewardInfo(ref rewardsToCommaList, rewards);

            foreach (var itemReward in rewards)
            {
                caravan.AddPawnOrItem(itemReward, true);
            }

            return(rewardsToCommaList);
        }
        private string GenerateBuff(TechLevel desiredTechLevel, Pawn pawn, Caravan caravan,
                                    Predicate <ThingDef> globalValidator, ThingSetMakerDef thingSetMakerDef)
        {
            string reward;

            var buff = Find.World.GetComponent <WorldComponent_MFI_AnnualExpo>()
                       .ApplyRandomBuff(x => x.MinTechLevel() >= desiredTechLevel && !x.Active);

            if (buff == null)
            {
                buff = Find.World.GetComponent <WorldComponent_MFI_AnnualExpo>().ApplyRandomBuff(x => !x.Active);
            }

            if (buff != null)
            {
                reward = buff.Description() + MaybeTheySuckAndDontHaveItYet(buff, caravan, thingSetMakerDef);
            }
            else
            {
                reward = base.GenerateRewards(pawn, caravan, globalValidator, thingSetMakerDef);
            }

            return(reward);
        }
 public override string GenerateRewards(Pawn pawn, Caravan caravan, Predicate <ThingDef> globalValidator, ThingSetMakerDef thingSetMakerDef)
 {
     return(GenerateBuff(thingSetMakerDef.root.fixedParams.techLevel.GetValueOrDefault(), pawn, caravan, globalValidator, thingSetMakerDef));
 }
Exemple #15
0
        public override string GenerateRewards(Pawn pawn, Caravan caravan, Predicate <ThingDef> globalValidator, ThingSetMakerDef thingSetMakerDef)
        {
            string rewards = string.Empty;

            if (thingSetMakerDef == eventDef.rewardFirstLoser)
            {
                foreach (Pawn performer in caravan.PlayerPawnsForStoryteller)
                {
                    if (!performer.story?.WorkTagIsDisabled(WorkTags.Artistic) ?? false)
                    {
                        pawn.skills.Learn(sDef: SkillDefOf.Artistic, eventDef.xPGainFirstLoser, direct: true);
                        TryAppendExpGainInfo(ref rewards, performer, SkillDefOf.Artistic, eventDef.xPGainFirstLoser);
                    }
                }
                return(rewards + (Rand.Bool ? string.Empty :
                                  Rand.Bool ? "\n\n---\n\n" + "MFI_AnnualExpoMedicalEmergency".Translate() : "\n\n---\n\n" + "MFI_AnnualExpoMedicalEmergencySerious".Translate()));
            }
            return(base.GenerateRewards(pawn, caravan, globalValidator, thingSetMakerDef));
        }