private Thing FindIngredient(Pawn pawn, string thirdItem, Building_ItemProcessor building_processor) { if (building_processor.compItemProcessor.Props.isCategoryBuilding) { Predicate <Thing> predicate = (Thing x) => !x.IsForbidden(pawn) && pawn.CanReserve(x, 1, 1, null, false); IntVec3 position = pawn.Position; Map map = pawn.Map; List <Thing> searchSet = new List <Thing>(); foreach (ThingDef thingDef in ThingCategoryDef.Named(thirdItem).childThingDefs) { if (!(DefDatabase <CombinationDef> .GetNamed(building_processor.thisRecipe).disallowedThingDefs != null && DefDatabase <CombinationDef> .GetNamed(building_processor.thisRecipe).disallowedThingDefs.Contains(thingDef.defName))) { searchSet.AddRange(pawn.Map.listerThings.ThingsOfDef(thingDef)); } } TraverseParms traverseParams = TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false); Predicate <Thing> validator = predicate; PathEndMode peMode = PathEndMode.ClosestTouch; return(GenClosest.ClosestThing_Global_Reachable(pawn.Position, pawn.Map, searchSet, peMode, traverseParams, 9999f, validator, null)); } else { Predicate <Thing> predicate = (Thing x) => !x.IsForbidden(pawn) && pawn.CanReserve(x, 1, 1, null, false); IntVec3 position = pawn.Position; Map map = pawn.Map; ThingRequest thingReq = ThingRequest.ForDef(ThingDef.Named(thirdItem)); PathEndMode peMode = PathEndMode.ClosestTouch; TraverseParms traverseParams = TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false); Predicate <Thing> validator = predicate; return(GenClosest.ClosestThingReachable(position, map, thingReq, peMode, traverseParams, 9999f, validator, null, 0, -1, false, RegionType.Set_Passable, false)); } }
private void TryInsertFirstThing(string item = "") { if (item != "") { building.firstCategory = ThingCategoryDef.Named(item).defName; building.firstItem = building.firstCategory; } else { building.firstItem = things.RandomElement().def.defName; } if (building.compItemProcessor.Props.isSemiAutomaticMachine) { if (building.compPowerTrader != null && !building.compPowerTrader.PowerOn && building.compItemProcessor.Props.noPowerDestroysProgress) { Messages.Message("IP_NoPowerDestroysWarning".Translate(building.def.LabelCap), building, MessageTypeDefOf.NegativeEvent, true); } else if (building.compFuelable != null && !building.compFuelable.HasFuel && building.compItemProcessor.Props.noPowerDestroysProgress) { Messages.Message("IP_NoFuelDestroysWarning".Translate(building.def.LabelCap), building, MessageTypeDefOf.NegativeEvent, true); } else { building.IngredientsChosenBringThemIn(); } } else { building.processorStage = ProcessorStage.IngredientsChosen; } }
private static void UnforbidItemsToLoadInCargoBay() { // Unforbid any weapon, apparel, raw food or corpse in the outpost area so it can be carried to a cargo bay. if (OG_Util.FindOutpostArea() != null) { foreach (IntVec3 cell in OG_Util.FindOutpostArea().ActiveCells) { foreach (Thing thing in cell.GetThingList()) { if (thing.def.thingCategories == null) { continue; } if (thing.def.thingCategories.Contains(ThingCategoryDefOf.Apparel) || thing.def.thingCategories.Contains(ThingCategoryDef.Named("Headgear")) || thing.def.thingCategories.Contains(ThingCategoryDef.Named("WeaponsMelee")) || thing.def.thingCategories.Contains(ThingCategoryDef.Named("WeaponsRanged")) || thing.def.thingCategories.Contains(ThingCategoryDef.Named("CorpsesHumanlike")) || thing.def.thingCategories.Contains(ThingCategoryDef.Named("Textiles")) || (thing.def == ThingDef.Named("RawHops")) || (thing.def.thingCategories.Contains(ThingCategoryDef.Named("PlantFoodRaw")) && (thing.def != ThingDef.Named("Hay")))) { thing.SetForbidden(false); } } } } }
public static void GenerateSmallRoomWeaponRoom(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData) { IntVec3 origin = Zone.GetZoneOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd); IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation); OG_Common.GenerateEmptyRoomAt(rotatedOrigin + new IntVec3(smallRoomWallOffset, 0, smallRoomWallOffset).RotatedBy(rotation), Genstep_GenerateOutpost.zoneSideSize - 2 * smallRoomWallOffset, Genstep_GenerateOutpost.zoneSideSize - 2 * smallRoomWallOffset, rotation, TerrainDefOf.Concrete, TerrainDef.Named("MetalTile"), ref outpostData); // Spawn weapon racks, weapons and lamps. Building_Storage rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(smallRoomWallOffset + 1, 0, smallRoomWallOffset + 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData) as Building_Storage; TrySpawnWeaponOnRack(rack); rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false); rack.GetStoreSettings().Priority = StoragePriority.Critical; rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(smallRoomWallOffset + 4, 0, smallRoomWallOffset + 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData) as Building_Storage; TrySpawnWeaponOnRack(rack); rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false); rack.GetStoreSettings().Priority = StoragePriority.Critical; rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(smallRoomWallOffset + 2, 0, smallRoomWallOffset + 5).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData) as Building_Storage; TrySpawnWeaponOnRack(rack); rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false); rack.GetStoreSettings().Priority = StoragePriority.Critical; rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(smallRoomWallOffset + 5, 0, smallRoomWallOffset + 5).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData) as Building_Storage; TrySpawnWeaponOnRack(rack); rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false); rack.GetStoreSettings().Priority = StoragePriority.Critical; OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(smallRoomWallOffset + 1, 0, smallRoomWallOffset + 3).RotatedBy(rotation), Color.white, ref outpostData); OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(smallRoomWallOffset + 5, 0, smallRoomWallOffset + 3).RotatedBy(rotation), Color.white, ref outpostData); // Spawn vertical alley and door. for (int zOffset = smallRoomWallOffset; zOffset <= Genstep_GenerateOutpost.zoneSideSize - smallRoomWallOffset; zOffset++) { Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideCenterOffset, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile")); } OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(Genstep_GenerateOutpost.zoneSideCenterOffset, 0, Genstep_GenerateOutpost.zoneSideSize - smallRoomWallOffset - 1).RotatedBy(rotation), ref outpostData); }
public static void Postfix(ref ThingFilter __instance, StorageSettingsPreset preset) { if (preset == StorageSettingsPreset.DefaultStockpile) { __instance.SetAllow(ThingCategoryDef.Named("RoadEquipment"), allow: true); } }
public void FindAllValidApparel() { var headgearCategoryDef = ThingCategoryDef.Named(defName: "Headgear"); var fullHead = Defs_Rimworld.Head; var eyes = Defs_Rimworld.Eyes; var allEyeCoveringHeadgearDefs = new HashSet <ThingDef>( collection: DefDatabase <ThingDef> .AllDefsListForReading.FindAll( match: def => def.IsApparel && ((def.thingCategories?.Contains(item: headgearCategoryDef) ?? false) || def.apparel.bodyPartGroups.Any(predicate: bpg => bpg == eyes || bpg == fullHead) || def.HasComp(compType: typeof(Comp_NightVisionApparel))) ) ); var nvApparel = Settings.Store.NVApparel ?? new Dictionary <ThingDef, ApparelVisionSetting>(); //Add defs that have NV comp foreach (ThingDef apparel in allEyeCoveringHeadgearDefs) { if (apparel.comps.Find(match: comp => comp is CompProperties_NightVisionApparel) is CompProperties_NightVisionApparel) { if (!nvApparel.TryGetValue(key: apparel, value: out ApparelVisionSetting setting)) { nvApparel[key : apparel] = new ApparelVisionSetting(apparel : apparel); } else { setting.InitExistingSetting(apparel: apparel); } }
public void GenerateStrangeMeatRecipe() { if (LoadedModManager.RunningMods.Any(x => x.Name.Contains("Cosmic Horrors")) && !AreRecipesReady) { //Not really, but hey, let's get started. AreRecipesReady = true; //We want to use strange meat to make wax. RecipeDef recipeMakeWax = DefDatabase <RecipeDef> .AllDefs.FirstOrDefault((RecipeDef d) => d.defName == "Jecrell_MakeWax"); if (recipeMakeWax != null) { ThingFilter newFilter = new ThingFilter(); newFilter.CopyAllowancesFrom(recipeMakeWax.fixedIngredientFilter); newFilter.SetAllow(ThingCategoryDef.Named("ROM_StrangeMeatRaw"), true); recipeMakeWax.fixedIngredientFilter = newFilter; ThingFilter newFilter2 = new ThingFilter(); newFilter2.CopyAllowancesFrom(recipeMakeWax.defaultIngredientFilter); newFilter2.SetAllow(ThingCategoryDef.Named("ROM_StrangeMeatRaw"), true); recipeMakeWax.defaultIngredientFilter = newFilter; foreach (IngredientCount temp in recipeMakeWax.ingredients) { if (temp.filter != null) { ThingFilter newFilter3 = new ThingFilter(); newFilter3.CopyAllowancesFrom(temp.filter); newFilter3.SetAllow(ThingCategoryDef.Named("ROM_StrangeMeatRaw"), true); temp.filter = newFilter3; Log.Message("Added new filter"); } } Log.Message("Strange meat added to wax recipes."); } //I want stoves to be able to cook strange meals too. ThingDef stoveDef = DefDatabase <ThingDef> .AllDefs.FirstOrDefault((ThingDef def) => def.defName == "WoodStoveFurnace"); if (stoveDef != null) { if (stoveDef.recipes.FirstOrDefault((RecipeDef def) => def.defName == "ROM_CookStrangeMealSimple") == null) { stoveDef.recipes.Add(DefDatabase <RecipeDef> .GetNamed("ROM_CookStrangeMealSimple")); } if (stoveDef.recipes.FirstOrDefault((RecipeDef def) => def.defName == "ROM_CookStrangeMealFine") == null) { stoveDef.recipes.Add(DefDatabase <RecipeDef> .GetNamed("ROM_CookStrangeMealFine")); } if (stoveDef.recipes.FirstOrDefault((RecipeDef def) => def.defName == "ROM_CookStrangeMealLavish") == null) { stoveDef.recipes.Add(DefDatabase <RecipeDef> .GetNamed("ROM_CookStrangeMealLavish")); } Log.Message("Strange meal recipes added to WoodStoveFurnace defs"); } } return; }
public static List <Thing> GetAllStoredFood() { return(Find.Maps.SelectMany(map => map.spawnedThings) .Where(thing => thing.Spawned && thing.IsInValidStorage() && thing.def.IsIngestible && thing.def.thingCategories.Contains(ThingCategoryDef.Named("FoodMeals"))) .OrderBy(thing => thing.thingIDNumber) .ToList()); }
/// <summary> /// Calculate the total number of ingredients needed to fully repair an item. /// </summary> /// <param name="itemDamaged">The item to be repaired.</param> /// <returns></returns> internal static List <ThingDefCount> CalculateTotalIngredients(Thing itemDamaged) { List <ThingDefCount> totalCost; switch (Settings.ResourceMode) { case ResourceModes.REPAIR_KIT: totalCost = new List <ThingDefCount>(1); int hpPerPack; if (Settings.HpPercentage) { hpPerPack = (int)Math.Floor(itemDamaged.MaxHitPoints * (Settings.HpPerPack / 100.0f)); if (hpPerPack == 0) { hpPerPack = 100; Log.Error($"RepairBench Error: Thing={itemDamaged}, MaxHitPoints={itemDamaged.MaxHitPoints}, Settings.HpPerPack={Settings.HpPerPack}, hpPercentage=true, hpPerPack=0%, did you put bad values in the config?"); } } else { hpPerPack = Settings.HpPerPack; } var kitsToFetch = (itemDamaged.MaxHitPoints - itemDamaged.HitPoints) / hpPerPack; totalCost.Add(new ThingDefCount(ThingDef.Named(Settings.THINGDEF_REPKIT), kitsToFetch)); break; case ResourceModes.INGREDIENTS: //tmpTotalCost is cached, DO NOT MODIFY IT var tmpFullCost = itemDamaged.CostListAdjusted(); totalCost = new List <ThingDefCount>(tmpFullCost.Count); foreach (var thingCount in tmpFullCost) { var origCount = thingCount.count; var damPercent = (itemDamaged.MaxHitPoints - itemDamaged.HitPoints) / (float)itemDamaged.MaxHitPoints; var amountPct = thingCount.thingDef.IsWithinCategory(ThingCategoryDef.Named("ResourcesRaw"))? 0.75f: 0.33f; var newCount = (int)Math.Floor(origCount * damPercent * amountPct * Settings.INGRED_REPAIR_PERCENT); Debug.PrintLine($"Thing={itemDamaged.LabelNoCount}, mat={thingCount.thingDef}, origCount: {origCount} | damPer:{damPercent} | newCount:{newCount}"); if (newCount > 0) { totalCost.Add(new ThingDefCount(thingCount.thingDef, newCount)); } } break; default: return(new List <ThingDefCount>(0)); } return(totalCost); }
public Command_SetFirstItemList() { //Loops through all things selected right now to see if it finds an item processor building //Just in case, item processors disable its Gizmos (buttons) if there are more things selected foreach (object obj in Find.Selector.SelectedObjects) { building = obj as Building_ItemProcessor; if (building != null) { if (building.firstItem == "") { //If a first ingredient hasn't been chosen yet, show an empty "choose ingredient" button. This is configurable in each building icon = ContentFinder <Texture2D> .Get(building.compItemProcessor.Props.chooseIngredientsIcon, true); defaultLabel = "IP_ChooseIngredient".Translate(); } foreach (ItemAcceptedDef element in DefDatabase <ItemAcceptedDef> .AllDefs.Where(element => (element.building == building.def.defName) && (element.slot == 1))) { foreach (string item in element.items) { //If a first ingredient has been chosen, then show the graphic of that ingredient if (building.firstItem == item) { if (building.compItemProcessor.Props.isCategoryBuilding) { icon = ContentFinder <Texture2D> .Get(ThingCategoryDef.Named(item).iconPath, true); defaultLabel = "IP_InsertVariable".Translate(ThingCategoryDef.Named(item).LabelCap); } else { if (ThingDef.Named(item).graphicData.graphicClass == typeof(Graphic_StackCount)) { icon = ContentFinder <Texture2D> .Get(ThingDef.Named(item).graphic.path + "/" + ThingDef.Named(item).defName + "_b", false); if (icon == null) { icon = ContentFinder <Texture2D> .Get(ThingDef.Named(item).graphic.path + "/" + ThingDef.Named(item).defName, false); } } else { icon = ContentFinder <Texture2D> .Get(ThingDef.Named(item).graphic.path, false); } defaultLabel = "IP_InsertVariable".Translate(ThingDef.Named(item).LabelCap); } } } } } } }
public static void GenerateMediumRoomWeaponRoom(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData) { IntVec3 origin = Zone.GetZoneOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd); IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation); OG_Common.GenerateEmptyRoomAt(rotatedOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), 9, 9, rotation, TerrainDefOf.Concrete, null, ref outpostData); // Spawn weapon racks, weapons and lamps. Building_Storage rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(3, 0, 2).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData) as Building_Storage; OG_Common.TrySpawnWeaponOnRack(rack); rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false); rack.GetStoreSettings().Priority = StoragePriority.Critical; rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(6, 0, 2).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData) as Building_Storage; OG_Common.TrySpawnWeaponOnRack(rack); rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false); rack.GetStoreSettings().Priority = StoragePriority.Critical; rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(2, 0, 7).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData) as Building_Storage; OG_Common.TrySpawnWeaponOnRack(rack); rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false); rack.GetStoreSettings().Priority = StoragePriority.Critical; rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(2, 0, 4).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData) as Building_Storage; OG_Common.TrySpawnWeaponOnRack(rack); rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false); rack.GetStoreSettings().Priority = StoragePriority.Critical; rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(4, 0, 8).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData) as Building_Storage; OG_Common.TrySpawnWeaponOnRack(rack); rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false); rack.GetStoreSettings().Priority = StoragePriority.Critical; rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(7, 0, 8).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData) as Building_Storage; OG_Common.TrySpawnWeaponOnRack(rack); rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false); rack.GetStoreSettings().Priority = StoragePriority.Critical; rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(8, 0, 3).RotatedBy(rotation), true, new Rot4(Rot4.West.AsInt + rotation.AsInt), ref outpostData) as Building_Storage; OG_Common.TrySpawnWeaponOnRack(rack); rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false); rack.GetStoreSettings().Priority = StoragePriority.Critical; rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(8, 0, 6).RotatedBy(rotation), true, new Rot4(Rot4.West.AsInt + rotation.AsInt), ref outpostData) as Building_Storage; OG_Common.TrySpawnWeaponOnRack(rack); rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false); rack.GetStoreSettings().Priority = StoragePriority.Critical; OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(2, 0, 5).RotatedBy(rotation), Color.red, ref outpostData); OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(8, 0, 5).RotatedBy(rotation), Color.red, ref outpostData); // Spawn vertical alley and doors. for (int zOffset = 0; zOffset <= 10; zOffset++) { Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(5, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile")); } OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(5, 0, 1).RotatedBy(rotation), ref outpostData); OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(5, 0, 9).RotatedBy(rotation), ref outpostData); }
public static void Postfix(List <TransferableOneWay> transferables, ref TransferableOneWayWidget pawnsTransfer, ref TransferableOneWayWidget itemsTransfer, string thingCountTip, IgnorePawnsInventoryMode ignorePawnInventoryMass, Func <float> availableMassGetter, bool ignoreSpawnedCorpsesGearAndInventoryMass, int tile, bool playerPawnsReadOnly) { var modifiedTransferables = transferables.Where(x => x.ThingDef.category != ThingCategory.Pawn).ToList(); modifiedTransferables = modifiedTransferables .Where(x => !x.ThingDef.IsWithinCategory(ThingCategoryDef.Named("RoadEquipment"))).ToList(); itemsTransfer = new TransferableOneWayWidget(modifiedTransferables, null, null, thingCountTip, true, ignorePawnInventoryMass, false, availableMassGetter, 0f, ignoreSpawnedCorpsesGearAndInventoryMass, tile, true, false, false, true, false, true); }
private void TryInsertFourthThing(string item = "") { building.processorStage = ProcessorStage.IngredientsChosen; if (item != "") { building.fourthCategory = ThingCategoryDef.Named(item).defName; building.fourthItem = building.fourthCategory; } else { building.fourthItem = things.RandomElement().def.defName; } }
public override void ProcessInput(Event ev) { base.ProcessInput(ev); List <FloatMenuOption> list = new List <FloatMenuOption>(); //This is for 2-3 slot recipes that allow one of the ingredients to be empty if (building.GetComp <CompItemProcessor>().Props.acceptsNoneAsInput) { list.Add(new FloatMenuOption("IP_None".Translate(), delegate { building.firstItem = "None"; }, MenuOptionPriority.Default, null, null, 29f, null, null)); } //For the rest, search for every recipe that is from this building, and this slot foreach (ItemAcceptedDef element in DefDatabase <ItemAcceptedDef> .AllDefs.Where(element => (element.building == building.def.defName) && (element.slot == 1))) { foreach (string item in element.items.Where(item => item != "None")) { if (building.compItemProcessor.Props.isCategoryBuilding) { list.Add(new FloatMenuOption("IP_InsertVariable".Translate(ThingCategoryDef.Named(item).LabelCap), delegate { if (building.processorStage <= ProcessorStage.ExpectingIngredients) { this.TryInsertFirstThing(item); } }, MenuOptionPriority.Default, null, null, 29f, null, null)); } else { list.Add(new FloatMenuOption("IP_InsertVariable".Translate(ThingDef.Named(item).LabelCap), delegate { things = map.listerThings.ThingsOfDef(DefDatabase <ThingDef> .GetNamed(item, true)); if (things.Count > 0) { if (building.processorStage <= ProcessorStage.ExpectingIngredients) { this.TryInsertFirstThing(); } } else { Messages.Message("IP_CantFindThing".Translate(ThingDef.Named(item).LabelCap), null, MessageTypeDefOf.NegativeEvent, true); } }, MenuOptionPriority.Default, null, null, 29f, null, null)); } } } Find.WindowStack.Add(new FloatMenu(list)); }
public static void Postfix(ref TransferableOneWayWidget widget, List <TransferableOneWay> transferables) { RoadsOfTheRim.DebugLog("DEBUG AddPawnsSection: "); List <TransferableOneWay> source = new List <TransferableOneWay>(); foreach (TransferableOneWay tow in transferables) { if (tow.ThingDef.IsWithinCategory(ThingCategoryDef.Named("RoadEquipment"))) { source.Add(tow); RoadsOfTheRim.DebugLog("Found an ISR2G"); } } widget.AddSection("RoadsOfTheRim_RoadEquipment".Translate(), source); }
public Command_SetFourthItemList() { foreach (object obj in Find.Selector.SelectedObjects) { building = obj as Building_ItemProcessor; if (building != null) { if (building.fourthItem == "") { icon = ContentFinder <Texture2D> .Get(building.compItemProcessor.Props.chooseIngredientsIcon, true); defaultLabel = "IP_ChooseIngredientFourth".Translate(); } foreach (ItemAcceptedDef element in DefDatabase <ItemAcceptedDef> .AllDefs.Where(element => (element.building == building.def.defName) && (element.slot == 4))) { foreach (string item in element.items) { if (building.fourthItem == item) { if (building.compItemProcessor.Props.isCategoryBuilding) { icon = ContentFinder <Texture2D> .Get(ThingCategoryDef.Named(item).iconPath, true); defaultLabel = "IP_InsertVariable".Translate(ThingCategoryDef.Named(item).LabelCap); } else { if (ThingDef.Named(item).graphicData.graphicClass == typeof(Graphic_StackCount)) { icon = ContentFinder <Texture2D> .Get(ThingDef.Named(item).graphic.path + "/" + ThingDef.Named(item).defName + "_b", false); if (icon == null) { icon = ContentFinder <Texture2D> .Get(ThingDef.Named(item).graphic.path + "/" + ThingDef.Named(item).defName, false); } } else { icon = ContentFinder <Texture2D> .Get(ThingDef.Named(item).graphic.path, false); } } } } } } } }
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill) { if (billDoer == null) { return; } Log.Message("Log 1"); if (!CheckSurgeryFail(billDoer, pawn, ingredients, part, bill)) { Log.Message("Log 2"); var newImplant = ingredients .FirstOrDefault(x => x.def.thingCategories.Contains(ThingCategoryDef.Named("PS_Dopamine_Pumps")) || x.def.thingCategories.Contains( ThingCategoryDef.Named("PS_Dopamine_Pumps_Adv"))); var newImplantName = newImplant?.def.defName; Log.Message("Log 3"); var currentImplantHeDiff = pawn.health.hediffSet.hediffs.FirstOrDefault(x => x.Part == part && x.def.defName.StartsWith("PS_Dopamine_Pump_")); if (currentImplantHeDiff != null) { ResetPassion(pawn, currentImplantHeDiff); if (currentImplantHeDiff.def.spawnThingOnRemoved != null) { GenPlace.TryPlaceThing(ThingMaker.MakeThing(currentImplantHeDiff.def.spawnThingOnRemoved), pawn.Position, pawn.Map, ThingPlaceMode.Near, out _); } } Log.Message("Log 4"); AddPassion(pawn, newImplantName, part, GetSkill(newImplantName)); Log.Message("Log 5"); TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn); } else { Log.Message("Log 7 failed"); } }
static RimWriterSetup() { var campFireDef = ThingDefOf.Campfire; var electricCrematoriumDef = ThingDef.Named("ElectricCrematorium"); campFireDef? .recipes?.Add(DefDatabase <RecipeDef> .GetNamed("RimWriter_BurnBooks")); electricCrematoriumDef? .recipes?.Add(DefDatabase <RecipeDef> .GetNamed("RimWriter_BurnBooks")); campFireDef? .recipes?.Add(DefDatabase <RecipeDef> .GetNamed("RimWriter_BurnScrolls")); electricCrematoriumDef? .recipes?.Add(DefDatabase <RecipeDef> .GetNamed("RimWriter_BurnScrolls")); Log.Message("Added recipes for burning books/scrolls successfully."); var cultsGrimoire = DefDatabase <ThingDef> .GetNamedSilentFail("Cults_Grimoire"); if (cultsGrimoire != null) { cultsGrimoire.thingCategories = new List <ThingCategoryDef> { ThingCategoryDef.Named("RimWriter_Books") }; } var cultsKingInYellow = DefDatabase <ThingDef> .GetNamedSilentFail("Cults_TheKingInYellow"); if (cultsKingInYellow != null) { cultsKingInYellow.thingCategories = new List <ThingCategoryDef> { ThingCategoryDef.Named("RimWriter_Books") }; } }
public List <Thing> Generate(int totalMarketValue, List <Thing> outThings) { for (int j = 0; j < 10; j++) { //Torn Scripts if (Rand.Chance(0.3f) && (totalMarketValue - collectiveMarketValue) > TorannMagicDefOf.Torn_BookOfArcanist.BaseMarketValue / 2) { if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfInnerFire, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfHeartOfFrost, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfStormBorn, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfArcanist, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfValiant, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfSummoner, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfNature, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfUndead, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfPriest, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfBard, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfDemons, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Chance(ArcaneScriptChance)) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.Torn_BookOfEarth, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } } //Arcane Scripts if (Rand.Chance(ArcaneScriptChance) && (totalMarketValue - collectiveMarketValue) > TorannMagicDefOf.BookOfArcanist.BaseMarketValue / 2) { float rnd = Rand.Range(0f, 1f); float scriptCount = 18f; if (rnd < 1f / scriptCount) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfInnerFire, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (rnd < 2f / scriptCount) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfHeartOfFrost, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (rnd < 3f / scriptCount) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfStormBorn, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (rnd < 4f / scriptCount) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfArcanist, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (rnd < 5f / scriptCount) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfValiant, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (rnd < 6f / scriptCount) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfSummoner, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (rnd < 7f / scriptCount) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfNecromancer, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (rnd < 8f / scriptCount) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfDruid, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (rnd < 9f / scriptCount) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfPriest, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (rnd < 10f / scriptCount) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfBard, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (rnd < 11f / scriptCount) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfDemons, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (rnd < 12f / scriptCount) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfEarth, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (rnd < 13f / scriptCount) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfGladiator, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (rnd < 14f / scriptCount) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfSniper, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (rnd < 15f / scriptCount) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfBladedancer, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (rnd < 16f / scriptCount) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfRanger, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else if (rnd < 17f / scriptCount) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfFaceless, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } else { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.BookOfPsionic, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } } //Mana Potions if (Rand.Chance(0.2f) && (totalMarketValue - collectiveMarketValue) > TorannMagicDefOf.ManaPotion.BaseMarketValue * ManaPotionRange.RandomInRange) { int randomInRange = ManaPotionRange.RandomInRange; for (int i = 0; i < randomInRange; i++) { Thing thing = ThingMaker.MakeThing(TorannMagicDefOf.ManaPotion, null); thing.stackCount = ManaPotionRange.RandomInRange; outThings.Add(thing); collectiveMarketValue += thing.MarketValue * thing.stackCount; } } //Artifacts if (Rand.Chance(ArtifactsChance) && (totalMarketValue - collectiveMarketValue) > 1000f) { int randomInRange = ArtifactsCountRange.RandomInRange; for (int i = 0; i < randomInRange; i++) { IEnumerable <ThingDef> source = from x in DefDatabase <ThingDef> .AllDefs where x.thingCategories.Contains(ThingCategoryDef.Named("Artifacts")) select x; ThingDef def = source.RandomElement <ThingDef>(); Thing item = ThingMaker.MakeThing(def, null); outThings.Add(item); collectiveMarketValue += item.MarketValue; } } //Luciferium if (Rand.Chance(LuciferiumChance) && (totalMarketValue - collectiveMarketValue) > ThingDefOf.Luciferium.BaseMarketValue * LuciferiumCountRange.RandomInRange) { Thing thing = ThingMaker.MakeThing(ThingDefOf.Luciferium, null); thing.stackCount = LuciferiumCountRange.RandomInRange; outThings.Add(thing); collectiveMarketValue += thing.MarketValue * thing.stackCount; } //Ambrosia if (Rand.Chance(DrugChance)) { int randomInRange = ArtifactsCountRange.RandomInRange; for (int i = 0; i < randomInRange; i++) { //Thing thing = ThingMaker.MakeThing(, null); Thing thing = ThingMaker.MakeThing(ThingDef.Named("Ambrosia"), null); outThings.Add(thing); } } //Master Spells if (Rand.Chance(MasterSpellChance) && (totalMarketValue - collectiveMarketValue) > TorannMagicDefOf.SpellOf_Blizzard.BaseMarketValue) { Thing thing; float rnd = Rand.Range(0f, 24f); if (rnd > 22) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_PsychicShock, null); } else if (rnd > 20 && rnd <= 22) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Meteor, null); } else if (rnd > 18 && rnd <= 20) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Scorn, null); } else if (rnd > 16 && rnd <= 18) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_BattleHymn, null); } else if (rnd > 14 && rnd <= 16) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_BattleHymn, null); } else if (rnd > 12 && rnd <= 14) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_HolyWrath, null); } else if (rnd > 10 && rnd <= 12) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_LichForm, null); } else if (rnd > 8 && rnd <= 10) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Blizzard, null); } else if (rnd > 6 && rnd <= 8) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Firestorm, null); } else if (rnd > 4 && rnd <= 6) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_FoldReality, null); } else if (rnd > 2 && rnd <= 4) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Resurrection, null); } else { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_RegrowLimb, null); } outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } //Spells if (Rand.Chance(SpellChance) && (totalMarketValue - collectiveMarketValue) > 1000f) { int randomInRange = SpellCountRange.RandomInRange; Thing thing = new Thing(); for (int i = 0; i < randomInRange; i++) { if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Blink, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Teleport, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Heal, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Rain, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Heater, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Cooler, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_DryGround, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_WetGround, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_ChargeBattery, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_SmokeCloud, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_EMP, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Extinguish, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_SummonMinion, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_TransferMana, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_SiphonMana, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_ManaShield, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_PowerNode, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_Sunlight, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_SpellMending, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_CauterizeWound, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SpellOf_FertileLands, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } } } //Skills if (Rand.Chance(SpellChance) && (totalMarketValue - collectiveMarketValue) > 600f) { int randomInRange = SkillCountRange.RandomInRange; Thing thing = new Thing(); for (int i = 0; i < randomInRange; i++) { if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SkillOf_Sprint, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SkillOf_GearRepair, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SkillOf_InnerHealing, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SkillOf_HeavyBlow, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SkillOf_StrongBack, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SkillOf_ThickSkin, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } if (Rand.Range(0, 10) > 9) { thing = ThingMaker.MakeThing(TorannMagicDefOf.SkillOf_FightersFocus, null); outThings.Add(thing); collectiveMarketValue += thing.MarketValue; } } } } return(outThings); }
public void Set() { try { // get the (main) product if (_recipe.products != null && _recipe.products.Count > 0 && _recipe.products.First().thingDef.BaseMarketValue > 0) { Clear(); _thingDef = _recipe.products.First().thingDef; Type = Types.Thing; Count = _recipe.products.First().count; return; } // no main, is there a special? if (_recipe.specialProducts == null) { Clear(); Type = Types.None; Count = 0; } if (_recipe.specialProducts != null && _recipe.specialProducts.Count > 0) { // get the first special product of the first thingdef allowed by the fixedFilter. if (_recipe.defaultIngredientFilter.AllowedThingDefs == null) { throw new Exception("AllowedThingDefs NULL"); } ThingDef allowedThingDef = _recipe.fixedIngredientFilter.AllowedThingDefs.DefaultIfEmpty(null).FirstOrDefault(); if (allowedThingDef == null) { throw new Exception("AllowedThingDef NULL"); } if (_recipe.specialProducts[0] == SpecialProductType.Butchery) { // if stone cutting, set stone block category if (_recipe.defName == "MakeStoneBlocks") { Clear(); _categoryDef = DefDatabase <ThingCategoryDef> .GetNamed("StoneBlocks"); Type = Types.Category; Count = 20; return; } if (allowedThingDef.butcherProducts != null && allowedThingDef.butcherProducts.Count > 0) { // butcherproducts are defined, no problem. List <ThingCountClass> butcherProducts = allowedThingDef.butcherProducts; if (butcherProducts.Count == 0) { throw new Exception("No butcherproducts defined: " + allowedThingDef.defName); } Clear(); _thingDef = butcherProducts.First().thingDef; Type = Types.Thing; Count = butcherProducts.First().count; return; } // still not defined, see if we can catch corpses. if (allowedThingDef.ingestible?.sourceDef?.race?.fleshType != FleshType.Mechanoid) { // meat for non-mech corpses Clear(); _categoryDef = ThingCategoryDef.Named("MeatRaw"); Type = Types.Category; Count = (int)((allowedThingDef.ingestible?.sourceDef?.race?.baseBodySize ?? 1) * 50); } else if (allowedThingDef.ingestible?.sourceDef?.race?.fleshType == FleshType.Mechanoid) { // plasteel for mech corpses Clear(); _thingDef = ThingDef.Named("Plasteel"); Type = Types.Thing; Count = 20; } else { Clear(); return; } } if (_recipe.specialProducts[0] == SpecialProductType.Smelted) { if (allowedThingDef.smeltProducts == null) { Clear(); return; } List <ThingCountClass> smeltingProducts = allowedThingDef.smeltProducts; if (smeltingProducts.Count == 0) { Clear(); return; } Clear(); _thingDef = smeltingProducts.First().thingDef; Type = Types.Thing; Count = smeltingProducts.First().count; if (_thingDef == null) { Clear(); } } } } // ReSharper disable once UnusedVariable catch (Exception e) { #if DEBUG Log.Warning(e.Message); #endif Clear(); } }
public static void Postfix(ref Pawn __result, PawnGenerationRequest request) { if (Current.ProgramState == ProgramState.Entry || request.Faction?.def != PsiTechDefOf.PTPsionic || !(request.KindDef is PsiTechPawnKindDef psiKind) || psiKind.PsiAbilitiesMoney == FloatRange.Zero) { return; } // Remove psychically dull/deaf - can't enforce this in def since it's a spectrum trait... __result.story.traits.allTraits.RemoveAll(trait => trait.def == TraitDefOf.PsychicSensitivity && trait.Degree < 0); // We've got psi ability money to burn var money = psiKind.PsiAbilitiesMoney.RandomInRange; // Prep pawn and get ability pool copy for manipulation __result.PsiTracker().ActivateTracker(); __result.PsiTracker().Abilities.Clear(); __result.PsiTracker().FocusLevel = psiKind.FocusRange.RandomInRange; __result.PsiTracker().EnergyLevel = psiKind.TotalLevelRange.RandomInRange - __result.PsiTracker().FocusLevel; var copiedPool = psiKind.AbilityPool.ListFullCopy(); foreach (var ability in copiedPool.ListFullCopy()) { if (ability.AbilityCostForRaid <= money && __result.PsiTracker().HasAvailableSlot(ability.Tier)) { continue; } copiedPool.Remove(ability); } // Time to roll some abilities while (copiedPool.Any()) { PsiTechAbilityDef abilityToAdd; // Always give synchronicity to fire support types if (__result.GetStatValue(PsiTechDefOf.PTPsiWeaponSynchronicity) != 0 && copiedPool.Contains(PsiTechDefOf.PTPerfectedSynchronicity)) { abilityToAdd = PsiTechDefOf.PTPerfectedSynchronicity; } else { abilityToAdd = copiedPool.RandomElement(); } money -= abilityToAdd.AbilityCostForRaid; var addedAbility = __result.PsiTracker().AddAbility(abilityToAdd); copiedPool.Remove(abilityToAdd); // Configure autocasting if autocast ability if (abilityToAdd.Autocastable && addedAbility != null) { AutocastProfileUtility.SelectAndConfigureAutocastProfile(ref addedAbility); addedAbility.Autocast = true; } // Force give capacitance so that they can use these abilities if ((abilityToAdd == PsiTechDefOf.PTPsiRally || abilityToAdd == PsiTechDefOf.PTPsiStorm) && copiedPool.Contains(PsiTechDefOf.PTPerfectedCapacitance)) { __result.PsiTracker().AddAbility(PsiTechDefOf.PTPerfectedCapacitance, true); money -= PsiTechDefOf.PTPerfectedCapacitance.AbilityCostForRaid; copiedPool.Remove(PsiTechDefOf.PTPerfectedCapacitance); } // Clean up pool foreach (var ability in copiedPool.ListFullCopy()) { if (ability.AbilityCostForRaid <= money && !__result.PsiTracker().Abilities.Any(existing => existing.Def.ConflictingAbilities.Contains(ability)) && __result.PsiTracker().HasAvailableSlot(ability.Tier)) { continue; } copiedPool.Remove(ability); } } // Check if we need a psychic weapon if (__result.equipment.Primary != null && __result.GetStatValue(PsiTechDefOf.PTPsiWeaponSynchronicity) > 1e-4 && !(__result.equipment.Primary.def.thingSetMakerTags?.Contains("SingleUseWeapon") ?? false) && !(__result.equipment.Primary.def.thingCategories?.Contains(ThingCategoryDef.Named("Grenades")) ?? false)) { __result.equipment.Primary.PsiEquipmentTracker().IsPsychic = true; } // Max out our energy for the assault __result.PsiTracker().MaxEnergy(); }
protected new void Impact(Thing hitThing) { bool flag = hitThing == null; if (flag) { Pawn pawn; bool flag2 = (pawn = base.Position.GetThingList(base.Map).FirstOrDefault((Thing x) => x == this.assignedTarget) as Pawn) != null; if (flag2) { hitThing = pawn; } } bool hasValue = this.impactDamage.HasValue; if (hasValue) { hitThing.TakeDamage(this.impactDamage.Value); } try { SoundDefOf.Ambient_AltitudeWind.sustainFadeoutTime.Equals(30.0f); if (this.flyingThing != null) { GenSpawn.Spawn(this.flyingThing, base.Position, base.Map); if (this.flyingThing is Pawn) { Pawn p = this.flyingThing as Pawn; if (p.IsColonist && this.drafted) { p.drafter.Drafted = true; } if (this.earlyImpact) { damageEntities(p, this.impactForce, DamageDefOf.Blunt); damageEntities(p, this.impactForce, DamageDefOf.Stun); } } else if (flyingThing.def.thingCategories != null && (flyingThing.def.thingCategories.Contains(ThingCategoryDefOf.Chunks) || flyingThing.def.thingCategories.Contains(ThingCategoryDef.Named("StoneChunks")))) { float radius = 4f; Vector3 center = this.ExactPosition; if (this.earlyImpact) { bool wallFlag90neg = false; IntVec3 wallCheck = (center + (Quaternion.AngleAxis(-90, Vector3.up) * this.direction)).ToIntVec3(); MoteMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); wallFlag90neg = wallCheck.Walkable(base.Map); wallCheck = (center + (Quaternion.AngleAxis(90, Vector3.up) * this.direction)).ToIntVec3(); MoteMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); bool wallFlag90 = wallCheck.Walkable(base.Map); if ((!wallFlag90 && !wallFlag90neg) || (wallFlag90 && wallFlag90neg)) { //fragment energy bounces in reverse direction of travel center = center + (Quaternion.AngleAxis(180, Vector3.up) * this.direction * 3); } else if (wallFlag90) { center = center + (Quaternion.AngleAxis(90, Vector3.up) * this.direction * 3); } else if (wallFlag90neg) { center = center + (Quaternion.AngleAxis(-90, Vector3.up) * this.direction * 3); } } List <IntVec3> damageRing = GenRadial.RadialCellsAround(base.Position, radius, true).ToList(); List <IntVec3> outsideRing = GenRadial.RadialCellsAround(base.Position, radius, false).Except(GenRadial.RadialCellsAround(base.Position, radius - 1, true)).ToList(); for (int i = 0; i < damageRing.Count; i++) { List <Thing> allThings = damageRing[i].GetThingList(base.Map); for (int j = 0; j < allThings.Count; j++) { var thing = allThings[j]; if (thing is Pawn) { damageEntities(thing, Rand.Range(14, 22), DamageDefOf.Blunt); } else if (thing is Building) { damageEntities(thing, Rand.Range(56, 88), DamageDefOf.Blunt); } else { if (Rand.Chance(.1f)) { GenPlace.TryPlaceThing(ThingMaker.MakeThing(ThingDefOf.Filth_RubbleRock), damageRing[i], base.Map, ThingPlaceMode.Near); } } } } for (int i = 0; i < outsideRing.Count; i++) { IntVec3 intVec = outsideRing[i]; if (intVec.IsValid && intVec.InBounds(base.Map)) { Vector3 moteDirection = TM_Calc.GetVector(this.ExactPosition.ToIntVec3(), intVec); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Rubble"), this.ExactPosition, base.Map, Rand.Range(.3f, .6f), .2f, .02f, .05f, Rand.Range(-100, 100), Rand.Range(8f, 13f), (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); TM_MoteMaker.ThrowGenericMote(ThingDefOf.Mote_Smoke, this.ExactPosition, base.Map, Rand.Range(.9f, 1.2f), .3f, .02f, Rand.Range(.25f, .4f), Rand.Range(-100, 100), Rand.Range(5f, 8f), (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); GenExplosion.DoExplosion(intVec, base.Map, .4f, DamageDefOf.Blunt, pawn, 0, 0, SoundDefOf.Pawn_Melee_Punch_HitBuilding, null, null, null, ThingDefOf.Filth_RubbleRock, .25f, 1, false, null, 0f, 1, 0, false); //MoteMaker.ThrowSmoke(intVec.ToVector3Shifted(), base.Map, Rand.Range(.6f, 1f)); } } //damageEntities(this.flyingThing, 305, DamageDefOf.Blunt); this.flyingThing.Destroy(DestroyMode.Vanish); } else if ((flyingThing.def.thingCategories != null && flyingThing.def.thingCategories.Contains(ThingCategoryDefOf.Corpses)) || this.flyingThing is Corpse) { Corpse flyingCorpse = this.flyingThing as Corpse; float radius = 3f; Vector3 center = this.ExactPosition; if (this.earlyImpact) { bool wallFlag90neg = false; IntVec3 wallCheck = (center + (Quaternion.AngleAxis(-90, Vector3.up) * this.direction)).ToIntVec3(); MoteMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); wallFlag90neg = wallCheck.Walkable(base.Map); wallCheck = (center + (Quaternion.AngleAxis(90, Vector3.up) * this.direction)).ToIntVec3(); MoteMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); bool wallFlag90 = wallCheck.Walkable(base.Map); if ((!wallFlag90 && !wallFlag90neg) || (wallFlag90 && wallFlag90neg)) { //fragment energy bounces in reverse direction of travel center = center + (Quaternion.AngleAxis(180, Vector3.up) * this.direction * 3); } else if (wallFlag90) { center = center + (Quaternion.AngleAxis(90, Vector3.up) * this.direction * 3); } else if (wallFlag90neg) { center = center + (Quaternion.AngleAxis(-90, Vector3.up) * this.direction * 3); } } List <IntVec3> damageRing = GenRadial.RadialCellsAround(base.Position, radius, true).ToList(); List <IntVec3> outsideRing = GenRadial.RadialCellsAround(base.Position, radius, false).Except(GenRadial.RadialCellsAround(base.Position, radius - 1, true)).ToList(); Filth filth = (Filth)ThingMaker.MakeThing(flyingCorpse.InnerPawn.def.race.BloodDef); for (int i = 0; i < damageRing.Count; i++) { List <Thing> allThings = damageRing[i].GetThingList(base.Map); for (int j = 0; j < allThings.Count; j++) { var thing = allThings[j]; if (thing is Pawn) { damageEntities(thing, Rand.Range(18, 28), DamageDefOf.Blunt); } else if (thing is Building) { damageEntities(thing, Rand.Range(56, 88), DamageDefOf.Blunt); } else { if (Rand.Chance(.05f)) { if (filth != null) { filth = (Filth)ThingMaker.MakeThing(flyingCorpse.InnerPawn.def.race.BloodDef); GenPlace.TryPlaceThing(filth, damageRing[i], base.Map, ThingPlaceMode.Near); } else { GenPlace.TryPlaceThing(ThingMaker.MakeThing(ThingDefOf.Filth_Blood), damageRing[i], base.Map, ThingPlaceMode.Near); } } if (Rand.Chance(.05f)) { GenPlace.TryPlaceThing(ThingMaker.MakeThing(ThingDefOf.Filth_CorpseBile), damageRing[i], base.Map, ThingPlaceMode.Near); } } } } for (int i = 0; i < outsideRing.Count; i++) { IntVec3 intVec = outsideRing[i]; if (intVec.IsValid && intVec.InBounds(base.Map)) { Vector3 moteDirection = TM_Calc.GetVector(this.ExactPosition.ToIntVec3(), intVec); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_BloodSquirt, this.ExactPosition, base.Map, Rand.Range(.3f, .6f), .2f, .02f, .05f, Rand.Range(-100, 100), Rand.Range(4f, 13f), (Quaternion.AngleAxis(Rand.Range(60, 120), Vector3.up) * moteDirection).ToAngleFlat(), 0); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_BloodMist, this.ExactPosition, base.Map, Rand.Range(.9f, 1.2f), .3f, .02f, Rand.Range(.25f, .4f), Rand.Range(-100, 100), Rand.Range(5f, 8f), (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); GenExplosion.DoExplosion(intVec, base.Map, .4f, DamageDefOf.Blunt, pawn, 0, 0, SoundDefOf.Pawn_Melee_Punch_HitBuilding, null, null, null, filth.def, .08f, 1, false, null, 0f, 1, 0, false); //MoteMaker.ThrowSmoke(intVec.ToVector3Shifted(), base.Map, Rand.Range(.6f, 1f)); } } //damageEntities(this.flyingThing, 305, DamageDefOf.Blunt); //this.flyingThing.Destroy(DestroyMode.Vanish); } } else { float radius = 2f; Vector3 center = this.ExactPosition; if (this.earlyImpact) { bool wallFlag90neg = false; IntVec3 wallCheck = (center + (Quaternion.AngleAxis(-90, Vector3.up) * this.direction)).ToIntVec3(); MoteMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); wallFlag90neg = wallCheck.Walkable(base.Map); wallCheck = (center + (Quaternion.AngleAxis(90, Vector3.up) * this.direction)).ToIntVec3(); MoteMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); bool wallFlag90 = wallCheck.Walkable(base.Map); if ((!wallFlag90 && !wallFlag90neg) || (wallFlag90 && wallFlag90neg)) { //fragment energy bounces in reverse direction of travel center = center + (Quaternion.AngleAxis(180, Vector3.up) * this.direction * 3); } else if (wallFlag90) { center = center + (Quaternion.AngleAxis(90, Vector3.up) * this.direction * 3); } else if (wallFlag90neg) { center = center + (Quaternion.AngleAxis(-90, Vector3.up) * this.direction * 3); } } List <IntVec3> damageRing = GenRadial.RadialCellsAround(base.Position, radius, true).ToList(); List <IntVec3> outsideRing = GenRadial.RadialCellsAround(base.Position, radius, false).Except(GenRadial.RadialCellsAround(base.Position, radius - 1, true)).ToList(); for (int i = 0; i < damageRing.Count; i++) { List <Thing> allThings = damageRing[i].GetThingList(base.Map); for (int j = 0; j < allThings.Count; j++) { var thing = allThings[j]; if (thing is Pawn) { damageEntities(thing, Rand.Range(10, 16), DamageDefOf.Blunt); } else if (thing is Building) { damageEntities(thing, Rand.Range(32, 88), DamageDefOf.Blunt); } else { if (Rand.Chance(.1f)) { GenPlace.TryPlaceThing(ThingMaker.MakeThing(ThingDefOf.Filth_RubbleRock), damageRing[i], base.Map, ThingPlaceMode.Near); } } } } for (int i = 0; i < outsideRing.Count; i++) { IntVec3 intVec = outsideRing[i]; if (intVec.IsValid && intVec.InBounds(base.Map)) { Vector3 moteDirection = TM_Calc.GetVector(this.ExactPosition.ToIntVec3(), intVec); TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_Rubble"), this.ExactPosition, base.Map, Rand.Range(.3f, .6f), .2f, .02f, .05f, Rand.Range(-100, 100), Rand.Range(8f, 13f), (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); TM_MoteMaker.ThrowGenericMote(ThingDefOf.Mote_Smoke, this.ExactPosition, base.Map, Rand.Range(.9f, 1.2f), .3f, .02f, Rand.Range(.25f, .4f), Rand.Range(-100, 100), Rand.Range(5f, 8f), (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); GenExplosion.DoExplosion(intVec, base.Map, .4f, DamageDefOf.Blunt, pawn, 0, 0, SoundDefOf.Pawn_Melee_Punch_HitBuilding, null, null, null, null, .4f, 1, false, null, 0f, 1, 0, false); //MoteMaker.ThrowSmoke(intVec.ToVector3Shifted(), base.Map, Rand.Range(.6f, 1f)); } } } this.Destroy(DestroyMode.Vanish); } catch { if (this.flyingThing != null) { if (!this.flyingThing.Spawned) { GenSpawn.Spawn(this.flyingThing, base.Position, base.Map); Log.Message("catch"); } } this.Destroy(DestroyMode.Vanish); } }
protected virtual void Impact(Thing hitThing) { bool flag = hitThing == null; if (flag) { Pawn pawn; bool flag2 = (pawn = (base.Position.GetThingList(base.Map).FirstOrDefault((Thing x) => x == this.assignedTarget) as Pawn)) != null; if (flag2) { hitThing = pawn; } } bool hasValue = this.impactDamage.HasValue; if (hasValue) { hitThing.TakeDamage(this.impactDamage.Value); } try { SoundDefOf.Ambient_AltitudeWind.sustainFadeoutTime.Equals(30.0f); GenSpawn.Spawn(this.flyingThing, base.Position, base.Map); if (this.flyingThing is Pawn) { Pawn p = this.flyingThing as Pawn; if (this.earlyImpact) { DamageEntities(p, this.impactForce, DamageDefOf.Blunt); DamageEntities(p, 2 * this.impactForce, DamageDefOf.Stun); } } else if (flyingThing.def.thingCategories != null && (flyingThing.def.thingCategories.Contains(ThingCategoryDefOf.Chunks) || flyingThing.def.thingCategories.Contains(ThingCategoryDef.Named("StoneChunks")))) { float radius = 3f; Vector3 center = this.ExactPosition; if (this.earlyImpact) { bool wallFlag90neg = false; IntVec3 wallCheck = (center + (Quaternion.AngleAxis(-90, Vector3.up) * this.flyingDirection)).ToIntVec3(); MoteMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); wallFlag90neg = wallCheck.Walkable(base.Map); wallCheck = (center + (Quaternion.AngleAxis(90, Vector3.up) * this.flyingDirection)).ToIntVec3(); MoteMaker.ThrowMicroSparks(wallCheck.ToVector3Shifted(), base.Map); bool wallFlag90 = wallCheck.Walkable(base.Map); if ((!wallFlag90 && !wallFlag90neg) || (wallFlag90 && wallFlag90neg)) { //fragment energy bounces in reverse direction of travel center = center + ((Quaternion.AngleAxis(180, Vector3.up) * this.flyingDirection) * 3); } else if (wallFlag90) { center = center + ((Quaternion.AngleAxis(90, Vector3.up) * this.flyingDirection) * 3); } else if (wallFlag90neg) { center = center + ((Quaternion.AngleAxis(-90, Vector3.up) * this.flyingDirection) * 3); } } int num = GenRadial.NumCellsInRadius(radius); for (int i = 0; i < num / 2; i++) { IntVec3 intVec = center.ToIntVec3() + GenRadial.RadialPattern[Rand.Range(1, num)]; if (intVec.IsValid && intVec.InBounds(base.Map)) { Vector3 moteDirection = GetVector(this.ExactPosition.ToIntVec3(), intVec); EffectMaker.MakeEffect(ThingDef.Named("Mote_Rubble"), this.ExactPosition, base.Map, Rand.Range(.3f, .5f), (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 12f, 0); GenExplosion.DoExplosion(intVec, base.Map, .4f, WizardryDefOf.LotRW_RockFragments, pawn, Rand.Range(6, 16), 0, SoundDefOf.Pawn_Melee_Punch_HitBuilding, null, null, null, ThingDef.Named("Filth_RubbleRock"), .6f, 1, false, null, 0f, 1, 0, false); MoteMaker.ThrowSmoke(intVec.ToVector3Shifted(), base.Map, Rand.Range(.6f, 1f)); } } Thing p = this.flyingThing; DamageEntities(p, 305, DamageDefOf.Blunt); } this.Destroy(DestroyMode.Vanish); } catch { if (!this.flyingThing.Spawned) { GenSpawn.Spawn(this.flyingThing, base.Position, base.Map); } this.Destroy(DestroyMode.Vanish); } }
private void TryConfigureIngredientsByOutput(CombinationDef element) { building.productToTurnInto = element.result; building.thisRecipe = element.defName; if (element.isCategoryRecipe) { switch (building.compItemProcessor.Props.numberOfInputs) { case 1: building.firstCategory = ThingCategoryDef.Named(element.items[0]).defName; building.firstItem = building.firstCategory; building.ExpectedAmountFirstIngredient = element.amount[0]; break; case 2: building.firstCategory = ThingCategoryDef.Named(element.items[0]).defName; building.firstItem = building.firstCategory; building.secondCategory = ThingCategoryDef.Named(element.secondItems[0]).defName; building.secondItem = building.secondCategory; building.ExpectedAmountFirstIngredient = element.amount[0]; building.ExpectedAmountSecondIngredient = element.amount[1]; break; case 3: building.firstCategory = ThingCategoryDef.Named(element.items[0]).defName; building.firstItem = building.firstCategory; building.secondCategory = ThingCategoryDef.Named(element.secondItems[0]).defName; building.secondItem = building.secondCategory; building.thirdCategory = ThingCategoryDef.Named(element.thirdItems[0]).defName; building.thirdItem = building.thirdCategory; building.ExpectedAmountFirstIngredient = element.amount[0]; building.ExpectedAmountSecondIngredient = element.amount[1]; building.ExpectedAmountThirdIngredient = element.amount[2]; break; case 4: building.firstCategory = ThingCategoryDef.Named(element.items[0]).defName; building.firstItem = building.firstCategory; building.secondCategory = ThingCategoryDef.Named(element.secondItems[0]).defName; building.secondItem = building.secondCategory; building.thirdCategory = ThingCategoryDef.Named(element.thirdItems[0]).defName; building.thirdItem = building.thirdCategory; building.fourthCategory = ThingCategoryDef.Named(element.fourthItems[0]).defName; building.fourthItem = building.fourthCategory; building.ExpectedAmountFirstIngredient = element.amount[0]; building.ExpectedAmountSecondIngredient = element.amount[1]; building.ExpectedAmountThirdIngredient = element.amount[2]; building.ExpectedAmountFourthIngredient = element.amount[3]; break; default: building.firstCategory = ThingCategoryDef.Named(element.items[0]).defName; building.firstItem = building.firstCategory; building.ExpectedAmountFirstIngredient = element.amount[0]; break; } } else { switch (building.compItemProcessor.Props.numberOfInputs) { case 1: building.firstItem = ThingDef.Named(element.items[0]).defName; building.ExpectedAmountFirstIngredient = element.amount[0]; break; case 2: building.firstItem = ThingDef.Named(element.items[0]).defName; building.secondItem = ThingDef.Named(element.secondItems[0]).defName; building.ExpectedAmountFirstIngredient = element.amount[0]; building.ExpectedAmountSecondIngredient = element.amount[1]; break; case 3: building.firstItem = ThingDef.Named(element.items[0]).defName; building.secondItem = ThingDef.Named(element.secondItems[0]).defName; building.thirdItem = ThingDef.Named(element.thirdItems[0]).defName; building.ExpectedAmountFirstIngredient = element.amount[0]; building.ExpectedAmountSecondIngredient = element.amount[1]; building.ExpectedAmountThirdIngredient = element.amount[2]; break; case 4: building.firstItem = ThingDef.Named(element.items[0]).defName; building.secondItem = ThingDef.Named(element.secondItems[0]).defName; building.thirdItem = ThingDef.Named(element.thirdItems[0]).defName; building.fourthItem = ThingDef.Named(element.fourthItems[0]).defName; building.ExpectedAmountFirstIngredient = element.amount[0]; building.ExpectedAmountSecondIngredient = element.amount[1]; building.ExpectedAmountThirdIngredient = element.amount[2]; building.ExpectedAmountFourthIngredient = element.amount[3]; break; default: building.firstItem = ThingDef.Named(element.items[0]).defName; building.ExpectedAmountFirstIngredient = element.amount[0]; break; } } if (building.compItemProcessor.Props.isSemiAutomaticMachine) { if (building.compPowerTrader != null && !building.compPowerTrader.PowerOn && building.compItemProcessor.Props.noPowerDestroysProgress) { Messages.Message("IP_NoPowerDestroysWarning".Translate(building.def.LabelCap), building, MessageTypeDefOf.NegativeEvent, true); } else if (building.compFuelable != null && !building.compFuelable.HasFuel && building.compItemProcessor.Props.noPowerDestroysProgress) { Messages.Message("IP_NoFuelDestroysWarning".Translate(building.def.LabelCap), building, MessageTypeDefOf.NegativeEvent, true); } else { building.IngredientsChosenBringThemIn(); } } else { building.processorStage = ProcessorStage.IngredientsChosen; } }
public HistoryAutoRecorderWorker_MoreGraphs_NutritionAnimalProd() : base(ThingCategoryDef.Named("AnimalProductRaw")) { }
private static bool isGrenade(Thing thing) { return(!thing.def.thingCategories.NullOrEmpty() && thing.def.thingCategories.Contains(ThingCategoryDef.Named("Grenades"))); }
public static Building_OutpostCommandConsole GenerateBigRoomCommandRoom(IntVec3 areaSouthWestOrigin, int zoneAbs, int zoneOrd, Rot4 rotation, ref OG_OutpostData outpostData) { Building_OutpostCommandConsole commandConsole = null; IntVec3 origin = Zone.GetZoneOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd); IntVec3 rotatedOrigin = Zone.GetZoneRotatedOrigin(areaSouthWestOrigin, zoneAbs, zoneOrd, rotation); OG_Common.GenerateEmptyRoomAt(rotatedOrigin, Genstep_GenerateOutpost.zoneSideSize, Genstep_GenerateOutpost.zoneSideSize, rotation, TerrainDefOf.Concrete, TerrainDef.Named("CarpetDark"), ref outpostData); // Spawn doors. OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(5, 0, 10).RotatedBy(rotation), ref outpostData); OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(10, 0, 5).RotatedBy(rotation), ref outpostData); OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(5, 0, 0).RotatedBy(rotation), ref outpostData); OG_Common.SpawnDoorAt(rotatedOrigin + new IntVec3(0, 0, 5).RotatedBy(rotation), ref outpostData); // Spawn weapon racks. Building_Storage rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(2, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData) as Building_Storage; OG_Common.TrySpawnWeaponOnRack(rack); rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false); rack.GetStoreSettings().Priority = StoragePriority.Critical; rack = OG_Common.TrySpawnThingAt(ThingDefOf.EquipmentRack, ThingDefOf.Steel, rotatedOrigin + new IntVec3(1, 0, 3).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData) as Building_Storage; OG_Common.TrySpawnWeaponOnRack(rack); rack.GetStoreSettings().filter.SetAllow(ThingCategoryDef.Named("WeaponsMelee"), false); rack.GetStoreSettings().Priority = StoragePriority.Critical; // Spawn lamps. OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(1, 0, 1).RotatedBy(rotation), Color.white, ref outpostData); OG_Common.TrySpawnLampAt(rotatedOrigin + new IntVec3(9, 0, 9).RotatedBy(rotation), Color.white, ref outpostData); // Spawn table and stools. OG_Common.TrySpawnThingAt(ThingDef.Named("Stool"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(7, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData); OG_Common.TrySpawnThingAt(ThingDef.Named("Stool"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(8, 0, 3).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData); OG_Common.TrySpawnThingAt(ThingDef.Named("TableShort"), ThingDefOf.Steel, rotatedOrigin + new IntVec3(8, 0, 1).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData); // Spawn outpost command console, battery and spare parts cabinet. OG_Common.TrySpawnThingAt(ThingDefOf.Battery, null, rotatedOrigin + new IntVec3(1, 0, 9).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData); OG_Common.TrySpawnThingAt(OG_Util.SparePartsCabinetDef, null, rotatedOrigin + new IntVec3(1, 0, 7).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData); OG_Common.SpawnResourceAt(ThingDefOf.Component, 10, rotatedOrigin + new IntVec3(1, 0, 7).RotatedBy(rotation), true); OG_Common.SpawnResourceAt(ThingDefOf.Component, 10, rotatedOrigin + new IntVec3(1, 0, 6).RotatedBy(rotation), true); commandConsole = OG_Common.TrySpawnThingAt(OG_Util.OutpostCommandConsoleDef, null, rotatedOrigin + new IntVec3(3, 0, 9).RotatedBy(rotation), true, new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData) as Building_OutpostCommandConsole; // Spawn workbenches. OG_Common.TrySpawnThingAt(ThingDef.Named("TableMachining"), null, rotatedOrigin + new IntVec3(7, 0, 9).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData); OG_Common.TrySpawnThingAt(ThingDef.Named("ElectricSmithy"), null, rotatedOrigin + new IntVec3(9, 0, 7).RotatedBy(rotation), true, new Rot4(Rot4.East.AsInt + rotation.AsInt), ref outpostData); // Spawn heaters and coolers. OG_Common.TrySpawnHeaterAt(rotatedOrigin + new IntVec3(1, 0, 4).RotatedBy(rotation), ref outpostData); OG_Common.TrySpawnHeaterAt(rotatedOrigin + new IntVec3(4, 0, 1).RotatedBy(rotation), ref outpostData); OG_Common.SpawnCoolerAt(rotatedOrigin + new IntVec3(0, 0, 1).RotatedBy(rotation), new Rot4(Rot4.West.AsInt + rotation.AsInt), ref outpostData); OG_Common.SpawnCoolerAt(rotatedOrigin + new IntVec3(1, 0, 0).RotatedBy(rotation), new Rot4(Rot4.South.AsInt + rotation.AsInt), ref outpostData); // Spawn floor and tactical computer. for (int xOffset = 0; xOffset <= 10; xOffset++) { Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(xOffset, 0, 5).RotatedBy(rotation), TerrainDef.Named("PavedTile")); } for (int zOffset = 0; zOffset <= 10; zOffset++) { Find.TerrainGrid.SetTerrain(rotatedOrigin + new IntVec3(5, 0, zOffset).RotatedBy(rotation), TerrainDef.Named("PavedTile")); } CellRect rect = new CellRect(origin.x + 3, origin.z + 3, 5, 5); foreach (IntVec3 cell in rect) { Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("PavedTile")); } foreach (IntVec3 cell in rect.ContractedBy(1)) { Find.TerrainGrid.SetTerrain(cell, TerrainDef.Named("CarpetRed")); } if (OG_Util.IsModActive("Misc. Incidents")) { OG_Common.TrySpawnThingAt(ThingDef.Named("TacticalComputer"), null, rotatedOrigin + new IntVec3(5, 0, 5).RotatedBy(rotation), true, new Rot4(Rot4.North.AsInt + rotation.AsInt), ref outpostData); } return(commandConsole); }
public static void GenerateIngredients(Thing meal, Pawn eater) { CompIngredients compIngredients = meal.TryGetComp <CompIngredients>(); if (compIngredients != null) { // Stage 1: Generate random ingredients according to recipe // 1.1: Find recipe Func <RecipeDef, bool> validator = delegate(RecipeDef r) { bool directMatch = r.ProducedThingDef == meal.def; // Add compatibility for VCE Soups and Stews, whose original recipes only makes uncooked versions bool indirectMatch = (r.ProducedThingDef != null) ? (r.ProducedThingDef.ToString().Replace("Uncooked", "Cooked") == meal.def.ToString()) : false; return(directMatch || indirectMatch); }; RecipeDef mealRecipe = DefDatabase <RecipeDef> .AllDefsListForReading.First(validator); if (mealRecipe != null) { // 1.2: Generate ingredients from recipe List <string> ingredientCategoryOptions = new List <string>(); List <ThingDef> ingredientThingDefs = new List <ThingDef>(); // 1.3: Find ingredient categories and/or fixed thingDefs foreach (IngredientCount currIngredientCount in mealRecipe.ingredients) { if (currIngredientCount.filter.categories != null) { // Limit to 3 instances of an ingredient category int ingredientCatInstances = Math.Min((int)Math.Ceiling(currIngredientCount.count / 0.5f), 3); for (int i = 0; i < ingredientCatInstances; i++) { // Max limit of one condiment from Vanilla Cooking Expanded if (currIngredientCount.filter.categories.Contains("VCE_Condiments") && ingredientCategoryOptions.Contains("VCE_Condiments")) { continue; } else { ingredientCategoryOptions.Add(currIngredientCount.filter.categories.RandomElement()); } } } if (currIngredientCount.filter.thingDefs != null) { ingredientThingDefs.AddRange(currIngredientCount.filter.thingDefs); } } // 1.4: Generate random ingredient thingDefs based on categories, and add them to the existing list of fixed thingDefs // // By default, we ignore ingredients that are: // - Permanently disallowed by the Computer // - Disallowed specifically by the pawn's food restriction policy // - Humanlike and insect meats // - Fertilized eggs List <ThingDef> allowedIngredients = ThingCategoryDef.Named("FoodRaw").DescendantThingDefs.Where(x => !replimatRestrictions.disallowedIngredients.Contains(x) && eater.foodRestriction.CurrentFoodRestriction.Allows(x) && FoodUtility.GetMeatSourceCategory(x) != MeatSourceCategory.Humanlike && FoodUtility.GetMeatSourceCategory(x) != MeatSourceCategory.Insect && !x.thingCategories.Contains(ThingCategoryDefOf.EggsFertilized) ).ToList(); // Also check allowed condiments if Vanilla Cooking Expanded mod is active if (ModCompatibility.VanillaCookingExpandedIsActive) { allowedIngredients.AddRange(ThingCategoryDef.Named("VCE_Condiments").DescendantThingDefs.Where(x => !replimatRestrictions.disallowedIngredients.Contains(x) && eater.foodRestriction.CurrentFoodRestriction.Allows(x) )); } foreach (string currentIngredientCatOption in ingredientCategoryOptions) { List <ThingDef> ingredients = ThingCategoryDef.Named(currentIngredientCatOption).DescendantThingDefs.Where((ThingDef d) => allowedIngredients.Contains(d)).ToList(); ThingDef ingredient = (ingredients.Count > 0) ? ingredients.RandomElement() : null; // Avoid empty or duplicate ingredients if (ingredient != null && !ingredientThingDefs.Contains(ingredient)) { ingredientThingDefs.Add(ingredient); } } // Stage 2: Ideo replacements Ideo ideo = eater.Ideo; // 2.1 Human cannibalism for meals containing meat if (ideo?.HasHumanMeatEatingRequiredPrecept() == true) { List <ThingDef> existingMeats = ingredientThingDefs.FindAll((ThingDef d) => d.thingCategories.Contains(ThingCategoryDefOf.MeatRaw)); // Replace existing meats with a single instance of human meat if (existingMeats.Count > 0) { ingredientThingDefs = ingredientThingDefs.Except(existingMeats).ToList(); ingredientThingDefs.Add(ThingDefOf.Meat_Human); } } // 2.2 Insect meat loved for meals containing meat if (ideo?.HasPrecept(ReplimatDef.InsectMeatEating_Loved) == true) { List <ThingDef> existingMeats = ingredientThingDefs.FindAll((ThingDef d) => d.thingCategories.Contains(ThingCategoryDefOf.MeatRaw)); // Replace existing meats with a single instance of insect meat if (existingMeats.Count > 0) { ingredientThingDefs = ingredientThingDefs.Except(existingMeats).ToList(); ingredientThingDefs.Add(ReplimatDef.Meat_Megaspider); } } // 2.3 Fungus preferred for meals containing raw plant food if (ideo?.HasPrecept(ReplimatDef.FungusEating_Preferred) == true) { List <ThingDef> existingPlantFoodRaws = ingredientThingDefs.FindAll((ThingDef d) => d.thingCategories.Contains(ThingCategoryDefOf.PlantFoodRaw) || d.ingestible.foodType == FoodTypeFlags.VegetableOrFruit); // todo - fix // Replace existing raw plant food with a single instance of fungus if (existingPlantFoodRaws.Count > 0) { ingredientThingDefs = ingredientThingDefs.Except(existingPlantFoodRaws).ToList(); ingredientThingDefs.Add(ReplimatDef.RawFungus); } } // 2.4 Fungus despised for meals containing raw plant food if (ideo?.HasPrecept(ReplimatDef.FungusEating_Despised) == true) { ingredientThingDefs.Remove(ReplimatDef.RawFungus); } // Stage 3: Assign final ingredients to meal compIngredients.ingredients.AddRange(ingredientThingDefs); } } }
public static void Postfix(List <TransferableOneWay> transferables, ref TransferableOneWayWidget pawnsTransfer, ref TransferableOneWayWidget itemsTransfer, string thingCountTip, IgnorePawnsInventoryMode ignorePawnInventoryMass, Func <float> availableMassGetter, bool ignoreSpawnedCorpsesGearAndInventoryMass, int tile, bool playerPawnsReadOnly) { List <TransferableOneWay> modifiedTransferables = transferables.Where((TransferableOneWay x) => x.ThingDef.category != ThingCategory.Pawn).ToList(); modifiedTransferables = modifiedTransferables.Where(x => !x.ThingDef.IsWithinCategory(ThingCategoryDef.Named("RoadEquipment"))).ToList(); itemsTransfer = new TransferableOneWayWidget(modifiedTransferables, null, null, thingCountTip, drawMass: true, ignorePawnInventoryMass, includePawnsMassInMassUsage: false, availableMassGetter, 0f, ignoreSpawnedCorpsesGearAndInventoryMass, tile, drawMarketValue: true, drawEquippedWeapon: false, drawNutritionEatenPerDay: false, drawItemNutrition: true, drawForagedFoodPerDay: false, drawDaysUntilRot: true); }