コード例 #1
0
        /// <summary>
        /// Check to see if the Heart of the Forest quest line has been completed.
        /// If so, remove the overgrowth so that the Wizard can successfully return home. :)
        /// </summary>
        private void UpdateRejForestOnQuestStatus()
        {
            // Ignore any update if the quest line hasn't been completed yet
            if (!Game1.player.hasOrWillReceiveMail("Custom_TTimber_ForestQuest_complete"))
            {
                return;
            }

            // Success - handle all logic relevant to the quest being previously completed
            Globals.Monitor.Log("Quest has been completed, removing bushes from Twizard's home", LogLevel.Debug);

            // Remove the two berry bushes in front of the Twizard's door.
            // A foreach doesn't work here since removing an object edits the collection's indexing.
            // By starting at the end of the collection and indexing backwards,
            // all indices are preserved while iterating.
            for (int i = rejuvenatingForest.largeTerrainFeatures.Count - 1; i >= 0; i--)
            {
                // Get a reference to the current object in the loop
                LargeTerrainFeature ltf = rejuvenatingForest.largeTerrainFeatures[i];

                // Remove the object if it's at X = 74, Y = 30 (should be a bush)
                if (ltf.tilePosition.Value == new Vector2(74, 30))
                {
                    rejuvenatingForest.largeTerrainFeatures.Remove(ltf);         // Remove the Bush object
                    rejuvenatingForest.Map.Layers[3].Tiles.Array[74, 30] = null; // Remove the tile for good measure
                }
                // Remove the object if it's at X = 72, Y = 31 (should be a bush)
                else if (ltf.tilePosition.Value == new Vector2(72, 31))
                {
                    rejuvenatingForest.largeTerrainFeatures.Remove(ltf);         // Remove the Bush object
                    rejuvenatingForest.Map.Layers[3].Tiles.Array[72, 31] = null; // Remove the tile for good measure
                }
            }
        }
コード例 #2
0
ファイル: Forest.cs プロジェクト: osheroff/stardew-valley
        private void showCommunityUpgradeShortcuts()
        {
            if (hasShownCCUpgrade)
            {
                return;
            }
            removeTile(119, 36, "Buildings");
            LargeTerrainFeature blockingBush = null;

            foreach (LargeTerrainFeature t in largeTerrainFeatures)
            {
                if (t.tilePosition.Equals(new Vector2(119f, 35f)))
                {
                    blockingBush = t;
                    break;
                }
            }
            if (blockingBush != null)
            {
                largeTerrainFeatures.Remove(blockingBush);
            }
            hasShownCCUpgrade = true;
            warps.Add(new Warp(120, 35, "Beach", 0, 6, flipFarmer: false));
            warps.Add(new Warp(120, 36, "Beach", 0, 6, flipFarmer: false));
        }
コード例 #3
0
        public void Update(GameLocation location)
        {
            if (!this.DisableAutoSpawning)
            {
                this.spawnWave();
            }

            IDictionary <Vector2, IShaker> tilesTouched = new Dictionary <Vector2, IShaker>();
            IList <Wave> wavesToRemove = new List <Wave>();

            foreach (Wave wave in waves)
            {
                wave.Update();

                Vector2[] waveTilesTouched = wave.TilesTouched();
                if (!waveTilesTouched.Any(tile => location.isTileOnMap(tile)))
                {
                    wavesToRemove.Add(wave);
                }

                foreach (Vector2 tile in waveTilesTouched)
                {
                    if (location.terrainFeatures.TryGetValue(tile, out TerrainFeature feature) && factory.TryGetShaker(feature, wave, location, out IShaker shaker))
                    {
                        tilesTouched[tile] = shaker;
                    }
                    else
                    {
                        LargeTerrainFeature largeFeature = location.largeTerrainFeatures.FirstOrDefault(ltf => ltf.tilePosition.Value == tile);
                        if (largeFeature != null && factory.TryGetShaker(largeFeature, wave, location, out shaker))
                        {
                            tilesTouched[tile] = shaker;
                        }
                    }
                }
            }

            foreach (Wave wave in wavesToRemove)
            {
                this.waves.Remove(wave);
            }

            Vector2[] currentTilesTouched = tilesTouched.Keys.Where(key => !lastTilesTouched.Contains(key)).ToArray();

            foreach (Vector2 p in currentTilesTouched)
            {
                tilesTouched[p].Shake(this.helper.Reflection, p);
            }

            this.lastTilesTouched = currentTilesTouched;
        }
コード例 #4
0
        public void AddAdditionalWalnutBushes()
        {
            List <Vector2> additional_bushes = GetAdditionalWalnutBushes();

            if (additional_bushes != null)
            {
                foreach (Vector2 point in additional_bushes)
                {
                    LargeTerrainFeature existing_feature = getLargeTerrainFeatureAt((int)point.X, (int)point.Y);
                    if (!(existing_feature is Bush) || (existing_feature as Bush).size.Value != 4)
                    {
                        largeTerrainFeatures.Add(new Bush(new Vector2((int)point.X, (int)point.Y), 4, this));
                    }
                }
            }
        }
