public static void Postfix(CompPowerPlantWater __instance, ref bool ___waterDoubleUsed) { if (___waterDoubleUsed) { return; } // additional check for advanced version var advWatermills = __instance.parent.Map.listerBuildings.AllBuildingsColonistOfDef(ThingDefOf.sd_adv_powergen_WatermillGenerator); foreach (IntVec3 current2 in __instance.WaterUseCells()) { if (current2.InBounds(__instance.parent.Map)) { foreach (Building advWatermilll in advWatermills) { if (advWatermilll != __instance.parent && advWatermilll.GetComp <CompPowerPlantWater>().WaterUseRect().Contains(current2)) { ___waterDoubleUsed = true; break; } } } } }
public override void DrawGhost(ThingDef def, IntVec3 loc, Rot4 rot, Color ghostCol, Thing thing = null) { GenDraw.DrawFieldEdges(CompPowerPlantWater.GroundCells(loc, rot).ToList <IntVec3>(), Color.white); Color color = this.WaterCellsPresent(loc, rot, Find.CurrentMap) ? Designator_Place.CanPlaceColor.ToOpaque() : Designator_Place.CannotPlaceColor.ToOpaque(); GenDraw.DrawFieldEdges(CompPowerPlantWater.WaterCells(loc, rot).ToList <IntVec3>(), color); bool flag = false; CellRect cellRect = CompPowerPlantWater.WaterUseRect(loc, rot); PlaceWorker_AdvancedWatermill.waterMills.AddRange(Find.CurrentMap.listerBuildings.AllBuildingsColonistOfDef(ThingDef.Named("VFE_AdvancedWatermillGenerator")).Cast <Thing>()); PlaceWorker_AdvancedWatermill.waterMills.AddRange(from t in Find.CurrentMap.listerThings.ThingsInGroup(ThingRequestGroup.Blueprint) where t.def.entityDefToBuild == ThingDef.Named("VFE_AdvancedWatermillGenerator") select t); PlaceWorker_AdvancedWatermill.waterMills.AddRange(from t in Find.CurrentMap.listerThings.ThingsInGroup(ThingRequestGroup.BuildingFrame) where t.def.entityDefToBuild == ThingDef.Named("VFE_AdvancedWatermillGenerator") select t); foreach (Thing thing2 in PlaceWorker_AdvancedWatermill.waterMills) { GenDraw.DrawFieldEdges(CompPowerPlantWater.WaterUseCells(thing2.Position, thing2.Rotation).ToList <IntVec3>(), new Color(0.2f, 0.2f, 1f)); if (cellRect.Overlaps(CompPowerPlantWater.WaterUseRect(thing2.Position, thing2.Rotation))) { flag = true; } } PlaceWorker_AdvancedWatermill.waterMills.Clear(); Color color2 = flag ? new Color(1f, 0.6f, 0f) : Designator_Place.CanPlaceColor.ToOpaque(); 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 static void PostfixDesiredPowerOutput(CompPowerPlantWater __instance, ref float __result) { // Season __result *= WatermillUtility.SeasonalPowerOutputFactorFor(__instance.parent.GetMapSeason()); // Outdoor Temperature __result *= WatermillUtility.GetTemperatureToPowerOutputFactorCurveFor(__instance.parent).Evaluate(__instance.parent.MapHeld.mapTemperature.OutdoorTemp); // Turbulent Waters if (__instance.parent.MapHeld.GameConditionManager.ConditionIsActive(BWG_GameConditionDefOf.TurbulentWaters)) { __result *= GameCondition_TurbulentWaters.WatermillPowerGenFactor; } }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null, Thing thing = null) { foreach (IntVec3 c in CompPowerPlantWater.GroundCells(loc, rot)) { if (!map.terrainGrid.TerrainAt(c).affordances.Contains(TerrainAffordanceDefOf.Heavy)) { return(new AcceptanceReport("TerrainCannotSupport_TerrainAffordance".Translate(checkingDef, TerrainAffordanceDefOf.Heavy))); } } if (!this.WaterCellsPresent(loc, rot, map)) { return(new AcceptanceReport("MustBeOnMovingWater".Translate())); } return(true); }
public static void PostfixCompInspectStringExtra(CompPowerPlantWater __instance, ref string __result) { // Season Season season = __instance.parent.GetMapSeason(); float seasonalPowerProductionFactor = WatermillUtility.SeasonalPowerOutputFactorFor(season); __result += "\n" + season.LabelCap() + ": x" + seasonalPowerProductionFactor.ToStringPercent(); // Outdoor Temperature float tempPowerProductionFactor = WatermillUtility.GetTemperatureToPowerOutputFactorCurveFor(__instance.parent).Evaluate(__instance.parent.MapHeld.mapTemperature.OutdoorTemp); if (tempPowerProductionFactor != 1f) { __result += "\n" + "BadTemperature".Translate().CapitalizeFirst() + ": x" + tempPowerProductionFactor.ToStringPercent(); } }
private bool IsObstructedGenerator(CompPowerTrader pct) { if (Power_Alerts.obstructedSolarEnabled) { CompPowerPlantSolar solar = pct as CompPowerPlantSolar; if (solar != null) { foreach (IntVec3 current in pct.parent.OccupiedRect()) { if (pct.parent.Map.roofGrid.Roofed(current)) { return(true); } } return(false); } } if (Power_Alerts.obstructedWindEnabled) { CompPowerPlantWind wind = pct as CompPowerPlantWind; if (wind != null) { return((windPathBlockedCellsField.GetValue(wind) as List <IntVec3>).Count() > 0); } } if (Power_Alerts.obstructedWaterEnabled) { CompPowerPlantWater water = pct as CompPowerPlantWater; if (water != null) { return(!((bool)waterUsableField.GetValue(water)) || ((bool)waterDoubleUsedField.GetValue(water))); } } return(false); }
public override void DrawGhost(ThingDef def, IntVec3 loc, Rot4 rot, Color ghostCol, Thing thing = null) { GenDraw.DrawFieldEdges(CompPowerPlantWater.GroundCells(loc, rot).ToList(), Color.white); var color = !WaterCellsPresent(loc, rot, Find.CurrentMap) ? Designator_Place.CannotPlaceColor.ToOpaque() : Designator_Place.CanPlaceColor.ToOpaque(); GenDraw.DrawFieldEdges(CompPowerPlantWater.WaterCells(loc, rot).ToList(), color); var overlaps = false; var cellRect = CompPowerPlantWater.WaterUseRect(loc, rot); advwaterMills.AddRange( Find.CurrentMap.listerBuildings.AllBuildingsColonistOfDef(ThingDefOf .sd_adv_powergen_WatermillGenerator)); advwaterMills.AddRange(from t in Find.CurrentMap.listerThings.ThingsInGroup(ThingRequestGroup.Blueprint) where t.def.entityDefToBuild == ThingDefOf.sd_adv_powergen_WatermillGenerator select t); advwaterMills.AddRange(from t in Find.CurrentMap.listerThings.ThingsInGroup(ThingRequestGroup.BuildingFrame) where t.def.entityDefToBuild == ThingDefOf.sd_adv_powergen_WatermillGenerator select t); foreach (var current in advwaterMills) { GenDraw.DrawFieldEdges(CompPowerPlantWater.WaterUseCells(current.Position, current.Rotation).ToList(), new Color(0.2f, 0.2f, 1f)); if (cellRect.Overlaps(CompPowerPlantWater.WaterUseRect(current.Position, current.Rotation))) { overlaps = true; } } advwaterMills.Clear(); var color2 = !overlaps?Designator_Place.CanPlaceColor.ToOpaque() : new Color(1f, 0.6f, 0f); if (!overlaps || Time.realtimeSinceStartup % 0.4f < 0.2f) { GenDraw.DrawFieldEdges(CompPowerPlantWater.WaterUseCells(loc, rot).ToList(), color2); } }