public static bool CanHaveGroup(Plant plant, bool flashcells) { var ingestible = plant.def.ingestible; var plantprops = plant.def.plant; if (ingestible == null || ingestible.foodType == FoodTypeFlags.Tree) { return(false); } if (plantprops == null || !plantprops.Sowable) { return(false); } if (plant.LifeStage != PlantLifeStage.Growing) { return(false); } if (defsBlacklist.Contains(plant.def)) { return(false); } if (!flashcells && GroupsUtils.HasGroup(plant)) { return(false); } return(true); }
internal static Group TryCreateGroup(MapCompGrowthSync mapComp, Plant crop, bool flashcells = false) { if (!flashcells && GroupsUtils.HasGroup(crop)) { return(null); } var list = new HashSet <Plant>(); try { if (!GroupsUtils.HasGroup(crop)) { Iterate(mapComp, crop, list, crop.Growth, crop.Growth, flashcells, IntVec3.Invalid); } } catch (Exception ex) { Log.Warning("failed to create group from crop " + crop + " at " + crop.Position + " : " + ex.Message + ". " + ex.StackTrace); return(null); } if (flashcells || list.Count <= 0) { return(null); } return(new Group(list)); }
public override void Update() { try { var t = Find.Selector.SingleSelectedThing; if (t == null) { return; } if (t is Plant) { #if DEBUG if (KeyBindingDefOf.Misc1.JustPressed) { GroupMaker.TryCreateGroup(Find.CurrentMap.GetComponent <MapCompGrowthSync>(), t as Plant, true); } #endif var group = GroupsUtils.GroupOf(t as Plant); if (group != null) { group.Draw(0); } } } catch (Exception ex) { //screw that bug, I can't fix it and it seems harmless. if (!(ex is InvalidCastException)) { throw ex; } } }