コード例 #5
0
 internal static void ClearNettlesGlobally()
 {
     foreach (string l in ModEntry.ItemDefinitions["NettlesLocations"])
     {
         GameLocation location = Game1.getLocationFromName(l);
         Log.D($"Removing {location.largeTerrainFeatures.Count(ltf => ltf is CustomBush cb && cb.Variety == BushVariety.Nettle)} nettles from {location.Name}.",
               ModEntry.Instance.Config.DebugMode);
         for (int i = location.largeTerrainFeatures.Count - 1; i >= 0; --i)
         {
             LargeTerrainFeature ltf = location.largeTerrainFeatures[i];
             if (ltf is CustomBush customBush && customBush.Variety == BushVariety.Nettle)
             {
                 Log.D($"Removing from {ltf.currentTileLocation}...",
                       ModEntry.Instance.Config.DebugMode);
                 location.largeTerrainFeatures.RemoveAt(i);
             }
         }
     }
 }
コード例 #6
0
        /// <summary>
        /// When rejuvenatingForest.loadObjects() is called, this loads new objects without removing the old ones.
        /// It is important to keep *some* items (e.g. trees) so they continue growing.
        /// However, duplicate bushes, stumps, rocks, etc. are unintended, and are causing visual tearing/extra drops.
        /// As a workaround, remove all duplicate objects from the map.
        ///
        /// TODO: Refactor this method, it is a workaround for rejuvenatingForest.loadObjects()
        /// that is also expensive to run.
        /// </summary>
        private void RemoveDuplicateTerrainFeatures()
        {
            /****************************************
            * please deprecate this forbidden code *
            ****************************************/

            // 2D array representing each tile on the map
            bool[,] tileHasTerrainFeature = new bool[
                rejuvenatingForest.map.Layers[0].LayerWidth,
                rejuvenatingForest.map.Layers[0].LayerHeight];

            // Remove any duplicate LargeTerrainFeatures
            for (int i = rejuvenatingForest.largeTerrainFeatures.Count - 1; i >= 0; i--)
            {
                // Get a reference to the current object in the loop
                LargeTerrainFeature ltf = rejuvenatingForest.largeTerrainFeatures[i];
                int x = (int)ltf.tilePosition.Value.X;
                int y = (int)ltf.tilePosition.Value.Y;

                // If this is the first instance of a terrain feature on a tile, record it
                if (tileHasTerrainFeature[x, y] == false)
                {
                    tileHasTerrainFeature[x, y] = true;
                }
                // If a terrain feature already exists at that tile, remove this feature instead
                else
                {
                    rejuvenatingForest.largeTerrainFeatures.RemoveAt(i);
                    Globals.Monitor.Log("Found and removing a duplicate LTF: [" + x + ", " + y + "]", LogLevel.Debug);
                }
            }

            // Apply the same check for normal terrain features too
            for (int i = rejuvenatingForest.terrainFeatures.Count() - 1; i >= 0; i--)
            {
                // Get a reference to the current object in the loop
                TerrainFeature tf = rejuvenatingForest.terrainFeatures.Values.ElementAt(i);
                int            x  = (int)tf.currentTileLocation.X;
                int            y  = (int)tf.currentTileLocation.Y;

                // If this is the first instance of a terrain feature on a tile, record it
                if (tileHasTerrainFeature[x, y] == false)
                {
                    tileHasTerrainFeature[x, y] = true;
                }
                // If a terrain feature already exists at that tile, remove this feature instead
                else
                {
                    rejuvenatingForest.terrainFeatures.Remove(new Vector2(x, y));
                    Globals.Monitor.Log("Found and removing a duplicate TF: [" + x + ", " + y + "]", LogLevel.Debug);
                }
            }

            // Apply the same check for resource clumps (big rocks) too
            for (int i = rejuvenatingForest.resourceClumps.Count() - 1; i >= 0; i--)
            {
                // Get a reference to the current object in the loop
                ResourceClump rc = rejuvenatingForest.resourceClumps[i];
                int           x  = (int)rc.tile.Value.X;
                int           y  = (int)rc.tile.Value.Y;

                // If this is the first instance of a terrain feature on a tile, record it
                if (tileHasTerrainFeature[x, y] == false)
                {
                    tileHasTerrainFeature[x, y] = true;
                }
                // If a terrain feature already exists at that tile, remove this feature instead
                else
                {
                    rejuvenatingForest.resourceClumps.RemoveAt(i);
                    Globals.Monitor.Log("Found and removing a duplicate RC: [" + x + ", " + y + "]", LogLevel.Debug);
                }
            }
        }
コード例 #7
0
 public void setlargeTerrainFeature(Vector2 vector2, LargeTerrainFeature largeterrainFeature)
 {
     this.vector2             = (vector2);
     this.largeterrainFeature = (largeterrainFeature);
 }
コード例 #8
0
 public LargeTerrainFeaturePair(Vector2 vector2, LargeTerrainFeature largeterrainFeature)
 {
     this.vector2             = (vector2);
     this.largeterrainFeature = (largeterrainFeature);
 }