/// <summary> /// Display the scan range of built mobile mineral sonar and the max scan range at the tested position. /// Allow placement nearly anywhere. /// </summary> public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot) { IEnumerable<Building> mobileMineralSonarList = Find.ListerBuildings.AllBuildingsColonistOfDef(ThingDef.Named("MobileMineralSonar")); if (mobileMineralSonarList != null) { foreach (Building mobileMineralSonar in mobileMineralSonarList) { (mobileMineralSonar as Building_MobileMineralSonar).DrawMaxScanRange(); } } ResearchProjectDef mmsResearch = ResearchProjectDef.Named("ResearchMobileMineralSonarEnhancedScan"); if (Find.ResearchManager.GetProgress(mmsResearch) >= mmsResearch.CostApparent) { Material scanRange30 = MaterialPool.MatFrom("Effects/ScanRange30"); Vector3 scanRangeScale30 = new Vector3(60f, 1f, 60f); Matrix4x4 scanRangeMatrix30 = default(Matrix4x4); // The 10f offset on Y axis is mandatory to be over the fog of war. scanRangeMatrix30.SetTRS(loc.ToVector3Shifted() + new Vector3(0f, 10f, 0f) + Altitudes.AltIncVect, (0f).ToQuat(), scanRangeScale30); Graphics.DrawMesh(MeshPool.plane10, scanRangeMatrix30, scanRange30, 0); } else { Material scanRange50 = MaterialPool.MatFrom("Effects/ScanRange50"); Vector3 scanRangeScale50 = new Vector3(100f, 1f, 100f); Matrix4x4 scanRangeMatrix50 = default(Matrix4x4); // The 10f offset on Y axis is mandatory to be over the fog of war. scanRangeMatrix50.SetTRS(loc.ToVector3Shifted() + new Vector3(0f, 10f, 0f) + Altitudes.AltIncVect, (0f).ToQuat(), scanRangeScale50); Graphics.DrawMesh(MeshPool.plane10, scanRangeMatrix50, scanRange50, 0); } return true; }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot) { bool flag = false; List<Thing> list = Find.ThingGrid.ThingsListAt(loc); if (list.Count > 0) { foreach (Thing current in list) { if (current.def.category == ThingCategory.Building) { if (current.def.holdsRoof && current.def.coversFloor && current.def.altitudeLayer == AltitudeLayer.BuildingTall && current.def.passability == Traversability.Impassable) { flag = true; break; } } } } else { flag = false; } AcceptanceReport result; if (flag) { result = true; } else { result = "Need to be placed on a colony wall"; } return result; }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Thing thingToIgnore = null) { IEnumerable<IntVec3> cells = GenAdj.CellsAdjacent8Way(loc, rot, checkingDef.Size).Union<IntVec3>(GenAdj.CellsOccupiedBy(loc, rot, checkingDef.Size)); foreach (IntVec3 cell in cells) { List<Thing> things = Map.thingGrid.ThingsListAt(cell); foreach (Thing thing in things) { if (thing.TryGetComp<CompRTQuantumStockpile>() != null || thing.TryGetComp<CompRTQuantumChunkSilo>() != null) { return "PlaceWorker_RTNoQSOverlap".Translate(); } else if (thing.def.entityDefToBuild != null) { ThingDef thingDef = thing.def.entityDefToBuild as ThingDef; if (null != thingDef && null != thingDef.comps && null != thingDef.comps.Find(x => typeof(CompRTQuantumStockpile) == x.compClass)) { return "PlaceWorker_RTNoQSOverlap".Translate(); } } } } return true; }
public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot ) { ThingDef def = checkingDef as ThingDef; var Restrictions = def.GetCompProperties( typeof( RestrictedPlacement_Comp ) ) as RestrictedPlacement_Properties; if( Restrictions == null ){ Log.Error( "Could not get restrictions!" ); return (AcceptanceReport)false; } // Override steam-geyser restriction if( ( Restrictions.RestrictedThing.FindIndex( r => r == ThingDefOf.SteamGeyser ) >= 0 )&& ( ThingDefOf.GeothermalGenerator != ( checkingDef as ThingDef ) ) ){ var newGeo = checkingDef as ThingDef; ThingDefOf.GeothermalGenerator = newGeo; } foreach( Thing t in loc.GetThingList() ){ if( ( Restrictions.RestrictedThing.Find( r => r == t.def ) != null )&& ( t.Position == loc ) ) return (AcceptanceReport)true; } return "MessagePlacementNotHere".Translate(); }
public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot ) { var Restrictions = checkingDef.RestrictedPlacement_Properties(); #if DEBUG if( Restrictions == null ){ CCL_Log.Error( "PlaceWorker_RestrictedCount unable to get properties!", checkingDef.defName ); return AcceptanceReport.WasRejected; } #endif var thingDef = checkingDef as ThingDef; #if DEBUG if( thingDef == null ) { CCL_Log.Error( "PlaceWorker_RestrictedCount unable to get cast BuildableDef to ThingDef!", checkingDef.defName ); return AcceptanceReport.WasRejected; } #endif // Get the current count of instances and blueprints of int count = Find.ListerThings.ThingsOfDef( thingDef ).Count + Find.ListerThings.ThingsOfDef( thingDef.blueprintDef ).Count; return count < Restrictions.MaxCount ? AcceptanceReport.WasAccepted : "MessagePlacementCountRestricted".Translate( Restrictions.MaxCount ); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot) { string reason = ""; bool canBePlacedHere = Building_LaserFencePylon.CanPlaceNewPylonHere(loc, out reason); if (canBePlacedHere == false) { return new AcceptanceReport(reason); } // Display potential placing positions. foreach (Thing pylon in Find.ListerThings.ThingsOfDef(ThingDef.Named("LaserFencePylon").blueprintDef)) { if (pylon.Position.InHorDistOf(loc, 6f)) { Building_LaserFencePylon.DrawPotentialPlacePositions(pylon.Position); } } foreach (Thing pylon in Find.ListerThings.ThingsOfDef(ThingDef.Named("LaserFencePylon").frameDef)) { if (pylon.Position.InHorDistOf(loc, 6f)) { Building_LaserFencePylon.DrawPotentialPlacePositions(pylon.Position); } } foreach (Thing pylon in Find.ListerThings.ThingsOfDef(ThingDef.Named("LaserFencePylon"))) { if (pylon.Position.InHorDistOf(loc, 6f)) { Building_LaserFencePylon.DrawPotentialPlacePositions(pylon.Position); } } return true; }
/// <summary> /// Checks if a new force field generator can be built at this location. /// - must not be too near from another force field generator (or it would perturb other fields). /// </summary> public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot) { // Check if another force field generator is not too close. List<Thing> forceFieldGeneratorList = new List<Thing>(); IEnumerable<Thing> list = Find.ListerThings.ThingsOfDef(ThingDef.Named("ForceFieldGenerator")); foreach (Thing generator in list) { forceFieldGeneratorList.Add(generator); } list = Find.ListerThings.ThingsOfDef(ThingDef.Named("ForceFieldGenerator").blueprintDef); foreach (Thing generator in list) { forceFieldGeneratorList.Add(generator); } list = Find.ListerThings.ThingsOfDef(ThingDef.Named("ForceFieldGenerator").frameDef); foreach (Thing generator in list) { forceFieldGeneratorList.Add(generator); } foreach (Thing generator in forceFieldGeneratorList) { if (generator.Position.InHorDistOf(loc, minDistanceBetweenTwoForceFieldGenerators)) { return new AcceptanceReport("An other force field generator is too close (would generate perturbations)."); } } // Display effect zone. List<IntVec3> coveredCells = Building_ForceFieldGenerator.GetCoveredCells(loc, rot); GenDraw.DrawFieldEdges(coveredCells); return true; }
public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot ) { if( CompHopper.FindHopperUser( loc + rot.FacingCell ) != null ) { return ( AcceptanceReport )true; } return ( AcceptanceReport )( "Must connect to a building that needs a hopper." ); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot) { Fissure thing = (Fissure)Find.ThingGrid.ThingAt(loc, ThingDef.Named("MD2Fissure")); if (thing != null && thing.Position == loc) return true; else return "OnFissureReportString".Translate(); }
/// <summary> /// Check if a new fishing pier can be built at this location. /// - the fishing pier bank cell must be on a bank. /// - the rest of the fishing pier and the fishing spot must be on water. /// - must not be too near from another fishing pier. /// </summary> public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot) { // Check fishing pier bank cell is on a "solid" terrain. if (IsAquaticTerrain(loc)) { return new AcceptanceReport("Fishing pier must touch a bank."); } // Check fishing pier middle and river cells are on water. if ((IsAquaticTerrain(loc + new IntVec3(0, 0, 1).RotatedBy(rot)) == false) || (IsAquaticTerrain(loc + new IntVec3(0, 0, 2).RotatedBy(rot)) == false)) { return new AcceptanceReport("Fishing pier must be placed on water."); } // Check fishing zone is on water. for (int xOffset = -1; xOffset <= 1; xOffset++) { for (int yOffset = 3; yOffset <= 5; yOffset++) { if (IsAquaticTerrain(loc + new IntVec3(xOffset, 0, yOffset).RotatedBy(rot)) == false) { return new AcceptanceReport("Fishing zone must be placed on water."); } } } // Check if another fishing pier is not too close (mind the test on "fishing pier" def and "fishing pier spawner" blueprint and frame defs. List<Thing> fishingPierList = Find.ListerThings.ThingsOfDef(Util_FishIndustry.FishingPierDef); List<Thing> fishingPierSpawnerBlueprintList = Find.ListerThings.ThingsOfDef(Util_FishIndustry.FishingPierSpawnerDef.blueprintDef); List<Thing> fishingPierSpawnerFrameList = Find.ListerThings.ThingsOfDef(Util_FishIndustry.FishingPierSpawnerDef.frameDef); if (fishingPierList != null) { IEnumerable<Thing> fishingPierInTheArea = fishingPierList.Where(building => loc.InHorDistOf(building.Position, minDistanceBetweenTwoFishingPiers)); if (fishingPierInTheArea.Count() > 0) { return new AcceptanceReport("An other fishing pier is too close."); } } if (fishingPierSpawnerBlueprintList != null) { IEnumerable<Thing> fishingPierBlueprintInTheArea = fishingPierSpawnerBlueprintList.Where(building => loc.InHorDistOf(building.Position, minDistanceBetweenTwoFishingPiers)); if (fishingPierBlueprintInTheArea.Count() > 0) { return new AcceptanceReport("An other fishing pier blueprint is too close."); } } if (fishingPierSpawnerFrameList != null) { IEnumerable<Thing> fishingPierFrameInTheArea = fishingPierSpawnerFrameList.Where(building => loc.InHorDistOf(building.Position, minDistanceBetweenTwoFishingPiers)); if (fishingPierFrameInTheArea.Count() > 0) { return new AcceptanceReport("An other fishing pier frame is too close."); } } return true; }
public override AcceptanceReport AllowsPlacing( BuildableDef def, IntVec3 center, Rot4 rot ) { var things = Find.Map.thingGrid.ThingsListAt( center ); if ( things.Exists( s => s is IWallAttachable ) ) { return ResourceBank.WallAlreadyOccupied; } return true; }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot) { var room = loc.GetRoom(); if( room.ContainedBeds.Any( bed => !bed.ForPrisoners ) ) { return (AcceptanceReport) Data.Strings.NoColonistBeds.Translate(); } return (AcceptanceReport) true; }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot) { TerrainDef mudDef = DefDatabase<TerrainDef>.GetNamed("Mud"); TerrainDef waterDef = DefDatabase<TerrainDef>.GetNamed("WaterShallow"); if (Find.TerrainGrid.TerrainAt(loc) == mudDef || Find.TerrainGrid.TerrainAt(loc) == waterDef) { return true; } return "OnMudOrWaterReportString".Translate(); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot) { ThingDef def = checkingDef as ThingDef; int num = Find.ListerBuildings.allBuildingsColonist.Where((Building b)=>b.def==def).Count(); num += Find.ListerThings.ThingsOfDef(def.blueprintDef).Count; if(num==0) { return AcceptanceReport.WasAccepted; } return "MaximumOneReportString".Translate(); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Thing thingToIgnore = null) { IEnumerable<IntVec3> cells = GenAdj.CellsOccupiedBy(loc, rot, checkingDef.Size); foreach (IntVec3 cell in cells) { if (!cell.Walkable(Map)) { return "PlaceWorker_RTRequireWalkable".Translate(); } } return true; }
public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot ) { foreach( Thing curThing in loc.GetThingList() ) { if( curThing.def.surfaceType != SurfaceType.None ) { return AcceptanceReport.WasAccepted; } } return (AcceptanceReport)( "MessagePlacementItemSurface".Translate() ); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Thing thingToIgnore = null) { IEnumerable<IntVec3> cells = GenAdj.CellsOccupiedBy(loc, rot, checkingDef.Size); foreach (IntVec3 cell in cells) { Zone_Stockpile zoneStockpile = cell.GetZone(Map) as Zone_Stockpile; if (zoneStockpile != null && zoneStockpile.FindWarehouse() != null) { return "PlaceWorker_RTOnlyOneQWPerZone".Translate(); } } return true; }
public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot ) { AcceptanceReport result; if( Find.RoofGrid.Roofed( loc ) ) { result = true; } else { result = "MessagePlacementMustBeUnderRoof".Translate(); } return result; }
public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot ) { IntVec3 c = loc + rot.FacingCell * -1; if( !c.InBounds() ) { return false; } if( c.GetEdifice() == null ) { return "MessagePlacementAgainstSupport".Translate(); } return true; }
/// <summary> /// Restrict placement over non stony floors. /// </summary> public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot) { TerrainDef terrain = loc.GetTerrain(); if ((terrain == TerrainDef.Named("Soil")) || (terrain == TerrainDef.Named("SoilRich")) || (terrain == TerrainDef.Named("Gravel")) || (terrain == TerrainDef.Named("MossyTerrain")) || (terrain == TerrainDef.Named("MarshyTerrain"))) { return true; } return new AcceptanceReport("Dirt floor must be placed on soft soil."); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot) { AcceptanceReport acceptanceReport = base.AllowsPlacing(checkingDef, loc, rot); if (acceptanceReport.Accepted == false) { return acceptanceReport; } // Draw party and beer search area. CampfireParty.Building_Pyre.DrawPartyAndBeerSearchAreas(loc); return true; }
public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot ) { IntVec3 c = loc - rot.FacingCell; Building support = c.GetEdifice(); if( support == null ) { return (AcceptanceReport)( "MessagePlacementAgainstSupport".Translate() ); } return ( support.def.graphicData.linkFlags & ( LinkFlags.Rock | LinkFlags.Wall ) ) != 0 ? AcceptanceReport.WasAccepted : ( AcceptanceReport )( "MessagePlacementAgainstSupport".Translate() ); }
public void PlaceFrameForBuild(BuildableDef sourceDef, IntVec3 center, Rot4 rotation, Faction faction, ThingDef stuff) { var frame = (Frame)ThingMaker.MakeThing(sourceDef.frameDef, stuff); frame.SetFactionDirect(faction); foreach (var resource in frame.MaterialsNeeded()) { var resource1 = ThingMaker.MakeThing(resource.thingDef); resource1.stackCount = (int)Math.Round(resource.count * Properties.upgradeDiscountMultiplier); frame.resourceContainer.TryAdd(resource1); } frame.workDone = (int)Math.Round(frame.def.entityDefToBuild.GetStatValueAbstract(StatDefOf.WorkToMake, frame.Stuff) * Properties.upgradeDiscountMultiplier); GenSpawn.Spawn(frame, center, rotation); }
public override AcceptanceReport AllowsPlacing( BuildableDef def, IntVec3 center, Rot4 rot ) { var vecSouth = center + IntVec3.South.RotatedBy( rot ); var vecSouthEast = vecSouth + IntVec3.East.RotatedBy( rot ); if (!vecSouth.InBounds() || !vecSouthEast.InBounds()) { return false; } if (vecSouth.Impassable() || vecSouthEast.Impassable()) { return ResourceBank.ExposeCold; } return true; }
/// <summary> /// Checks if a new alert speaker can be built at this location. /// - must be near a wall, /// - must not be too near from another alert speaker. /// </summary> public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot) { IntVec3 potentialWallPosition = loc; // Check if another alert speaker is not too close. List<Thing> alertSpeakerList = Find.ListerThings.ThingsOfDef(ThingDef.Named("AlertSpeaker")); List<Thing> alertSpeakerBlueprintList = Find.ListerThings.ThingsOfDef(ThingDef.Named("AlertSpeaker").blueprintDef); List<Thing> alertSpeakerFrameList = Find.ListerThings.ThingsOfDef(ThingDef.Named("AlertSpeaker").frameDef); if (alertSpeakerList != null) { IEnumerable<Thing> alertSpeakerInTheArea = alertSpeakerList.Where(building => loc.InHorDistOf(building.Position, minDistanceBetweenTwoAlertSpeakers)); if (alertSpeakerInTheArea.Count() > 0) { return new AcceptanceReport("An other alert speaker is too close."); } } if (alertSpeakerBlueprintList != null) { IEnumerable<Thing> alertSpeakerBlueprintInTheArea = alertSpeakerBlueprintList.Where(building => loc.InHorDistOf(building.Position, minDistanceBetweenTwoAlertSpeakers)); if (alertSpeakerBlueprintInTheArea.Count() > 0) { return new AcceptanceReport("An other alert speaker blueprint is too close."); } } if (alertSpeakerFrameList != null) { IEnumerable<Thing> alertSpeakerFrameInTheArea = alertSpeakerFrameList.Where(building => loc.InHorDistOf(building.Position, minDistanceBetweenTwoAlertSpeakers)); if (alertSpeakerFrameInTheArea.Count() > 0) { return new AcceptanceReport("An other alert speaker frame is too close."); } } // Check it is built near a wall. if (Building_AlertSpeaker.CheckIfSupportingWallIsAlive(loc, rot) == false) { return new AcceptanceReport("Alert speaker must be built near a wall."); } // Display effect zone. if (Find.ThingGrid.CellContains(loc, ThingCategory.Building) == false) { List<IntVec3> cellsInEffectZone = Building_AlertSpeaker.GetEffectZoneCells(loc); GenDraw.DrawFieldEdges(cellsInEffectZone); } return true; }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot) { ThingDef def = ThingDef.Named("MD2CoalBurner"); foreach (IntVec3 pos in GenAdj.CellsAdjacentCardinal(loc,Rot4.North,IntVec2.One)) { foreach (Thing thing in Find.ThingGrid.ThingsAt(pos)) { if (thing.def == def) { return true; } } } return "Must be placed next to a coal burner"; }
public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot ) { IntVec3 c = loc + rot.FacingCell * -1; if( !c.InBounds() ) { return false; } Building support = c.GetEdifice(); if( ( support == null )|| ( ( support.def.graphicData.linkFlags & ( LinkFlags.Rock | LinkFlags.Wall ) ) == 0 ) ) { return "MessagePlacementAgainstSupport".Translate(); } return true; }
public override AcceptanceReport AllowsPlacing( BuildableDef def, IntVec3 center, Rot4 rot ) { var vecNorth = center + IntVec3.North.RotatedBy( rot ); if (!vecNorth.InBounds()) { return false; } if (vecNorth.Impassable()) { return ResourceBank.ExposeDuct; } return true; }
public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot ) { ThingDef def = checkingDef as ThingDef; var Restrictions = def.GetCompProperties( typeof( RestrictedPlacement_Comp ) ) as RestrictedPlacement_Properties; if( Restrictions == null ){ Log.Error( "Could not get restrictions!" ); return false; } foreach( Thing t in loc.GetThingList() ) if( Restrictions.RestrictedThing.Find( r => r == t.def ) != null ) return "MessagePlacementNotOn".Translate() + t.def.label; return true; }
public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot ) { ThingDef def = checkingDef as ThingDef; var Restrictions = def.GetCompProperties( typeof( RestrictedPlacement_Comp ) ) as RestrictedPlacement_Properties; if( Restrictions == null ){ Log.Error( "Could not get restrictions!" ); return false; } TerrainDef terrainDef = loc.GetTerrain(); for( int i = 0; i < Restrictions.RestrictedTerrain.Count; i++ ) if( Restrictions.RestrictedTerrain[ i ] == terrainDef ) return true; return "MessagePlacementNotOnTerrain".Translate() + terrainDef.label; }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { for (int i = 0; i < 4; i++) { IntVec3 intVec3 = loc + GenAdj.CardinalDirections[i]; if (intVec3.InBounds(map)) { List <Thing> thingList = intVec3.GetThingList(map); for (int j = 0; j < thingList.Count; j++) { Thing item = thingList[j]; ThingDef thingDef = GenConstruct.BuiltDefOf(item.def) as ThingDef; if (thingDef != null && thingDef.building != null) { if (thingDef.defName == NanoPrinterDef) { return(true); } } } } } return(txtMustPlaceNextToNanoPrinter.Translate()); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null) { Thing avaliWormholePlatform = AvaliUtility.SpecifiedThingAtCellWithDefName(map.thingGrid.ThingsListAtFast(loc), "AvaliWormholePlatform"); if (avaliWormholePlatform != null && loc == avaliWormholePlatform.InteractionCell) { return(true); } Thing avaliWormholePod = AvaliUtility.SpecifiedThingAtCellWithDefName(map.thingGrid.ThingsListAtFast(new IntVec3(loc.x, loc.y, loc.z + 1)), "AvaliWormholePod"); if (DirectionCorrect(avaliWormholePod, loc)) { return(true); } avaliWormholePod = AvaliUtility.SpecifiedThingAtCellWithDefName(map.thingGrid.ThingsListAtFast(new IntVec3(loc.x, loc.y, loc.z - 1)), "AvaliWormholePod"); if (DirectionCorrect(avaliWormholePod, loc)) { return(true); } avaliWormholePod = AvaliUtility.SpecifiedThingAtCellWithDefName(map.thingGrid.ThingsListAtFast(new IntVec3(loc.x + 1, loc.y, loc.z)), "AvaliWormholePod"); if (DirectionCorrect(avaliWormholePod, loc)) { return(true); } avaliWormholePod = AvaliUtility.SpecifiedThingAtCellWithDefName(map.thingGrid.ThingsListAtFast(new IntVec3(loc.x - 1, loc.y, loc.z)), "AvaliWormholePod"); if (DirectionCorrect(avaliWormholePod, loc)) { return(true); } return(new AcceptanceReport("MustPlaceOnWormholePlatformIntCell".Translate())); }
private Job GetDeconstructingJob(Pawn meeseeks, SavedTargetInfo jobTarget, Map map) { BuildableDef buildableDef = jobTarget.BuildableDef; if (buildableDef == null) { return(null); } CellRect cellRect = GenAdj.OccupiedRect(jobTarget.Cell, jobTarget.blueprintRotation, buildableDef.Size); foreach (IntVec3 cell in cellRect) { foreach (Thing thing in cell.GetThingList(map)) { if (!GenConstruct.CanPlaceBlueprintOver(buildableDef, thing.def)) { return(JobMaker.MakeJob(JobDefOf.Deconstruct, thing)); } } } return(null); }
/// <summary> /// Checks if a new force field generator can be built at this location. /// - must not be too near from another force field generator (or it would perturb other fields). /// </summary> public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Thing thingToIgnore = null) { // Check if another force field generator is not too close. List <Thing> forceFieldGeneratorList = new List <Thing>(); IEnumerable <Thing> list = this.Map.listerThings.ThingsOfDef(ThingDef.Named("ForceFieldGenerator")); foreach (Thing generator in list) { forceFieldGeneratorList.Add(generator); } list = this.Map.listerThings.ThingsOfDef(ThingDef.Named("ForceFieldGenerator").blueprintDef); foreach (Thing generator in list) { forceFieldGeneratorList.Add(generator); } list = this.Map.listerThings.ThingsOfDef(ThingDef.Named("ForceFieldGenerator").frameDef); foreach (Thing generator in list) { forceFieldGeneratorList.Add(generator); } foreach (Thing generator in forceFieldGeneratorList) { if (generator.Position.InHorDistOf(loc, minDistanceBetweenTwoForceFieldGenerators)) { return(new AcceptanceReport("An other force field generator is too close (would generate perturbations).")); } } // Display effect zone. List <IntVec3> coveredCells = Building_ForceFieldGenerator.GetCoveredCells(loc, rot); GenDraw.DrawFieldEdges(coveredCells); return(true); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { foreach (var current in CompPowerPlantWater.GroundCells(loc, rot)) { if (map.terrainGrid.TerrainAt(current).affordances.Contains(TerrainAffordanceDefOf.Heavy)) { continue; } var result = new AcceptanceReport( "TerrainCannotSupport_TerrainAffordance".Translate(checkingDef, TerrainAffordanceDefOf.Heavy)); return(result); } if (!WaterCellsPresent(loc, rot, map)) { return(new AcceptanceReport("MustBeOnMovingWater".Translate())); } return(true); }
// Token: 0x06004746 RID: 18246 RVA: 0x00215755 File Offset: 0x00213B55 public override bool ForceAllowPlaceOver(BuildableDef otherDef) { return(otherDef == DefDatabase <ThingDef> .GetNamed("ra2_GoldMineral", true)); }
public static bool IsSurvivalTool(this BuildableDef def, out SurvivalToolProperties toolProps) { toolProps = def.GetModExtension <SurvivalToolProperties>(); return(def.IsSurvivalTool()); }
public static bool OrRotDoesntMatter(bool result, BuildableDef entDef) { return(result || PlacingRotationDoesntMatter(entDef)); }
public CostListPair(BuildableDef buildable, ThingDef stuff) { this.buildable = buildable; this.stuff = stuff; }
public static ThingDef DefaultStuffFor(BuildableDef bd) { if (!bd.MadeFromStuff) { return(null); } ThingDef thingDef = bd as ThingDef; if (thingDef != null) { if (thingDef.IsMeleeWeapon) { if (ThingDefOf.Steel.stuffProps.CanMake(bd)) { return(ThingDefOf.Steel); } if (ThingDefOf.Plasteel.stuffProps.CanMake(bd)) { return(ThingDefOf.Plasteel); } } if (thingDef.IsApparel) { if (ThingDefOf.Cloth.stuffProps.CanMake(bd)) { return(ThingDefOf.Cloth); } if (ThingDefOf.Leather_Plain.stuffProps.CanMake(bd)) { return(ThingDefOf.Leather_Plain); } if (ThingDefOf.Steel.stuffProps.CanMake(bd)) { return(ThingDefOf.Steel); } } } if (ThingDefOf.WoodLog.stuffProps.CanMake(bd)) { return(ThingDefOf.WoodLog); } if (ThingDefOf.Steel.stuffProps.CanMake(bd)) { return(ThingDefOf.Steel); } if (ThingDefOf.Plasteel.stuffProps.CanMake(bd)) { return(ThingDefOf.Plasteel); } if (ThingDefOf.BlocksGranite.stuffProps.CanMake(bd)) { return(ThingDefOf.BlocksGranite); } if (ThingDefOf.Cloth.stuffProps.CanMake(bd)) { return(ThingDefOf.Cloth); } if (ThingDefOf.Leather_Plain.stuffProps.CanMake(bd)) { return(ThingDefOf.Leather_Plain); } return(AllowedStuffsFor(bd).First()); }
public static AcceptanceReport CanPlaceBlueprintAt(BuildableDef entDef, IntVec3 center, Rot4 rot, Map map, bool godMode = false, Thing thingToIgnore = null) { CellRect cellRect = GenAdj.OccupiedRect(center, rot, entDef.Size); CellRect.CellRectIterator iterator = cellRect.GetIterator(); while (!iterator.Done()) { IntVec3 c = iterator.Current; if (!c.InBounds(map)) { return(new AcceptanceReport("OutOfBounds".Translate())); } if (c.InNoBuildEdgeArea(map) && !DebugSettings.godMode) { return("TooCloseToMapEdge".Translate()); } iterator.MoveNext(); } if (center.Fogged(map)) { return("CannotPlaceInUndiscovered".Translate()); } List <Thing> thingList = center.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { Thing thing = thingList[i]; if (thing != thingToIgnore) { if (thing.Position == center && thing.Rotation == rot) { if (thing.def == entDef) { return(new AcceptanceReport("IdenticalThingExists".Translate())); } if (thing.def.entityDefToBuild == entDef) { if (thing is Blueprint) { return(new AcceptanceReport("IdenticalBlueprintExists".Translate())); } return(new AcceptanceReport("IdenticalThingExists".Translate())); } } } } ThingDef thingDef = entDef as ThingDef; if (thingDef != null && thingDef.hasInteractionCell) { IntVec3 c2 = ThingUtility.InteractionCellWhenAt(thingDef, center, rot, map); if (!c2.InBounds(map)) { return(new AcceptanceReport("InteractionSpotOutOfBounds".Translate())); } List <Thing> list = map.thingGrid.ThingsListAtFast(c2); for (int j = 0; j < list.Count; j++) { if (list[j] != thingToIgnore) { if (list[j].def.passability == Traversability.Impassable) { return(new AcceptanceReport("InteractionSpotBlocked".Translate(new object[] { list[j].LabelNoCount }).CapitalizeFirst())); } Blueprint blueprint = list[j] as Blueprint; if (blueprint != null && blueprint.def.entityDefToBuild.passability == Traversability.Impassable) { return(new AcceptanceReport("InteractionSpotWillBeBlocked".Translate(new object[] { blueprint.LabelNoCount }).CapitalizeFirst())); } } } } if (entDef.passability == Traversability.Impassable) { foreach (IntVec3 c3 in GenAdj.CellsAdjacentCardinal(center, rot, entDef.Size)) { if (c3.InBounds(map)) { thingList = c3.GetThingList(map); for (int k = 0; k < thingList.Count; k++) { Thing thing2 = thingList[k]; if (thing2 != thingToIgnore) { Blueprint blueprint2 = thing2 as Blueprint; ThingDef thingDef3; if (blueprint2 != null) { ThingDef thingDef2 = blueprint2.def.entityDefToBuild as ThingDef; if (thingDef2 == null) { goto IL_37F; } thingDef3 = thingDef2; } else { thingDef3 = thing2.def; } if (thingDef3.hasInteractionCell && cellRect.Contains(ThingUtility.InteractionCellWhenAt(thingDef3, thing2.Position, thing2.Rotation, thing2.Map))) { return(new AcceptanceReport("WouldBlockInteractionSpot".Translate(new object[] { entDef.label, thingDef3.label }).CapitalizeFirst())); } } IL_37F :; } } } } TerrainDef terrainDef = entDef as TerrainDef; if (terrainDef != null) { if (map.terrainGrid.TerrainAt(center) == terrainDef) { return(new AcceptanceReport("TerrainIsAlready".Translate(new object[] { terrainDef.label }))); } if (map.designationManager.DesignationAt(center, DesignationDefOf.SmoothFloor) != null) { return(new AcceptanceReport("SpaceBeingSmoothed".Translate())); } } if (!GenConstruct.CanBuildOnTerrain(entDef, center, map, rot, thingToIgnore)) { return(new AcceptanceReport("TerrainCannotSupport".Translate())); } if (!godMode) { CellRect.CellRectIterator iterator2 = cellRect.GetIterator(); while (!iterator2.Done()) { thingList = iterator2.Current.GetThingList(map); for (int l = 0; l < thingList.Count; l++) { Thing thing3 = thingList[l]; if (thing3 != thingToIgnore) { if (!GenConstruct.CanPlaceBlueprintOver(entDef, thing3.def)) { return(new AcceptanceReport("SpaceAlreadyOccupied".Translate())); } } } iterator2.MoveNext(); } } if (entDef.PlaceWorkers != null) { for (int m = 0; m < entDef.PlaceWorkers.Count; m++) { AcceptanceReport result = entDef.PlaceWorkers[m].AllowsPlacing(entDef, center, rot, map, thingToIgnore); if (!result.Accepted) { return(result); } } } return(AcceptanceReport.WasAccepted); }
public static bool PlacingRotationDoesntMatter(BuildableDef entDef) { return(entDef is ThingDef def && def.thingClass == typeof(Building_Door)); }
public static void Modified_WipeExistingThings(IntVec3 thingPos, Rot4 thingRot, BuildableDef thingDef, Map map, DestroyMode mode, Thing thing) { if (!(thing.TryGetComp <CompMountable>() is CompMountable comp && comp.Active)) { GenSpawn.WipeExistingThings(thingPos, thingRot, thingDef, map, mode); } }
public static bool SpawningWipesPrefix(ref bool __result, BuildableDef newEntDef, BuildableDef oldEntDef) { ThingDef thingDef = newEntDef as ThingDef; ThingDef thingDef2 = oldEntDef as ThingDef; if (thingDef == null || thingDef2 == null) { __result = false; return(false); } if (thingDef.category == ThingCategory.Attachment || thingDef.category == ThingCategory.Mote || thingDef.category == ThingCategory.Filth || thingDef.category == ThingCategory.Projectile) { __result = false; return(false); } if (!thingDef2.destroyable) { __result = false; return(false); } if (thingDef.category == ThingCategory.Plant) { __result = false; return(false); } if (thingDef2.category == ThingCategory.Filth && thingDef.passability != Traversability.Standable) { __result = true; return(false); } if (thingDef2.category == ThingCategory.Item && thingDef.passability == Traversability.Impassable && thingDef.surfaceType == SurfaceType.None) { __result = true; return(false); } if (thingDef.EverTransmitsPower && thingDef2 == ThingDefOf.PowerConduit) { __result = true; return(false); } if (thingDef.IsFrame && GenSpawn.SpawningWipes(thingDef.entityDefToBuild, oldEntDef)) { __result = true; return(false); } BuildableDef buildableDef = GenConstruct.BuiltDefOf(thingDef); BuildableDef buildableDef2 = GenConstruct.BuiltDefOf(thingDef2); if (buildableDef == null || buildableDef2 == null) { __result = false; return(false); } ThingDef thingDef3 = thingDef.entityDefToBuild as ThingDef; if (thingDef2.IsBlueprint) { if (thingDef.IsBlueprint) { if (thingDef3 != null && thingDef3.building != null && thingDef3.building.canPlaceOverWall && thingDef2.entityDefToBuild is ThingDef && ((ThingDef)thingDef2.entityDefToBuild == ThingDefOf.Wall || ((ThingDef)thingDef2.entityDefToBuild).thingClass == typeof(GL_Building))) { __result = true; return(false); } if (thingDef2.entityDefToBuild is TerrainDef) { if (thingDef.entityDefToBuild is ThingDef && ((ThingDef)thingDef.entityDefToBuild).coversFloor) { __result = true; return(false); } if (thingDef.entityDefToBuild is TerrainDef) { __result = true; return(false); } } } __result = thingDef2.entityDefToBuild == ThingDefOf.PowerConduit && thingDef.entityDefToBuild is ThingDef && (thingDef.entityDefToBuild as ThingDef).EverTransmitsPower; return(false); } if ((thingDef2.IsFrame || thingDef2.IsBlueprint) && thingDef2.entityDefToBuild is TerrainDef) { ThingDef thingDef4 = buildableDef as ThingDef; if (thingDef4 != null && !thingDef4.CoexistsWithFloors) { __result = true; return(false); } } if (thingDef2 == ThingDefOf.ActiveDropPod) { __result = false; return(false); } if (thingDef == ThingDefOf.ActiveDropPod) { __result = thingDef2 != ThingDefOf.ActiveDropPod && (thingDef2.category == ThingCategory.Building && thingDef2.passability == Traversability.Impassable); return(false); } if (thingDef.IsEdifice()) { if (thingDef.BlockPlanting && thingDef2.category == ThingCategory.Plant) { __result = true; return(false); } if (!(buildableDef is TerrainDef) && buildableDef2.IsEdifice()) { __result = true; return(false); } } __result = false; return(false); }
public static bool CanPlaceBlueprintOverPrefix(ref bool __result, BuildableDef newDef, ThingDef oldDef) { if (oldDef.EverHaulable) { __result = true; return(false); } TerrainDef terrainDef = newDef as TerrainDef; if (terrainDef != null) { if (oldDef.IsBlueprint || oldDef.IsFrame) { if (!terrainDef.affordances.Contains(oldDef.entityDefToBuild.terrainAffordanceNeeded)) { __result = false; return(false); } } else if (oldDef.category == ThingCategory.Building && !terrainDef.affordances.Contains(oldDef.terrainAffordanceNeeded)) { __result = false; return(false); } } ThingDef thingDef = newDef as ThingDef; BuildableDef buildableDef = GenConstruct.BuiltDefOf(oldDef); ThingDef thingDef2 = buildableDef as ThingDef; if (oldDef == ThingDefOf.SteamGeyser && !newDef.ForceAllowPlaceOver(oldDef)) { __result = false; return(false); } if (oldDef.category == ThingCategory.Plant && oldDef.passability == Traversability.Impassable && thingDef != null && thingDef.category == ThingCategory.Building && !thingDef.building.canPlaceOverImpassablePlant) { __result = false; return(false); } if (oldDef.category == ThingCategory.Building || oldDef.IsBlueprint || oldDef.IsFrame) { if (thingDef != null) { if (!thingDef.IsEdifice()) { __result = (oldDef.building == null || oldDef.building.canBuildNonEdificesUnder) && (!thingDef.EverTransmitsPower || !oldDef.EverTransmitsPower); return(false); } if (thingDef.IsEdifice() && oldDef != null && oldDef.category == ThingCategory.Building && !oldDef.IsEdifice()) { __result = thingDef.building == null || thingDef.building.canBuildNonEdificesUnder; return(false); } if (thingDef2 != null && (thingDef2 == ThingDefOf.Wall || thingDef2.IsSmoothed || thingDef2.thingClass == typeof(GL_Building)) && thingDef.building != null && thingDef.building.canPlaceOverWall) { __result = true; return(false); } if (newDef != ThingDefOf.PowerConduit && buildableDef == ThingDefOf.PowerConduit) { __result = true; return(false); } } __result = (newDef is TerrainDef && buildableDef is ThingDef && ((ThingDef)buildableDef).CoexistsWithFloors) || (buildableDef is TerrainDef && !(newDef is TerrainDef)); return(false); } __result = true; return(false); }
public bool AllowsPlacingBlueprint(BuildableDef buildable, IntVec3 pos, Rot4 rot, ThingDef stuff) { Rot4 rot2 = rot; if (!base.Spawned) { return(true); } CellRect newRect = GenAdj.OccupiedRect(pos, rot2, buildable.Size); if (!sketch.OccupiedRect.MovedBy(base.Position).Overlaps(newRect)) { return(true); } bool collided = false; foreach (IntVec3 item in newRect) { sketch.ThingsAt(item - base.Position, out SketchThing singleResult, out List <SketchThing> multipleResults); if (singleResult != null && CheckEntity(singleResult)) { return(true); } if (multipleResults != null) { for (int i = 0; i < multipleResults.Count; i++) { if (CheckEntity(multipleResults[i])) { return(true); } } } SketchTerrain sketchTerrain = sketch.SketchTerrainAt(item - base.Position); if (sketchTerrain != null && CheckEntity(sketchTerrain)) { return(true); } } return(!collided); bool CheckEntity(SketchBuildable entity) { if (entity.IsSameSpawned(entity.pos + base.Position, base.Map)) { return(false); } if (entity.OccupiedRect.MovedBy(base.Position).Overlaps(newRect)) { collided = true; } SketchThing sketchThing = entity as SketchThing; if (entity.OccupiedRect.MovedBy(base.Position).Equals(newRect) && IsSameOrSimilar(entity) && (stuff == null || entity.Stuff == null || stuff == entity.Stuff)) { if (sketchThing != null && !(sketchThing.rot == rot2) && !(sketchThing.rot == rot2.Opposite)) { return(!sketchThing.def.rotatable); } return(true); } return(false); } bool IsSameOrSimilar(SketchBuildable entity) { SketchTerrain sketchTerrain2; if (buildable == entity.Buildable || ((sketchTerrain2 = (entity as SketchTerrain)) != null && sketchTerrain2.IsSameOrSimilar(buildable))) { return(true); } return(false); } }
public static void SetStatBaseValue(this BuildableDef def, StatDef stat, float newBaseValue) { StatUtility.SetStatValueInList(ref def.statBases, stat, newBaseValue); }
public static float GetStatValueAbstract(this BuildableDef def, StatDef stat, ThingDef stuff = null) { return(stat.Worker.GetValueAbstract(def, stuff)); }
public static List <RecipeDef> GetRecipeDefs(this BuildableDef buildableDef) { return (DefDatabase <RecipeDef> .AllDefsListForReading.Where( r => r.products.Any(tc => tc.thingDef == buildableDef as ThingDef)).ToList()); }
/// <summary> /// Place Worker for Air Pipes. Checks if Air Pipes are in a Suitable Location or not. /// /// Checks: /// - Current Cell shouldn't have an Air Flow Building (Since they already have a Pipe) /// </summary> /// <param name="def">The Def Being Built</param> /// <param name="loc">Target Location</param> /// <param name="rot">Rotation of the Object to be Placed</param> /// <param name="thingToIgnore">Unused field</param> /// <returns>Boolean/Acceptance Report if we can place the object of not.</returns> public override AcceptanceReport AllowsPlacing(BuildableDef def, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null) { var thingList = loc.GetThingList(map); return(thingList.OfType <Building_AirFlowControl>().Any() ? AcceptanceReport.WasRejected : AcceptanceReport.WasAccepted); }
public static PurposeInfo Make(LocalTargetInfo targetInfo) { //reports of nullrefs in here for somereason. try { PurposeInfo purposeInfo = new PurposeInfo(); if (targetInfo.IsValid) { purposeInfo.pos = targetInfo.CenterVector3; } if (targetInfo.Thing is Thing target) { target = MinifyUtility.GetInnerIfMinified(target); BuildableDef def = target.def; purposeInfo.pos = target.DrawPos; purposeInfo.color = target.DrawColor; if (target is Pawn || target is Corpse) { Pawn pawn = target as Pawn; if (pawn == null) { pawn = ((Corpse)target).InnerPawn; } if (!pawn.RaceProps.Humanlike) { //This seems unnecessary //if (!pawn.Drawer.renderer.graphics.AllResolved) //{ // pawn.Drawer.renderer.graphics.ResolveAllGraphics(); //} Material matSingle = pawn.Drawer.renderer.graphics.nakedGraphic.MatSingle; purposeInfo.icon = matSingle.mainTexture; purposeInfo.color = matSingle.color; } else { purposeInfo.icon = PortraitsCache.Get(pawn, Vector2.one * Gizmo.Height, Rot4.South, cameraZoom: 1.5f); } purposeInfo.proportions = new Vector2(purposeInfo.icon.width, purposeInfo.icon.height); } else { if (target is IConstructible buildThing) { def = target.def.entityDefToBuild; if (buildThing.EntityToBuildStuff() != null) { purposeInfo.color = buildThing.EntityToBuildStuff().stuffProps.color; } else { purposeInfo.color = def.uiIconColor; } } purposeInfo.icon = def.uiIcon; if (def is ThingDef td) { purposeInfo.proportions = td.graphicData.drawSize; purposeInfo.scale = GenUI.IconDrawScale(td); } if (def is TerrainDef) { //private static readonly Vector2 TerrainTextureCroppedSize = new Vector2(64f, 64f); purposeInfo.texCoords = new Rect(0f, 0f, 64f / purposeInfo.icon.width, 64f / purposeInfo.icon.height); } else if (def.uiIconPath.NullOrEmpty()) { Material iconMat = def.graphic.MatSingle; purposeInfo.texCoords = new Rect(iconMat.mainTextureOffset, iconMat.mainTextureScale); } } } return(purposeInfo); } catch (NullReferenceException) { return(null); } }
public override bool ForceAllowPlaceOver(BuildableDef otherDef) { return(otherDef == ThingDefOf.SteamGeyser); }
public Designator_StorageBuild(BuildableDef bDef, StorageSettings settings) : base(bDef) { tmpSettings = settings; }
public static bool PlaceWorker_ShowTurretRadius_Prefix(ref AcceptanceReport __result, BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { __result = true; VerbProperties verbProperties = ((ThingDef)checkingDef).building.turretGunDef.Verbs.Find((VerbProperties v) => v.verbClass == typeof(Verbs.VoidNetWeapon_Lanuch)); if (verbProperties == null) { return(true); } if (verbProperties.range > 0f) { GenDraw.DrawRadiusRing(loc, verbProperties.range); } if (verbProperties.minRange > 0f) { GenDraw.DrawRadiusRing(loc, verbProperties.minRange); } return(false); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { // don't allow building pipes on top of piped buildings (blueprints) return(!loc.GetThingList(map).Where(t => t != thingToIgnore).Any(t => t.def.BuildingFrameOrBlueprintEverTransmitsGas())); }
public static bool IsSurvivalTool(this BuildableDef def) => def is ThingDef tDef && tDef.thingClass == typeof(SurvivalTool) && tDef.HasModExtension <SurvivalToolProperties>();
public override bool ShouldShowFor(BuildableDef def) { ThingDef thingDef = def as ThingDef; return(thingDef != null && thingDef.IsWeapon && !thingDef.tools.NullOrEmpty()); }
public static List <ThingDefCountClass> CostListAdjusted(this BuildableDef entDef, ThingDef stuff, bool errorOnNullStuff = true) { CostListPair key = new CostListPair(entDef, stuff); if (!cachedCosts.TryGetValue(key, out List <ThingDefCountClass> value)) { value = new List <ThingDefCountClass>(); int num = 0; if (entDef.MadeFromStuff) { if (errorOnNullStuff && stuff == null) { Log.Error("Cannot get AdjustedCostList for " + entDef + " with null Stuff."); if (GenStuff.DefaultStuffFor(entDef) == null) { return(null); } return(entDef.CostListAdjusted(GenStuff.DefaultStuffFor(entDef))); } if (stuff != null) { num = Mathf.RoundToInt((float)entDef.costStuffCount / stuff.VolumePerUnit); if (num < 1) { num = 1; } } else { num = entDef.costStuffCount; } } else if (stuff != null) { Log.Error("Got AdjustedCostList for " + entDef + " with stuff " + stuff + " but is not MadeFromStuff."); } bool flag = false; if (entDef.costList != null) { for (int i = 0; i < entDef.costList.Count; i++) { ThingDefCountClass thingDefCountClass = entDef.costList[i]; if (thingDefCountClass.thingDef == stuff) { value.Add(new ThingDefCountClass(thingDefCountClass.thingDef, thingDefCountClass.count + num)); flag = true; } else { value.Add(thingDefCountClass); } } } if (!flag && num > 0) { value.Add(new ThingDefCountClass(stuff, num)); } cachedCosts.Add(key, value); } return(value); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore, Thing thing) => ((loc.GetEdifice(map)?.def?.graphicData?.linkFlags & (LinkFlags.Rock | LinkFlags.Wall)) > 0) ? AcceptanceReport.WasAccepted : "MessagePlaceOnlyOnTheWall".Translate();
public static bool IsEdificeOrFrame(BuildableDef def) { return(def.IsEdifice() || (def is ThingDef thingDef && thingDef.IsFrame)); }