Esempio n. 1
0
        /// <summary>
        /// Uses a slightly edited version of the growth call of StardewValley.TerrainFeatures.Tree.dayUpdate.
        /// </summary>
        /// <param name="tree">current tree</param>
        /// <param name="location">ingame location (e.g. farm)</param>
        /// <param name="tileLocation">position in said location</param>
        /// <returns>whether the tree's growth is only blocked by a stump and not a still fully grown stage</returns>
        private bool IsGrowthOnlyBlockedByStump(Tree tree, GameLocation location, Vector2 tileLocation)
        {
            Rectangle growthRect = new Rectangle((int)((tileLocation.X - 1f) * 64f), (int)((tileLocation.Y - 1f) * 64f), 192, 192);

            using (NetDictionary <Vector2, TerrainFeature, NetRef <TerrainFeature>, SerializableDictionary <Vector2, TerrainFeature>, NetVector2Dictionary <TerrainFeature, NetRef <TerrainFeature> > > .PairsCollection.Enumerator enumerator = location.terrainFeatures.Pairs.GetEnumerator())
            {
                bool foundStump = false;

                while (enumerator.MoveNext())
                {
                    KeyValuePair <Vector2, TerrainFeature> t = enumerator.Current;
                    if (t.Value is Tree && !t.Value.Equals(tree) && ((Tree)t.Value).growthStage >= 5 && t.Value.getBoundingBox(t.Key).Intersects(growthRect))
                    {
                        if (((Tree)t.Value).stump)
                        {
                            foundStump = true;
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }

                return(foundStump);
            }
        }
Esempio n. 2
0
        private List <FarmAnimal> GetAnimals(object currentLocation)
        {
            List <FarmAnimal> list = null;

            if (currentLocation is Farm farm)
            {
                if (farm.animals == null || farm.animals.Count() <= 0)
                {
                    return(list);
                }
                list = new List <FarmAnimal>();
                using (NetDictionary <long, FarmAnimal, NetRef <FarmAnimal>, SerializableDictionary <long, FarmAnimal>, NetLongDictionary <FarmAnimal, NetRef <FarmAnimal> > > .ValuesCollection.Enumerator enumerator = farm.animals.Values.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        FarmAnimal item = enumerator.Current;
                        list.Add(item);
                    }
                    return(list);
                }
            }
            if (currentLocation is AnimalHouse animalHouse)
            {
                if (animalHouse.animals != null && animalHouse.animals.Count() > 0)
                {
                    list = new List <FarmAnimal>();
                    foreach (FarmAnimal item2 in animalHouse.animals.Values)
                    {
                        list.Add(item2);
                    }
                }
            }
            return(list);
        }
Esempio n. 3
0
 public bool MoveNext()
 {
     if (_base.MoveNext())
     {
         _current = _base.Current;
         return(true);
     }
     if (_overlay.MoveNext())
     {
         _current = _overlay.Current.Value;
         return(true);
     }
     _done    = true;
     _current = null;
     return(false);
 }
Esempio n. 4
0
 public bool MoveNext()
 {
     if (_base.MoveNext())
     {
         _current = _base.Current;
         return(true);
     }
     while (_overlay.MoveNext())
     {
         Vector2 key = _overlay.Current.Key;
         if (!_dict.baseDict.ContainsKey(key))
         {
             _current = _overlay.Current.Key;
             return(true);
         }
     }
     _done    = true;
     _current = Vector2.Zero;
     return(false);
 }
Esempio n. 5
0
 public bool MoveNext()
 {
     while (_base.MoveNext())
     {
         KeyValuePair <Vector2, Object> pair = _base.Current;
         if (!_dict.overlayDict.ContainsKey(pair.Key))
         {
             _current = new KeyValuePair <Vector2, Object>(pair.Key, pair.Value);
             return(true);
         }
     }
     if (_overlay.MoveNext())
     {
         KeyValuePair <Vector2, Object> pair2 = _overlay.Current;
         _current = new KeyValuePair <Vector2, Object>(pair2.Key, pair2.Value);
         return(true);
     }
     _done    = true;
     _current = default(KeyValuePair <Vector2, Object>);
     return(false);
 }
Esempio n. 6
0
        /// <summary>
        /// Checks for saplings that are growth stage 1 despite being in the shade of another tree.
        /// Uses an unedited version of the location check StardewValley.TerrainFeatures.Tree.dayUpdate so saplings cant grow when tree stumps are in the way.
        /// </summary>
        /// <param name="tree">current sapling</param>
        /// <param name="location">ingame location (e.g. farm)</param>
        /// <param name="tileLocation">position in said location</param>
        public void RevertSaplingGrowthInShade(Tree tree, GameLocation location, Vector2 tileLocation)
        {
            if (tree.growthStage.Value != 1 || !treeOverhaulConfig.StopShadeSaplingGrowth)
            {
                return;
            }

            Rectangle growthRect = new Rectangle((int)((tileLocation.X - 1f) * 64f), (int)((tileLocation.Y - 1f) * 64f), 192, 192);

            using (NetDictionary <Vector2, TerrainFeature, NetRef <TerrainFeature>, SerializableDictionary <Vector2, TerrainFeature>, NetVector2Dictionary <TerrainFeature, NetRef <TerrainFeature> > > .PairsCollection.Enumerator enumerator = location.terrainFeatures.Pairs.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    KeyValuePair <Vector2, TerrainFeature> t = enumerator.Current;
                    if (t.Value is Tree && !t.Value.Equals(this) && ((Tree)t.Value).growthStage >= 5 && t.Value.getBoundingBox(t.Key).Intersects(growthRect))
                    {
                        tree.growthStage.Set(0);
                        return;
                    }
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Adjusts tree and mushroom tree growth depending on settings like growing them in the winter.
        /// Uses a slightly edited version of the growth call of StardewValley.TerrainFeatures.Tree.dayUpdate.
        /// </summary>
        /// <param name="tree">current tree</param>
        /// <param name="location">ingame location (e.g. farm)</param>
        /// <param name="tileLocation">position in said location</param>
        public void GrowTree(Tree tree, GameLocation location, Vector2 tileLocation)
        {
            Rectangle growthRect = new Rectangle((int)((tileLocation.X - 1f) * 64f), (int)((tileLocation.Y - 1f) * 64f), 192, 192);

            string s = location.doesTileHaveProperty((int)tileLocation.X, (int)tileLocation.Y, "NoSpawn", "Back");

            if (s != null && (s.Equals("All") || s.Equals("Tree") || s.Equals("True")))
            {
                return;
            }

            if (tree.growthStage == 4 || treeOverhaulConfig.StopShadeSaplingGrowth)
            {
                using (NetDictionary <Vector2, TerrainFeature, NetRef <TerrainFeature>, SerializableDictionary <Vector2, TerrainFeature>, NetVector2Dictionary <TerrainFeature, NetRef <TerrainFeature> > > .PairsCollection.Enumerator enumerator = location.terrainFeatures.Pairs.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        KeyValuePair <Vector2, TerrainFeature> t = enumerator.Current;
                        if (t.Value is Tree && !t.Value.Equals(this) && ((Tree)t.Value).growthStage >= 5 && t.Value.getBoundingBox(t.Key).Intersects(growthRect))
                        {
                            return;
                        }
                    }
                }
            }

            if (tree.growthStage == 0 && location.objects.ContainsKey(tileLocation))
            {
                return;
            }

            if (Game1.random.NextDouble() < 0.2 || tree.fertilized.Value)
            {
                tree.growthStage.Set(tree.growthStage.Value + 1);
            }
        }