private void DamageWallOnTile(ref PlantInfo plantInfo, ref BlockingInfo blockInfo, int x, int y) { if (plantInfo.type == PlantType.NotDefined) { return; } var plantRule = _zone.Configuration.PlantRules.GetPlantRule(plantInfo.type); if (plantRule == null) { return; } //is it wall? if (!plantRule.AllowedOnNonNatural) { return; } //only degrades in the last few phases if (!plantInfo.IsWallInLastFewStates(plantRule)) { return; } var globalX = x + _area.X1; var globalY = y + _area.Y1; //pbs might save it if (_pbsPositions != null && _pbsPositions.Count > 0) { if (PBSHelper.IsPBSInRange(_wallDistanceFromPBS, _pbsPositions, globalX, globalY)) { var closestPBSDistance = PBSHelper.GetMinimalDistance(_pbsPositions, globalX, globalY); if (closestPBSDistance <= _intactDistance) { //pbs object in intact distance, wall is protected return; } //in fading range //near 1 .. far 0 var chanceToSurvive = 1 - ((closestPBSDistance - _intactDistance) / _gradientRange); var random = FastRandom.NextDouble(); if (random < chanceToSurvive) { //it will happen inwards more often //so the plant wont get unhealed as it is closer to a pbs but within the range return; } } } plantInfo.UnHealPlant(); if (plantInfo.health > 0) { return; } blockInfo.Plant = false; blockInfo.Height = 0; plantInfo.Clear(); plantInfo.state = 1; }