public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null) { if (!GenAdj.CellsOccupiedBy(loc, rot, checkingDef.Size).Any(x => x.Roofed(map))) { return("MustPlaceEntirelyUnderRoof".Translate()); } return(true); }
public virtual IEnumerable <IntVec3> AllSlotCells() { foreach (IntVec3 c in GenAdj.CellsOccupiedBy(this)) { yield return(c); } yield break; }
public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol, Thing thing = null) { if (!DebugSettings.godMode) { // Draw the placement areas Find.CurrentMap.GetComponent <QuarryGrid>().MarkForDraw(); GenDraw.DrawFieldEdges(GenAdj.CellsOccupiedBy(center, rot, def.Size).ToList()); } }
public override void SpawnSetup() { base.SpawnSetup(); maxStorage = ((DSUDef)def).maxStorage; List <IntVec3> cells = GenAdj.CellsOccupiedBy(this).ToList(); inputSlot = cells[0]; outputSlot = cells[1]; }
public override void PostSpawnSetup(bool respawningAfterLoad) { base.PostSpawnSetup(respawningAfterLoad); this.powerTrader = this.parent.TryGetComp <CompPowerTrader>(); this.network = QNetworkManager.Get(this.parent.Map); this.network.RegisterInput(this.powerTrader, GenAdj.CellsAdjacent8Way(this.parent)); this.network.RegisterStorage(this.powerTrader, GenAdj.CellsOccupiedBy(this.parent)); }
public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol, Thing thing = null) { var drawFieldCells = new List <IntVec3>(); foreach (var c in GenAdj.CellsOccupiedBy(center, rot, def.size)) { drawFieldCells.Add(c); } GenDraw.DrawFieldEdges(drawFieldCells, Color.Lerp(ghostCol, transparentWhite, 0.5f)); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null) { foreach (IntVec3 current in GenAdj.CellsOccupiedBy(loc, rot, checkingDef.Size)) { if (!map.roofGrid.Roofed(current)) { return(new AcceptanceReport("SRV_NeedsRoof".Translate(new object[] { checkingDef.LabelCap }))); } } return(true); }
public override void SpawnSetup() { base.SpawnSetup(); var defStacks = ((DispenserDef)this.def).maxStacks; if (defStacks > 0) { this.maxStacks = defStacks; } this.outputSlot = GenAdj.CellsOccupiedBy(this).ToList <IntVec3>().First(); }
public override void SpawnSetup() { base.SpawnSetup(); cellsThisContains = GenAdj.CellsOccupiedBy(this).ToList <IntVec3>(); this.maxStorage = ((DSUDef)def).maxStorage; inputSlot = cellsThisContains[0]; outputSlot = cellsThisContains[1]; if (storedThingName != "") { this.storedThing = DefDatabase <ThingDef> .GetNamed(storedThingName); } }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { foreach (IntVec3 c in GenAdj.CellsOccupiedBy(loc, rot, checkingDef.Size)) { if (map.terrainGrid.TerrainAt(c).defName != "AB_SolidPropane") { return(new AcceptanceReport("AB_TerrainCannotSupport_Propane".Translate())); } } return(true); }
public static IntVec3 FacingCell(IntVec3 center, IntVec2 size, Rot4 rot) { var list = GenAdj.CellsOccupiedBy(center, rot, size).ToList(); var minX = list.Min(c => c.x); var maxX = list.Max(c => c.x); var minZ = list.Min(c => c.z); var maxZ = list.Max(c => c.z); var x = rot.FacingCell.x == 0 ? center.x : (rot.FacingCell.x > 0 ? maxX + 1 : minX - 1); var z = rot.FacingCell.z == 0 ? center.z : (rot.FacingCell.z > 0 ? maxZ + 1 : minZ - 1); return(new IntVec3(x, center.y, z)); }
//public static Blueprint_Build PlaceBlueprintForBuild(BuildableDef sourceDef, IntVec3 center, Map map, Rot4 rotation, Faction faction, ThingDef stuff) public static void Prefix(BuildableDef sourceDef, IntVec3 center, Map map, Rot4 rotation, Faction faction, ThingDef stuff) { if (faction != Faction.OfPlayer || sourceDef.IsBridgelike()) { return; } foreach (IntVec3 pos in GenAdj.CellsOccupiedBy(center, rotation, sourceDef.Size)) { EnsureBridge.PlaceBridgeIfNeeded(sourceDef, pos, map, rotation, faction, stuff); } }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot) { IEnumerable <IntVec3> cells = GenAdj.CellsOccupiedBy(loc, rot, checkingDef.Size); foreach (IntVec3 cell in cells) { if (!cell.Walkable()) { return("PlaceWorker_RTRequireWalkable".Translate()); } } return(true); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { IEnumerable <IntVec3> allcells = GenAdj.CellsOccupiedBy(loc, rot, checkingDef.Size); if (allcells.All(t => t.GetThingList(map).Where(t => t.def.IsNonResourceNaturalRock || t.def.IsSmoothed).Any())) { return(AcceptanceReport.WasAccepted); } else { return(new AcceptanceReport("PRF_PlaceWorker_NaturalWall_denied".Translate())); } }
public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; bool flag = false; switch (num) { case 0u: enumerator = GenAdj.CellsOccupiedBy(this).GetEnumerator(); num = 4294967293u; break; case 1u: break; default: return(false); } try { switch (num) { } if (enumerator.MoveNext()) { c = enumerator.Current; this.$current = c; if (!this.$disposing) { this.$PC = 1; } flag = true; return(true); } } finally { if (!flag) { if (enumerator != null) { enumerator.Dispose(); } } } this.$PC = -1; return(false); }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot) { IEnumerable <IntVec3> cells = GenAdj.CellsOccupiedBy(loc, rot, checkingDef.Size); foreach (IntVec3 cell in cells) { Zone_Stockpile zoneStockpile = cell.GetZone() as Zone_Stockpile; if (zoneStockpile != null && zoneStockpile.FindWarehouse() != null) { return("PlaceWorker_RTOnlyOneQWPerZone".Translate()); } } return(true); }
//public static Blueprint_Build PlaceBlueprintForBuild(BuildableDef sourceDef, IntVec3 center, Map map, Rot4 rotation, Faction faction, ThingDef stuff) public static void Prefix(BuildableDef sourceDef, IntVec3 center, Map map, Rot4 rotation, Faction faction, ThingDef stuff) { if (faction != Faction.OfPlayer || sourceDef == TerrainDefOf.Bridge) { return; } TerrainAffordanceDef affNeeded = sourceDef.GetTerrainAffordanceNeed(stuff); foreach (IntVec3 pos in GenAdj.CellsOccupiedBy(center, rotation, sourceDef.Size)) { EnsureBridge.PlaceBridgeIfNeeded(sourceDef, pos, map, rotation, faction, stuff); } }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { foreach (IntVec3 c in GenAdj.CellsOccupiedBy(loc, rot, checkingDef.Size)) { if (!map.terrainGrid.TerrainAt(c).IsWater) { return(new AcceptanceReport("VFE_NeedsWater".Translate())); } } return(true); }
// Token: 0x0600013B RID: 315 RVA: 0x0000B4A4 File Offset: 0x000096A4 public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { bool flag = true; // bool flag = GridsUtility.GetThingList(loc, map).FirstOrDefault((Thing x) => x.def.defName.Contains("Wall") || x.def.defName.Contains("Smoothed")) != null; foreach (IntVec3 c in GenAdj.CellsOccupiedBy(loc, rot, checkingDef.Size)) { if (GridsUtility.GetThingList(c, map).FirstOrDefault((Thing x) => x.def.defName.Contains("Wall") || x.def.defName.Contains("Smoothed")) == null) { return(new AcceptanceReport(Translator.Translate("PWP_PlaceWorker_OnTopOfWalls"))); } } return(true); }
public static bool TryFindShipDropLocationNear(IntVec3 center, int maxAcceptableDistance, Map map, out IntVec3 result, IntVec2 size) { int num = 0; while (num < 5) { Predicate <IntVec3> validator = delegate(IntVec3 c) { foreach (IntVec3 current2 in GenAdj.CellsOccupiedBy(c, Rot4.North, size)) { if (!current2.Standable(map)) { return(false); } if (map.roofGrid.Roofed(current2) && current2.GetRoof(map) != null) { return(false); } } if (map.IsPlayerHome) { return(map.reachability.CanReachColony(c)); } else { return(true); } }; for (int i = 0; i < 1000; i++) { CellFinder.TryFindRandomCellNear(center, map, maxAcceptableDistance, validator, out result); if (validator(result)) { return(true); } else { result = CellFinder.RandomEdgeCell(map); if (validator(result)) { return(true); } } } num++; } result = IntVec3.Invalid; return(false); }
public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol) { //RoomGroup roomGroup = center.GetRoomGroup(base.Map); //if (roomGroup != null && !roomGroup.UsesOutdoorTemperature) //{ var drawFieldCells = new List <IntVec3>(); foreach (var c in GenAdj.CellsOccupiedBy(center, rot, def.size)) { drawFieldCells.Add(c); } GenDraw.DrawFieldEdges(drawFieldCells); drawFieldCells = null; //} }
public virtual IEnumerable <IntVec3> AllSlotCells() { using (IEnumerator <IntVec3> enumerator = GenAdj.CellsOccupiedBy(this).GetEnumerator()) { if (enumerator.MoveNext()) { IntVec3 c = enumerator.Current; yield return(c); /*Error: Unable to find new state assignment for yield return*/; } } yield break; IL_00b9: /*Error near IL_00ba: Unexpected return in MoveNext()*/; }
public override void Tick() { base.Tick(); if (this.ticksToExplode > 0) { this.wickSustainer.Maintain(); this.ticksToExplode--; if (this.ticksToExplode == 0) { IntVec3 loc = GenAdj.CellsOccupiedBy(this).ToList <IntVec3>().RandomListElement <IntVec3>(); float radius = Rand.Range(0.5f, 1f) * 3f; GenExplosion.DoExplosion(loc, radius, DamageTypeDefOf.Flame, null, null, null); base.GetComp <CompPowerBattery>().DrawPower(400f); } } }
protected override bool TryExecuteWorker(IncidentParms parms) { Map map = (Map)parms.target; int countToSpawn = this.CountToSpawn; IntVec3 cell = IntVec3.Invalid; Predicate <IntVec3> validator = delegate(IntVec3 c) { if (c.Fogged(map)) { return(false); } foreach (IntVec3 current in GenAdj.CellsOccupiedBy(c, Rot4.North, this.def.shipPart.size)) { if (!current.Standable(map)) { bool result = false; return(result); } if (map.roofGrid.Roofed(current)) { bool result = false; return(result); } } return(map.reachability.CanReachColony(c)); }; if (!CellFinderLoose.TryFindRandomNotEdgeCellWith(14, validator, map, out IntVec3 intVec)) { return(false); } //GenExplosion.DoExplosion(intVec, map, 3f, DamageDefOf.Flame, null, null, null, null, null, 0f, 1, false, null, 0f, 1); Building_PitChthonian building_CrashedShipPart = (Building_PitChthonian)GenSpawn.Spawn(this.def.shipPart, intVec, map); building_CrashedShipPart.SetFaction(Find.FactionManager.FirstFactionOfDef(FactionDef.Named("ROM_Chthonian")), null); cell = intVec; if (map == Find.VisibleMap) { Find.CameraDriver.shaker.DoShake(1f); } Find.LetterStack.ReceiveLetter(this.def.letterLabel, this.def.letterText, this.def.letterDef, new TargetInfo(cell, map, false), null); return(true); }
//public static Blueprint_Build PlaceBlueprintForBuild(BuildableDef sourceDef, IntVec3 center, Map map, Rot4 rotation, Faction faction, ThingDef stuff) public static void Prefix(BuildableDef sourceDef, IntVec3 center, Map map, Rot4 rotation, Faction faction) { if (faction != Faction.OfPlayer || sourceDef == TerrainDefOf.Bridge) { return; } TerrainAffordanceDef affNeeded = sourceDef.terrainAffordanceNeeded; foreach (IntVec3 pos in GenAdj.CellsOccupiedBy(center, rotation, sourceDef.Size)) { if (PlaceBridges.NeedsBridge(sourceDef, pos, map)) { GenConstruct.PlaceBlueprintForBuild(TerrainDefOf.Bridge, pos, map, rotation, faction, null); } } }
public bool IsValidPositionForShipCrashSite(Map map, IntVec3 position) { if ((position.InBounds(map) == false) || position.Fogged(map)) { return(false); } foreach (IntVec3 checkedPosition in GenAdj.CellsOccupiedBy(position, Rot4.North, this.def.shipPart.size)) { if ((checkedPosition.Standable(map) == false) || checkedPosition.Roofed(map) || map.reachability.CanReachColony(checkedPosition) == false) { return(false); } } return(true); }
public bool TryFindBestStoreCellFor(Thing t, Pawn carrier, Map map, Faction faction, out IntVec3 foundCell) { List <Thing> facilities = facilityComp.LinkedFacilitiesListForReading; for (int f = 0; f < facilities.Count; f++) { foreach (IntVec3 c in GenAdj.CellsOccupiedBy(facilities[f])) { if (StoreUtility.IsGoodStoreCell(c, map, t, carrier, faction)) { foundCell = c; return(true); } } } foundCell = IntVec3.Invalid; return(false); }
public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null ) { var containsNotWalkable = GenAdj.CellsOccupiedBy(loc, rot, checkingDef.Size). Any(cell => !cell.Walkable(map)); if (containsNotWalkable) { return("PlaceWorker_QSRRequireWalkable".Translate()); } return(true); }
public override void Destroy(DestroyMode mode = DestroyMode.Vanish) { foreach (IntVec3 c in GenAdj.CellsOccupiedBy(this)) { // Change the terrain here back to quarried stone, removing the walls Map.terrainGrid.SetTerrain(c, QuarryDefOf.QRY_QuarriedGround); } if (!QuarryMod.LetterSent && !TutorSystem.AdaptiveTrainingEnabled) { Find.LetterStack.ReceiveLetter(Static.LetterLabel, Static.LetterText, QuarryDefOf.CuproLetter, new RimWorld.Planet.GlobalTargetInfo(Position, Map)); QuarryMod.Instance.Notify_LetterSent(); } if (TutorSystem.AdaptiveTrainingEnabled) { LessonAutoActivator.TeachOpportunity(QuarryDefOf.QRY_ReclaimingSoil, OpportunityType.GoodToKnow); } base.Destroy(mode); }
private void DrawDebugPowerNets() { if (Current.ProgramState == ProgramState.Playing && Find.CurrentMap == map) { int num = 0; foreach (PowerNet allNet in allNets) { foreach (CompPower item in allNet.transmitters.Concat(allNet.connectors)) { foreach (IntVec3 item2 in GenAdj.CellsOccupiedBy(item.parent)) { CellRenderer.RenderCell(item2, (float)num * 0.44f); } } num++; } } }