public Command_SetFishList() { defaultDesc = "VCEF_ChooseFishDesc".Translate(); defaultLabel = "VCEF_ChooseFish".Translate(); foreach (object obj in Find.Selector.SelectedObjects) { Zone_Fishing zone = obj as Zone_Fishing; if (zone != null) { if (zone.GetFishToCatch() == FishSizeCategory.Small) { this.icon = ContentFinder <Texture2D> .Get("UI/Commands/VCEF_Command_ChooseSmallFish", true); } else if (zone.GetFishToCatch() == FishSizeCategory.Medium) { this.icon = ContentFinder <Texture2D> .Get("UI/Commands/VCEF_Command_ChooseMediumFish", true); } else if (zone.GetFishToCatch() == FishSizeCategory.Large) { this.icon = ContentFinder <Texture2D> .Get("UI/Commands/VCEF_Command_ChooseLargeFish", true); } } else { this.icon = ContentFinder <Texture2D> .Get("UI/Commands/VCEF_Command_ChooseMediumFish", true); } } }
public ThingDef SelectFishToCatch(Zone_Fishing fishingZone) { if (fishingZone.fishInThisZone.Count > 0) { if (rand.NextDouble() > 0.99) { List <FishDef> tempSpecialFish = new List <FishDef>(); tempSpecialFish.Clear(); foreach (FishDef element in DefDatabase <FishDef> .AllDefs.Where(element => element.fishSizeCategory == FishSizeCategory.Special)) { tempSpecialFish.Add(element); } return(tempSpecialFish.RandomElementByWeight(((FishDef s) => s.commonality)).thingDef); } else { ThingDef fishCaught = fishingZone.fishInThisZone.RandomElement(); return(fishCaught); } } else { return(null); } }
public ThingDef SelectFishToCatch(Zone_Fishing fishingZone) { if (fishingZone.fishInThisZone.Count > 0) { //Log.Message(((float)(100 - Options.VCE_Fishing_Settings.VCEF_chanceForSpecials) / 100).ToString()); if (rand.NextDouble() > ((float)(100 - Options.VCE_Fishing_Settings.VCEF_chanceForSpecials) / 100)) { List <FishDef> tempSpecialFish = new List <FishDef>(); tempSpecialFish.Clear(); foreach (FishDef element in DefDatabase <FishDef> .AllDefs.Where(element => element.fishSizeCategory == FishSizeCategory.Special)) { tempSpecialFish.Add(element); } caughtSomethingSpecial = true; return(tempSpecialFish.RandomElementByWeight(((FishDef s) => s.commonality)).thingDef); } else { ThingDef fishCaught = fishingZone.fishInThisZone.RandomElement(); return(fishCaught); } } else { return(null); } }
public static Command_SetFishList SetFishToCatchCommand(Zone_Fishing passingZone, Map passingMap) { return(new Command_SetFishList() { hotKey = KeyBindingDefOf.Misc1, map = passingMap, zone = passingZone }); }
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 override IEnumerable <IntVec3> PotentialWorkCellsGlobal(Pawn pawn) { Danger maxDanger = pawn.NormalMaxDanger(); List <Zone> zonesList = pawn.Map.zoneManager.AllZones; for (int j = 0; j < zonesList.Count; j++) { Zone_Fishing fishingZone = zonesList[j] as Zone_Fishing; if (fishingZone != null) { if (fishingZone.cells.Count == 0) { Log.ErrorOnce("Fishing zone has 0 cells (this should never happen): " + fishingZone, -563487, false); } if (!fishingZone.someoneFishing) { if (fishingZone.allowFishing) { if (fishingZone.isZoneBigEnough) { if (!fishingZone.isZoneEmpty) { if (!fishingZone.ContainsStaticFire) { if (pawn.CanReserveAndReach(fishingZone.Cells[0], PathEndMode.OnCell, maxDanger)) { for (int k = 0; k < fishingZone.cells.Count; k++) { yield return(fishingZone.cells[k]); } } } } } } } } } }
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 override void MapComponentTick() { base.MapComponentTick(); if (fishTickProgress >= fishTickMax) { foreach (Zone zone in this.map.zoneManager.AllZones.Where(zone => zone.GetType() == typeof(Zone_Fishing))) { Zone_Fishing zoneFishing = zone as Zone_Fishing; if (zoneFishing.cells.Count < Options.VCE_Fishing_Settings.VCEF_minimumZoneSize) { zoneFishing.isZoneBigEnough = false; } else { zoneFishing.isZoneBigEnough = true; } int index = 0; while (index < zoneFishing.cells.Count) { if (zoneFishing.cells[index].GetTerrain(this.map).defName == "WaterOceanDeep" || zoneFishing.cells[index].GetTerrain(this.map).defName == "WaterOceanShallow") { zoneFishing.isOcean = true; zoneFishing.initialSetZoneFishList(); break; } index++; zoneFishing.isOcean = false; } } fishTickProgress = 0; } fishTickProgress++; }