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 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); }
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); }
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); }
public Thing FromRealmThing(RealmThing realmThing) { ThingDef thingDef = DefDatabase <ThingDef> .AllDefs.First((def) => { return(def.defName == realmThing.thingDefName); }); ThingDef stuffDef = null; if (realmThing.stuffDefName != "") { stuffDef = DefDatabase <ThingDef> .AllDefs.First((def) => { return(def.defName == realmThing.stuffDefName); }); } Thing thing = ThingMaker.MakeThing(thingDef, stuffDef); thing.stackCount = realmThing.stackCount; CompQuality compQuality = thing.TryGetComp <CompQuality>(); if (compQuality != null && realmThing.compQuality != -1) { compQuality.SetQuality((QualityCategory)realmThing.compQuality, ArtGenerationContext.Outsider); } thing.HitPoints = realmThing.hitPoints; // Minimified thing if (thing is MinifiedThing) { MinifiedThing minifiedThing = (MinifiedThing)thing; minifiedThing.InnerThing = FromRealmThing(realmThing.innerThing); } return(thing); }
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); }
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); } }
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)); } } }
public List <Thing> createProducts() { List <Thing> generatedProducts = new List <Thing>(); foreach (ProductConfig pc in products) { Thing t; if (pc.countClass.thingDef.MadeFromStuff) { t = ThingMaker.MakeThing(pc.countClass.thingDef, pc.stuff); } else { t = ThingMaker.MakeThing(pc.countClass.thingDef, null); } t.stackCount = pc.countClass.count; MinifiedThing minifiedThing = t as MinifiedThing; CompQuality compQuality = (minifiedThing == null) ? t.TryGetComp <CompQuality>() : minifiedThing.InnerThing.TryGetComp <CompQuality>(); if (compQuality != null) { compQuality.SetQuality(pc.quality, ArtGenerationContext.Outsider); } generatedProducts.Add(t); } return(generatedProducts); }
public Thing FromRealmThing(RealmThing realmThing) { ThingDef thingDef = DefDatabase <ThingDef> .AllDefs.First((def) => { return(def.label == realmThing.thingDefLabel); }); ThingDef stuffDef = null; if (realmThing.stuffDefLabel != "") { stuffDef = DefDatabase <ThingDef> .AllDefs.First((def) => { return(def.label == realmThing.stuffDefLabel); }); } Thing thing = ThingMaker.MakeThing(thingDef, stuffDef); thing.stackCount = realmThing.stackCount; CompQuality compQuality = thing.TryGetComp <CompQuality>(); if (compQuality != null && realmThing.compQuality != -1) { compQuality.SetQuality((QualityCategory)realmThing.compQuality, ArtGenerationContext.Outsider); } thing.HitPoints = realmThing.hitPoints; return(thing); }
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); }
// 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); }
// 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 override void PostPostMake() { CompQuality comp = base.parent.GetComp <CompQuality>(); QualityCategory offsetQuality = (QualityCategory)Mathf.Clamp((int)comp.Quality + Props.qualityChange, (int)QualityCategory.Awful, (int)QualityCategory.Legendary); // Will regenerate art in colony context in the MakeRecipeProducts patch comp.SetQuality(offsetQuality, ArtGenerationContext.Outsider); base.parent.AllComps.Remove(this); }
protected override void PostProcessRecipeProduct(Thing thing) { CompQuality compQuality = thing.TryGetComp <CompQuality>(); if (compQuality != null) { compQuality.SetQuality(GetRandomProductionQuality(), ArtGenerationContext.Colony); } }
public static void TrySpawnWeaponOnRack(Thing rack) { Building_Storage storage = rack as Building_Storage; QualityRange qualityRange = new QualityRange(QualityCategory.Good, QualityCategory.Legendary); storage.settings.filter.AllowedQualityLevels = qualityRange; FloatRange hitPointsRange = new FloatRange(0.8f, 1f); storage.settings.filter.AllowedHitPointsPercents = hitPointsRange; foreach (IntVec3 cell in rack.OccupiedRect()) { if (Rand.Value < 0.33f) { float weaponSelector = Rand.Value; ThingDef thingDef = ThingDefOf.Gun_Pistol; const float weaponsRatio = 1f / 7f; if (weaponSelector < weaponsRatio * 1f) { thingDef = ThingDef.Named("Gun_PumpShotgun"); } else if (weaponSelector < weaponsRatio * 2f) { thingDef = ThingDef.Named("Gun_AssaultRifle"); } else if (weaponSelector < weaponsRatio * 3f) { thingDef = ThingDef.Named("Gun_SniperRifle"); } else if (weaponSelector < weaponsRatio * 4f) { thingDef = ThingDef.Named("Gun_IncendiaryLauncher"); } else if (weaponSelector < weaponsRatio * 5f) { thingDef = ThingDef.Named("Gun_LMG"); } else if (weaponSelector < weaponsRatio * 6f) { thingDef = ThingDef.Named("Gun_ChargeRifle"); } else { thingDef = ThingDefOf.Gun_Pistol; } Thing weapon = ThingMaker.MakeThing(thingDef); CompQuality qualityComp = weapon.TryGetComp <CompQuality>(); if (qualityComp != null) { QualityCategory quality = (QualityCategory)Rand.RangeInclusive((int)QualityCategory.Normal, (int)QualityCategory.Excellent); qualityComp.SetQuality(quality, ArtGenerationContext.Outsider); } GenSpawn.Spawn(weapon, cell); } } }
// Token: 0x0600244E RID: 9294 RVA: 0x0011437D File Offset: 0x0011277D public void EditGun() { CompQuality Weapon_Quality = gun.TryGetComp <CompQuality>(); if (Weapon_Quality != null) { this.comp.parent.TryGetQuality(out QualityCategory Q); Weapon_Quality.SetQuality(Q, ArtGenerationContext.Outsider); } this.UpdateGunVerbs(); }
private static bool CompQuality_TradeQualityIncreaseDestructivePreFix(CompQuality __instance, TraderKindDef trader, int forTile, Faction forFaction) { //forTile is assigned in RimWorld.ThingSetMaker_TraderStock.Generate. It's either a best-effort map, or -1. Map map = null; if (forTile != -1) { map = Current.Game.FindMap(tile: forTile); } __instance.SetQuality(q: FactionAndGoodWillDependantQuality(faction: forFaction, map: map, trader: trader), source: ArtGenerationContext.Outsider); return(false); }
public override Thing CreateThing(bool useOriginalID = false, int stackCount = 0, bool needPirate = false) { //useOriginalID не используется. var def = (ThingDef)GenDefDatabase.GetDef(typeof(ThingDef), DefName); var stuffDef = !string.IsNullOrEmpty(StuffName) ? (ThingDef)GenDefDatabase.GetDef(typeof(ThingDef), StuffName) : null; Thing thing = !string.IsNullOrEmpty(StuffName) ? ThingMaker.MakeThing(def, stuffDef) : ThingMaker.MakeThing(def); thing.stackCount = stackCount > 0 ? stackCount : Count; if (HitPoints > 0) { thing.HitPoints = HitPoints; } SetFaction(thing, isColonist && !needPirate); CompQuality compQuality = thing.TryGetComp <CompQuality>(); if (compQuality != null) { compQuality.SetQuality((QualityCategory)Quality, ArtGenerationContext.Outsider); } if (WornByCorpse) { Apparel thingA = thing as Apparel; if (thingA != null) { typeof(Apparel) .GetField("wornByCorpseInt", BindingFlags.Instance | BindingFlags.NonPublic) .SetValue(thingA, true); } } thing.Rotation = new Rot4(Rotation); Plant thingP = thing as Plant; if (thingP != null) { thingP.Growth = Growth; } thing.Position = Position.Get(); return(thing); }
public static void TrySpawnWeaponOnRack(Thing rack) { foreach (IntVec3 cell in rack.OccupiedRect()) { if (Rand.Value < 0.33f) { float weaponSelector = Rand.Value; ThingDef thingDef = ThingDefOf.Gun_Pistol; const float weaponsRatio = 1f / 7f; if (weaponSelector < weaponsRatio * 1f) { thingDef = ThingDef.Named("Gun_PumpShotgun"); } else if (weaponSelector < weaponsRatio * 2f) { thingDef = ThingDef.Named("Gun_AssaultRifle"); } else if (weaponSelector < weaponsRatio * 3f) { thingDef = ThingDef.Named("Gun_SniperRifle"); } else if (weaponSelector < weaponsRatio * 4f) { thingDef = ThingDef.Named("Gun_IncendiaryLauncher"); } else if (weaponSelector < weaponsRatio * 5f) { thingDef = ThingDef.Named("Gun_LMG"); } else if (weaponSelector < weaponsRatio * 6f) { thingDef = ThingDef.Named("Bullet_ChargeRifle"); } else { thingDef = ThingDefOf.Gun_Pistol; } Thing weapon = ThingMaker.MakeThing(thingDef); CompQuality qualityComp = weapon.TryGetComp <CompQuality>(); if (qualityComp != null) { QualityCategory quality = (QualityCategory)Rand.RangeInclusive((int)QualityCategory.Normal, (int)QualityCategory.Superior); qualityComp.SetQuality(quality, ArtGenerationContext.Outsider); } GenSpawn.Spawn(weapon, cell); } } }
public static void EnhanceArmor(Pawn pawn, BodyPartRecord part, GeneSeedHediffWithComps geneSeedAvailable) { foreach (var apparel in pawn.apparel.WornApparel) { if (apparel.WornByCorpse) { apparel.Notify_PawnResurrected();//Artifacts are good. CompQuality compQuality = apparel.TryGetComp <CompQuality>(); compQuality.SetQuality(QualityCategory.Legendary, ArtGenerationContext.Colony); } apparel.HitPoints = (int)Math.Max(apparel.HitPoints, apparel.MaxHitPoints); } }
//Selects a random weapon type and improves it to a legendary status public ThingWithComps GenerateLegendaryWeapon() { ThingDef def; if (!(from td in DefDatabase <ThingDef> .AllDefs where this.HandlesWeaponDefs(td) select td).TryRandomElement(out def)) { return(null); } ThingWithComps thingWithComps = (ThingWithComps)ThingMaker.MakeThing(def, null); CompQuality compQuality = thingWithComps.TryGetComp <CompQuality>(); compQuality.SetQuality(QualityCategory.Legendary, ArtGenerationContext.Outsider); return(thingWithComps); }
public static void PostProcessProductPostfix(Thing product) { if (product.Stuff != Mythril) { return; } CompQuality comp = product.TryGetComp <CompQuality>(); if (comp == null) { return; } QualityCategory offsetQuality = (QualityCategory)Mathf.Clamp((int)comp.Quality + 1, (int)QualityCategory.Awful, (int)QualityCategory.Legendary); comp.SetQuality(offsetQuality, ArtGenerationContext.Colony); Messages.Message("D9MM_ThingMadeOfMythril".Translate(product.Label, offsetQuality.ToString()), product, MessageTypeDefOf.PositiveEvent); }
public static void PostProcessGeneratedGear(Thing gear, Pawn pawn) { CompQuality compQuality = gear.TryGetComp <CompQuality>(); if (compQuality != null) { compQuality.SetQuality(QualityUtility.RandomGeneratedGearQuality(pawn.kindDef), ArtGenerationContext.Outsider); } if (gear.def.useHitPoints) { float randomInRange = pawn.kindDef.gearHealthRange.RandomInRange; if (randomInRange < 1.0) { int b = Mathf.RoundToInt(randomInRange * (float)gear.MaxHitPoints); b = (gear.HitPoints = Mathf.Max(1, b)); } } }
public Thing CreateThing() { var def = (ThingDef)GenDefDatabase.GetDef(typeof(ThingDef), DefName); var stuffDef = !string.IsNullOrEmpty(StuffName) ? (ThingDef)GenDefDatabase.GetDef(typeof(ThingDef), StuffName) : null; Thing thing = !string.IsNullOrEmpty(StuffName) ? ThingMaker.MakeThing(def, stuffDef) : ThingMaker.MakeThing(def); thing.stackCount = Count; if (HitPoints > 0) { thing.HitPoints = HitPoints; } CompQuality compQuality = thing.TryGetComp <CompQuality>(); if (compQuality != null) { compQuality.SetQuality((QualityCategory)Quality, ArtGenerationContext.Outsider); } if (WornByCorpse) { Apparel thingA = thing as Apparel; if (thingA != null) { typeof(Apparel) .GetField("wornByCorpseInt", BindingFlags.Instance | BindingFlags.NonPublic) .SetValue(thingA, true); } } thing.Rotation = new Rot4(Rotation); Plant thingP = thing as Plant; if (thingP != null) { thingP.Growth = Growth; } return(thing); }
// Token: 0x06000062 RID: 98 RVA: 0x00006438 File Offset: 0x00004638 public static void CorrectActiveApparel(Apparel apparel, Pawn pawn = null) { Thing thing = ThingMaker.MakeThing(apparel.def, apparel.Stuff); if (QualityUtility.TryGetQuality(apparel, out QualityCategory qualityCategory)) { CompQuality compQuality = ThingCompUtility.TryGetComp <CompQuality>(thing); if (compQuality != null) { compQuality.SetQuality(qualityCategory, ArtGenerationContext.Colony); } } CompColorable compColorable = ThingCompUtility.TryGetComp <CompColorable>(apparel); if (compColorable != null) { CompColorable compColorable2 = ThingCompUtility.TryGetComp <CompColorable>(thing); if (compColorable2 != null) { compColorable2.Color = compColorable.Color; } } if (pawn != null) { pawn.apparel.Remove(apparel); apparel.Destroy(0); pawn.apparel.Wear(thing as Apparel, true, false); return; } if (apparel.Spawned) { IntVec3 intVec = IntVec3.Zero; Map map = apparel?.Map; if (map != null) { intVec = apparel.Position; } apparel.Destroy(0); if (intVec != IntVec3.Zero) { GenSpawn.Spawn(thing, intVec, map, 0); } } }
/// <summary> /// Try to generate a random treasure /// </summary> /// <returns></returns> private Thing TryGetTreasure() { Thing treasure = null; // find fitting treasure TreasureCollection foundTreasure = null; if (!def.treasureDefs.TryRandomElementByWeight <TreasureCollection>(f => f.Chance, out foundTreasure)) { return(null); } // make treasure if (foundTreasure == null) { return(null); } treasure = ThingMaker.MakeThing(foundTreasure.TreasureDef, foundTreasure.StuffDef); // try adjust quality CompQuality treasureCQ = treasure.TryGetComp <CompQuality>(); if (treasureCQ != null) { treasureCQ.SetQuality(QualityUtility.RandomCreationQuality(Rand.RangeInclusive(10, 20)), ArtGenerationContext.Outsider); } // adjust Stack to a random stack size if (foundTreasure.GiveStack && treasure.def.stackLimit > 1) { treasure.stackCount = Rand.RangeInclusive(1, treasure.def.stackLimit); } // adjust Hitpoints (60 to Max) if (treasure.stackCount == 1) { treasure.HitPoints = Rand.RangeInclusive((int)(treasure.MaxHitPoints * 0.6), treasure.MaxHitPoints); } return(treasure); }
public static List <Thing> GenerateApperalReward(int apperalCount) { List <Thing> returnList = new List <Thing>(); IEnumerable <ThingDef> apperalList = (from x in DefDatabase <ThingDef> .AllDefs where x.IsApparel == true && x.apparel.tags != null && (x.apparel.tags.Contains("SpacerMilitary") || x.apparel.tags.Contains("IndustrialAdvanced") || x.apparel.tags.Contains("BeltDefense") || x.apparel.tags.Contains("BeltDefensePop")) select x); for (int i = 0; i < apperalCount; i++) { ThingDef thingDef; ThingDef stuffDef = null; if (apperalList == null) { Log.Error("Potential apperal list count is 0"); break; } apperalList.TryRandomElement(out thingDef); if (thingDef == null) { Log.Error("Could not resolve thingdef to spawn apperal"); continue; } if (thingDef.MadeFromStuff) { if (!(from x in GenStuff.AllowedStuffsFor(thingDef, TechLevel.Undefined) where !PawnWeaponGenerator.IsDerpWeapon(thingDef, x) select x).TryRandomElementByWeight((ThingDef x) => x.stuffProps.commonality, out stuffDef)) { stuffDef = GenStuff.RandomStuffByCommonalityFor(thingDef, TechLevel.Undefined); } } Thing apperal = ThingMaker.MakeThing(thingDef, stuffDef); CompQuality compQuality = apperal.TryGetComp <CompQuality>(); if (compQuality != null) { compQuality.SetQuality(QualityUtility.GenerateQualityTraderItem(), ArtGenerationContext.Outsider); } returnList.Add(apperal); } return(returnList); }
public static void ScatterWeaponsWhere(CellRect within, int num, Map map, Predicate <ThingDef> validator) { List <ThingStuffPair> list = MapGenUtility.GetWeapons(validator); for (int i = 0; i < num; i++) { ThingStuffPair thingStuffPair = GenCollection.RandomElement <ThingStuffPair>(list); Thing thing = ThingMaker.MakeThing(thingStuffPair.thing, thingStuffPair.stuff); CompQuality compQuality = ThingCompUtility.TryGetComp <CompQuality>(thing); if (compQuality != null) { compQuality.SetQuality(QualityUtility.RandomCreationQuality(12), 0); } IntVec3 intVec; if (thing != null && CellFinder.TryFindRandomCellInsideWith(within, (IntVec3 loc) => GenGrid.Standable(loc, map), out intVec)) { GenSpawn.Spawn(thing, intVec, map); } } }