public static Thing MakeThingWithoutID(this ThingStuffPair pair) { if (pair.thing.MadeFromStuff && pair.stuff == null) { pair.stuff = AwesomeInventoryStuffDefOf.AwesomeInventoryGenericResource; } if (pair.stuff != null && !pair.stuff.IsStuff) { Log.Error("MakeThing error: Tried to make " + pair.thing + " from " + pair.stuff + " which is not a stuff. Assigning default."); pair.stuff = GenStuff.DefaultStuffFor(pair.thing); } if (!pair.thing.MadeFromStuff && pair.stuff != null) { Log.Error("MakeThing error: " + pair.thing + " is not madeFromStuff but stuff=" + pair.stuff + ". Setting to null."); pair.stuff = null; } Thing thing = (Thing)Activator.CreateInstance(pair.thing.thingClass); thing.def = pair.thing; thing.SetStuffDirect(pair.stuff); if (thing.def.useHitPoints) { thing.HitPoints = thing.MaxHitPoints; } if (thing is ThingWithComps thingWithComps) { thingWithComps.InitializeComps(); } return(thing); }
public override void Resolve(ResolveParams rp) { //Add rubble ResolveParams resolveParamsDebris = rp; BaseGen.symbolStack.Push("scatterRubbleLGE", resolveParamsDebris); //set up variables for the rooms to skip floors and walls to give the ruined look int roomCount = rp.rect.Width * rp.rect.Height / 30; ResolveParams resolveParams = rp; resolveParams.chanceToSkipWallBlock = 0.38f; resolveParams.chanceToSkipFloor = 0.38f; resolveParams.noRoof = true; for (int i = 0; i < roomCount; i++) { int width = Rand.RangeInclusive(3, 12); int height = Rand.RangeInclusive(3, 12); resolveParams.wallStuff = GenStuff.RandomStuffInexpensiveFor(ThingDefOf.Wall, TechLevel.Industrial); resolveParams.floorDef = BaseGenUtility.CorrespondingTerrainDef(resolveParams.wallStuff, true); resolveParams.rect = new CellRect(Rand.RangeInclusive(rp.rect.minX, rp.rect.maxX - width), Rand.RangeInclusive(rp.rect.minZ, rp.rect.maxZ - height), width, height); BaseGen.symbolStack.Push("emptyRoom", resolveParams); } //Clear out the entire map (including roofs) rp.clearRoof = true; BaseGen.symbolStack.Push("clear", rp); }
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); } }
public static List <IPCInterface.Rows.Apparel> Get() { ceSharpStatWorker = StatDef.Named("BodyPartSharpArmor")?.workerClass?.Assembly.GetName().Name?.Equals("CombatExtended") ?? false; ceBluntStatWorker = StatDef.Named("BodyPartBluntArmor")?.workerClass?.Assembly.GetName().Name?.Equals("CombatExtended") ?? false; var rows = new List <IPCInterface.Rows.Apparel>(); var dataSources = from d in DefDatabase <ThingDef> .AllDefs where d.IsApparel orderby d.BaseMarketValue select d; foreach (var d in dataSources) { if (d.MadeFromStuff) { ThingDef defStuff = GenStuff.DefaultStuffFor(d); foreach (var stuff in GenStuff.AllowedStuffsFor(d)) { rows.Add(MakeRow(d, defStuff, stuff)); } } else { rows.Add(MakeRow(d)); } } return(rows); }
public override Table?Create() { //_statDefs = DefDatabase<StatDef>.AllDefsListForReading; Table table = new(Name); var defs = from d in DefDatabase <ThingDef> .AllDefs where d.IsApparel orderby d.BaseMarketValue select d; foreach (var d in defs) { if (!UseDefStuff && d.MadeFromStuff) { ThingDef defStuff = GenStuff.DefaultStuffFor(d); foreach (var stuff in GenStuff.AllowedStuffsFor(d)) { MakeRow(table, d, defStuff, stuff); } } else { MakeRow(table, d); } } // удаление мусора после брута StatDef. все колонки где значение одинаковые для всех строк // ClearEqualsColumns(table); return(table); }
private void TrySpawnSandbags(IntVec3 c, Map map, Faction faction, ThingDef stuff) { if (!c.InBounds(map)) { return; } if (TryClearCell(c, map)) { // Try and make it buildable if (!GenConstruct.CanBuildOnTerrain(DefToUse, c, map, Rot4.North)) { if (GenConstruct.CanBuildOnTerrain(TerrainDefOf.PavedTile, c, map, Rot4.North)) { map.terrainGrid.SetTerrain(c, TerrainDefOf.PavedTile); } else if (GenConstruct.CanBuildOnTerrain(TerrainDefOf.Bridge, c, map, Rot4.North)) { map.terrainGrid.SetTerrain(c, TerrainDefOf.Bridge); } } if (!GenConstruct.CanBuildOnTerrain(DefToUse, c, map, Rot4.North)) { return; } var usedStuff = DefToUse.MadeFromStuff ? (stuff ?? GenStuff.DefaultStuffFor(DefToUse)) : null; Thing thing = ThingMaker.MakeThing(DefToUse, usedStuff); thing.SetFaction(faction, null); GenSpawn.Spawn(thing, c, map, WipeMode.Vanish); } }
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); }
private static ArgWorker.ItemProxy GenerateItem() { var proxy = new ArgWorker.ItemProxy { Thing = Data.Items.Where(i => i.Thing != null) .Where(i => i.Thing.race == null) .Where(i => i.Cost > 200 && i.Cost < 2000) .InRandomOrder() .FirstOrDefault() }; if (proxy.Thing == null) { return(null); } if (!proxy.Thing.Thing.MadeFromStuff) { return(proxy); } ThingDef stuff = GenStuff.RandomStuffByCommonalityFor(proxy.Thing.Thing); proxy.Stuff = Data.Items.Find(i => string.Equals(i.DefName, stuff.defName)); return(proxy); }
private void GenerateWeapons(IntVec3 t) { MapParent parent = (MapParent)this.parent; if (!DefDatabase <ThingDef> .AllDefs.Where(def => def.IsWeapon && def.BaseMarketValue > 20 && def.techLevel <= parent.Faction.def.techLevel && !def.label.Contains("tornado") && !def.label.Contains("orbital")).TryRandomElement(out ThingDef thingDef)) { Log.Error("Didn't find a sutiable weapon def for supplydepot which shouldn't happen"); return; } for (int i = 0; i < 2; i++) { Thing weapon = ThingMaker.MakeThing(thingDef, GenStuff.RandomStuffByCommonalityFor(thingDef, parent.Faction.def.techLevel)); weapon.TryGetComp <CompQuality>().SetQuality(Rand.Chance(0.5f) ? QualityCategory.Good : Rand.Chance(0.75f) ? QualityCategory.Excellent : QualityCategory.Normal, ArtGenerationContext.Outsider); if (Prefs.DevMode) { Log.Warning("Spawning: " + weapon.Label); } if (t != new IntVec3() && !RCellFinder.TryFindRandomCellNearWith(t, x => x.Standable(parent.Map) && x.Roofed(parent.Map) && !x.Filled(parent.Map), parent.Map, out t, 1, 30)) { Log.Warning("t failed to find cell"); return; } if (t == new IntVec3() && !RCellFinder.TryFindRandomCellNearTheCenterOfTheMapWith(x => x.Roofed(parent.Map) && !x.Filled(parent.Map) && x.IsValid && x.Standable(parent.Map), parent.Map, out t)) { return; } GenSpawn.Spawn(weapon, t, parent.Map); } }
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 DrawMouseAttachmentWithThing(this ThingDef thingDef, ThingDef stuffDef) { if (!(thingDef.uiIcon == null) && !(thingDef.uiIcon == BaseContent.BadTex)) { Color color; if (stuffDef != null) { color = thingDef.GetColorForStuff(stuffDef); } else { color = thingDef.MadeFromStuff ? thingDef.GetColorForStuff(GenStuff.DefaultStuffFor(thingDef)) : thingDef.uiIconColor; } Rect dragRect = new Rect(Verse.UI.GUIToScreenPoint(Event.current.mousePosition) + new Vector2(GenUI.SmallIconSize / 2, 0), new Vector2(GenUI.SmallIconSize, GenUI.SmallIconSize)); Find.WindowStack.ImmediateWindow( Rand.Int, dragRect, WindowLayer.Super, () => { GUI.color = color; GUI.DrawTexture(dragRect.AtZero(), thingDef.uiIcon); GUI.color = Color.white; }, false); } }
private static float CostToMake(ThingDef d, bool real = false) { if (d.recipeMaker == null) { return(d.BaseMarketValue); } float num = 0f; if (d.costList != null) { foreach (ThingDefCountClass cost in d.costList) { float num2 = 1f; if (real) { num2 = ((!RequiresBuying(cost.thingDef)) ? 0.6f : 1.4f); } num += (float)cost.count * CostToMake(cost.thingDef, real: true) * num2; } } if (d.costStuffCount > 0) { ThingDef thingDef = GenStuff.DefaultStuffFor(d); num += (float)d.costStuffCount * thingDef.BaseMarketValue; } return(num); }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; bool @bool = Rand.Bool; ThingDef thingDef = rp.singleThingDef ?? Rand.Element(ThingDefOf.Bed, ThingDefOf.Bedroll, ThingDefOf.SleepingSpot); ThingDef singleThingStuff = rp.singleThingStuff ?? GenStuff.RandomStuffByCommonalityFor(thingDef, (rp.faction != null) ? rp.faction.def.techLevel : TechLevel.Undefined); foreach (IntVec3 item in rp.rect) { IntVec3 current = item; if (@bool) { if (current.x % 3 == 0 && current.z % 2 == 0) { goto IL_00d5; } } else if (current.x % 2 == 0 && current.z % 3 == 0) { goto IL_00d5; } continue; IL_00d5: Rot4 rot = (!@bool) ? Rot4.North : Rot4.West; if (!GenSpawn.WouldWipeAnythingWith(current, rot, thingDef, map, (Thing x) => x.def.category == ThingCategory.Building) && !BaseGenUtility.AnyDoorAdjacentCardinalTo(GenAdj.OccupiedRect(current, rot, thingDef.Size), map)) { ResolveParams resolveParams = rp; resolveParams.rect = GenAdj.OccupiedRect(current, rot, thingDef.size); resolveParams.singleThingDef = thingDef; resolveParams.singleThingStuff = singleThingStuff; resolveParams.thingRot = rot; BaseGen.symbolStack.Push("bed", resolveParams); } } }
public override void Execute(int amount, string boughtBy) { ThingDef itemDef = DefDatabase <ThingDef> .GetNamed(defName); String dropMessage; // I hope no viewer uses RC with the name "Poll" if (boughtBy == "Poll") { dropMessage = $"<color=#9147ff>By popular opinion</color>, your channel has gifted you {amount} {defLabel}s for your colony. Enjoy!!"; } else { dropMessage = $"<color=#9147ff>{boughtBy}</color> purchased {amount} {defLabel}s for your colony. Enjoy!!"; } if (itemDef.race != null) { List <Thing> pawnList = new List <Thing>(); for (int i = 0; i < amount; i++) { pawnList.Add(PawnGenerator.GeneratePawn(itemDef.race.AnyPawnKind, null)); } DropPodManager.createDropOfThings(pawnList, defLabel, dropMessage); } else { Thing thing = ThingMaker.MakeThing(itemDef, GenStuff.DefaultStuffFor(itemDef)); bool thingHasQuality = thing.TryGetQuality(out QualityCategory qualityCategory); if (itemDef.MadeFromStuff || itemDef.Minifiable || thingHasQuality) { List <Thing> thingsToSpawn = new List <Thing>(); for (int i = 0; i < amount; i++) { ThingDef itemStuff = null; if (itemDef.MadeFromStuff) { itemStuff = GenStuff.RandomStuffByCommonalityFor(itemDef); } Thing newThing = ThingMaker.MakeThing(itemDef, itemStuff); TryAddQualityToThing(newThing); if (itemDef.Minifiable) { newThing = newThing.MakeMinified(); } thingsToSpawn.Add(newThing); } DropPodManager.createDropOfThings(thingsToSpawn, defLabel, dropMessage); } // If Our item doesn't have stuff, is minifiable, or doesn't have quality // we can spawn it the old way with the itemdef else { DropPodManager.createDropFromDef(itemDef, amount, defLabel, dropMessage); } } }
public override void TryExecute() { ThingDef itemDef = ThingDef.Named("DropPodIncoming"); Thing itemThing = new Thing(); ThingDef stuff = null; ThingDef itemThingDef = ThingDef.Named(item.defname); if (itemThingDef.race != null) { TryExecuteAnimal(itemThingDef, quantity); return; } if (itemThingDef.MadeFromStuff) { if (!(from x in GenStuff.AllowedStuffsFor(itemThingDef, TechLevel.Undefined) where !PawnWeaponGenerator.IsDerpWeapon(itemThingDef, x) select x).TryRandomElementByWeight((ThingDef x) => x.stuffProps.commonality, out stuff)) { stuff = GenStuff.RandomStuffByCommonalityFor(itemThingDef, TechLevel.Undefined); } } itemThing = ThingMaker.MakeThing(itemThingDef, (stuff != null) ? stuff : null); QualityCategory q = new QualityCategory(); if (itemThing.TryGetQuality(out q)) { ItemHelper.setItemQualityRandom(itemThing); } Map map = Helper.AnyPlayerMap; IntVec3 vec = DropCellFinder.TradeDropSpot(map); if (itemThingDef.Minifiable) { itemThingDef = itemThingDef.minifiedDef; MinifiedThing minifiedThing = (MinifiedThing)ThingMaker.MakeThing(itemThingDef, null); minifiedThing.InnerThing = itemThing; minifiedThing.stackCount = quantity; TradeUtility.SpawnDropPod(vec, map, minifiedThing); } else { itemThing.stackCount = quantity; TradeUtility.SpawnDropPod(vec, map, itemThing); } string letter = Helper.ReplacePlaceholder("TwitchStoriesDescription80".Translate(), from: Viewer.username, amount: quantity.ToString(), item: item.abr.CapitalizeFirst()); LetterDef letterDef = ItemHelper.GetLetterFromValue(price); Find.LetterStack.ReceiveLetter(item.abr.Truncate(15, true).CapitalizeFirst(), letter, letterDef, new TargetInfo(vec, map, false)); EndCarePackage(); }
public static ThingDef GetStuffDefFromSettings(ThingDef def) { if (def.MadeFromStuff && MeMiMoSettings.chooseItemStuff && MeMiMoSettings.stuffDefName != "" && DefDatabase <ThingDef> .GetNamed(MeMiMoSettings.stuffDefName) != null) { return(DefDatabase <ThingDef> .GetNamed(MeMiMoSettings.stuffDefName)); } return(GenStuff.RandomStuffFor(def)); }
// Token: 0x06000037 RID: 55 RVA: 0x00003C00 File Offset: 0x00001E00 private Thing GenerateThing(ThingDef def, ThingDef stuff, Faction fac) { Thing thing = ThingMaker.MakeThing(def, def.MadeFromStuff ? (stuff ?? GenStuff.RandomStuffFor(def)) : null); thing.SetFactionDirect(fac); this.thingList.Add(thing); return(thing); }
public static void CourierInventory(Pawn pawn, Map map) { ThingDef swordDef = DefDatabase <ThingDef> .AllDefsListForReading.FirstOrDefault(x => x.defName == "MeleeWeapon_LongSword"); Thing sword = ThingMaker.MakeThing(swordDef, GenStuff.RandomStuffByCommonalityFor(swordDef)); pawn.equipment.AddEquipment((ThingWithComps)sword); }
public void MakeFuel() { ThingDef stuff = GenStuff.RandomStuffFor(ThingDefOf.Chemfuel); Thing thing = ThingMaker.MakeThing(ThingDefOf.Chemfuel, stuff); thing.stackCount = 35; GenPlace.TryPlaceThing(thing, Position, Find.CurrentMap, ThingPlaceMode.Near, null, null); }
protected override void ResolveInt(ResolveParams parms) { ThingDef assignRandomStuffTo = parms.assignRandomStuffTo; bool flag = parms.connectedGroupsSameStuff ?? false; bool allowWood = parms.allowWood ?? true; bool allowFlammableWalls = parms.allowFlammableWalls ?? true; thingsAt.Clear(); foreach (SketchThing thing2 in parms.sketch.Things) { if (assignRandomStuffTo == null || thing2.def == assignRandomStuffTo) { foreach (IntVec3 item in thing2.OccupiedRect) { if (!thingsAt.TryGetValue(item, out List <SketchThing> value)) { value = new List <SketchThing>(); thingsAt.Add(item, value); } value.Add(thing2); } } } visited.Clear(); foreach (SketchThing thing in parms.sketch.Things) { if ((assignRandomStuffTo == null || thing.def == assignRandomStuffTo) && !visited.Contains(thing)) { ThingDef stuff = GenStuff.RandomStuffInexpensiveFor(thing.def, null, (ThingDef x) => SketchGenUtility.IsStuffAllowed(x, allowWood, parms.useOnlyStonesAvailableOnMap, allowFlammableWalls, thing.def)); thing.stuff = stuff; visited.Add(thing); if (flag) { stack.Clear(); stack.Push(thing); while (stack.Count != 0) { SketchThing sketchThing = stack.Pop(); sketchThing.stuff = stuff; foreach (IntVec3 item2 in sketchThing.OccupiedRect.ExpandedBy(1)) { if (thingsAt.TryGetValue(item2, out List <SketchThing> value2)) { for (int i = 0; i < value2.Count; i++) { if (value2[i].def == thing.def && !visited.Contains(value2[i])) { visited.Add(value2[i]); stack.Push(value2[i]); } } } } } } } } }
public static bool TryRandomStuffByCommonalityFor(ThingDef td, out ThingDef stuff, TechLevel maxTechLevel = TechLevel.Undefined) { if (!td.MadeFromStuff) { stuff = null; return(true); } return(GenStuff.AllowedStuffsFor(td, maxTechLevel).TryRandomElementByWeightAndCommonality(td, out stuff)); }
// 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); }
private IEnumerable <ThingDef> GetStuffsForThing() { if (!thing.MadeFromStuff) { return(Enumerable.Empty <ThingDef>()); } return(GenStuff.AllowedStuffsFor(thing).OrderBy(t => t.label)); }
private void GiveRewardsAndSendLetter(bool giveTech, bool newFaction) { string text = "RD_GratefulSurvivors".Translate(); string text2 = "RD_GratefulSurvivorsDesc".Translate(); //"The survivors of the crash are very thankful for your help, and have send some supplies as a gesture of gratitude."; if (giveTech) { ThingDef.Named("Gun_ChargeRifle"); ThingDef thingDef = this.RandomHiTechReward(); ThingDef stuff = null; if (thingDef.MadeFromStuff) { stuff = GenStuff.DefaultStuffFor(thingDef); } this.rewards.TryAdd(ThingMaker.MakeThing(thingDef, stuff), true); text2 = "RD_GratefulSurvivorsAmazedDesc".Translate(); //"The survivors of the crash are amazed by your rapid and professional emergency medical response, thanks to which no-one died. In gratitude, they have included a special system removed form the wreck."; } Find.LetterStack.ReceiveLetter(text, text2, LetterDefOf.PositiveEvent, null); Map map = Find.AnyPlayerHomeMap ?? ((MapParent)this.parent).Map; QuestComp_MedicalEmergency.tmpRewards.AddRange(this.rewards); this.rewards.Clear(); IntVec3 dropCenter = DropCellFinder.TradeDropSpot(map); DropPodUtility.DropThingsNear(dropCenter, map, QuestComp_MedicalEmergency.tmpRewards, 110, false, false, true); QuestComp_MedicalEmergency.tmpRewards.Clear(); if (newFaction) { int tile = this.parent.Tile; this.CloseMapImmediate(); Faction faction = FactionGenerator.NewGeneratedFaction(FactionDefOf.Ancients); map.pawnDestinationReservationManager.GetPawnDestinationSetFor(faction); Find.FactionManager.Add(faction); Settlement settlement = (Settlement)WorldObjectMaker.MakeWorldObject(WorldObjectDefOf.Settlement); settlement.SetFaction(faction); settlement.Tile = tile; settlement.Name = SettlementNameGenerator.GenerateSettlementName(settlement, null); Find.WorldObjects.Add(settlement); faction.leader = null; foreach (Pawn pawn in this.injured) { if (!pawn.Dead && pawn.Faction != Faction.OfPlayer) { pawn.SetFactionDirect(faction); if (faction.leader == null) { faction.leader = pawn; } } } faction.TryAffectGoodwillWith(Faction.OfPlayer, 100); string text3 = "RD_NewFaction".Translate(); //New Faction! string text4 = "RD_NewFactionDesc".Translate() + faction.Name; //"The survivors of the crash have decided to make a life for themselves here, and have founded a new faction" Find.LetterStack.ReceiveLetter(text3, text4, LetterDefOf.PositiveEvent, null); } }
public void ResetStuffToDefault() { ThingDef thingDef = entDef as ThingDef; if (thingDef != null && thingDef.MadeFromStuff) { stuffDef = GenStuff.DefaultStuffFor(thingDef); } }
public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; ThingDef thingDef; if (rp.singleThingDef != null) { thingDef = rp.singleThingDef; } else if (rp.faction != null && rp.faction.def.techLevel >= TechLevel.Medieval) { thingDef = ThingDefOf.Bed; } else { thingDef = Rand.Element <ThingDef>(ThingDefOf.Bed, ThingDefOf.Bedroll, ThingDefOf.SleepingSpot); } ThingDef singleThingStuff; if (rp.singleThingStuff != null && rp.singleThingStuff.stuffProps.CanMake(thingDef)) { singleThingStuff = rp.singleThingStuff; } else { singleThingStuff = GenStuff.RandomStuffInexpensiveFor(thingDef, rp.faction); } bool @bool = Rand.Bool; foreach (IntVec3 current in rp.rect) { if (@bool) { if (current.x % 3 != 0 || current.z % 2 != 0) { continue; } } else if (current.x % 2 != 0 || current.z % 3 != 0) { continue; } Rot4 rot = (!@bool) ? Rot4.North : Rot4.West; if (!GenSpawn.WouldWipeAnythingWith(current, rot, thingDef, map, (Thing x) => x.def.category == ThingCategory.Building)) { if (!BaseGenUtility.AnyDoorAdjacentCardinalTo(GenAdj.OccupiedRect(current, rot, thingDef.Size), map)) { ResolveParams resolveParams = rp; resolveParams.rect = GenAdj.OccupiedRect(current, rot, thingDef.size); resolveParams.singleThingDef = thingDef; resolveParams.singleThingStuff = singleThingStuff; resolveParams.thingRot = new Rot4?(rot); BaseGen.symbolStack.Push("bed", resolveParams); } } } }
public override void TryExecute() { ThingDef itemDef = ThingDef.Named("DropPodIncoming"); Thing itemThing = new Thing(); ThingDef stuff = null; ThingDef itemThingDef = ThingDef.Named(item.defname); if (itemThingDef.race != null) { TryExecuteAnimal(itemThingDef, quantity); return; } if (itemThingDef.MadeFromStuff) { if (!(from x in GenStuff.AllowedStuffsFor(itemThingDef, TechLevel.Undefined) where !PawnWeaponGenerator.IsDerpWeapon(itemThingDef, x) select x).TryRandomElementByWeight((ThingDef x) => x.stuffProps.commonality, out stuff)) { stuff = GenStuff.RandomStuffByCommonalityFor(itemThingDef, TechLevel.Undefined); } } itemThing = ThingMaker.MakeThing(itemThingDef, (stuff != null) ? stuff : null); QualityCategory q = new QualityCategory(); if (itemThing.TryGetQuality(out q)) { ItemHelper.setItemQualityRandom(itemThing); } IntVec3 vec; if (itemThingDef.Minifiable) { itemThingDef = itemThingDef.minifiedDef; MinifiedThing minifiedThing = (MinifiedThing)ThingMaker.MakeThing(itemThingDef, null); minifiedThing.InnerThing = itemThing; minifiedThing.stackCount = quantity; vec = Helper.Rain(itemDef, minifiedThing); } else { itemThing.stackCount = quantity; vec = Helper.Rain(itemDef, itemThing); } string letter = Helper.ReplacePlaceholder("TwitchStoriesDescription80".Translate(), from: viewer.username, amount: quantity.ToString(), item: item.abr.CapitalizeFirst()); Helper.CarePackage(letter, LetterDefOf.PositiveEvent, vec); EndCarePackage(); }
private static Texture2D GetHumanMeatTexture() { ThingDef humanMeat = DefDatabase <ThingDef> .GetNamed("Meat_Human"); if (humanMeat.graphic is Graphic_Appearances graphic) { return(graphic.SubGraphicFor(GenStuff.DefaultStuffFor(humanMeat)).MatAt(humanMeat.defaultPlacingRot).GetMaskTexture()); } return(humanMeat.uiIcon); }
public override bool TryExecute(IncidentParms parms) { Map map = (Map)parms.target; Pawn pawn = this.PotentialVictims(map).RandomElement(); ThingDef defToMake = DefDatabase <ThingDef> .AllDefsListForReading.FindAll(x => x.defName.Contains("Effigy_")).RandomElement(); Thing effigy = ThingMaker.MakeThing(defToMake, GenStuff.RandomStuffFor(defToMake)); pawn.inventory.TryAddItemNotForSale(effigy); return(true); }
// Token: 0x0600007A RID: 122 RVA: 0x00004CA8 File Offset: 0x00002EA8 private Apparel MakeApparel(int index) { ThingDef def = this.data.wornApparelDefs[index]; Apparel apparel = (Apparel)ThingMaker.MakeThing(def, GenStuff.DefaultStuffFor(def)); if (this.data.wornApparelColors.Count > index && this.data.wornApparelDefs[index] != null) { apparel.SetColor(this.data.wornApparelColors[index], false); } return(apparel); }