public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null) { //Next to water. var checkCells = new HashSet <IntVec3>(CellsForWater(checkingDef as ThingDef, loc, rot)); foreach (var checkCell in checkCells) { if (!checkCell.InBounds(map)) { return(false); } TerrainDef terrainDef = checkCell.GetTerrain(map); if (terrainDef == null || terrainDef?.IsWater() == false) { return("Estate_WaterPlaceWorker_NeedSource".Translate()); } } HashSet <IntVec3> cells = new HashSet <IntVec3>(GenRadial.RadialCellsAround(loc, 9.6f, true)); if (cells.Any(x => x.GetFirstThing(map, ThingDef.Named(checkingDef.defName)) != null)) { return("Estate_WaterPlaceWorker_TwoPumps".Translate()); } return(true); }
public static float GetWaterTerrainScore(Pawn eater, IntVec3 c, float dist, bool priorQuality) { TerrainDef terrain = c.GetTerrain(eater.Map); // 水源ではない or 水源として使えない if (!terrain.IsWater()) { return(float.MinValue); } var waterTypeDef = MizuDef.Dic_WaterTypeDef[terrain.ToWaterType()]; // 基本点計算 // 距離 float distScore = -dist; // 心情変化量(水質) // メモ // きれい= +10 // 普通 = 0 // 生水 = 0 // 泥水 = -6 // 海水 = -6 float thoughtScore = 0f; // 禁欲の影響も含まれている List <ThoughtDef> thoughtList = new List <ThoughtDef>(); MizuUtility.ThoughtsFromWaterTypeDef(eater, waterTypeDef, true, thoughtList); foreach (var thought in thoughtList) { thoughtScore += thought.stages[0].baseMoodEffect; } // 食中毒 // メモ // きれい= 0 => 0 // 普通 = 0 => 0 // 生水 = 0.01 => -10 // 泥水 = 0.03 => -30 // 海水 = 0.03 => -30 float foodPoisoningScore = -(waterTypeDef.foodPoisonChance * 1000f); // 健康悪化 float hediffScore = 0f; if (waterTypeDef.hediffs != null) { foreach (var hediff in waterTypeDef.hediffs) { hediffScore -= 100f; } } // 基本点合計メモ // 心情,食中毒,健康,合計(禁欲) // きれい= +10, 0, 0, +10( 0) // 普通 = 0, 0, 0, 0( 0) // 生水 = 0, -10, 0, -10( -10) // 泥水 = -6, -30, 0, -36( -30) // 海水 = -6, -30,-100,-136(-130) // 各種状態によるスコアの変化 // 水質優先モードか否か if (priorQuality) { distScore /= 10f; } return(distScore + thoughtScore + foodPoisoningScore); }
public static bool IsWaterStandable(this TerrainDef def) { return(def.IsWater() && def.passability == Traversability.Standable); }