private void GrowPlantOnTile(int x, int y, ref PlantInfo plantInfo, ref BlockingInfo blockInfo) { var plantRule = _zone.Configuration.PlantRules.GetPlantRule(plantInfo.type); if (plantRule == null) { return; } if (plantInfo.time < plantRule.GrowRate) { //increase tile time plantInfo.time = (byte)(plantInfo.time + 1).Clamp(0, 255); } else { //make it grow! //Reset time plantInfo.time = 0; //get new state PlantType nextAction; byte nextState; plantRule.GetNextState(plantInfo.state, out nextState, out nextAction); if (nextAction == 0) { plantInfo.Clear(); plantInfo.state = 1; //kill signal for client --> resulting type:0 state:1 which should NOT be cleaned, just next round!!! blockInfo.Height = 0; blockInfo.Plant = false; if (!plantRule.PlacesConcrete) { return; } var gx = x + _area.X1; var gy = y + _area.Y1; _zone.Terrain.Controls.UpdateValue(gx, gy, ci => { ci.ClearAllConcrete(); return(ci); }); } else { var healthRatio = plantInfo.GetHealthRatio(plantRule); plantInfo.type = nextAction; plantInfo.state = nextState; plantInfo.health = (byte)(healthRatio * plantRule.Health[plantInfo.state]).Clamp(1, 255); if (!plantRule.NotFruiting) { //yes, fruiting if (plantRule.FruitingState <= nextState) { if (plantRule.FruitingState == nextState) { // first phase when the plant reached fruiting state plantInfo.material = (byte)(Math.Min((int)(FastRandom.NextDouble(plantRule.FruitAmount * 0.05, plantRule.FruitAmount * 0.15)).Clamp(0, 255), plantRule.FruitAmount)); } else { // change happened plantInfo.material = (byte)(Math.Min((plantInfo.material + FastRandom.NextDouble(plantRule.FruitAmount * 0.15, plantRule.FruitAmount * 0.25)), plantRule.FruitAmount)).Clamp(0, 255); } } else { plantInfo.material = 0; } } else { plantInfo.material = 0; } blockInfo.Height = plantRule.GetBlockingHeight(plantInfo.state); blockInfo.Plant = blockInfo.Height > 0; } } }