public override void DrawGhost(ThingDef def, IntVec3 loc, Rot4 rot, Color ghostCol) { GenDraw.DrawFieldEdges(CompPowerPlantWater.GroundCells(loc, rot).ToList <IntVec3>(), Color.white); Color color = (!this.WaterCellsPresent(loc, rot, Find.CurrentMap)) ? Designator_Place.CannotPlaceColor.ToOpaque() : Designator_Place.CanPlaceColor.ToOpaque(); GenDraw.DrawFieldEdges(CompPowerPlantWater.WaterCells(loc, rot).ToList <IntVec3>(), color); bool flag = false; CellRect cellRect = CompPowerPlantWater.WaterUseRect(loc, rot); PlaceWorker_WatermillGenerator.waterMills.AddRange(Find.CurrentMap.listerBuildings.AllBuildingsColonistOfDef(ThingDefOf.WatermillGenerator).Cast <Thing>()); PlaceWorker_WatermillGenerator.waterMills.AddRange(from t in Find.CurrentMap.listerThings.ThingsInGroup(ThingRequestGroup.Blueprint) where t.def.entityDefToBuild == ThingDefOf.WatermillGenerator select t); PlaceWorker_WatermillGenerator.waterMills.AddRange(from t in Find.CurrentMap.listerThings.ThingsInGroup(ThingRequestGroup.BuildingFrame) where t.def.entityDefToBuild == ThingDefOf.WatermillGenerator select t); foreach (Thing thing in PlaceWorker_WatermillGenerator.waterMills) { GenDraw.DrawFieldEdges(CompPowerPlantWater.WaterUseCells(thing.Position, thing.Rotation).ToList <IntVec3>(), new Color(0.2f, 0.2f, 1f)); if (cellRect.Overlaps(CompPowerPlantWater.WaterUseRect(thing.Position, thing.Rotation))) { flag = true; } } PlaceWorker_WatermillGenerator.waterMills.Clear(); Color color2 = (!flag) ? Designator_Place.CanPlaceColor.ToOpaque() : new Color(1f, 0.6f, 0f); if (!flag || Time.realtimeSinceStartup % 0.4f < 0.2f) { GenDraw.DrawFieldEdges(CompPowerPlantWater.WaterUseCells(loc, rot).ToList <IntVec3>(), color2); } }
private bool WaterCellsPresent(IntVec3 loc, Rot4 rot, Map map) { foreach (IntVec3 c in CompPowerPlantWater.WaterCells(loc, rot)) { if (!map.terrainGrid.TerrainAt(c).affordances.Contains(TerrainAffordanceDefOf.MovingFluid)) { return(false); } } return(true); }
public IEnumerable <IntVec3> WaterCells() { return(CompPowerPlantWater.WaterCells(this.parent.Position, this.parent.Rotation)); }