public override bool TryMakePreToilReservations(bool errorOnFailed) { fishingZone = this.Map.zoneManager.ZoneAt(this.job.targetA.Cell) as Zone_Fishing; sizeAtBeginning = fishingZone.GetFishToCatch(); fishCaught = SelectFishToCatch(fishingZone); foreach (FishDef element in DefDatabase <FishDef> .AllDefs.Where(element => element.thingDef == fishCaught)) { fishAmount = element.baseFishingYield; } //fishingZone.someoneFishing = true; fishingSkill = this.pawn.skills.AverageOfRelevantSkillsFor(DefDatabase <WorkTypeDef> .GetNamed("VCEF_Fishing")); if (fishingSkill >= minFishingSkillForMinYield) { fishAmountWithSkill = fishAmount + (int)((fishingSkill - minFishingSkillForMinYield) / 2); } else { fishAmountWithSkill = (int)(fishAmount - (minFishingSkillForMinYield - fishingSkill)); } if (fishAmountWithSkill < 1) { fishAmountWithSkill = 1; } Pawn pawn = this.pawn; LocalTargetInfo target = this.job.targetA; Job job = this.job; bool result; if (pawn.Reserve(target, job, 1, -1, null, errorOnFailed)) { pawn = this.pawn; target = this.job.targetA.Cell; job = this.job; result = pawn.Reserve(target, job, 1, -1, null, errorOnFailed); } else { fishingZone.someoneFishing = false; result = false; } return(result); }
public override bool TryMakePreToilReservations(bool errorOnFailed) { fishingZone = this.Map.zoneManager.ZoneAt(this.job.targetA.Cell) as Zone_Fishing; sizeAtBeginning = fishingZone.GetFishToCatch(); caughtSomethingSpecial = false; fishCaught = SelectFishToCatch(fishingZone); bool dontScaleFishingYieldWithSkill = false; foreach (FishDef element in DefDatabase <FishDef> .AllDefs.Where(element => element.thingDef == fishCaught)) { fishAmount = element.baseFishingYield; dontScaleFishingYieldWithSkill = element.dontScaleFishingYieldWithSkill; } fishAmountWithSkill = CalculateFishAmountWithSkillAndConditions(fishAmount, dontScaleFishingYieldWithSkill); Pawn pawn = this.pawn; LocalTargetInfo target = this.job.targetA; Job job = this.job; bool result; if (pawn.Reserve(target, job, 1, -1, null, errorOnFailed)) { pawn = this.pawn; target = this.job.targetA.Cell; job = this.job; int index = 0; LocalTargetInfo moreTargetCells; while (index < fishingZone.cells.Count) { moreTargetCells = fishingZone.cells[index]; pawn.Reserve(moreTargetCells, job, 1, -1, null, errorOnFailed); index++; } result = pawn.Reserve(target, job, 1, -1, null, errorOnFailed); } else { result = false; } return(result); }
public void setZoneFishList(Zone_Fishing zone, FishSizeCategory size) { if (zone.fishInThisZone != null) { zone.fishInThisZone.Clear(); } foreach (FishDef element in DefDatabase <FishDef> .AllDefs.Where(element => element.fishSizeCategory == size)) { foreach (string biomeTemp in element.allowedBiomes) { foreach (BiomeTempDef biometempdef in DefDatabase <BiomeTempDef> .AllDefs.Where(biometempdef => biometempdef.biomeTempLabel == biomeTemp)) { foreach (string biome in biometempdef.biomes) { if (map.Biome.defName == biome) { if (zone.isOcean && element.canBeSaltwater) { zone.fishInThisZone.Add(element.thingDef); } if (!zone.isOcean && element.canBeFreshwater) { zone.fishInThisZone.Add(element.thingDef); } } } } } } if (zone.fishInThisZone.Count > 0) { zone.isZoneEmpty = false; } else { zone.isZoneEmpty = true; } }
public void SetFishToCatch(FishSizeCategory fishSizeDef) { this.fishSizeToCatch = fishSizeDef; }
internal static TaggedString FishSizeCategoryTooltip(FishSizeCategory fishSizeCategory) { return($"FishingAutomation.FishSizeCategory.{fishSizeCategory}.Tooltip".Translate()); }