private void GatherSingleZoneData(Building_PlantGrower plantGrower, out SinglePlantGrowerData data) { data = new SinglePlantGrowerData(); data.plantGrower = plantGrower; int growthRate; float harvestMinGrowth = plantGrower.GetPlantDefToGrow().plant.harvestMinGrowth * 100; //analyze growth values foreach (Plant plant in plantGrower.PlantsOnMe) { if (plant != null) { growthRate = (int)(plant.Growth * 100); data.growRatesAbsolute[growthRate]++; data.totalPlantedCount++; if (growthRate >= 100) { data.fullyGrownPlants.Add(plant); } if (growthRate >= harvestMinGrowth) { data.harvestablePlants.Add(plant); } } } //add curve points growthValueDrawInfo.curve = new SimpleCurve(); float maxYValue = 0; if (data.totalPlantedCount > 0) { for (int i = 0; i < data.growRatesAbsolute.Length; i++) { growthValueDrawInfo.curve.Add(new CurvePoint((float)i, 100 * data.growRatesAbsolute[i] / data.totalPlantedCount), false); } maxYValue = 100 * data.growthRateMaxCount / data.totalPlantedCount + 5; } else { growthValueDrawInfo.curve.Add(new CurvePoint(0f, 0f), false); growthValueDrawInfo.curve.Add(new CurvePoint(100f, 0f), false); maxYValue = 5; } //draw vertical marker harvestableMarkerDrawInfo.color = Color.white; harvestableMarkerDrawInfo.curve = new SimpleCurve(); harvestableMarkerDrawInfo.curve.Add(-5, -5f, false); harvestableMarkerDrawInfo.curve.Add(harvestMinGrowth, -5f, false); harvestableMarkerDrawInfo.curve.Add(harvestMinGrowth, Math.Min(100, maxYValue), false); harvestableMarkerDrawInfo.curve.Add(harvestMinGrowth, -5f, false); curves.Add(growthValueDrawInfo); curves.Add(harvestableMarkerDrawInfo); }
public static bool CanBeGroupedTo(this Building_PlantGrower lhs, Building_PlantGrower rhs) { return(lhs.IsConnectedTo(rhs) && lhs.GetPlantDefToGrow() == rhs.GetPlantDefToGrow()); }