internal bool IsPatchSuitableAt(BlockPatch patch, Block onBlock, IWorldManagerAPI world, int climate, int y, float forestRel) { if ((patch.Placement == EnumBlockPatchPlacement.NearWater || patch.Placement == EnumBlockPatchPlacement.UnderWater) && onBlock.LiquidCode != "water") { return(false); } if ((patch.Placement == EnumBlockPatchPlacement.NearSeaWater || patch.Placement == EnumBlockPatchPlacement.UnderSeaWater) && onBlock.LiquidCode != "seawater") { return(false); } rain = TerraGenConfig.GetRainFall((climate >> 8) & 0xff, y); rainRel = rain / 255f; temp = TerraGenConfig.GetScaledAdjustedTemperature((climate >> 16) & 0xff, y - TerraGenConfig.seaLevel); sealevelDistRel = ((float)y - TerraGenConfig.seaLevel) / ((float)world.MapSizeY - TerraGenConfig.seaLevel); fertilityRel = TerraGenConfig.GetFertility(rain, temp, sealevelDistRel) / 255f; return (fertilityRel >= patch.MinFertility && fertilityRel <= patch.MaxFertility && rainRel >= patch.MinRain && rainRel <= patch.MaxRain && temp >= patch.MinTemp && temp <= patch.MaxTemp && sealevelDistRel >= patch.MinY && sealevelDistRel <= patch.MaxY && forestRel >= patch.MinForest && forestRel <= patch.MaxForest ); }
// What if we the horizontal plane could modify the terrain thresholds? // Example: A heavily perlin wobbled map that creates lots of stripes should // give us ripples or dents in the terrain // Should probably only be taken into calculation if the base thresholds is a above a certain value (e.g. so only hills/mountains are affected) public void Init(IWorldManagerAPI api, int index) { this.index = index; LerpThresholds(api.MapSizeY); ColorInt = int.Parse(HexColor.TrimStart('#'), System.Globalization.NumberStyles.HexNumber); LoadAndNormalizeAmplitudes(); }
public void InitPos(IWorldManagerAPI world, int climate, float forestRel, int y) { rain = TerraGenConfig.GetRainFall((climate >> 8) & 0xff, y); rainRel = rain / 255f; temp = TerraGenConfig.GetScaledAdjustedTemperature((climate >> 16) & 0xff, y - TerraGenConfig.seaLevel); sealevelDistRel = ((float)y - TerraGenConfig.seaLevel) / ((float)world.MapSizeY - TerraGenConfig.seaLevel); fertilityRel = TerraGenConfig.GetFertility(rain, temp, sealevelDistRel) / 255f; }