/// <summary> /// /// Heart of terraforming. /// /// checks terrain conditions for the terraforming operation /// simply ignores invalid tiles /// damages plants if there are any on the area /// /// all good => modify terrain /// /// </summary> /// <param name="zone"></param> /// <param name="terrain"></param> /// <param name="tileAction"></param> protected void ProcessAreaHelper(IZone zone, Action <int, int> tileAction) { zone.ForEachAreaInclusive(TerraformArea, (x, y) => { var controlInfo = zone.Terrain.Controls.GetValue(x, y); if (controlInfo.IsAnyTerraformProtected) { return; } var blockingInfo = zone.Terrain.Blocks.GetValue(x, y); if (blockingInfo.NonNaturally) { return; } var plantInfo = zone.Terrain.Plants.GetValue(x, y); if (plantInfo.type != PlantType.NotDefined) { //do plant damage zone.DamageToPlant(x, y, _plantDamage); return; } tileAction(x, y); }); }
/// <summary> /// Load raw altitude into buffer /// </summary> private void FillBufferWithCurrentAltitude(IZone zone) { _buffer = new ushort[_bufferArea.Ground]; zone.ForEachAreaInclusive(_bufferArea, (x, y) => { var bufferOffset = (x - _bufferArea.X1) + (y - _bufferArea.Y1) * _bufferArea.Width; var alt = zone.Terrain.Altitude.GetValue(x, y); _buffer[bufferOffset] = alt; }); }
public static int CountPlantsInArea(this IZone zone, PlantType plantType, Area area) { var counter = 0; zone.ForEachAreaInclusive(area, (x, y) => { var pi = zone.Terrain.Plants.GetValue(x, y); if (pi.type == plantType) { counter++; } }); return(counter); }