Ejemplo n.º 1
0
        private static void SpawnPawnQuality()
        {
            List <DebugMenuOption> list = new List <DebugMenuOption>();

            foreach (PawnKindDef item in DefDatabase <PawnKindDef> .AllDefs.Where(x => x.GetModExtension <DefExtension_Hybrid>() != null || x.race.tradeTags?.Contains("AnimalGeneticMechanoid") == true).OrderBy((PawnKindDef kd) => kd.defName))
            {
                PawnKindDef localKindDef = item;
                list.Add(new DebugMenuOption(localKindDef.defName, DebugMenuOptionMode.Tool, delegate
                {
                    Faction faction = FactionUtility.DefaultFactionFrom(localKindDef.defaultFactionType);
                    Pawn newPawn    = PawnGenerator.GeneratePawn(localKindDef, faction);
                    GenSpawn.Spawn(newPawn, UI.MouseCell(), Find.CurrentMap);
                    CompHybrid compHybrid = newPawn.TryGetComp <CompHybrid>();
                    if (compHybrid != null)
                    {
                        compHybrid.quality = QualityUtility.GenerateQualityRandomEqualChance();
                    }
                    if (faction != null && faction != Faction.OfPlayer)
                    {
                        Lord lord = null;
                        if (newPawn.Map.mapPawns.SpawnedPawnsInFaction(faction).Any((Pawn p) => p != newPawn))
                        {
                            lord = ((Pawn)GenClosest.ClosestThing_Global(newPawn.Position, newPawn.Map.mapPawns.SpawnedPawnsInFaction(faction), 99999f, (Thing p) => p != newPawn && ((Pawn)p).GetLord() != null)).GetLord();
                        }
                        if (lord == null)
                        {
                            LordJob_DefendPoint lordJob = new LordJob_DefendPoint(newPawn.Position);
                            lord = LordMaker.MakeNewLord(faction, lordJob, Find.CurrentMap);
                        }
                        lord.AddPawn(newPawn);
                    }
                }));
            }
            Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
        }
Ejemplo n.º 2
0
        public static void DebugSpawn(ThingDef def, IntVec3 c, int stackCount = -1, bool direct = false)
        {
            if (stackCount <= 0)
            {
                stackCount = def.stackLimit;
            }
            ThingDef    stuff       = GenStuff.RandomStuffFor(def);
            Thing       thing       = ThingMaker.MakeThing(def, stuff);
            CompQuality compQuality = thing.TryGetComp <CompQuality>();

            if (compQuality != null)
            {
                compQuality.SetQuality(QualityUtility.GenerateQualityRandomEqualChance(), ArtGenerationContext.Colony);
            }
            if (thing.def.Minifiable)
            {
                thing = thing.MakeMinified();
            }
            thing.stackCount = stackCount;
            if (direct)
            {
                GenPlace.TryPlaceThing(thing, c, Find.CurrentMap, ThingPlaceMode.Direct, null, null);
            }
            else
            {
                GenPlace.TryPlaceThing(thing, c, Find.CurrentMap, ThingPlaceMode.Near, null, null);
            }
        }
Ejemplo n.º 3
0
        public static QualityCategory GenerateQualityFromSettings()
        {
            if (!MeMiMoSettings.forceItemQuality)
            {
                return(QualityUtility.GenerateQualityRandomEqualChance());
            }

            switch (MeMiMoSettings.forcedItemQuality)
            {
            case 0:
                return(QualityCategory.Awful);

            case 1:
                return(QualityCategory.Poor);

            case 3:
                return(QualityCategory.Good);

            case 4:
                return(QualityCategory.Excellent);

            case 5:
                return(QualityCategory.Masterwork);

            case 6:
                return(QualityCategory.Legendary);

            default:
                return(QualityCategory.Normal);
            }
        }
