Example #1
0
        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));
        }
Example #2
0
        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 /*|| plantprops.IsTree*/)
            {
                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);
        }