private IEnumerable <Thing> FindValidThingsInRange(Map map) { Room room = parent.GetRoom(); // Does not block wind, is a plant, not a tree, not any kind of grass and ( harvestable or beauty > 2 ) IEnumerable <Thing> foundThings = map.listerThings.AllThings.Where <Thing>(t => !t.def.blockWind && t.def.plant != null && !t.def.plant.IsTree && !t.def.defName.ToLower().Contains("grass") && (t.def.plant.Harvestable || t.GetStatValue(StatDefOf.Beauty, true) >= 2) && t.GetRoom() == room && (t as Plant) != null && (t as Plant).Growth > 0.07f); if (foundThings == null) { yield break; } foreach (Thing t in foundThings) { if (BeeAndHoneyUtility.IsCellInRadius(t.Position, this.parent.PositionHeld, Props.rangeThings)) { yield return(t); } } }
public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol) { CompProperties_BeeHive comp = def.comps.Where(c => c as CompProperties_BeeHive != null).FirstOrDefault() as CompProperties_BeeHive; if (comp == null) { Log.Warning("Placeworker_ShowBeeRange -- comp is null!"); return; } //Log.Error("Placeworker_ShowBeeRange -- radius: " + comp.rangeBees.ToString() + " // count of cells: " + BeeAndHoneyUtility.CalculateAllCellsInsideRadius(center, Mathf.RoundToInt(comp.rangeBees)).Count().ToString()); List <IntVec3> cells = new List <IntVec3>(BeeAndHoneyUtility.CalculateAllCellsInsideRadius(center, Find.CurrentMap, Mathf.RoundToInt(comp.rangeThings))); GenDraw.DrawFieldEdges(cells, ghostCol); }