Ejemplo n.º 4
0
        public void RegenerateStock()
        {
            TryDestroyStock();

            ThingSetMaker_MarketValue maker = new ThingSetMaker_MarketValue();
            ThingSetMakerParams       parms = default;

            foreach (var cat in stock)
            {
                CategoryItemSetting <Tab> settings = Comp.Props.CategoryItemSettings.First(x => x.Tab == cat.Tab);

                if (cat.Items == null)
                {
                    cat.Items = new List <SellableItemWithModif>();
                }

                int   itemsCount = settings.CountRange.RandomInRange;
                float valueRange = settings.ValueRange.RandomInRange * itemsCount;

                parms.totalMarketValueRange = new FloatRange(valueRange, valueRange);
                parms.countRange            = new IntRange(itemsCount, itemsCount);

                ThingFilter filter = DarkNetPriceUtils.GetThingFilter(settings.Goods);
                if (filter.AllowedDefCount == 0)
                {
                    continue;
                }

                parms.filter = filter;

                maker.fixedParams = parms;

                var items = maker.Generate();

                foreach (var item in items)
                {
                    if (!DarkNetPriceUtils.TryMerge(item, cat.Items))
                    {
                        int marketValue = (int)((item.MarketValue * Character.Greed) * settings.PriceMultiplier);

                        var quality = item.TryGetComp <CompQuality>();
                        if (quality != null)
                        {
                            quality.SetQuality(QualityUtility.GenerateQualityRandomEqualChance(), ArtGenerationContext.Colony);
                            marketValue = (int)(marketValue * GetPriceMultiplierForQuality(quality.Quality));
                        }

                        SellableItemWithModif newItem = new SellableItemWithModif(item, marketValue, null);

                        cat.Items.Add(newItem);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public override Thing GenerateItem(DarkNetTrader trader)
        {
            TraderWorker_RogerEdmonson roger = (TraderWorker_RogerEdmonson)trader;

            Thing newArt = ThingMaker.MakeThing(Art, Stuff);

            newArt.TryGetComp <CompQuality>()?.SetQuality(QualityUtility.GenerateQualityRandomEqualChance(), ArtGenerationContext.Colony);
            newArt = newArt.MakeMinified();

            return(newArt);
        }
Ejemplo n.º 6
0
        public static void DebugSpawnWithAffixes(ThingDef def, IntVec3 c, float affixPoints = 0, int ttlAffixes = 0)
        {
            ThingDef stuff = GenStuff.RandomStuffFor(def);
            Thing    thing = ThingMaker.MakeThing(def, stuff);

            thing.TryGetComp <CompQuality>()?.SetQuality(QualityUtility.GenerateQualityRandomEqualChance(), ArtGenerationContext.Colony);
            if (thing.def.Minifiable)
            {
                thing = thing.MakeMinified();
            }
            thing.TryGetComp <CompLootAffixableThing>()?.InitializeAffixes(affixPoints, ttlAffixes);

            GenPlace.TryPlaceThing(thing, c, Find.CurrentMap, ThingPlaceMode.Near);
        }
Ejemplo n.º 7
0
        public static List <DebugMenuOption> SpawnOptions(WipeMode wipeMode)
        {
            List <DebugMenuOption> list = new List <DebugMenuOption>();

            foreach (ThingDef item in DefDatabase <ThingDef> .AllDefs.Where((ThingDef def) => IsDebugSpawnable(def, allowPlayerBuildable: true)))
            {
                ThingDef localDef = item;
                list.Add(new DebugMenuOption(localDef.LabelCap, DebugMenuOptionMode.Tool, delegate
                {
                    Thing thing = ThingMaker.MakeThing(localDef, GenStuff.RandomStuffFor(localDef));
                    thing.TryGetComp <CompQuality>()?.SetQuality(QualityUtility.GenerateQualityRandomEqualChance(), ArtGenerationContext.Colony);
                    GenSpawn.Spawn(thing, UI.MouseCell(), Find.CurrentMap, wipeMode);
                }));
            }
            return(list);
        }
        public static QualityCategory GenerateQualityFromSettings()
        {
            if (!MeMiMoSettings.forceItemQuality)
            {
                return(QualityUtility.GenerateQualityRandomEqualChance());
            }

            return(MeMiMoSettings.forcedItemQuality switch
            {
                0 => QualityCategory.Awful,
                1 => QualityCategory.Poor,
                3 => QualityCategory.Good,
                4 => QualityCategory.Excellent,
                5 => QualityCategory.Masterwork,
                6 => QualityCategory.Legendary,
                _ => QualityCategory.Normal,
            });
        public void SpawnHostileHYbrid()
        {
            Pawn pawn = PawnGenerator.GeneratePawn(new PawnGenerationRequest(hybridsList.RandomElement(), null, fixedBiologicalAge: 3, fixedChronologicalAge: 3,
                                                                             newborn: false, forceGenerateNewPawn: true));
            IntVec3 near = CellFinder.StandableCellNear(this.parent.Position, this.parent.Map, 2f);

            GenSpawn.Spawn(pawn, near, this.parent.Map);

            CompHybrid compHybrid = pawn.TryGetComp <CompHybrid>();

            if (compHybrid != null)
            {
                compHybrid.quality = QualityUtility.GenerateQualityRandomEqualChance();
            }

            pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent, null, true, false, null, false);
            pawn.health.AddHediff(InternalDefOf.GR_GreaterScaria);

            this.parent.Destroy();
        }
Ejemplo n.º 10
0
        private static Thing TryGetTreasure(ThingDef treasureDef, ThingDef stuffDef)
        {
            Thing treasure = null;

            // make treasure
            if (treasureDef == null)
            {
                return(null);
            }

            treasure = ThingMaker.MakeThing(treasureDef, stuffDef);

            // try adjust quality
            CompQuality treasureQuality = treasure.TryGetComp <CompQuality>();

            if (treasureQuality != null)
            {
                treasureQuality.SetQuality(QualityUtility.GenerateQualityRandomEqualChance(), ArtGenerationContext.Outsider);
            }

            // adjust Stack to a random stack size
            if (treasure.def.stackLimit > 1)
            {
                if (treasure.def.stackLimit > 50)
                {
                    treasure.stackCount = Rand.RangeInclusive(1, 45);
                }
                else
                {
                    treasure.stackCount = Rand.RangeInclusive(1, treasure.def.stackLimit);
                }
            }

            // adjust Hitpoints (40% to 100%)
            if (treasure.stackCount == 1)
            {
                treasure.HitPoints = Rand.RangeInclusive((int)(treasure.MaxHitPoints * 0.4), treasure.MaxHitPoints);
            }

            return(treasure);
        }
Ejemplo n.º 11
0
        public static List <DebugMenuOption> SpawnOptions(WipeMode wipeMode)
        {
            List <DebugMenuOption> list       = new List <DebugMenuOption>();
            IEnumerable <ThingDef> enumerable = from def in DefDatabase <ThingDef> .AllDefs
                                                where DebugThingPlaceHelper.IsDebugSpawnable(def, true)
                                                select def;

            foreach (ThingDef current in enumerable)
            {
                ThingDef localDef = current;
                list.Add(new DebugMenuOption(localDef.LabelCap, DebugMenuOptionMode.Tool, delegate
                {
                    Thing thing             = ThingMaker.MakeThing(localDef, GenStuff.RandomStuffFor(localDef));
                    CompQuality compQuality = thing.TryGetComp <CompQuality>();
                    if (compQuality != null)
                    {
                        compQuality.SetQuality(QualityUtility.GenerateQualityRandomEqualChance(), ArtGenerationContext.Colony);
                    }
                    GenSpawn.Spawn(thing, UI.MouseCell(), Find.CurrentMap, wipeMode);
                }));
            }
            return(list);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            Map map = (Map)parms.target;

            float totalPoints = parms.points / 2;

            HashSet <PawnKindDef> hybridsList;

            if (StaticCollectionsClass.AnyMechAntennas())
            {
                hybridsList = DefDatabase <PawnKindDef> .AllDefsListForReading.Where(x => (x.race.tradeTags?.Contains("AnimalGenetic") == true) && (x.race.tradeTags?.Contains("AnimalGeneticFailure") == false) && (x.race.tradeTags?.Contains("AnimalGeneticCentipede") == false)).ToHashSet();
            }
            else
            {
                hybridsList = DefDatabase <PawnKindDef> .AllDefsListForReading.Where(x => (x.race.tradeTags?.Contains("AnimalGenetic") == true) && (x.race.tradeTags?.Contains("AnimalGeneticFailure") == false) && (x.race.tradeTags?.Contains("AnimalGeneticMechanoid") == false)).ToHashSet();
            }

            List <Pawn> list = new List <Pawn>();

            PawnKindDef firstPawn;

            hybridsList.TryRandomElementByWeight((PawnKindDef a) => ManhunterPackIncidentUtility.ManhunterAnimalWeight(a, parms.points), out firstPawn);
            IntVec3 result = parms.spawnCenter;

            if (firstPawn != null)
            {
                if (!result.IsValid && !RCellFinder.TryFindRandomPawnEntryCell(out result, map, CellFinder.EdgeRoadChance_Animal))
                {
                    return(false);
                }
                Pawn item = PawnGenerator.GeneratePawn(new PawnGenerationRequest(firstPawn, null, PawnGenerationContext.NonPlayer, map.Tile));
                list.Add(item);
                totalPoints -= item.kindDef.combatPower;
                while (totalPoints > 0)
                {
                    PawnKindDef nextPawn;
                    hybridsList.TryRandomElementByWeight((PawnKindDef a) => ManhunterPackIncidentUtility.ManhunterAnimalWeight(a, totalPoints), out nextPawn);
                    Pawn nextitem = PawnGenerator.GeneratePawn(new PawnGenerationRequest(nextPawn, null, PawnGenerationContext.NonPlayer, map.Tile));
                    list.Add(nextitem);
                    totalPoints -= nextitem.kindDef.combatPower;
                }
            }


            Rot4 rot = Rot4.FromAngleFlat((map.Center - result).AngleFlat);

            for (int i = 0; i < list.Count; i++)
            {
                Pawn    pawn = list[i];
                IntVec3 loc  = CellFinder.RandomClosewalkCellNear(result, map, 10);
                QuestUtility.AddQuestTag(GenSpawn.Spawn(pawn, loc, map, rot), parms.questTag);
                pawn.health.AddHediff(InternalDefOf.GR_GreaterScaria);
                pawn.mindState.mentalStateHandler.TryStartMentalState(MentalStateDefOf.ManhunterPermanent);
                CompHybrid compHybrid = pawn.TryGetComp <CompHybrid>();

                if (compHybrid != null)
                {
                    compHybrid.quality = QualityUtility.GenerateQualityRandomEqualChance();
                }
            }
            SendStandardLetter("GR_LetterLabelMonstrositiesArrived".Translate(), "GR_LetterMonstrositiesArrived".Translate(), LetterDefOf.ThreatBig, parms, list[0]);
            Find.TickManager.slower.SignalForceNormalSpeedShort();

            return(true);
        }
Ejemplo n.º 13
0
        public override void DoSettingsWindowContents(Rect rect)
        {
            Settings.Initialize();

            Settings.OptionsOpen = !this.putHatOnPawn;

            if (Current.Game != null && this.pawn == null)
            {
                foreach (Pawn p in PawnsFinder.All_AliveOrDead)
                {
                    if (p.Faction != Faction.OfPlayer &&
                        p.def.race.Humanlike &&
                        !p.health.Downed &&
                        p.equipment != null)
                    {
                        this.pawn          = p;
                        this.originalColor = p.story.hairColor;
                        foreach (ThingWithComps t in p.apparel.WornApparel)
                        {
                            if (t.def.apparel?.layers.Contains(ApparelLayerDefOf.Overhead) == true)
                            {
                                this.pawnBackupHat = t;
                                this.RemoveApparel(pawnBackupHat);
                                try
                                {
                                    this.pawn.Drawer.renderer.graphics.SetAllGraphicsDirty();
                                }
                                catch
                                {
                                    Log.ErrorOnce(msgErrorDirty, msgErrorDirty.GetHashCode());
                                }
                                break;
                            }
                        }
                        PortraitsCache.SetDirty(this.pawn);
                        break;
                    }
                }
            }
            else if (Current.Game == null)
            {
                this.pawn = null;
            }

            float y = 60f;

            Widgets.CheckboxLabeled(new Rect(0, y, 250, 22), "ShowHair.OnlyApplyToColonists".Translate(), ref Settings.OnlyApplyToColonists);
            y += 30;
            Widgets.CheckboxLabeled(new Rect(0, y, 250, 22), "ShowHair.HideAllHats".Translate(), ref Settings.HideAllHats);
            y += 30;
            Widgets.CheckboxLabeled(new Rect(0, y, 250, 22), "ShowHair.UseDontShaveHead".Translate(), ref Settings.UseDontShaveHead);
            y += 30;

            if (!Settings.HideAllHats)
            {
                Widgets.CheckboxLabeled(new Rect(0, y, 250, 22), "ShowHair.ShowHatsOnlyWhenDrafted".Translate(), ref Settings.ShowHatsOnlyWhenDrafted);
                y += 30;

                if (!Settings.ShowHatsOnlyWhenDrafted)
                {
                    Widgets.Label(new Rect(0, y, 225, 22), "ShowHair.HideHatsIndoors".Translate());
                    string label;
                    if (Settings.Indoors == Indoors.ShowHats)
                    {
                        label = "Off";
                    }
                    else if (Settings.Indoors == Indoors.HideHats)
                    {
                        label = "ShowHair.HideHatsIndoors";
                    }
                    else
                    {
                        label = "ShowHair.HideHatsIndoorsShowWhenDrafted";
                    }
                    if (Widgets.ButtonText(new Rect(235, y, 200, 22), label.Translate()))
                    {
                        Find.WindowStack.Add(new FloatMenu(new List <FloatMenuOption>()
                        {
                            new FloatMenuOption("Off".Translate(), delegate() { Settings.Indoors = Indoors.ShowHats; }),
                            new FloatMenuOption("ShowHair.HideHatsIndoors".Translate(), delegate() { Settings.Indoors = Indoors.HideHats; }),
                            new FloatMenuOption("ShowHair.HideHatsIndoorsShowWhenDrafted".Translate(), delegate() { Settings.Indoors = Indoors.ShowHatsWhenDrafted; }),
                        }));
                    }
                    y += 30;

                    /*
                     * {
                     *  if (Settings.HideHatsIndoors)
                     *  {
                     *      Widgets.CheckboxLabeled(new Rect(10, y, 300, 22), "ShowHair.UpdatePortrait".Translate(), ref Settings.UpdatePortrait);
                     *      y += 30;
                     *      Widgets.CheckboxLabeled(new Rect(10, y, 300, 22), "ShowHair.HideHatsIndoorsShowWhenDrafted".Translate(), ref Settings.ShowHatsWhenDraftedIndoors);
                     *      y += 30;
                     *      Widgets.CheckboxLabeled(new Rect(10, y, 300, 22), "ShowHair.ShowHatsUnderNaturalRoof".Translate(), ref Settings.HideHatsNaturalRoof);
                     *      y += 30;
                     *  }
                     * }*/
                }
                y += 10;

                DrawTable(0f, y, 320f, ref scrollPosition, ref previousHatY, "ShowHair.Hats", "ShowHair.HatsDesc", ref leftTableSearchBuffer, Settings.HatsThatHide.Keys, null, Settings.HatsThatHide);
                DrawTable(340f, y, 300f, ref scrollPosition2, ref previousHairY, "ShowHair.HairThatWillBeHidden", "", ref rightTableSearchBuffer, Settings.HairToHide.Keys, Settings.HairToHide, null);

                if (this.mouseOverThingDef != null)
                {
                    if (this.putHatOnPawn)
                    {
                        if (this.previousHatDef != this.mouseOverThingDef)
                        {
                            if (this.previousHatDef != null)
                            {
                                if (this.spawnedHats.TryGetValue(this.previousHatDef, out ThingWithComps t))
                                {
                                    this.RemoveApparel(t);
                                }
                            }

                            if (this.mouseOverThingDef != null)
                            {
                                this.previousHatDef = this.mouseOverThingDef;
                                if (!spawnedHats.TryGetValue(this.mouseOverThingDef, out ThingWithComps thing))
                                {
                                    ThingDef stuff = GenStuff.RandomStuffFor(this.mouseOverThingDef);
                                    thing = ThingMaker.MakeThing(this.mouseOverThingDef, stuff) as ThingWithComps;
                                    thing.TryGetComp <CompQuality>()?.SetQuality(QualityUtility.GenerateQualityRandomEqualChance(), ArtGenerationContext.Colony);
                                    thing.stackCount = 1;
                                    this.spawnedHats.Add(thing.def, thing);
                                }
                                this.AddApparel(thing);
                                try
                                {
                                    this.pawn.Drawer.renderer.graphics.SetAllGraphicsDirty();
                                }
                                catch
                                {
                                    Log.ErrorOnce(msgErrorDirty, msgErrorDirty.GetHashCode() + 1);
                                }
                                PortraitsCache.SetDirty(this.pawn);
                            }
                        }
                    }
                    else
                    {
                        //Widgets.ThingIcon(new Rect(700f, y + 50, 50, 50), this.mouseOverThingDef);
                    }
                }
                if (this.pawn != null && this.mouseOverHairDef != null)
                {
                    if (this.mouseOverHairDef != this.previousHairDef)
                    {
                        this.previousHairDef = this.mouseOverHairDef;
                        if (this.mouseOverHairDef != null)
                        {
                            this.pawnBackupHairDef = this.pawn.story.hairDef;

                            this.pawn.story.hairDef = this.mouseOverHairDef;
                            try
                            {
                                this.pawn.Drawer.renderer.graphics.ResolveAllGraphics();
                            }
                            catch
                            {
                                Log.ErrorOnce(msgErrorDirty, msgErrorDirty.GetHashCode() + 9);
                            }
                            PortraitsCache.SetDirty(this.pawn);
                        }
                    }
                }

                if (pawn != null)
                {
                    y -= 60;
                    DrawPortraitWidget(630f, y + 150f);
                    bool b = this.putHatOnPawn;
                    Widgets.CheckboxLabeled(new Rect(650f, y + 350, 150, 30), "ShowHair.PutHatOnPawn".Translate(), ref this.putHatOnPawn);
                    if (b != this.putHatOnPawn)
                    {
                        Stack <Apparel> toRemove = new Stack <Apparel>();
                        foreach (Apparel a in this.pawn.apparel.WornApparel)
                        {
                            var layers = a.def.apparel?.layers;
                            if (layers != null && (layers.Contains(ApparelLayerDefOf.Overhead)))
                            {
                                toRemove.Push(a);
                            }
                        }
                        foreach (Apparel a in toRemove)
                        {
                            this.pawn.apparel.Remove(a);
                        }
                        try
                        {
                            this.pawn.Drawer.renderer.graphics.SetAllGraphicsDirty();
                        }
                        catch
                        {
                            Log.ErrorOnce(msgErrorDirty, msgErrorDirty.GetHashCode() + 2);
                        }
                        PortraitsCache.SetDirty(this.pawn);
                    }
                    Widgets.Label(new Rect(600f, y + 400, 75, 30), "ShowHair.HairColor".Translate());
                    if (Widgets.ButtonText(new Rect(680, y + 400, 50, 30), "ShowHair.WhiteHairColor".Translate()))
                    {
                        this.pawn.story.hairColor = Color.white;
                        try
                        {
                            this.pawn.Drawer.renderer.graphics.ResolveAllGraphics();
                        }
                        catch
                        {
                            Log.ErrorOnce(msgErrorDirty, msgErrorDirty.GetHashCode() + 5);
                        }
                        PortraitsCache.SetDirty(this.pawn);
                    }
                    if (Widgets.ButtonText(new Rect(740, y + 400, 50, 30), "ShowHair.YellowHairColor".Translate()))
                    {
                        this.pawn.story.hairColor = Color.yellow;
                        try
                        {
                            this.pawn.Drawer.renderer.graphics.ResolveAllGraphics();
                        }
                        catch
                        {
                            Log.ErrorOnce(msgErrorDirty, msgErrorDirty.GetHashCode() + 6);
                        }
                        PortraitsCache.SetDirty(this.pawn);
                    }
                    if (Widgets.ButtonText(new Rect(800, y + 400, 50, 30), "ShowHair.GreenHairColor".Translate()))
                    {
                        this.pawn.story.hairColor = Color.green;
                        try
                        {
                            this.pawn.Drawer.renderer.graphics.ResolveAllGraphics();
                        }
                        catch
                        {
                            Log.ErrorOnce(msgErrorDirty, msgErrorDirty.GetHashCode() + 7);
                        }
                        PortraitsCache.SetDirty(this.pawn);
                    }
                }
                else
                {
                    Widgets.Label(new Rect(650f, y + 150f, 200, 30), "ShowHair.StartGameToSeePawn".Translate());
                }
            }
        }
Ejemplo n.º 14
0
        public virtual void RegenerateStock()
        {
            TryDestroyStock();

            int raidsCount = Find.StoryWatcher.statsRecord.numRaidsEnemy - lastRaidsEnemy;

            lastRaidsEnemy = raidsCount;

            int   itemsCount = (int)itemsCountPerRaidCurve.Evaluate(raidsCount);
            float valueRange = startMarketValue + (marketValueMultiplierPerMapEvent * raidsCount);

            ThingSetMaker_MarketValue maker = new ThingSetMaker_MarketValue();

            ThingSetMakerParams parms = default;

            parms.totalMarketValueRange = new FloatRange(valueRange, valueRange);
            parms.countRange            = new IntRange(itemsCount, itemsCount);

            parms.filter = DarkNetPriceUtils.GetThingFilter(def.AvaliableGoods);

            maker.fixedParams = parms;

            var items = maker.Generate();

            stock = new List <SellableItemWithModif>();

            foreach (var item in items)
            {
                int itemValue = (int)(item.MarketValue * Character.Greed);

                if (PriceModificatorUtils.TryGetPriceModificator(item, def, out PriceModificatorDef modificator))
                {
                    itemValue = (int)(itemValue * modificator.PriceModficator);
                    DarkNetPriceUtils.FinalizeItem(item, modificator);
                }

                MinifiedThing minifiedThing = item as MinifiedThing;
                if (minifiedThing != null)
                {
                    var quality = minifiedThing.InnerThing.TryGetComp <CompQuality>();
                    if (quality != null)
                    {
                        quality.SetQuality(QualityUtility.GenerateQualityRandomEqualChance(), ArtGenerationContext.Colony);
                        itemValue = (int)(itemValue * GetPriceMultiplierForQuality(quality.Quality));
                    }
                }
                else
                {
                    var quality = item.TryGetComp <CompQuality>();
                    if (quality != null)
                    {
                        quality.SetQuality(QualityUtility.GenerateQualityRandomEqualChance(), ArtGenerationContext.Colony);
                        itemValue = (int)(itemValue * GetPriceMultiplierForQuality(quality.Quality));
                    }
                }

                stock.Add(new SellableItemWithModif(item, itemValue, modificator));
            }

            if (raidsCount >= minRaidsCountToGeneralGood && Rand.Chance(generalGoodsChance))
            {
                parms.totalMarketValueRange = new FloatRange(specialGoodMarketValue, specialGoodMarketValue);
                parms.countRange            = new IntRange(1, 1);
                parms.filter      = specialGoodsFilter;
                maker.fixedParams = parms;
                Thing generalGood = maker.Generate().FirstOrDefault();
                if (generalGood != null)
                {
                    goodOfTheWeek = new SellableItemWithModif(generalGood, (int)(generalGood.MarketValue * Character.Greed), null);
                }
            }
        }