private static Thing PostProcessProduct(Thing product, RecipeDef recipeDef, Pawn worker) { CompQuality compQuality = product.TryGetComp <CompQuality>(); if (compQuality != null) { if (recipeDef.workSkill == null) { Log.Error(recipeDef + " needs workSkill because it creates a product with a quality."); } int level = worker.skills.GetSkill(recipeDef.workSkill).Level; QualityCategory qualityCategory = QualityUtility.RandomCreationQuality(level); if (worker.InspirationDef == InspirationDefOf.InspiredArt && (product.def.IsArt || (product.def.minifiedDef != null && product.def.minifiedDef.IsArt))) { qualityCategory = qualityCategory.AddLevels(3); worker.mindState.inspirationHandler.EndInspiration(InspirationDefOf.InspiredArt); } compQuality.SetQuality(qualityCategory, ArtGenerationContext.Colony); } CompArt compArt = product.TryGetComp <CompArt>(); if (compArt != null) { compArt.JustCreatedBy(worker); if ((int)compQuality.Quality >= 6) { TaleRecorder.RecordTale(TaleDefOf.CraftedArt, worker, product); } } if (product.def.Minifiable) { product = product.MakeMinified(); } return(product); }
public static void PostProcessGeneratedGear(Thing gear, Pawn pawn) { CompQuality compQuality = gear.TryGetComp <CompQuality>(); if (compQuality != null) { QualityCategory q = QualityUtility.GenerateQualityGeneratingPawn(pawn.kindDef); if (pawn.royalty != null && pawn.Faction != null) { RoyalTitleDef currentTitle = pawn.royalty.GetCurrentTitle(pawn.Faction); if (currentTitle != null) { q = (QualityCategory)Mathf.Clamp((int)QualityUtility.GenerateQualityGeneratingPawn(pawn.kindDef), (int)currentTitle.requiredMinimumApparelQuality, 6); } } compQuality.SetQuality(q, ArtGenerationContext.Outsider); } if (gear.def.useHitPoints) { float randomInRange = pawn.kindDef.gearHealthRange.RandomInRange; if (randomInRange < 1f) { int b = Mathf.RoundToInt(randomInRange * (float)gear.MaxHitPoints); b = (gear.HitPoints = Mathf.Max(1, b)); } } }
private static Thing CreateRandomItem(Pawn visitor, ThingDef thingDef) { ThingDef stuff = GenStuff.RandomStuffFor(thingDef); var item = ThingMaker.MakeThing(thingDef, stuff); item.stackCount = 1; CompQuality compQuality = item.TryGetComp <CompQuality>(); if (compQuality != null) { compQuality.SetQuality(QualityUtility.RandomGeneratedGearQuality(visitor.kindDef), ArtGenerationContext.Outsider); } if (item.def.Minifiable) { item = item.MakeMinified(); } if (item.def.useHitPoints) { // Make sure health is at least 60%. Otherwise too expensive items can become gifts. const float minHealthPct = 0.6f; var healthRange = visitor.kindDef.gearHealthRange; healthRange.min = minHealthPct; healthRange.max = Mathf.Max(minHealthPct, healthRange.max); var healthPct = healthRange.RandomInRange; if (healthPct < 1) { int num = Mathf.RoundToInt(healthPct * item.MaxHitPoints); num = Mathf.Max(1, num); item.HitPoints = num; } } return(item); }
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.RandomQuality(), ArtGenerationContext.Colony); } if (thing.def.Minifiable) { thing = thing.MakeMinified(); } thing.stackCount = stackCount; if (direct) { GenPlace.TryPlaceThing(thing, c, Find.VisibleMap, ThingPlaceMode.Direct, null); } else { GenPlace.TryPlaceThing(thing, c, Find.VisibleMap, ThingPlaceMode.Near, null); } }
// Token: 0x06000041 RID: 65 RVA: 0x000049B0 File Offset: 0x00002BB0 internal static float GetQualFactor(Apparel apparel) { if (QualityUtility.TryGetQuality(apparel, out QualityCategory qualityCategory)) { switch (qualityCategory) { case QualityCategory.Awful: return(0.96f); case QualityCategory.Poor: return(0.98f); case QualityCategory.Normal: return(1f); case QualityCategory.Good: return(1.02f); case QualityCategory.Excellent: return(1.04f); case QualityCategory.Masterwork: return(1.06f); case QualityCategory.Legendary: return(1.08f); default: break; } } return(1f); }
public static void Postfix(ref int relevantSkillLevel, ref bool inspired, ref QualityCategory __result) { if (relevantSkillLevel >= minSkillLegendary && __result < QualityCategory.Legendary && Rand.Chance(legendaryChanceAt20 - ((20 - relevantSkillLevel) * gradientLegendary))) { __result = QualityCategory.Legendary; } else if (relevantSkillLevel >= minSkillMasterwork && __result < QualityCategory.Masterwork) { __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired); } else if (relevantSkillLevel >= minSkillExcellent && __result < QualityCategory.Excellent) { __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired); } else if (relevantSkillLevel >= minSkillGood && __result < QualityCategory.Good) { __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired); } else if (relevantSkillLevel >= minSkillNormal && __result < QualityCategory.Normal) { __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired); } else if (relevantSkillLevel >= minSkillPoor && __result < QualityCategory.Poor) { __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired); } }
protected void DoEffect() { Thing target = base.TargetA.Thing; Map map = target.Map; target.Destroy(DestroyMode.WillReplace); Thing wall = ThingMaker.MakeThing(ThingDef.Named("Engraved" + target.def.building.unsmoothedThing.defName), target.Stuff); CompQuality compQuality = wall.TryGetComp <CompQuality>(); if (compQuality != null) { int level = this.pawn.skills.GetSkill(SkillDefOf.Artistic).Level; QualityCategory qualityCategory = QualityUtility.GenerateQualityCreatedByPawn(level, false); compQuality.SetQuality(qualityCategory, ArtGenerationContext.Colony); } CompArt compArt = wall.TryGetComp <CompArt>(); if (compArt != null) { compArt.JustCreatedBy(this.pawn); if (compQuality.Quality >= QualityCategory.Excellent) { TaleRecorder.RecordTale(TaleDefOf.CraftedArt, new object[] { this.pawn, wall }); } } wall.SetFaction(this.pawn.Faction, null); GenSpawn.Spawn(wall, target.Position, map, target.Rotation, WipeMode.Vanish, false); map.designationManager.TryRemoveDesignation(target.Position, DesignationDefOf.EngraveWall); }
public static void Postfix(ref int relevantSkillLevel, ref bool inspired, ref QualityCategory __result) { try { if (relevantSkillLevel >= minSkill[(int)QualityCategory.Legendary] && __result < QualityCategory.Legendary && Rand.Chance(legendaryChanceAt20 - ((20 - relevantSkillLevel) * gradientLegendary))) { __result = QualityCategory.Legendary; } else if (relevantSkillLevel >= minSkill[(int)QualityCategory.Masterwork] && __result < QualityCategory.Masterwork) { __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired); } else if (relevantSkillLevel >= minSkill[(int)QualityCategory.Excellent] && __result < QualityCategory.Excellent) { __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired); } else if (relevantSkillLevel >= minSkill[(int)QualityCategory.Good] && __result < QualityCategory.Good) { __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired); } else if (relevantSkillLevel >= minSkill[(int)QualityCategory.Normal] && __result < QualityCategory.Normal) { __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired); } else if (relevantSkillLevel >= minSkill[(int)QualityCategory.Poor] && __result < QualityCategory.Poor) { __result = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, inspired); } } catch (Exception ex) { Log.Error(ex.ToString()); } }
public static ThingTrade CreateTrade(Thing thing, int count) { var that = new ThingTrade(); that.SetBaseInfo(thing, count); //Data заполняется! that.DataThing = thing; that.Concrete = true; that.DefName = thing.def.defName; that.StuffName = thing.Stuff == null ? null : thing.Stuff.defName; that.HitPoints = thing.HitPoints; that.MaxHitPoints = thing.MaxHitPoints; QualityCategory qq; if (QualityUtility.TryGetQuality(thing, out qq)) { that.Quality = (int)qq; } Apparel thingA = thing as Apparel; if (thingA != null) { that.WornByCorpse = thingA.WornByCorpse; } return(that); }
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); } }
public static List <Thing> GenerateWeaponsCacheReward(int gunCount) { List <Thing> returnList = new List <Thing>(); IEnumerable <ThingDef> weaponList = (from x in ThingSetMakerUtility.allGeneratableItems where x.weaponTags != null && (x.weaponTags.Contains("SpacerGun") || x.weaponTags.Contains("SniperRifle") || x.weaponTags.Contains("GunHeavy") || x.weaponTags.Contains("IndustrialGunAdvanced")) select x); for (int i = 0; i < gunCount; i++) { ThingDef thingDef; weaponList.TryRandomElement(out thingDef); if (thingDef == null) { Log.Error("Could not resolve thingdef to spawn weapons"); continue; } Thing weapon = ThingMaker.MakeThing(thingDef); CompQuality compQuality = weapon.TryGetComp <CompQuality>(); if (compQuality != null) { compQuality.SetQuality(QualityUtility.GenerateQualityTraderItem(), ArtGenerationContext.Outsider); } returnList.Add(weapon); } return(returnList); }
/// <summary> /// Change quality carried by traders depending on Faction/Goodwill/Wealth. /// </summary> /// <returns>QualityCategory depending on wealth or goodwill. Fallsback to vanilla when fails.</returns> private static QualityCategory FactionAndGoodWillDependantQuality(Faction faction, Map map, TraderKindDef trader) { if ((trader.orbital || trader.defName.Contains(value: "_Base")) && map != null) { if (Rand.Value < 0.25f) { return(QualityCategory.Normal); } float num = Rand.Gaussian(centerX: WealthQualityDeterminationCurve.Evaluate(x: map.wealthWatcher.WealthTotal), widthFactor: WealthQualitySpreadDeterminationCurve.Evaluate(x: map.wealthWatcher.WealthTotal)); num = Mathf.Clamp(value: num, min: 0f, max: QualityUtility.AllQualityCategories.Count - 0.5f); return((QualityCategory)num); } if (map != null && faction != null) { float qualityIncreaseFromTimesTradedWithFaction = Mathf.Clamp01(value: (float)map.GetComponent <MapComponent_GoodWillTrader>().TimesTraded[key: faction] / 100); float qualityIncreaseFactorFromPlayerGoodWill = Mathf.Clamp01(value: (float)faction.GoodwillWith(other: Faction.OfPlayer) / 100); if (Rand.Value < 0.25f) { return(QualityCategory.Normal); } float num = Rand.Gaussian(centerX: 2.5f + qualityIncreaseFactorFromPlayerGoodWill, widthFactor: 0.84f + qualityIncreaseFromTimesTradedWithFaction); num = Mathf.Clamp(value: num, min: 0f, max: QualityUtility.AllQualityCategories.Count - 0.5f); return((QualityCategory)num); } return(QualityUtility.GenerateQualityTraderItem()); }
private static Thing PostProcessProduct(Thing product, RecipeDef recipeDef, IRecipeProductWorker worker) { CompQuality compQuality = product.TryGetComp <CompQuality>(); if (compQuality != null) { if (recipeDef.workSkill == null) { Log.Error(recipeDef + " needs workSkill because it creates a product with a quality."); } int level = worker.GetSkillLevel(recipeDef.workSkill); QualityCategory qualityCategory = QualityUtility.GenerateQualityCreatedByPawn(level, false); compQuality.SetQuality(qualityCategory, ArtGenerationContext.Colony); } CompArt compArt = product.TryGetComp <CompArt>(); if (compArt != null) { if (compQuality.Quality >= QualityCategory.Excellent) { /* * TaleRecorder.RecordTale(TaleDefOf.CraftedArt, new object[] * { * product * }); */ } } if (product.def.Minifiable) { product = product.MakeMinified(); } return(product); }
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)); }
private static Thing CreateRandomItem(Pawn visitor, ThingDef thingDef) { ThingDef stuff = GenStuff.RandomStuffFor(thingDef); var item = ThingMaker.MakeThing(thingDef, stuff); item.stackCount = 1; CompQuality compQuality = item.TryGetComp <CompQuality>(); if (compQuality != null) { compQuality.SetQuality(QualityUtility.RandomGeneratedGearQuality(visitor.kindDef), ArtGenerationContext.Outsider); } if (item.def.Minifiable) { item = item.MakeMinified(); } if (item.def.useHitPoints) { float randomInRange = visitor.kindDef.gearHealthRange.RandomInRange; if (randomInRange < 1f) { int num = Mathf.RoundToInt(randomInRange * item.MaxHitPoints); num = Mathf.Max(1, num); item.HitPoints = num; } } return(item); }
// Token: 0x0600001B RID: 27 RVA: 0x00003198 File Offset: 0x00001398 internal static int GetQualOffset(Apparel apparel) { if (QualityUtility.TryGetQuality(apparel, out QualityCategory qualityCategory)) { switch (qualityCategory) { case QualityCategory.Awful: return(-10); case QualityCategory.Poor: return(-5); case QualityCategory.Normal: return(0); case QualityCategory.Good: return(5); case QualityCategory.Excellent: return(10); case QualityCategory.Masterwork: return(15); case QualityCategory.Legendary: return(20); default: break; } } return(0); }
private static Thing PostProcessProduct(Thing product, RecipeDef recipeDef, Pawn worker) { CompQuality compQuality = product.TryGetComp <CompQuality>(); if (compQuality != null) { if (recipeDef.workSkill == null) { Log.Error(recipeDef + " needs workSkill because it creates a product with a quality.", false); } QualityCategory q = QualityUtility.GenerateQualityCreatedByPawn(worker, recipeDef.workSkill); compQuality.SetQuality(q, ArtGenerationContext.Colony); QualityUtility.SendCraftNotification(product, worker); } CompArt compArt = product.TryGetComp <CompArt>(); if (compArt != null) { compArt.JustCreatedBy(worker); if (compQuality.Quality >= QualityCategory.Excellent) { TaleRecorder.RecordTale(TaleDefOf.CraftedArt, new object[] { worker, product }); } } if (product.def.Minifiable) { product = product.MakeMinified(); } return(product); }
// Token: 0x0600009F RID: 159 RVA: 0x00004884 File Offset: 0x00002A84 protected override float GetFinalQuality() { var num = (float)GetQualityModifier(QualityUtility.GenerateQualityCreatedByPawn(Lead, SkillDefOf.Social)); var num2 = (float)GetQualityModifier(QualityUtility.GenerateQualityCreatedByPawn(Lead, SkillDefOf.Artistic)); return(Lead.health.capacities.GetLevel(PawnCapacityDefOf.Talking) * Rand.Range(num, num + num2)); }
// Token: 0x06000018 RID: 24 RVA: 0x0000322C File Offset: 0x0000142C private static Thing PostProcessProduct(Thing product, RecipeDef recipeDef, Pawn worker) { string[] array = new string[6]; array[0] = "post processing: product "; int num = 1; Thing thing = product; array[num] = ((thing != null) ? thing.ToString() : null); array[2] = " recipeDef "; array[3] = ((recipeDef != null) ? recipeDef.ToString() : null); array[4] = " worker "; array[5] = ((worker != null) ? worker.ToString() : null); Log.Message(string.Concat(array), false); CompQuality compQuality = product.TryGetComp <CompQuality>(); bool flag = compQuality != null; if (flag) { bool flag2 = recipeDef.workSkill == null; if (flag2) { Log.Error(((recipeDef != null) ? recipeDef.ToString() : null) + " needs workSkill because it creates a product with a quality.", false); } int relevantSkillLevel = 1; QualityCategory q = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, false); bool flag3 = worker.InspirationDef == InspirationDefOf.Inspired_Creativity && (product.def.IsArt || (product.def.minifiedDef != null && product.def.minifiedDef.IsArt)); if (flag3) { int relevantSkillLevel2 = 4; q = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel2, false); } compQuality.SetQuality(q, ArtGenerationContext.Colony); } CompArt compArt = product.TryGetComp <CompArt>(); bool flag4 = compArt != null; if (flag4) { compArt.JustCreatedBy(worker); } bool minifiable = product.def.Minifiable; if (minifiable) { product = product.MakeMinified(); } string[] array2 = new string[6]; array2[0] = "end post processing:product "; int num2 = 1; Thing thing2 = product; array2[num2] = ((thing2 != null) ? thing2.ToString() : null); array2[2] = " recipeDef "; array2[3] = ((recipeDef != null) ? recipeDef.ToString() : null); array2[4] = " worker "; array2[5] = ((worker != null) ? worker.ToString() : null); Log.Message(string.Concat(array2), false); return(product); }
private Thing TryAddQualityToThing(Thing thing) { if (thing.TryGetQuality(out QualityCategory qualityCategory)) { thing.TryGetComp <CompQuality>().SetQuality(QualityUtility.GenerateQualityTraderItem(), ArtGenerationContext.Outsider); } return(thing); }
// Token: 0x06000004 RID: 4 RVA: 0x00002160 File Offset: 0x00000360 private List <Thing> CreateLoot() { List <Thing> list = new List <Thing>(); int ItemCount; if (PropsResourceBox.spawnAll) { ItemCount = PropsResourceBox.possibleItems.Count; } else { ItemCount = Rand.RangeInclusive(PropsResourceBox.minItems, PropsResourceBox.maxItems); } for (int i = 0; i < ItemCount; i++) { ThingDef named = null; int PerItemCount; int j = 0; if (PropsResourceBox.PerItemCount != 0) { PerItemCount = PropsResourceBox.PerItemCount; } else { PerItemCount = Rand.RangeInclusive(PropsResourceBox.minPerItem, PropsResourceBox.maxPerItem); } if (!PropsResourceBox.possibleItems.NullOrEmpty()) { if (PropsResourceBox.spawnAll) { named = PropsResourceBox.possibleItems[i]; } else { named = PropsResourceBox.possibleItems.RandomElement(); } } if (named != null) { Thing thing = ThingMaker.MakeThing(named, GenStuff.RandomStuffFor(named)); thing.stackCount = PerItemCount; CompQuality compQuality = ThingCompUtility.TryGetComp <CompQuality>(thing); if (compQuality != null) { QualityCategory qualityCategory = QualityUtility.GenerateQualityCreatedByPawn(Rand.RangeInclusive(0, 19), false); compQuality.SetQuality(qualityCategory, 0); } CompArt compArt = ThingCompUtility.TryGetComp <CompArt>(thing); if (compArt != null) { compArt.InitializeArt(0); } list.Add(thing); } } return(list); }
public static ThingTrade CreateTrade(Thing thing, int count, bool withData = true) { var that = new ThingTrade(); that.SetBaseInfo(thing, count); if (withData) { that.SetData(thing); } that.DataThing = thing; that.Concrete = true; that.DefName = thing.def.defName; that.StuffName = thing.Stuff == null ? null : thing.Stuff.defName; var pawn = thing as Pawn; if (pawn == null) { that.HitPoints = thing.HitPoints; that.MaxHitPoints = thing.MaxHitPoints; } else { that.HitPoints = (int)(pawn.health.summaryHealth.SummaryHealthPercent * 100f); that.MaxHitPoints = 100; } QualityCategory qq; if (QualityUtility.TryGetQuality(thing, out qq)) { that.Quality = (int)qq; } Apparel thingA = thing as Apparel; if (thingA != null) { that.WornByCorpse = thingA.WornByCorpse; } that.Rotation = thing.Rotation.AsInt; Plant thingP = thing as Plant; if (thingP != null) { that.Growth = thingP.Growth; } that.Position = new IntVec3S(thing.Position); return(that); }
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); }
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); } } } }
public static void PostProcessGeneratedGear(Thing gear, Pawn pawn) { gear.TryGetComp <CompQuality>()?.SetQuality(QualityUtility.GenerateQualityGeneratingPawn(pawn.kindDef), ArtGenerationContext.Outsider); if (gear.def.useHitPoints) { float randomInRange = pawn.kindDef.gearHealthRange.RandomInRange; if (randomInRange < 1f) { int b = Mathf.RoundToInt(randomInRange * (float)gear.MaxHitPoints); b = (gear.HitPoints = Mathf.Max(1, b)); } } }
// Token: 0x0600008B RID: 139 RVA: 0x000041B8 File Offset: 0x000023B8 protected virtual float GetFinalQuality() { var num = (float)GetQualityModifier(Venue.artQuality); var num2 = (float)GetQualityModifier(QualityUtility.GenerateQualityCreatedByPawn(Lead, SkillDefOf.Social)); var statModifier = GetStatModifier(); if (Venue.VenueDef.performersNeeded > 1) { num2 = (0.6f * num2) + (0.4f * (float)GetQualityModifier(QualityUtility.GenerateQualityCreatedByPawn(Support, SkillDefOf.Social))); } num2 *= statModifier; return(Rand.Range(num2, num2 + num)); }
public static void FinalizeReplace(Thing thing, ThingDef stuff, Pawn worker = null) { DeconstructDropStuff(thing); thing.ChangeStuff(stuff); if (worker != null && thing.TryGetComp <CompQuality>() is CompQuality compQuality) { QualityCategory qualityCreatedByPawn = QualityUtility.GenerateQualityCreatedByPawn(worker, SkillDefOf.Construction); compQuality.SetQuality(qualityCreatedByPawn, ArtGenerationContext.Colony); QualityUtility.SendCraftNotification(thing, worker); } }
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); }
public static void FinalizeReplace(Thing thing, ThingDef stuff, Pawn worker = null) { DeconstructDropStuff(thing); thing.SetStuffDirect(stuff); thing.HitPoints = thing.MaxHitPoints; //Deconstruction/construction implicitly repairs thing.Notify_ColorChanged(); if (worker != null && thing.TryGetComp <CompQuality>() is CompQuality compQuality) { QualityCategory qualityCreatedByPawn = QualityUtility.GenerateQualityCreatedByPawn(worker, SkillDefOf.Construction); compQuality.SetQuality(qualityCreatedByPawn, ArtGenerationContext.Colony); QualityUtility.SendCraftNotification(thing, worker); } }
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); }