public static bool CanGetWater(this Thing t) { if (!t.CanDrinkWater()) { return(false); } var comp = t.TryGetComp <CompWaterSource>(); return(comp.WaterAmount > 0.0f); }
protected override Job TryGiveJob(Pawn pawn) { Need_Water need_water = pawn.needs.water(); if (need_water == null) { return(null); } if (need_water.lastSearchWaterTick + SearchWaterIntervalTick > Find.TickManager.TicksGame) { return(null); } // Only trink if we're really thirsty. if (need_water.CurLevelPercentage > need_water.PercentageThreshThirsty) { return(null); } need_water.lastSearchWaterTick = Find.TickManager.TicksGame; Thing thing = MizuUtility.TryFindBestWaterSourceFor(pawn, pawn, false, true); if (thing != null) { if (thing.CanDrinkWater()) { return(new Job(MizuDef.Job_DrinkWater, thing) { count = MizuUtility.WillGetStackCountOf(pawn, thing) }); } else if (thing is IBuilding_DrinkWater) { return(new Job(MizuDef.Job_DrinkWaterFromBuilding, thing)); } } // 何も見つからなかった場合は隠し水飲み場を探す // 人間、家畜、野生の動物全て IntVec3 hiddenWaterSpot; if (MizuUtility.TryFindHiddenWaterSpot(pawn, out hiddenWaterSpot)) { return(new Job(MizuDef.Job_DrinkWater, hiddenWaterSpot) { count = 1 }); } // 水を発見できず return(null); }
protected override Job TryGiveJob(Pawn pawn) { Need_Water need_water = pawn.needs.water(); if (need_water == null) { return(null); } // 最後に水を探してから少し経つまで次の探索はしない if (need_water.lastSearchWaterTick + SearchWaterIntervalTick > Find.TickManager.TicksGame) { return(null); } need_water.lastSearchWaterTick = Find.TickManager.TicksGame; // 水の供給源を探す Thing thing = MizuUtility.TryFindBestWaterSourceFor(pawn, pawn, false, true); if (thing != null) { if (thing.CanDrinkWater()) { // 水アイテムが見つかった return(new Job(MizuDef.Job_DrinkWater, thing) { count = MizuUtility.WillGetStackCountOf(pawn, thing) }); } else if (thing is IBuilding_DrinkWater) { // 水を汲める設備が見つかった return(new Job(MizuDef.Job_DrinkWaterFromBuilding, thing)); } } // 何も見つからなかった場合は隠し水飲み場を探す // 人間、家畜、野生の動物全て IntVec3 hiddenWaterSpot; if (MizuUtility.TryFindHiddenWaterSpot(pawn, out hiddenWaterSpot)) { return(new Job(MizuDef.Job_DrinkWater, hiddenWaterSpot) { count = 1 }); } // 水を発見できず return(null); }
public static bool CanDrinkWaterNow(this Thing t) { return(!t.IsBurning() && t.CanDrinkWater()); }